Memory
## Consolidated Implementation Plan — Work Engineering in Sphere (APPROVED) **Date:** 2026-09-09 **Status:** **Approved by Mike, 2026-09-09** **Related:** Work Engineering Design Reconciliation (e9fa8b66), Work Item ↔ Work Engineering Join (cb8498bf), Work Engineering in the Workspace DO (4b6691c7), Map Definition Tools (7b4ca278), Quality Workstations Have Contracts (ec2127f9), LLM Assigned to Workstation (fb041f01) --- ## Approved Plan ### Phase 0 — Evidence & naming groundwork (worksphere `p4-think-admin-agent`) **Decision records as files + memory-indexed per P3.5:** - `P4-002-work-item-we-join.md` (from `cb8498bf` + `fb041f01` + `ec2127f9` + reconciliation e9fa8b66) - `P4-003-work-engineering-in-workspace-do.md` (from `4b6691c7` + Q-A/Q-G) - `P4-004-map-definition-mcp-surface.md` (from `7b4ca278` + Q-F/Q-I) **Naming contract:** - `/contracts/SPHERE_NAMING_CONTRACT.md` in `p4-think-admin-agent`: - Sphere, project, default_project, personal - Work item vs work object vs lot - Callsign (global, D1) vs operator profile (DO-local authorization) - Workstation/contract/routing - `evaluateGate` canonical - `closed` not `completed` - Tag `project:<slug>` --- ### Phase W1 — WE core in SphereWorkspace DO (SQLite-first) 1. **Port reference schema** (`records/edges/revisions/run_log`) into `SphereWorkspaceBase` (`src/workspace/workspace.ts`) — no table-name collisions; **drop** the unused DO-side `work_items` table (Q-H). [mikesecondbrain:1] 2. **Port all domain verbs + error catalogue + `{ok,err}` envelopes** verbatim; thread session callsign as `by` on mutations/revisions/run_log. 3. **Hybrid contracts (Q-B):** `defineContract` gains `inputs/outputs/rules/evidenceRequirements/operatorIndependence`; characteristics keep target+method and keep required `contractId`; `evaluateGate` canonical, contract-level alias later. [mikesecondbrain:1] 4. **Auto-advance production stations unchanged**; `claimWorkstation(lotId, stationId)` enforced **only at quality stations** (Q-C), operator sessions mirrored from D1 assignment (Q-H). [mikesecondbrain:1] 5. **`resetAll()` kept**, guarded as dev-only (config flag). 6. **Tests:** Port the reference's proof sequence (quality-independence rejection, gate-direction no-advance, rework reset, revision supersession, persistence) as the integration test suite. [mikesecondbrain:2] --- ### Phase W2 — Join + MCP surface 1. **D1 `work_items` new columns:** `routing_id`, `workstation_id` (tracks lot's current station), `lot_id`, `contract_id`, `rejection_reason` (Q-D, Q-E) — via the same probe/ALTER pattern as `ENTRIES_COLUMNS`. [mikesecondbrain:1] 2. **`start_work` on bound item** → idempotent `startLot` via DO stub; `working_on` tag = routing/station context. 3. **Status mirroring, lot authoritative (Q-E):** `open→open`, `blocked→blocked`, `accepted→review` (completable), `rework→open`, `rejected→closed` + `rejection_reason`. `complete_work` rejected unless lot accepted. [mikesecondbrain:1] 4. **`get_attention` enrichment for bound items:** Current station, gate state, next action. 5. **Grouped MCP tools (Q-I),** Zod structured inputs, callsign-attributed: - `we_brief` (brief/report/runlog) - `we_define` (objects/contracts/stations/routings/allocations/characteristics/evidence + `validateRouting`/`validateWorkMap`) - `we_run` (startLot/evaluateGate/markLotVerdict/claimWorkstation/recordEvidence/appendRunLog) - `we_map` (findMap/graphView/getRecord/linkRecords/reviseRecord) 6. **Promotion:** On `markLotVerdict accepted` + quality evidence → derived memory entry (source = project + WE record IDs) with `part_of_project` edge to the project anchor. 7. **`create_project` provisioning:** `/README.md` + `/contracts/_TEMPLATE.md`, `/decisions/_TEMPLATE.md`, `/runs/_TEMPLATE.md` + WE map bootstrap. 8. **Fix audit gaps in the same pass:** - Default-to-current-project for `recall`/`list_recent`/`list_documents` - `ingest` slug `"default"`→`personal` - Store `create_work` description - `get_project` counts --- ### Phase W3 — deferred (tracked, not built now) - Artifacts mirror (Q-A v2) - Capability/workingAreas enforcement (Q-G v2) - `operatorIndependence: 'required'` - `assigned_reviewer` handoff - Contract SHA-256 pinning - Think UI cards - FTS5 - AgentSphere coordination - Callsign-cleanup agent - Backfill of existing projects --- ## Five defaults approved 1. **Project anchors = Option A** (canonical anchor memory per project, tag-located, no schema change) — promotion edges need it. 2. **Templates canonical home = `sphere-admin` worksphere** `/templates/`, copied at provisioning. 3. **Naming contract file** at `/contracts/SPHERE_NAMING_CONTRACT_CONTRACT.md` in `p4-think-admin-agent`. 4. **Test strategy** = ported proof sequence as integration tests. 5. **Phase 0 decision records written before any code** (evidence-first, per DocuClear pattern). --- ## Next steps 1. **Phase 0 first** — Write decision records + naming contract. 2. **Then W1** — Port schema + domain verbs + tests. 3. **Then W2** — Join + MCP surface + audit fixes. 4. **W3 deferred** — Track in backlog, build when needed. **All decisions Q-A through Q-I confirmed and canonical. Smaller items closed. Nothing left blocking. Approved to proceed with Phase 0.** --- **Note:** This plan is now canonical. All work proceeds according to this plan unless explicitly amended.
Tags: work-engineering, implementation-plan, approved, phase-0, phase-w1, phase-w2, phase-w3, decisions, naming-contract, sqlite-first, mcp-tools, volatility:durable, kind:episodic, status:canonical — Source: mcp — 2026-09-08 23:17:41 UTC