codecartographer-pi 0.14.1 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/.codecarto/BACKLOG.md +4 -12
  2. package/.codecarto/GUIDE.md +35 -36
  3. package/.codecarto/NEW_THREAD_BLURB.md +3 -3
  4. package/.codecarto/skills/spec-delta-application/SKILL.md +2 -2
  5. package/.codecarto/templates/amendment.yaml +17 -0
  6. package/.codecarto/templates/conventions-template.md +6 -5
  7. package/.codecarto/templates/decisions-template.md +13 -10
  8. package/.codecarto/templates/phase-handoff.yaml +7 -0
  9. package/.codecarto/templates/spike-report.md +51 -0
  10. package/.codecarto/workflow/scaffold-version.yaml +1 -1
  11. package/agent-skill/codecartographer/SKILL.md +7 -1
  12. package/agent-skill/codecartographer/references/handoff-contract.md +12 -1
  13. package/agent-skill/codecartographer/references/library.md +32 -0
  14. package/agent-skill/codecartographer/references/orchestration.md +45 -0
  15. package/dist/core/amendment.d.ts +41 -0
  16. package/dist/core/amendment.js +143 -0
  17. package/dist/core/completion.d.ts +16 -0
  18. package/dist/core/completion.js +196 -5
  19. package/dist/core/index.d.ts +1 -0
  20. package/dist/core/index.js +1 -0
  21. package/dist/core/pipeline.js +18 -0
  22. package/dist/core/prompts.js +53 -0
  23. package/dist/core/status.d.ts +16 -1
  24. package/dist/core/status.js +49 -1
  25. package/dist/core/types.d.ts +24 -0
  26. package/dist/core/usage.d.ts +7 -0
  27. package/dist/core/usage.js +2 -1
  28. package/dist/core/workspace.d.ts +39 -0
  29. package/dist/core/workspace.js +92 -4
  30. package/dist/extensions/codecarto/auto-runner.js +1 -0
  31. package/dist/extensions/codecarto/dashboard-writer.d.ts +8 -1
  32. package/dist/extensions/codecarto/dashboard-writer.js +10 -1
  33. package/dist/extensions/codecarto/index.js +4 -1
  34. package/dist/mcp-server/server.d.ts +23 -0
  35. package/dist/mcp-server/server.js +139 -7
  36. package/package.json +1 -1
@@ -9,23 +9,15 @@ of the change would look like.
9
9
 
10
10
  ---
11
11
 
12
- ## B1. Spike template + first-class spike concept
12
+ ## B1. Spike template + first-class spike concept — SHIPPED in smallest viable form (v0.15.0, issue #101)
13
13
 
14
- **Raised by:** `Run three Thaumaturge implementation spikes.txt`, `Apply 20 spec deltas to Thaumaturge.txt`, `Agent on protocols phase - protocols.txt` (3 agents)
15
-
16
- **Why deferred:** A spike template would land cleanly, but "first-class spike concept" implies workflow machinery (a `spikes/` directory convention, a validation rule for spike outputs, status.yaml fields for spike tracking). The 2026-05-02 pass is already changing the closeouts pattern, the open_questions schema, and the orchestrator-maintained artifacts list. Adding spike machinery on top risks too much surface change in one revision.
17
-
18
- **Smallest viable form:** `templates/spike-report.md` skeleton with sections for Goal, Method, Measurements, Findings, Recommended Deltas. No workflow machinery; spikes stay a per-project convention initially. Status.yaml integration deferred until a project demonstrates the need.
14
+ Landed exactly as scoped: `templates/spike-report.md` (Goal / Method / Measurements / Findings / Recommended Deltas) with the `scratch/spikes/<spike-id>/<scenario>.md` convention documented in GUIDE.md and the spec-delta-application skill. No workflow machinery; spikes stay registered as `post_pipeline` entries (`kind: spike`), their findings flow to the spec through spec-delta-application and to `status.yaml` through `codecarto_amend`. Status.yaml spike tracking remains deferred until a project demonstrates the need.
19
15
 
20
16
  ---
21
17
 
22
- ## B2. Amendments mechanic (`findings/amendments/` directory)
23
-
24
- **Raised by:** `Run three Thaumaturge implementation spikes.txt`, `Agent on protocols phase - protocols.txt` (2 agents — under threshold but persistent)
25
-
26
- **Why deferred:** "Phase outputs can't correct prior phases" is a real gap, but `carry_forward` (introduced in this pass) already covers the most common case (forward-routing a deferred item). True back-amendment (a later phase says "the architecture map is wrong about X") needs more design — should it edit the prior output? Append a "superseded by" marker? Live in a parallel directory? The shape isn't obvious enough to land safely.
18
+ ## B2. Amendments mechanic — SHIPPED (v0.15.0, issue #99)
27
19
 
28
- **Smallest viable form:** A pre-reimpl-spec "reconciliation" pass that surfaces contradictions across primary outputs. Less ambitious than a full amendments directory; uses existing artifacts.
20
+ Landed as `codecarto_amend` over `scratch/amendments/<slug>.yaml` (see `templates/amendment.yaml`): post-pipeline open-question closures and post_pipeline backlog retirement, applied to `workflow/status.yaml` under the completion lock with an amendment closeout and THREAD_LOG entry. The narrower back-amendment question ("a later phase says a prior output is wrong") remains open a real run handled it with a correction section in the later report plus a delta-application pass, which worked; promote that pattern only if it recurs.
29
21
 
30
22
  ---
31
23
 
@@ -12,43 +12,40 @@ Work in explicit phases. Do not try to do everything at once.
12
12
 
13
13
  ## Roles
14
14
 
15
- CodeCartographer distinguishes two roles. They are different jobs, often held by different threads, and the framework's discipline depends on both existing.
15
+ CodeCartographer distinguishes two roles. They are different jobs but they are not different threads by default, and the framework's discipline depends on the first one existing.
16
16
 
17
- **Implementing session.** One phase or one module of work, fresh thread, follows a SKILL.md and a template, validates, writes a closeout, ends. The bulk of the frameworkphases, skills, templates, validation gates — is written for this role. The "You are an LLM assistant" framing in "What This Is" addresses this role.
17
+ **Orchestrator.** The persistent chat driving the runnormally the very session reading this guide. The role is defined by its **duties**, not by who executes phases:
18
18
 
19
- **Orchestrator.** One persistent thread (typically the first LLM the user points at the project) paired with the human user. The orchestrator holds cross-session context, drafts implementing-session prompts from prior closeouts, curates `CONVENTIONS.md` and `DECISIONS.md` (promoting patterns when they recur), and gates strategic forks the user makes. **The orchestrator does not execute pipeline phases itself** — that is the implementing-session role. The orchestrator's deliverables are *prompts and curated artifacts*, not phase outputs. When the orchestrator finds itself reading a SKILL.md or producing a `findings/<phase>/<primary-output>.md`, it has slipped into the implementing-session role and should stop, draft a prompt, and hand off instead. Without an orchestrator, the framework still works phase-by-phase but cross-cutting conventions and decisions don't accumulate, and each implementing session re-discovers what prior sessions established.
19
+ - **Curate `CONVENTIONS.md` and `DECISIONS.md`**: promote patterns when they recur; append cross-cutting decisions as they land.
20
+ - **Re-triage open questions at every phase boundary.** A question's `kind` label is itself a claim that needs evidence: before accepting `needs-maintainer-decision` or `needs-runtime-test`, re-test whether the question has become answerable by reading. A mislabeled question suppresses verification for every later phase (the `orchestration` guide topic records a real four-phase failure).
21
+ - **Sweep for contradictions** between the incoming phase's required reads and earlier phases' `owner_notes`. A measured fact that contradicts a summarized claim is a gap to route, not a nuance to smooth over.
22
+ - **Route gaps**: confirm each completed phase's declared secondary outputs were written or explicitly routed, and that handoff `decisions` deferring work landed somewhere a later phase will actually see.
23
+ - **Gate strategic forks** with the user: pipeline switches, opinionated-vs-agnostic specs, scope changes.
20
24
 
21
- If you are an LLM reading this guide for the first time on a project where `CONVENTIONS.md` and `DECISIONS.md` are unwritten (still showing template content) and `closeouts/` is empty, **see "First-Time Project Setup" below before starting any phase.**
25
+ **Phase executor.** Whoever performs one phase against its SKILL.md and template: reads the sources, writes the primary output, validates, writes the handoff. The bulk of the framework phases, skills, templates, validation gates — is written for this role; the "You are an LLM assistant" framing in "What This Is" addresses it.
22
26
 
23
- ## First-Time Project Setup
27
+ How the roles map onto threads is an **execution strategy**, chosen per run:
28
+
29
+ - **Inline** — the orchestrator executes phases itself, wearing both hats. This is the normal mode for a single chat driving the MCP tools. The duties above happen at each phase boundary: after completion, before the next phase begins.
30
+ - **Delegated** — the orchestrator dispatches each phase to a separate execution context (the Pi extension's phase sub-agents, or fresh threads the user spins up from drafted prompts) and reviews each closeout. Same duties, same boundary; only the executor differs, keeping phase context out of the orchestrator's window.
24
31
 
25
- If this is the first LLM to touch this project no closeouts in `closeouts/`, `CONVENTIONS.md` and `DECISIONS.md` still showing template skeletons, `workflow/status.yaml` at defaults stop before starting any pipeline phase and have a one-time role conversation with the user. Combine the explanation and the ask in one structured prompt:
32
+ Either strategy is full orchestration. The **session-by-session fallback**each phase in an isolated session, nobody holding the cross-phase duties — is not: `CONVENTIONS.md` stays empty, proposals die in closeout prose, and mislabeled questions go unchallenged. Use it only when the user explicitly declines orchestration or the driving model cannot sustain cross-phase context, and record the reason in the first handoff's `owner_notes`.
26
33
 
27
- > "I see this is a fresh CodeCartographer-equipped project. Before I start the analysis, one one-time decision: would you like me to take on the **orchestrator role** for this project, or work session-by-session?
28
- >
29
- > The orchestrator role means I'd hold cross-session context across the entire project — drafting prompts for implementation threads you'll spin up, curating two project-wide files (`CONVENTIONS.md` for patterns and `DECISIONS.md` for cross-cutting calls), and gating the strategic forks where you'd want to make a call.
30
- >
31
- > How it works in practice: this thread becomes the orchestrator; you spin up fresh threads for each implementation session using the prompts I draft, run them, and paste the closeout report back here. I update `CONVENTIONS.md`/`DECISIONS.md` and prepare the next prompt. The framework's discipline compounds across sessions instead of being reinvented each time.
32
- >
33
- > One operational tip: if your coding agent supports renaming and pinning threads, rename this thread to "Orchestrator" and pin it. Keeps it organized and quick to find when you switch back from implementation threads.
34
- >
35
- > The alternative is session-by-session work with no cross-session context — the framework still works phase-by-phase, but `CONVENTIONS.md` stays empty and each session has to re-derive patterns from prior closeouts. Better for one-off audits; worse for long-running multi-module projects.
36
- >
37
- > Which would you like?"
34
+ If you are an LLM reading this guide for the first time on a project where `CONVENTIONS.md` and `DECISIONS.md` are missing or unwritten (still showing template content) and `closeouts/` is empty, **see "First-Time Project Setup" below before starting any phase.**
38
35
 
39
- If the user accepts the orchestrator role:
36
+ ## First-Time Project Setup
40
37
 
41
- 1. Initialize `CONVENTIONS.md` from `templates/conventions-template.md` and `DECISIONS.md` from `templates/decisions-template.md` (skeletons onlypopulate as patterns and decisions accumulate).
42
- 2. Confirm the project name. `project_name` defaults to the repository directory name and is persisted by the framework on the first completion; it only needs attention if the project should be called something else.
43
- 3. **Do not run the architecture phase yourself.** The orchestrator never executes pipeline phases — that is the implementing-session role (see §Roles). Instead, **draft an implementing-session prompt for the architecture phase** that a fresh thread will execute. Hand the prompt to the user; they spin up a new thread with it; the implementing thread runs the phase, validates, writes a closeout, and reports back; you (the orchestrator) read the returned closeout and update `CONVENTIONS.md` / `DECISIONS.md` from it, then draft the next phase's prompt. The implementing session's own completion already applied its handoff to `workflow/status.yaml` — the orchestrator never edits that file. **Phase work always happens in fresh implementing-session threads, never in the orchestration thread.** A useful self-check: if you find yourself reading a `findings/<phase>/SKILL.md` or writing a `findings/<phase>/<primary-output>.md`, you have slipped into the implementing-session role — stop, draft the prompt, hand off.
38
+ If this is the first LLM to touch this project — no closeouts in `closeouts/`, `CONVENTIONS.md` and `DECISIONS.md` missing or still template skeletons, `workflow/status.yaml` at defaults**adopt the orchestrator role by default.** Do not interview the user about whether orchestration should happen. Concretely:
44
39
 
45
- If the user declines:
40
+ 1. `codecarto_init` (and Pi's `/codecarto-init`) seeds `CONVENTIONS.md` and `DECISIONS.md` from their templates. On an older workspace where they are missing, initialize them from `templates/conventions-template.md` and `templates/decisions-template.md` yourself (skeletons only — they fill as patterns and decisions accumulate).
41
+ 2. Confirm the project name only if the repository directory name is wrong for the project; `project_name` otherwise resolves and persists automatically on the first completion.
42
+ 3. Note the run's execution strategy (inline or delegated) in the first phase handoff's `owner_notes`.
46
43
 
47
- 1. Note in `THREAD_LOG.md` that the project runs in degraded no-orchestrator mode.
48
- 2. Proceed phase-by-phase as a standalone implementing session.
49
- 3. `CONVENTIONS.md` and `DECISIONS.md` stay as templates; closeouts accumulate but cross-cutting promotion doesn't happen.
44
+ Choose the execution strategy from the situation rather than asking: a single chat driving the MCP tools runs **inline**; a host with phase sub-agent dispatch (the Pi extension) runs **delegated**. Ask the user only when their instructions genuinely conflict with both defaults — and never under `/codecarto-next --auto`, which must not block on questions.
50
45
 
51
- If the user is ambivalent, default to recommending the orchestrator path for any project expected to span more than one phase or module the framework's compounding-discipline benefits are real and the cost is just paste-and-react work for the user.
46
+ Fall back to session-by-session mode only if the user explicitly declines orchestration or the driving model cannot hold cross-phase context. Record the reason in the first handoff's `owner_notes`, and expect the costs named under §Roles.
47
+
48
+ One operational tip for delegated runs: if your coding agent supports renaming and pinning threads, rename the orchestrator thread to "Orchestrator" and pin it — quick to find when you switch back from phase threads.
52
49
 
53
50
  ## First Read For New Sessions
54
51
 
@@ -82,12 +79,12 @@ Some files in this workspace are **read-only instructions** and must not be modi
82
79
  | Workflow state (framework-owned) | `workflow/status.yaml` | Read to understand progress. Implementing sessions never edit it directly; completion applies a validated phase handoff under a lock. |
83
80
  | Scaffold version stamp (framework-owned) | `workflow/scaffold-version.yaml` | Written at release, copied by init. The framework compares it to its own version to warn about stale scaffolds. Never edit. |
84
81
  | Findings (read-write) | `findings/<phase>/<primary-output>.md`, secondary output files | Create and update during phases. |
85
- | Phase handoff (read-write) | `scratch/handoffs/<phase>.yaml` | Implementing sessions propose state changes and closeout content here. The framework validates and applies them. |
82
+ | Phase handoff (read-write) | `scratch/handoffs/<phase>.yaml` | Phase executors propose state changes and closeout content here. The framework validates and applies them. |
86
83
  | Closeouts (framework-owned) | `closeouts/<date>-<phase-or-module>.md`, `THREAD_LOG.md` | Completion writes or updates one canonical closeout and one idempotent index entry. |
87
- | Conventions (orchestrator-maintained) | `CONVENTIONS.md` | Cross-cutting patterns promoted to project-wide invariants. Implementing sessions propose; the orchestrator writes. |
88
- | Decisions (orchestrator-maintained, append-only) | `DECISIONS.md` | Numbered log of decisions that diverge from spec, prompt, or obvious-default. Appended at session close. |
84
+ | Conventions (orchestrator-maintained) | `CONVENTIONS.md` | Cross-cutting patterns promoted to project-wide invariants. Phase executors propose; the orchestrator promotes at the phase boundary — in inline runs, the same chat changing hats. |
85
+ | Decisions (orchestrator-maintained, append-only) | `DECISIONS.md` | Numbered log of decisions that diverge from spec, prompt, or obvious-default. Completion appends each handoff's `decisions` under `## Completion log`; the orchestrator may re-file entries into categories. |
89
86
  | Backlog (read-write) | `BACKLOG.md` | Deferred items with rationale. |
90
- | Scratch (read-write) | `scratch/*` | Working notes; `scratch/checkpoints/<phase>.md` is the durable in-phase continuation checkpoint until the phase validates. |
87
+ | Scratch (read-write) | `scratch/*` | Working notes; `scratch/checkpoints/<phase>.md` is the durable in-phase continuation checkpoint until the phase validates; `scratch/spikes/<spike-id>/<scenario>.md` holds spike reports (`templates/spike-report.md`); `scratch/amendments/<slug>.yaml` holds post-pipeline amendments (`templates/amendment.yaml`). |
91
88
 
92
89
  If you are uncertain whether a file should be modified, treat it as read-only.
93
90
 
@@ -156,10 +153,10 @@ If a primary and a secondary output describe the same topic (e.g., the architect
156
153
 
157
154
  Two cross-cutting files compound across sessions and live at the `.codecarto/` top level:
158
155
 
159
- - **`CONVENTIONS.md`** — cross-cutting patterns that have been promoted to project-wide invariants (e.g., a shared discriminated-union return shape, a tripwire-naming vocabulary, a verbatim-spec-quote discipline). Implementing sessions propose additions in their closeout; the orchestrator promotes them. New conventions land when a third independent session reaches for the same pattern, or when a spec/feedback corpus identifies a project-wide invariant.
160
- - **`DECISIONS.md`** — append-only numbered log of cross-cutting decisions that diverge from spec, prompt, or obvious-default. Each entry: `D<NNN> | <one-liner> | <source-session> | <rationale-pointer>`. Categories partition the namespace (type system, toolchain, module-internal patterns, lifted primitives, etc.).
156
+ - **`CONVENTIONS.md`** — cross-cutting patterns that have been promoted to project-wide invariants (e.g., a shared discriminated-union return shape, a tripwire-naming vocabulary, a verbatim-spec-quote discipline). Completion **stages** each handoff's `proposed_conventions` under `## Pending proposals`; the orchestrator promotes a staged entry into a numbered convention (or removes it with a note) at the phase boundary. New conventions land when a third independent phase reaches for the same pattern, or when a spec/feedback corpus identifies a project-wide invariant.
157
+ - **`DECISIONS.md`** — append-only numbered log of cross-cutting decisions that diverge from spec, prompt, or obvious-default. Each entry: `D<NNN> | <one-liner> | <source-closeout> | <rationale-pointer>`. Completion **appends** each handoff's `decisions` as rows under `## Completion log`, numbering shared with the orchestrator-curated category sections; the orchestrator may re-file entries into categories later.
161
158
 
162
- Both files are skeletons in the framework templates (`templates/conventions-template.md`, `templates/decisions-template.md`) and become project-specific artifacts when a session writes to them. They are *orchestrator-maintained*, not implementer-editedimplementing sessions propose, the orchestrator promotes.
159
+ Both files are seeded from the framework templates (`templates/conventions-template.md`, `templates/decisions-template.md`) at init and become project-specific artifacts as entries accumulate. The bookkeeping half is mechanized completion collects, so proposals can never be stranded in closeout prose while promotion stays judged: phase executors propose, the orchestrator promotes, and in an inline run the same chat does both at the phase boundary.
163
160
 
164
161
  ## Context Budget
165
162
 
@@ -210,6 +207,8 @@ post_pipeline:
210
207
 
211
208
  `kind` is one of: `needs-runtime-test`, `needs-maintainer-decision`, `needs-spec-ruling`, `defer-to-phase`, `needs-fixture-capture`, or a post-pipeline work kind such as `spike` or `amendment`. Every new `carry_forward.target_phase` must be an ID in the active pipeline. Every `post_pipeline` entry requires a stable ID. Open questions should carry a stable `id` (e.g. `q-loadconfig-ambiguity`); if omitted, the framework auto-assigns one. When a later phase resolves an open question, list its id in `open_question_closures` to remove it from all phases. The downstream phase records resolved carry-forward IDs in `carry_forward_closures`; completion removes those entries atomically.
212
209
 
210
+ After the pipeline completes, the handoff channel closes with it. Post-pipeline resolutions — an open question answered on evidence, a finished `post_pipeline` backlog item — are applied with an **amendment**: write `scratch/amendments/<slug>.yaml` (see `templates/amendment.yaml`) and run `codecarto_amend`. It updates `workflow/status.yaml` under the same lock completion uses and writes an amendment closeout plus THREAD_LOG entry. Never hand-edit `status.yaml` for this; amendments are refused while the pipeline is still running, so the two channels cannot race.
211
+
213
212
  ## Phase Selection Logic
214
213
 
215
214
  1. Load the active pipeline YAML (see `pipeline` field in `workflow/status.yaml`).
@@ -238,11 +237,11 @@ When a session starts:
238
237
  When a session finishes durable work:
239
238
 
240
239
  1. Run the validation step described in `workflow/VALIDATE.md`. Append a validation block to the output.
241
- 2. Write `scratch/handoffs/<phase>.yaml` with `schema_version: 1`, the exact `phase_id`, arrays for `owner_notes`, `open_questions`, `carry_forward`, `carry_forward_closures`, `open_question_closures`, `post_pipeline`, and `decisions`, plus `closeout_summary` and optional multiline `closeout_content`. Omitted arrays default to empty; malformed collection shapes fail completion.
240
+ 2. Write `scratch/handoffs/<phase>.yaml` with `schema_version: 1`, the exact `phase_id`, arrays for `owner_notes`, `open_questions`, `carry_forward`, `carry_forward_closures`, `open_question_closures`, `post_pipeline`, `decisions`, and `proposed_conventions`, plus `closeout_summary` and optional multiline `closeout_content`. Omitted arrays default to empty; malformed collection shapes fail completion.
242
241
  3. Record 2-3 key observations in the handoff's `owner_notes` (e.g., row counts, notable decisions, scope of analysis). Do not provide a canonical timestamp; the host clock owns timestamps.
243
242
  4. Run `/codecarto-complete` (or `codecarto_complete`). The framework atomically updates `workflow/status.yaml`, writes or updates one canonical closeout, and appends one idempotent `THREAD_LOG.md` entry. Do not edit those files directly.
244
243
  5. Store the durable output in the declared `findings/` path.
245
- 6. If the session made cross-cutting decisions or discovered project-wide invariants, propose additions to `CONVENTIONS.md` (in the closeout's "Proposed Conventions" section) and `DECISIONS.md` (numbered entries in the closeout's "Decisions Beyond Prompt" section). The orchestrator promotes these to the canonical files.
244
+ 6. If the session made cross-cutting decisions or discovered project-wide invariants, record them in the handoff: `decisions` entries are appended to `DECISIONS.md` by completion (numbered `D<NNN>` rows under `## Completion log`), and `proposed_conventions` entries are staged in `CONVENTIONS.md` under `## Pending proposals`. Promoting a staged proposal into a numbered convention or removing it with a note is the orchestrator duty at the next phase boundary; in an inline run, do it yourself before starting the next phase.
246
245
 
247
246
  ### Strategic Alignment Hook (before synthesis)
248
247
 
@@ -270,7 +269,7 @@ These rules combine framework enforcement with explicit agent discipline:
270
269
  - The primary outputs are listed in the deliverables table above.
271
270
  - Secondary outputs are created only when needed, using `mode: append`.
272
271
  - Completion owns `closeouts/<YYYY-MM-DD>-<phase-or-module>.md` and `THREAD_LOG.md`; implementing sessions supply closeout content through their phase handoff.
273
- - Cross-cutting patterns go in `CONVENTIONS.md`; numbered cross-cutting decisions go in `DECISIONS.md`. Both are orchestrator-maintained — implementing sessions propose in their closeout, the orchestrator promotes.
272
+ - Cross-cutting patterns go in `CONVENTIONS.md`; numbered cross-cutting decisions go in `DECISIONS.md`. Both are orchestrator-maintained — phase executors propose in their closeout, the orchestrator promotes at the phase boundary.
274
273
  - Do not store durable findings only in `THREAD_LOG.md`. The log is an index, not the primary artifact store.
275
274
 
276
275
  ## Folder Layout
@@ -4,7 +4,7 @@ Source code under evaluation: `../` (this repository — everything outside `.co
4
4
 
5
5
  All CodeCartographer files are inside `.codecarto/`. Paths below are relative to `.codecarto/`.
6
6
 
7
- **First-time project?** If `CONVENTIONS.md` and `DECISIONS.md` are still template skeletons and `closeouts/` is empty, see GUIDE.md §Roles and §First-Time Project Setup before reading the rest. The first LLM on a project takes a one-time role decision with the user (orchestrator vs session-by-session).
7
+ **First-time project?** If `CONVENTIONS.md` and `DECISIONS.md` are missing or still template skeletons and `closeouts/` is empty, see GUIDE.md §Roles and §First-Time Project Setup before reading the rest. The chat driving the run **is the orchestrator by default** seed `CONVENTIONS.md`/`DECISIONS.md` and pick an execution strategy (inline or delegated) from the situation; do not interview the user about whether orchestration should happen.
8
8
 
9
9
  Read these in order before doing work:
10
10
 
@@ -26,11 +26,11 @@ Where to store results:
26
26
  After completing work:
27
27
 
28
28
  1. Run validation per `workflow/VALIDATE.md`. Append the validation block to the output.
29
- 2. Write `scratch/handoffs/<phase>.yaml` (see `templates/phase-handoff.yaml`): `schema_version: 1`, the exact `phase_id`, arrays for `owner_notes`, `open_questions`, `carry_forward`, `carry_forward_closures`, `open_question_closures`, `post_pipeline`, and `decisions`, plus `closeout_summary` and optional multiline `closeout_content`. See GUIDE.md "Open Questions vs Carry-Forward" for the entry shape.
29
+ 2. Write `scratch/handoffs/<phase>.yaml` (see `templates/phase-handoff.yaml`): `schema_version: 1`, the exact `phase_id`, arrays for `owner_notes`, `open_questions`, `carry_forward`, `carry_forward_closures`, `open_question_closures`, `post_pipeline`, `decisions`, and `proposed_conventions`, plus `closeout_summary` and optional multiline `closeout_content`. See GUIDE.md "Open Questions vs Carry-Forward" for the entry shape.
30
30
  3. Record 2-3 key observations in the handoff's `owner_notes`.
31
31
  4. Store the durable output in the declared `findings/` path.
32
32
  5. Run completion. The framework verifies the primary output and validation, applies the handoff to `workflow/status.yaml`, and writes the closeout and `THREAD_LOG.md` entry.
33
- 6. If the session made cross-cutting decisions or proposed conventions, record them in the handoff's `decisions` array and the closeout content's "Decisions Beyond Prompt" and "Proposed Conventions" sections. The orchestrator promotes them to `DECISIONS.md` and `CONVENTIONS.md` respectively.
33
+ 6. If the session made cross-cutting decisions or proposed conventions, record them in the handoff's `decisions` array and the closeout content's "Decisions Beyond Prompt" and "Proposed Conventions" sections. Promoting them to `DECISIONS.md` and `CONVENTIONS.md` is the orchestrator duty at the phase boundary — in an inline run, do it yourself before the next phase.
34
34
 
35
35
  ## File-System Sync Warning
36
36
 
@@ -9,7 +9,7 @@ Use this skill when:
9
9
 
10
10
  - The pipeline has produced a complete `findings/reimplementation-spec/reimplementation-spec.md` (the spec is `complete` in status.yaml).
11
11
  - A separate source has surfaced changes the spec should absorb. Common sources:
12
- - **Spike reports** (`spikes/<spike-id>/<scenario>.md` plus a `CONSOLIDATED-DELTA.md`).
12
+ - **Spike reports** (`scratch/spikes/<spike-id>/<scenario>.md`, written from `templates/spike-report.md`, plus an optional `CONSOLIDATED-DELTA.md` when several scenarios merge).
13
13
  - **Defect-scan re-runs** that find corrections to spec text.
14
14
  - **Implementation discoveries** that contradict spec assumptions (e.g., a wire format the spec misread).
15
15
  - **Maintainer rulings** that close prior open questions.
@@ -86,7 +86,7 @@ Per the standard closeout ritual:
86
86
 
87
87
  - Append a one-line entry to `THREAD_LOG.md` pointing at the closeout file.
88
88
  - Write `closeouts/<YYYY-MM-DD>-spec-deltas.md` using `templates/closeout-template.md`.
89
- - If a delta closed an `open_questions` or `carry_forward` entry, record that in the closeout. Do not edit `status.yaml` phase state is framework-owned, and post-pipeline work has no completion step that applies handoffs, so a hand-edit here is unreviewed and can be overwritten by a later phase completion.
89
+ - If a delta resolved an `open_questions` entry (or finished a `post_pipeline` backlog item), apply it: write `scratch/amendments/<slug>.yaml` (see `templates/amendment.yaml`) listing the closures, then run `codecarto_amend`. It updates `status.yaml` under the completion lock and writes the amendment closeout — never hand-edit `status.yaml`, which is framework-owned. Without the MCP server, record the intended amendment file in the closeout for the next MCP-capable session to apply.
90
90
  - Append numbered entries to `DECISIONS.md` for any decisions made during triage that weren't already in the deltas (e.g., "rejected Δ7 because the spec already covered the case at §X").
91
91
 
92
92
  ## What to avoid
@@ -0,0 +1,17 @@
1
+ # Post-pipeline amendment schema v1. Copy to scratch/amendments/<slug>.yaml,
2
+ # then run codecarto_amend (MCP) with the slug. Refused while the pipeline is
3
+ # incomplete — mid-pipeline resolutions belong in the phase handoff
4
+ # (open_question_closures / carry_forward_closures).
5
+ schema_version: 1
6
+ # Open-question ids resolved on evidence after the pipeline completed;
7
+ # removed from every phase in workflow/status.yaml.
8
+ open_question_closures: []
9
+ # Finished post-pipeline backlog item ids; removed from status.yaml's
10
+ # post_pipeline list (the amendment closeout records the closure).
11
+ post_pipeline_closures: []
12
+ # Durable observations worth keeping with the amendment record.
13
+ notes: []
14
+ closeout_summary: ""
15
+ # Optional full closeout Markdown; generated from the applied closures when omitted.
16
+ closeout_content: |-
17
+ # Amendment — <slug>
@@ -8,16 +8,17 @@
8
8
  Every new session reads this file and either honors these conventions or documents why it
9
9
  diverges.
10
10
 
11
- This file is **orchestrator-maintained**. Implementing sessions should not edit it without
12
- explicit invitation; they propose additions in their session closeout and the orchestrator
13
- promotes them.
11
+ This file is **orchestrator-maintained**. Phase executors propose additions in their session
12
+ closeout; the orchestrator promotes them at the phase boundary. In an inline run the same chat
13
+ does both — the rule is about *when* (between phases, deliberately), not about which thread.
14
14
  -->
15
15
 
16
16
  Cross-cutting patterns promoted to project-wide invariants. Every session reads this file at start
17
17
  and either honors these conventions or documents why it diverges.
18
18
 
19
- This file is **orchestrator-maintained**. Implementing sessions propose additions in their
20
- closeout's "Proposed Conventions" section; the orchestrator promotes them here.
19
+ This file is **orchestrator-maintained**. Phase executors propose additions in their closeout's
20
+ "Proposed Conventions" section; the orchestrator promotes them here at the phase boundary — in an
21
+ inline run, the same chat changing hats between phases.
21
22
 
22
23
  ## How conventions get added
23
24
 
@@ -1,25 +1,27 @@
1
1
  # Decisions
2
2
 
3
3
  <!--
4
- Project-level skeleton. Copy this to `.codecarto/DECISIONS.md` (one level up from templates/)
5
- the first time the orchestrator promotes a decision. Then add entries as they accumulate.
4
+ Project-level skeleton. codecarto_init seeds this to `.codecarto/DECISIONS.md` (one level up
5
+ from templates/); entries accumulate as phases complete.
6
6
 
7
7
  This file is an append-only numbered log of cross-cutting decisions made during the project
8
8
  that diverge from spec text, prompt direction, or the obvious-default. Each entry is a
9
9
  one-liner with a back-reference to the closeout where the decision was made and the rationale
10
10
  lives.
11
11
 
12
- This file is **append-only and orchestrator-maintained**. Every implementing session's
13
- "Decisions Beyond Prompt" section in the closeout becomes one or more entries here.
12
+ This file is **append-only and orchestrator-maintained**. Completion appends each phase
13
+ handoff's `decisions` array as rows under `## Completion log` (added at first use); the
14
+ orchestrator may re-file entries into the category sections below. Numbering is shared across
15
+ the whole file.
14
16
  -->
15
17
 
16
18
  Append-only log of cross-cutting decisions that diverge from spec text, prompt direction, or
17
19
  obvious-default. Each entry is a one-liner with a back-reference to the closeout where the
18
20
  decision was made and the rationale lives.
19
21
 
20
- This file is **append-only and orchestrator-maintained**. Every implementing session's
21
- "Decisions Beyond Prompt" section in the closeout becomes one or more entries here. The
22
- orchestrator updates this file at session close as part of the closeout ritual.
22
+ This file is **append-only and orchestrator-maintained**. Completion appends each phase handoff's
23
+ `decisions` array as numbered rows under `## Completion log`; the orchestrator may re-file entries
24
+ into the category sections at the phase boundary.
23
25
 
24
26
  ## Format
25
27
 
@@ -73,9 +75,10 @@ D001 | Outcome<T,E> is a brand newtype keyed by a unique Symbol, NOT a value-uni
73
75
 
74
76
  ## How decisions get added
75
77
 
76
- Every implementing session's "Decisions Beyond Prompt" section in the closeout becomes one or
77
- more `D<NNN>` entries here. The orchestrator promotes them at session close as part of the
78
- closeout ritual. Implementing sessions never edit this file directly.
78
+ Completion appends every phase handoff's `decisions` array as `D<NNN>` rows under
79
+ `## Completion log` nothing gets stranded in closeout prose. The orchestrator may re-file an
80
+ entry into the category sections above at the phase boundary. Phase executors never edit this
81
+ file directly; they record decisions in the handoff.
79
82
 
80
83
  If a decision is later overturned, do **not** delete the entry. Append a new `D<NNN>` superseding
81
84
  it (with `Supersedes D<old-NNN>` in the one-liner) and update the old entry's one-liner to begin
@@ -12,6 +12,13 @@ open_question_closures: []
12
12
  # or opinionated reruns. Every entry requires a stable id.
13
13
  post_pipeline: []
14
14
  decisions: []
15
+ # Conventions proposed for promotion. Completion stages each entry in
16
+ # CONVENTIONS.md under "## Pending proposals"; the orchestrator promotes or
17
+ # removes it at the phase boundary. Entries require non-empty name and rule.
18
+ # - name: <short pattern name>
19
+ # rule: <the rule, one or two sentences>
20
+ # evidence: <optional: where the pattern showed up>
21
+ proposed_conventions: []
15
22
  closeout_summary: ""
16
23
  # Optional full closeout Markdown. YAML literal blocks are supported.
17
24
  closeout_content: |-
@@ -0,0 +1,51 @@
1
+ # Spike — <spike-id>: <one-line question>
2
+
3
+ <!--
4
+ Output template for one spike: a bounded investigation that answers a question
5
+ the pipeline could not settle from source reading alone (a runtime probe, a
6
+ measurement, a reproduction attempt).
7
+
8
+ Place the report at: scratch/spikes/<spike-id>/<scenario>.md
9
+ (one file per scenario; several scenarios may serve one spike-id).
10
+
11
+ Spikes are usually registered first as post_pipeline entries (kind: spike) in a
12
+ phase handoff. When a spike's findings change the reimplementation spec, write
13
+ the deltas as Recommended Deltas below and apply them with the
14
+ spec-delta-application skill; when a spike resolves an open question after the
15
+ pipeline completed, close it with an amendment (templates/amendment.yaml +
16
+ codecarto_amend), citing this report.
17
+
18
+ Keep it honest: a spike that failed to answer its question is a valid result —
19
+ record what was tried and what blocked it.
20
+ -->
21
+
22
+ ## Goal
23
+
24
+ <!-- The exact question this spike answers, and which open_questions / post_pipeline
25
+ id(s) it serves. One paragraph. -->
26
+
27
+ ## Method
28
+
29
+ <!-- What was run, built, probed, or measured — precisely enough to re-run it.
30
+ Include commands, fixtures, and environment facts that affect the result. -->
31
+
32
+ ## Measurements
33
+
34
+ <!-- Raw observations before interpretation: outputs, timings, counts, captured
35
+ frames, exit codes. Paste the actual returns — a summary is not evidence. -->
36
+
37
+ ## Findings
38
+
39
+ <!-- What the measurements mean for the question in Goal. Mark each finding:
40
+ confirmed / refuted / inconclusive. An inconclusive spike states what would
41
+ settle it. -->
42
+
43
+ ## Recommended Deltas
44
+
45
+ <!-- Changes the findings imply, one per bullet, each addressed to a specific
46
+ artifact section (usually the reimplementation spec). These feed the
47
+ spec-delta-application skill's triage — APPLY / CLARIFY / DEFER / REJECT is
48
+ that session's call, not this report's. If a finding closes an open
49
+ question, name the amendment slug that will apply it. -->
50
+
51
+ - Δ1 —
@@ -3,4 +3,4 @@
3
3
  # workspace's framework-owned files (GUIDE.md, templates/, workflow/ pipelines
4
4
  # and VALIDATE.md) predate the running release. Written at release time and
5
5
  # copied verbatim by init — never edit by hand.
6
- scaffold_version: 0.14.1
6
+ scaffold_version: 0.16.0
@@ -14,9 +14,11 @@ Three roles, and you hold two of them:
14
14
  | Role | Who | Does |
15
15
  |---|---|---|
16
16
  | State machine | the MCP server | phase order, prompts, validation parsing, completion gate, canonical state |
17
- | Orchestrator | you | pick the pipeline, drive the loop, choose an executor, verify |
17
+ | Orchestrator | you | pick the pipeline, drive the loop, choose an executor, verify, and hold the cross-phase duties (`references/orchestration.md`) |
18
18
  | Executor | you, or a model you delegate to | read the repo, write the phase artifact |
19
19
 
20
+ Being the orchestrator does not preclude executing phases yourself — a single chat driving these tools inline is the normal case, and it holds both the Orchestrator and Executor rows. What makes a run orchestrated is performing the phase-boundary duties (convention promotion, open-question re-triage, contradiction sweeps, gap routing), not delegating the work. If the workspace `GUIDE.md` predates this contract and says the orchestrator must not execute phases, trust this guide.
21
+
20
22
  ## The drive loop
21
23
 
22
24
  ```
@@ -120,6 +122,8 @@ A PARTIAL row's evidence must name what is missing and which `open_questions` or
120
122
 
121
123
  ## When the run drives a rewrite
122
124
 
125
+ When the pipeline completes, the finished spec has a designed destination: publish it to a **library** (`codecarto_publish`; create one with `codecarto_library_init`) so synthesis runs and other projects can consume it — `references/library.md`. A spec that only ever lives in its workspace helps exactly one repository.
126
+
123
127
  If the goal is to rebuild or refactor rather than to understand, two phases carry that weight and both have their own reference:
124
128
 
125
129
  - the defect scans feed `porting` and `reimplementation-spec` as inputs, not as an appendix — `references/deep-audit-synthesis.md`;
@@ -129,6 +133,7 @@ If the goal is to rebuild or refactor rather than to understand, two phases carr
129
133
 
130
134
  Running the pipeline:
131
135
 
136
+ - `references/orchestration.md` — the orchestrator's duties, inline vs delegated execution, and the session-by-session fallback's real costs
132
137
  - `references/pipeline-selection.md` — choosing a variant, and switching without losing work
133
138
  - `references/executors.md` — the executor contract, adapters, and model selection
134
139
  - `references/handoff-contract.md` — full handoff schema, routing, and closure semantics
@@ -139,5 +144,6 @@ Using what it produces:
139
144
  - `references/deep-audit-synthesis.md` — defect dispositions, hazards as normative rules, reporting
140
145
  - `references/kernel-first-rewrite.md` — rings, build order, acceptance harness, strategic assumptions
141
146
  - `references/carrying-results-forward.md` — starting implementation, autonomy boundaries, publishing findings
147
+ - `references/library.md` — publishing finished specs to a library and consuming them from synthesis runs
142
148
 
143
149
  This guide is also served by the `codecarto_guide` MCP tool, so an agent with the server configured can read it without installing anything.
@@ -19,7 +19,8 @@ carry_forward: [] # deferred to a specific later phase in this pip
19
19
  carry_forward_closures: [] # ids of carry_forward entries this phase resolved
20
20
  open_question_closures: [] # ids of open questions this phase resolved, removed everywhere
21
21
  post_pipeline: [] # work after the pipeline; every entry needs a stable id
22
- decisions: [] # choices made beyond what the prompt specified
22
+ decisions: [] # choices made beyond what the prompt specified; completion appends them to DECISIONS.md
23
+ proposed_conventions: [] # patterns proposed for promotion; completion stages them in CONVENTIONS.md
23
24
  closeout_summary: "" # one clause, ~20 words; becomes the THREAD_LOG entry
24
25
  closeout_content: |- # optional full closeout markdown
25
26
  # Closeout — architecture
@@ -52,6 +53,16 @@ Omitted arrays default to empty. A malformed collection fails completion without
52
53
 
53
54
  Allowed `kind` values: `needs-runtime-test`, `needs-maintainer-decision`, `needs-spec-ruling`, `defer-to-phase`, `needs-fixture-capture`.
54
55
 
56
+ `proposed_conventions` entries (optional; omitted defaults to empty):
57
+
58
+ ```yaml
59
+ - name: evidence-marker-citations
60
+ rule: Cite every load-bearing claim with an evidence marker naming its source file.
61
+ evidence: Third phase in a row independently adopted the [fact/inference] vocabulary.
62
+ ```
63
+
64
+ `name` and `rule` are required and non-empty — a malformed entry fails completion. Completion stages each entry in `CONVENTIONS.md` under `## Pending proposals` (mechanical, deduplicated on re-run); promoting a staged proposal into a numbered convention stays an orchestrator judgment at the phase boundary. `decisions` are simpler: plain strings that completion both renders into the closeout's "Decisions Beyond Prompt" section and appends to `DECISIONS.md` as numbered `D<NNN>` rows under `## Completion log`.
65
+
55
66
  ## Open question or carry-forward?
56
67
 
57
68
  - **`open_questions`** — nobody in this pipeline will resolve it. It needs a runtime test, a maintainer decision, or a spec ruling. It survives to the end as a known unknown.
@@ -0,0 +1,32 @@
1
+ # The library: where finished specs go
2
+
3
+ A CodeCartographer **library** is a directory of published reimplementation-specs with provenance — the bridge between analysis runs and everything downstream. An analysis pipeline ends with a spec in one workspace; publishing it makes it addressable from any other project, and the **synthesis pipeline** consumes exactly these entries ("convert a user vision and explicitly confirmed library specs into a provenance-backed project plan" — see `codecarto_guide` topic `pipeline-selection`). Without a publish step, every analysis is an island.
4
+
5
+ ## Anatomy
6
+
7
+ - A directory holding a `.codecarto-library` marker, `entries/` (optionally namespaced), and a generated `index.yaml` + `INDEX.md`.
8
+ - Discovery: tools take `library_path` (absolute) directly, or resolve the library from a workspace `cwd`'s `config.yaml`; `codecarto_library_init` also writes `library.path` into the user-global config so later calls need no path at all.
9
+ - `codecarto_config` shows the effective merge (`library.path`, `library.namespace`, `publish_confirm`) and whether the marker was found.
10
+
11
+ ## The four tools
12
+
13
+ | Tool | Does | Notes |
14
+ |---|---|---|
15
+ | `codecarto_library_init` | Create the directory, write the marker, record `library.path` in user-global config | Idempotent; pass `namespace` to create a namespaced library |
16
+ | `codecarto_publish` | Publish a spec as a library entry | Required: `source_repo`, `headline`, and `spec` (inline) or `spec_path` (absolute). Content-hash idempotent: identical bytes update metadata in place, no version bump. `slug` derives from `source_repo` if omitted; namespaced libraries require `namespace` (or inherit via `cwd`). Provenance (`source_commit`, `source_branch`, `source_dirty`, `analyzed_at`, `pipeline`, `model_metadata`) is recorded; omitted generation fields default to `unknown` |
17
+ | `codecarto_library_list` | List entries | Filter by `namespace`, `tag`, `slug`, or `source_repo` |
18
+ | `codecarto_library_reindex` | Regenerate `index.yaml` + `INDEX.md` from filesystem state | For manual edits and index merge conflicts |
19
+
20
+ ## When to publish
21
+
22
+ The moment `reimplementation-spec` completes and validates is the publish moment — the spec is finished, the workspace still knows its provenance (`cwd` inherits `pipeline` from `status.yaml`), and the terminal `next_actions` point here. Publish with `cwd` set so provenance rides along:
23
+
24
+ ```
25
+ codecarto_publish cwd:<workspace repo> source_repo:<repo URL or path> headline:"<one line>" spec_path:<abs path to reimplementation-spec.md>
26
+ ```
27
+
28
+ Set `publish_confirm` in config if you want an explicit confirmation gate before writes.
29
+
30
+ ## What this is not
31
+
32
+ Publishing a spec into a library is different from copying findings into a product repository you are about to build — that curated-snapshot flow is `references/carrying-results-forward.md`. The library holds *specs as reusable inputs*; a product repo holds *your implementation of one*.
@@ -0,0 +1,45 @@
1
+ # Orchestration
2
+
3
+ The orchestrator is the persistent chat driving the run — normally the session reading this guide. The role is defined by **duties**, not by who executes phases. A single chat that runs every phase itself and performs the duties below is fully orchestrated; a fleet of delegated sub-agents whose driver skips them is not.
4
+
5
+ ## The duties
6
+
7
+ All of them happen at the **phase boundary**: after one phase completes, before the next begins. None of them happen mid-phase — a phase executor follows its SKILL.md; the orchestrator judges between phases.
8
+
9
+ 1. **Promote conventions and append decisions.** Phase closeouts carry "Proposed Conventions" and "Decisions Beyond Prompt" sections; handoffs carry a `decisions` array. Promotion into `CONVENTIONS.md` (when a pattern recurs or clearly generalizes) and `DECISIONS.md` (every cross-cutting decision, numbered, append-only) is your call to make at the boundary. Proposals left in closeout prose are proposals lost — a real seven-phase run stranded ~12 proposed conventions and 23 decisions this way, because nobody held the duty.
10
+
11
+ 2. **Re-triage open-question labels.** An `open_questions` entry's `kind` is itself a claim that needs evidence. Before accepting `needs-maintainer-decision` or `needs-runtime-test` into the next phase, re-test: *has this become answerable by reading?* Labels are sticky — the routing machinery faithfully carries a question forward, but nothing re-examines whether the label was right, so a mislabel suppresses verification for the rest of the pipeline.
12
+
13
+ 3. **Sweep for contradictions.** Compare the incoming phase's required reads against earlier phases' `owner_notes`. A measured fact that contradicts a summarized claim (a line count that belies "this layer is pure configuration", a schema that admits a value a doc says is impossible) is a gap to route — into the next phase's work, an `open_questions` entry, or a correction — not a nuance to smooth over.
14
+
15
+ 4. **Route gaps.** Confirm the completed phase's declared secondary outputs were written or explicitly routed to a later phase. Confirm any handoff decision that *defers* work names a place a later phase will actually look. A deferral recorded only as prose in a decision entry goes nowhere: the same seven-phase run deferred a declared secondary output via a handoff decision, and it was silently dropped.
16
+
17
+ 5. **Gate strategic forks with the user.** Pipeline switches, the opinionated-vs-language-agnostic spec choice, scope changes, force-reinit. These are the user's calls; your job is to surface them at the right moment with a recommendation.
18
+
19
+ ## The failure this section exists to prevent
20
+
21
+ In a real `full-with-deep-audit` run, the architecture phase recorded an open question — "is the absence of authentication on the web surface intended?" — labeled `needs-maintainer-decision`, on the stated ground that a threat model is not derivable from code. The label was wrong: the shipped launcher *refuses* non-loopback binds in code, with the reason in the error string, and five minutes of reading would have answered the question. But the label was never re-examined. The question rode the carry-forward machinery through four phases (`arch-OQ2` → `dss-OQ3` → `port-OQ1` → `spec-OQ1`), and its unverified premise hardened into a wrong high-severity security finding that survived into the final reimplementation spec — corrected only because the user happened to ask about it directly afterward.
22
+
23
+ Two duties would each have caught it: re-triage (duty 2) would have re-tested the label at any of four boundaries; the contradiction sweep (duty 3) had the evidence in hand, since the run's own notes contained both "the launcher owns only composition selection" and "no enforcement exists anywhere."
24
+
25
+ ## Execution strategies
26
+
27
+ How the orchestrator and executor roles map onto threads is a per-run choice, orthogonal to the duties:
28
+
29
+ - **Inline** — you execute phases yourself. The normal mode for a single chat driving the MCP tools; also the right mode when the user asks one thread to do everything. Perform the duties between `codecarto_complete` and the next `codecarto_next`.
30
+ - **Delegated** — you dispatch each phase to a separate execution context (the Pi extension's phase sub-agents do this automatically; on other hosts, fresh threads run prompts you draft) and review each closeout. Keeps phase context out of your window, which matters on long pipelines and small context budgets. Same duties, same boundary.
31
+
32
+ Mixing is normal: delegate the wide-read phases, run the synthesis phases inline where your judgment is the value. See `references/executors.md` for choosing per phase.
33
+
34
+ ## The session-by-session fallback
35
+
36
+ Running each phase in an isolated session with nobody holding the duties is a **fallback, not a peer mode**. Its costs are the failures above: empty `CONVENTIONS.md`, stranded proposals, unchallenged labels, dropped deferrals. It is legitimate in exactly two cases:
37
+
38
+ - the user explicitly declines orchestration, or
39
+ - the driving model cannot sustain cross-phase context.
40
+
41
+ Record the reason in the first handoff's `owner_notes` so a later session knows the mode was chosen, not defaulted into.
42
+
43
+ ## First run on a fresh workspace
44
+
45
+ Adopt the orchestrator role by default — do not interview the user about whether orchestration should happen. Seed `CONVENTIONS.md` and `DECISIONS.md` from their templates if missing, pick the execution strategy from the situation (single MCP chat → inline; sub-agent host → delegated), and note the strategy in the first handoff's `owner_notes`. Ask the user only when their instructions genuinely conflict with both defaults, and never under an `--auto` run, which must not block on questions.
@@ -0,0 +1,41 @@
1
+ import type { WorkspaceState } from "./types.ts";
2
+ /** One parsed amendment file from scratch/amendments/<slug>.yaml. */
3
+ export type Amendment = {
4
+ /** The file's basename without extension; names the closeout. */
5
+ slug: string;
6
+ /** Open-question ids to remove from every phase. */
7
+ open_question_closures: string[];
8
+ /** post_pipeline item ids to remove from the backlog (the closeout records the closure). */
9
+ post_pipeline_closures: string[];
10
+ /** Durable observations recorded in the amendment closeout. */
11
+ notes: string[];
12
+ closeout_summary: string;
13
+ closeout_content: string;
14
+ schema_version?: number;
15
+ };
16
+ /** What one amendment application changed, id by id. */
17
+ export type AmendmentApplication = {
18
+ openQuestionsClosed: string[];
19
+ postPipelineClosed: string[];
20
+ /** Requested ids that matched nothing — already closed or never existed. Re-running an amendment is safe. */
21
+ unknownIds: string[];
22
+ };
23
+ export type AmendmentResult = {
24
+ updatedState: WorkspaceState;
25
+ closeoutNotice: string;
26
+ applied: AmendmentApplication;
27
+ };
28
+ /** Same charset rule as phase ids: the slug becomes file names, so path shapes are refused. */
29
+ export declare function assertSafeAmendmentSlug(slug: string): void;
30
+ /**
31
+ * Load and validate one amendment file.
32
+ * @param name - the amendment slug, with or without a `.yaml` suffix.
33
+ */
34
+ export declare function loadAmendmentFile(name: string, workspaceDir: string): Promise<Amendment>;
35
+ /**
36
+ * Apply one amendment to canonical state under the completion lock. Refuses
37
+ * while the pipeline is incomplete — mid-pipeline resolutions belong in the
38
+ * phase handoff, and allowing both channels at once would race them.
39
+ * Idempotent: ids that no longer match anything are reported, not fatal.
40
+ */
41
+ export declare function applyAmendment(cwd: string, name: string): Promise<AmendmentResult>;