codecartographer-pi 0.1.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 (75) hide show
  1. package/.codecarto/BACKLOG.md +192 -0
  2. package/.codecarto/CHANGELOG-2026-05-02-feedback-pass.md +118 -0
  3. package/.codecarto/CONTRIBUTING.md +56 -0
  4. package/.codecarto/GUIDE.md +298 -0
  5. package/.codecarto/LICENSE +21 -0
  6. package/.codecarto/NEW_THREAD_BLURB.md +47 -0
  7. package/.codecarto/README.md +39 -0
  8. package/.codecarto/THREAD_LOG.md +39 -0
  9. package/.codecarto/closeouts/2026-05-02-framework-feedback-pass.md +111 -0
  10. package/.codecarto/findings/architecture/README.md +3 -0
  11. package/.codecarto/findings/architecture/SKILL.md +102 -0
  12. package/.codecarto/findings/build-and-deploy/.gitkeep +0 -0
  13. package/.codecarto/findings/config-model/.gitkeep +0 -0
  14. package/.codecarto/findings/contracts/README.md +3 -0
  15. package/.codecarto/findings/contracts/SKILL.md +89 -0
  16. package/.codecarto/findings/defect-scan/README.md +18 -0
  17. package/.codecarto/findings/defect-scan/SKILL.md +87 -0
  18. package/.codecarto/findings/defect-scan/passes/01-logic-and-correctness.md +50 -0
  19. package/.codecarto/findings/defect-scan/passes/02-error-handling.md +55 -0
  20. package/.codecarto/findings/defect-scan/passes/03-concurrency-and-resources.md +54 -0
  21. package/.codecarto/findings/defect-scan/passes/04-security-and-trust.md +62 -0
  22. package/.codecarto/findings/defect-scan/passes/05-api-contract-violations.md +57 -0
  23. package/.codecarto/findings/defect-scan/passes/06-config-and-environment.md +58 -0
  24. package/.codecarto/findings/defect-scan-mechanical/README.md +17 -0
  25. package/.codecarto/findings/defect-scan-mechanical/SKILL.md +60 -0
  26. package/.codecarto/findings/defect-scan-semantic/README.md +17 -0
  27. package/.codecarto/findings/defect-scan-semantic/SKILL.md +54 -0
  28. package/.codecarto/findings/porting/README.md +3 -0
  29. package/.codecarto/findings/porting/SKILL.md +52 -0
  30. package/.codecarto/findings/protocols/README.md +3 -0
  31. package/.codecarto/findings/protocols/SKILL.md +87 -0
  32. package/.codecarto/findings/public-surfaces/README.md +3 -0
  33. package/.codecarto/findings/reimplementation-spec/README.md +3 -0
  34. package/.codecarto/findings/reimplementation-spec/SKILL.md +66 -0
  35. package/.codecarto/findings/runtime-lifecycle/README.md +3 -0
  36. package/.codecarto/findings/state-and-storage/README.md +3 -0
  37. package/.codecarto/scratch/.gitkeep +0 -0
  38. package/.codecarto/skills/spec-delta-application/SKILL.md +102 -0
  39. package/.codecarto/templates/architecture-map.md +143 -0
  40. package/.codecarto/templates/behavioral-contracts.md +134 -0
  41. package/.codecarto/templates/closeout-template.md +85 -0
  42. package/.codecarto/templates/conventions-template.md +65 -0
  43. package/.codecarto/templates/decisions-template.md +82 -0
  44. package/.codecarto/templates/defect-fix-tracker.md +77 -0
  45. package/.codecarto/templates/defect-report.md +116 -0
  46. package/.codecarto/templates/deltas-applied.md +71 -0
  47. package/.codecarto/templates/mechanical-defects.md +104 -0
  48. package/.codecarto/templates/protocols-and-state.md +126 -0
  49. package/.codecarto/templates/reimplementation-spec-opinionated.md +183 -0
  50. package/.codecarto/templates/reimplementation-spec.md +148 -0
  51. package/.codecarto/templates/reverse-engineering-bundle.md +141 -0
  52. package/.codecarto/templates/semantic-defects.md +109 -0
  53. package/.codecarto/templates/thread-log-entry-template.md +27 -0
  54. package/.codecarto/workflow/VALIDATE.md +81 -0
  55. package/.codecarto/workflow/pipeline-architecture-only.yaml +38 -0
  56. package/.codecarto/workflow/pipeline-defect-scan.yaml +61 -0
  57. package/.codecarto/workflow/pipeline-full-with-audit.yaml +188 -0
  58. package/.codecarto/workflow/pipeline-full-with-deep-audit.yaml +227 -0
  59. package/.codecarto/workflow/pipeline-lite.yaml +100 -0
  60. package/.codecarto/workflow/pipeline.yaml +163 -0
  61. package/.codecarto/workflow/status.yaml +64 -0
  62. package/LICENSE +21 -0
  63. package/README.md +356 -0
  64. package/core/index.ts +11 -0
  65. package/core/pipeline.ts +175 -0
  66. package/core/prompts.ts +183 -0
  67. package/core/status.ts +155 -0
  68. package/core/types.ts +96 -0
  69. package/core/utils.ts +52 -0
  70. package/core/workspace.ts +81 -0
  71. package/core/yaml.ts +256 -0
  72. package/extensions/codecarto/index.ts +446 -0
  73. package/mcp-server/bin.mjs +7 -0
  74. package/mcp-server/server.ts +497 -0
  75. package/package.json +52 -0
@@ -0,0 +1,17 @@
1
+ # Defect Scan — Mechanical Pass
2
+
3
+ Early, context-light defect pass. Runs after architecture and before contracts in the `pipeline-full-with-deep-audit` workflow. Covers logic and correctness, error handling, and configuration hazards — the bugs visible from local code reading.
4
+
5
+ **Primary output:** `mechanical-defects.md`
6
+
7
+ **Depends on:** architecture phase (required).
8
+
9
+ **Pass subset (mechanical):**
10
+
11
+ 1. Logic and correctness
12
+ 2. Error handling and resilience
13
+ 6. Configuration and environment hazards
14
+
15
+ The deeper passes (concurrency, security, API contract violations) live in the `defect-scan-semantic` phase, which runs after protocols.
16
+
17
+ See `SKILL.md` for instructions. Pass-specific guidance is reused from `findings/defect-scan/passes/`.
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: scan-for-defects-mechanical
3
+ description: Run the early, mechanical subset of the multi-pass defect scan — local bugs that do not need contracts or protocols context to spot. Run after the architecture phase, before contracts. Covers logic and correctness, error handling and resilience, and configuration and environment hazards. The semantic subset (concurrency, security, API contract violations) runs later in the `defect-scan-semantic` phase, after protocols.
4
+ ---
5
+
6
+ # Scan For Defects — Mechanical Pass
7
+
8
+ This phase runs the **early, mechanical** half of the defect-scan methodology. It catches the bugs that are visible from local code reading without needing the contracts or protocols phases to be done first. The deeper passes (concurrency, security, API contract violations) live in the later `defect-scan-semantic` phase.
9
+
10
+ The source code to analyze is in the parent directory (`../` relative to `.codecarto/`).
11
+
12
+ ## Prerequisites
13
+
14
+ **Required:**
15
+ - `findings/architecture/architecture-map.md` — for the layer map and public surfaces.
16
+
17
+ You do **not** need contracts or protocols for this phase. If those exist already, skim them as bonus context, but do not block on them — the mechanical pass is by design context-light.
18
+
19
+ ## Pass Execution Order
20
+
21
+ Run these three passes sequentially. Read the pass file, scan the source, record findings, then move to the next pass. Each pass file is the same one used by the legacy `defect-scan` phase — only the subset is different.
22
+
23
+ | Pass | File | Focus |
24
+ |------|------|-------|
25
+ | 1 | `findings/defect-scan/passes/01-logic-and-correctness.md` | Dead code, boundary errors, null handling, boolean logic, control flow |
26
+ | 2 | `findings/defect-scan/passes/02-error-handling.md` | Swallowed errors, missing cleanup, uncaught exceptions, retry gaps |
27
+ | 6 | `findings/defect-scan/passes/06-config-and-environment.md` | Hardcoded values, missing validation, dangerous defaults, OS assumptions |
28
+
29
+ Passes 3, 4, and 5 are deferred to `defect-scan-semantic` because they benefit from contracts/protocols context.
30
+
31
+ ## Prioritization
32
+
33
+ Use the architecture map to decide emphasis:
34
+ - **Pure library with no config?** Skim pass 6.
35
+ - **Heavy generic-types or branching logic?** Spend extra time on pass 1.
36
+ - **No surfaced error model in architecture?** Pass 2 may surface that gap as a finding.
37
+
38
+ ## Evidence and Severity Classification
39
+
40
+ Use the same scheme as the legacy defect-scan SKILL:
41
+
42
+ - **Evidence levels:** `observed fact`, `strong inference`, `open question`.
43
+ - **Severity:** `critical`, `high`, `medium`, `low`.
44
+ - **Action (pre-porting pipelines):** `fix before porting`, `port differently`, `leave behind`.
45
+
46
+ See `findings/defect-scan/SKILL.md` for the full criteria; this phase intentionally does not duplicate them.
47
+
48
+ ## Output
49
+
50
+ Write findings to the primary output using `templates/mechanical-defects.md`. Organize by pass, then by severity within each pass. End with a summary table covering only passes 1, 2, and 6.
51
+
52
+ If the semantic phase later finds related defects, those go in its own report — do not amend this one after this phase is complete.
53
+
54
+ ## What to defer to the semantic phase
55
+
56
+ - Concurrency, race conditions, and lock issues → pass 3 in `defect-scan-semantic`.
57
+ - Auth, input validation, secrets, and trust boundary defects → pass 4 in `defect-scan-semantic`.
58
+ - API/spec/state-machine drift → pass 5 in `defect-scan-semantic`.
59
+
60
+ If you spot something semantic during this phase, record it as a `carry_forward` entry in `workflow/status.yaml` with `target_phase: defect-scan-semantic` so the later phase picks it up.
@@ -0,0 +1,17 @@
1
+ # Defect Scan — Semantic Pass
2
+
3
+ Deep, context-rich defect pass. Runs after protocols and before porting in the `pipeline-full-with-deep-audit` workflow. Covers concurrency, security, and API contract violations — bugs that need contracts and protocols already documented to spot reliably.
4
+
5
+ **Primary output:** `semantic-defects.md`
6
+
7
+ **Depends on:** architecture, contracts, protocols, and `defect-scan-mechanical` phases (all required).
8
+
9
+ **Pass subset (semantic):**
10
+
11
+ 3. Concurrency and resource management
12
+ 4. Security and trust boundaries
13
+ 5. API contract violations
14
+
15
+ The early passes (logic, error handling, config) live in the `defect-scan-mechanical` phase, which runs right after architecture.
16
+
17
+ See `SKILL.md` for instructions. Pass-specific guidance is reused from `findings/defect-scan/passes/`.
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: scan-for-defects-semantic
3
+ description: Run the deep, semantic subset of the multi-pass defect scan — bugs that need contracts and protocols context to spot. Run after protocols, before porting. Covers concurrency and resource management, security and trust boundaries, and API contract violations (including state machine drift). The mechanical subset (logic, error handling, config) runs earlier in the `defect-scan-mechanical` phase, after architecture.
4
+ ---
5
+
6
+ # Scan For Defects — Semantic Pass
7
+
8
+ This phase runs the **deep, semantic** half of the defect-scan methodology. The findings here only become legible once you know what the code is *supposed* to do — that is what the contracts and protocols phases give you. The early mechanical bugs (passes 1, 2, 6) were caught in the earlier `defect-scan-mechanical` phase.
9
+
10
+ The source code to analyze is in the parent directory (`../` relative to `.codecarto/`).
11
+
12
+ ## Prerequisites
13
+
14
+ **Required:**
15
+ - `findings/architecture/architecture-map.md`
16
+ - `findings/contracts/behavioral-contracts.md` — pass 5 needs this to define "violation."
17
+ - `findings/protocols/protocols-and-state.md` — passes 3 and 5 need this for state machine and event-ordering analysis.
18
+ - `findings/defect-scan-mechanical/mechanical-defects.md` — read so you do not re-flag what the mechanical phase already covered.
19
+
20
+ If any prerequisite is missing, stop and surface the gap. The semantic pass is the *paid-for* benefit of running the mechanical phase early; do not regress it by running the semantic pass blind.
21
+
22
+ ## Pass Execution Order
23
+
24
+ Run these three passes sequentially. Read the pass file, scan the source, record findings, then move to the next pass. Each pass file is reused from the legacy `defect-scan` phase.
25
+
26
+ | Pass | File | Focus |
27
+ |------|------|-------|
28
+ | 3 | `findings/defect-scan/passes/03-concurrency-and-resources.md` | Race conditions, lock issues, async pitfalls, resource leaks |
29
+ | 4 | `findings/defect-scan/passes/04-security-and-trust.md` | Input validation, auth gaps, secrets in code, trust boundaries |
30
+ | 5 | `findings/defect-scan/passes/05-api-contract-violations.md` | Spec vs. implementation drift, return type mismatches, state machine violations |
31
+
32
+ ## Prioritization
33
+
34
+ Use the contracts and protocols outputs to decide emphasis:
35
+ - **No concurrency model in protocols?** Skim pass 3, focus elsewhere.
36
+ - **No auth system in contracts?** Skip the auth sections of pass 4, still check input validation.
37
+ - **Heavy state machine in protocols?** Spend extra time on pass 5.
38
+ - **Many features in contracts marked "core" or "important"?** Pass 5 spec-vs-impl drift on those is high-value.
39
+
40
+ ## Evidence, Severity, and Action Classification
41
+
42
+ Use the scheme from `findings/defect-scan/SKILL.md`. The severity and action sets are the same as the legacy defect-scan phase.
43
+
44
+ When citing a contract or protocol violation, include the contract ID or state-machine reference from the upstream finding so the porting phase can trace the chain.
45
+
46
+ ## Honor the carry_forward routing
47
+
48
+ Read the `carry_forward` entries in `workflow/status.yaml` whose `target_phase` is `defect-scan-semantic`. The mechanical phase may have routed semantic-flavored sightings here for closure.
49
+
50
+ ## Output
51
+
52
+ Write findings to the primary output using `templates/semantic-defects.md`. Organize by pass, then by severity within each pass. End with a summary table covering only passes 3, 4, and 5.
53
+
54
+ The porting phase's reverse-engineering bundle has a "Defect Synthesis" section that consolidates this report and the mechanical report — do not pre-fill that here.
@@ -0,0 +1,3 @@
1
+ # Porting Findings
2
+
3
+ Store porting order, migration strategy, compatibility risks, and acceptance criteria here.
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: reverse-engineer-for-porting
3
+ description: Synthesize architecture, contracts, and protocol findings into a reverse-engineering bundle oriented toward reimplementation in another language or runtime.
4
+ ---
5
+
6
+ # Reverse Engineer For Porting
7
+
8
+ This phase synthesizes the outputs of architecture, contracts, and protocols. If defect reports exist, also read and integrate them: `findings/defect-scan/defect-report.md` (full-with-audit pipeline) or both `findings/defect-scan-mechanical/mechanical-defects.md` and `findings/defect-scan-semantic/semantic-defects.md` (full-with-deep-audit pipeline). The pipeline ensures all required phases are complete before this one runs. Read the prior phase artifacts before starting.
9
+
10
+ The source code to analyze is in the parent directory (`../` relative to `.codecarto/`). This is the repository root.
11
+
12
+ Keep four classes of findings separate throughout:
13
+ - `observed fact`: direct statements from docs, tests, schemas, types, and code.
14
+ - `strong inference`: architectural conclusions drawn from multiple facts.
15
+ - `portability hazard`: assumptions tied to the source language, runtime, terminal, OS, or third-party SDKs.
16
+ - `open question`: missing or conflicting behavior that still needs evidence.
17
+
18
+ Prefer concept names over source names:
19
+ - Translate file- or class-level details into concepts such as `provider adapter`, `message normalizer`, `agent loop`, `tool executor`, `session store`, `render loop`, `UI surface`, or `product shell`.
20
+ - Do not assume the target implementation should mirror the source folder layout.
21
+
22
+ Treat layered repositories as a composition problem:
23
+ - Identify the lowest reusable core first.
24
+ - Separate shared middle layers from delivery surfaces.
25
+ - Treat UI, CLI, bot, web, or deployment wrappers as adapters around shared behavior unless evidence says otherwise.
26
+ - Look for reusable layers such as provider normalization, agent runtime, UI surfaces, and product wrappers.
27
+
28
+ Sort features by porting importance:
29
+ - `core`: required for the system to function.
30
+ - `important`: required for parity on major workflows.
31
+ - `optional`: valuable, but not required for a first viable port.
32
+ - `incidental`: source-specific ergonomics or implementation accidents.
33
+
34
+ If the defect report is available, integrate defect findings into the porting bundle:
35
+ - Reference relevant defects in the feature contract table.
36
+ - Tag each referenced defect with a porting recommendation: `fix before porting` (the defect would carry into a new implementation), `port differently` (the new implementation should handle this case differently by design), or `leave behind` (the defect is specific to the source implementation and won't survive porting).
37
+ - Consolidate defect-related portability hazards alongside hazards from other phases.
38
+
39
+ Use the output template at `templates/reverse-engineering-bundle.md`. Produce:
40
+ - A system summary in plain language.
41
+ - A layer map with package or module ownership.
42
+ - A feature contract table with porting priority (include defect references if the defect report exists).
43
+ - A protocol and state note set.
44
+ - Portability hazards consolidated from all prior phases.
45
+ - Observed facts separated from inferred structure.
46
+
47
+ Bias toward evidence over cleverness:
48
+ - Prefer tests over assumptions.
49
+ - Prefer behavior over implementation detail.
50
+ - Mark uncertainty explicitly instead of flattening it away.
51
+
52
+ When fixing defects before or during porting, use the tracker template at `templates/defect-fix-tracker.md` to log each fix, deferral, or acceptance decision. The tracker uses defect IDs from the report (D{pass}.{number}) so progress maps directly back to findings.
@@ -0,0 +1,3 @@
1
+ # Protocol Findings
2
+
3
+ Store JSONL formats, RPC/message protocols, event streams, conversion rules, and state-machine notes here.
@@ -0,0 +1,87 @@
1
+ ---
2
+ name: extract-protocols-and-state
3
+ description: Extract message formats, event streams, state machines, file formats, and cross-boundary protocols from a system. Use when you need to port event-driven agents, session formats, RPC or JSONL interfaces, storage schemas, or tool-calling systems into another language or runtime.
4
+ ---
5
+
6
+ # Extract Protocols And State
7
+
8
+ Treat every boundary as a protocol boundary.
9
+
10
+ Enumerate the boundaries first:
11
+ - process to process
12
+ - UI to core
13
+ - core to provider
14
+ - tool layer to runtime
15
+ - runtime to persistence
16
+ - local files to exported artifacts
17
+
18
+ Prefer type definitions, schemas, and docs before implementation code:
19
+ - Read event and message types first.
20
+ - Read file format docs next.
21
+ - Use source to fill ordering, retry, and recovery gaps.
22
+
23
+ For each protocol, record:
24
+ - `producer`
25
+ - `consumer`
26
+ - `transport or carrier`
27
+ - `ordering guarantees`
28
+ - `required fields`
29
+ - `optional fields`
30
+ - `identifiers and timestamps`
31
+ - `error cases`
32
+ - `restart or resume behavior`
33
+
34
+ Convert control flow into a state machine:
35
+ - Name the states.
36
+ - Name the transitions.
37
+ - Record guards and side effects.
38
+ - Separate synchronous barriers from observational events.
39
+
40
+ Capture persistence semantics explicitly:
41
+ - append-only vs mutable
42
+ - branching vs linear history
43
+ - compaction or summarization
44
+ - replay or resume behavior
45
+ - locking, deduplication, or conflict handling
46
+
47
+ Look for these protocol-heavy areas:
48
+ - streamed assistant events
49
+ - tool call validation and execution
50
+ - session files
51
+ - JSONL or RPC framing
52
+ - queueing semantics
53
+ - background event scheduling
54
+ - transport fallbacks
55
+
56
+ Treat configuration propagation as a protocol when it crosses boundaries:
57
+ - How config values flow from files or env vars into runtime behavior.
58
+ - Whether config changes require a restart or are hot-reloaded.
59
+ - How config is validated and what happens on invalid input.
60
+ - If the config propagation model is complex, use the secondary output at `findings/config-model/config-model.md`.
61
+
62
+ Flag portability hazards that frequently break ports:
63
+ - ANSI terminal semantics
64
+ - IME or cursor positioning rules
65
+ - filesystem locking assumptions
66
+ - async ordering guarantees
67
+ - OAuth token refresh behavior
68
+ - shell quoting and OS differences
69
+ - encoding, width, or Unicode handling
70
+
71
+ Produce four outputs:
72
+ 1. `Event catalog`
73
+ 2. `State machine`
74
+ 3. `Persistent schema notes`
75
+ 4. `Compatibility hazards`
76
+
77
+ Mark every finding with one of these evidence levels:
78
+ - `observed fact`: direct statement from docs, tests, schemas, types, or code.
79
+ - `strong inference`: protocol conclusion drawn from multiple facts.
80
+ - `portability hazard`: assumption tied to the source language, runtime, terminal, OS, or third-party SDKs.
81
+ - `open question`: missing or conflicting behavior that still needs evidence.
82
+
83
+ Do not copy the wire syntax blindly. Preserve the meaning of the interaction, then decide how the target language should encode it.
84
+
85
+ Use the output template at `templates/protocols-and-state.md`.
86
+
87
+ The source code to analyze is in the parent directory (`../` relative to `.codecarto/`). This is the repository root.
@@ -0,0 +1,3 @@
1
+ # Public Surfaces Findings
2
+
3
+ Store binary commands, exports, external APIs, user-facing screens, and integration surfaces here.
@@ -0,0 +1,3 @@
1
+ # Reimplementation Spec Findings
2
+
3
+ Final language-agnostic build plan and acceptance spec for reimplementation.
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: write-reimplementation-spec
3
+ description: Convert reverse-engineering findings into a language-agnostic reimplementation plan and acceptance spec. Restate a project's features and behavior so another implementation can be built in a different language or runtime without copying the source structure.
4
+ ---
5
+
6
+ # Write Reimplementation Spec
7
+
8
+ Use this skill after the architecture, behavior, and protocol passes are complete enough to trust.
9
+
10
+ Treat the source repo as evidence, not as a template.
11
+
12
+ Define concept-level modules:
13
+ - State each module's responsibility in one sentence.
14
+ - List public inputs and outputs.
15
+ - List owned state and invariants.
16
+ - List collaborators and dependencies.
17
+
18
+ Split the system into three layers of concern:
19
+ - `core semantics`: behavior that must survive the port unchanged
20
+ - `adapters`: integrations with terminal, browser, Slack, filesystem, cloud APIs, or SDKs
21
+ - `delivery surfaces`: CLI, TUI, web, bot, daemon, or deployment wrappers
22
+
23
+ Refactor the findings into target-language-friendly shapes:
24
+ - Do not mirror file names or package names unless they still make sense.
25
+ - Preserve contracts and state semantics before preserving organization.
26
+ - Collapse source-language helper layers that exist only for tooling or typing convenience.
27
+
28
+ For each external dependency, choose one stance:
29
+ - `replace`
30
+ - `wrap`
31
+ - `emulate`
32
+ - `postpone`
33
+
34
+ Write the plan in this order:
35
+ 1. `System summary`
36
+ 2. `Conceptual module model`
37
+ 3. `Required behaviors`
38
+ 4. `Protocols and persisted state`
39
+ 5. `Portability hazards`
40
+ 6. `Implementation sequence`
41
+ 7. `Acceptance scenarios`
42
+ 8. `Known unknowns`
43
+
44
+ Define scope tiers:
45
+ - `minimum viable port`
46
+ - `major-workflow parity`
47
+ - `full parity`
48
+
49
+ Write acceptance scenarios as black-box checks:
50
+ - Inputs must be concrete.
51
+ - Outputs and side effects must be observable.
52
+ - Avoid assertions that depend on internal file names, classes, or source-language idioms.
53
+
54
+ Call out deliberate non-goals:
55
+ - features intentionally deferred
56
+ - source-specific UX details not worth carrying over
57
+ - integrations that will be stubbed first
58
+
59
+ End with a spike list:
60
+ - unknown behaviors that need a prototype
61
+ - risky performance assumptions
62
+ - platform-sensitive areas that need targeted tests
63
+
64
+ Use the output template at `templates/reimplementation-spec.md`.
65
+
66
+ The source code to analyze is in the parent directory (`../` relative to `.codecarto/`). This is the repository root.
@@ -0,0 +1,3 @@
1
+ # Runtime Lifecycle Findings
2
+
3
+ Store boot flow, execution loop, session flow, compaction behavior, and runtime sequencing notes here.
@@ -0,0 +1,3 @@
1
+ # State And Storage Findings
2
+
3
+ Store config files, environment variables, auth material, session files, logs, caches, databases, and generated artifacts here.
File without changes
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: apply-spec-deltas
3
+ description: Apply triaged spec deltas (from spike findings, defect-scan corrections, post-implementation discoveries, or any source proposing changes to a finished reimplementation spec) without rubber-stamping. Use this skill after the pipeline has produced a complete reimplementation-spec and a separate source has surfaced changes the spec should absorb. The skill enforces triage discipline (apply blockers, defer nice-to-haves, reject what doesn't fit), preserves traceability via [revised per <source> §<delta-id>] citations, and produces a DELTAS-APPLIED.md audit table.
4
+ ---
5
+
6
+ # Apply Spec Deltas
7
+
8
+ Use this skill when:
9
+
10
+ - The pipeline has produced a complete `findings/reimplementation-spec/reimplementation-spec.md` (the spec is `complete` in status.yaml).
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`).
13
+ - **Defect-scan re-runs** that find corrections to spec text.
14
+ - **Implementation discoveries** that contradict spec assumptions (e.g., a wire format the spec misread).
15
+ - **Maintainer rulings** that close prior open questions.
16
+
17
+ This is a **post-pipeline** activity. `current_phase` stays `complete`. The spec is updated in place; no phase status changes.
18
+
19
+ ## Core posture: triage, do not rubber-stamp
20
+
21
+ The single rule of this skill: **don't apply deltas verbatim without thinking.** Every delta gets categorized, and only some get applied. Rubber-stamping a delta list produces an incorrect spec — the discipline is the value.
22
+
23
+ Triage every delta into one of four buckets:
24
+
25
+ | Bucket | Definition | Action |
26
+ |---|---|---|
27
+ | **APPLY** | Delta is a real correction or required addition; the spec is wrong without it. | Edit the spec body. Add a `[revised per <source> §<delta-id>]` marker at the changed section. Record in DELTAS-APPLIED.md. |
28
+ | **CLARIFY** | Delta proposes wording change; the spec's *meaning* is correct but the language is ambiguous. | Edit the spec wording (not the rule). Record in DELTAS-APPLIED.md as a clarification. |
29
+ | **DEFER** | Delta is a real improvement but not load-bearing for the next implementation step. | Add to BACKLOG.md with rationale and a back-reference. Do NOT edit the spec. |
30
+ | **REJECT** | Delta is wrong on close reading (premise was incorrect, scope was misread, the rule it proposes already exists, etc.). | Document in DELTAS-APPLIED.md with a one-line rationale. Do NOT edit the spec. |
31
+
32
+ The previous wisdom: any delta you can't decisively bucket should default to DEFER. The cost of a missed correction is one re-application pass; the cost of a bad correction is shipped.
33
+
34
+ ## Citation convention
35
+
36
+ Every applied or clarified delta leaves a citation marker in the spec body so a future reader can trace the change back to its source.
37
+
38
+ ```
39
+ <original spec text> [revised per spike-3-cancellation.md §Δ7]
40
+ <revised spec text> [revised per spike-3-cancellation.md §Δ7]
41
+ ```
42
+
43
+ The marker form is **canonical**, not per-session: `[revised per <source-filename> §<delta-id>]`. The citation convention list at the front-matter of the spec (or the project's `CONVENTIONS.md`) should include `[revised per ...]` as a recognized form.
44
+
45
+ ## Step-by-step
46
+
47
+ ### 1. Pre-flight
48
+
49
+ - Confirm `findings/reimplementation-spec/reimplementation-spec.md` is complete (PASS or PASS WITH GAPS validation block).
50
+ - Read every delta source named in the session prompt (the spike reports, the defect-scan addendum, the maintainer-decision file).
51
+ - Read the spec once end-to-end if you haven't recently. The spec's structure determines where deltas land.
52
+ - Read the project's `CONVENTIONS.md` if present — some deltas may be moved into convention entries instead of the spec body.
53
+
54
+ ### 2. Triage every delta
55
+
56
+ For each delta from each source:
57
+
58
+ - **Read the delta carefully.** Is the premise correct? Does the affected spec section actually say what the delta claims it says?
59
+ - **Categorize: APPLY / CLARIFY / DEFER / REJECT.** Put each delta in exactly one bucket.
60
+ - If APPLY or CLARIFY: identify the exact spec section to edit. Note line numbers (or section anchors) for the audit table.
61
+ - If DEFER: write a one-line BACKLOG.md entry now, don't wait.
62
+ - If REJECT: write a one-paragraph rationale now, don't wait.
63
+
64
+ ### 3. Apply changes (in spec-source order, not delta-order)
65
+
66
+ - Group APPLY/CLARIFY deltas by the spec section they touch.
67
+ - Edit each section once (not once per delta), even if multiple deltas converge on the same section.
68
+ - Add the `[revised per <source> §<delta-id>]` citation marker at the changed paragraph.
69
+ - After edits in a section, re-read the section in full to confirm it still hangs together — neighboring claims may need adjustment.
70
+
71
+ ### 4. Re-run validation on the spec
72
+
73
+ Re-run validation per `workflow/VALIDATE.md` against the spec's `completion_criteria`. The spec was PASS or PASS WITH GAPS before; it must remain PASS or PASS WITH GAPS after. If the validation block degrades, the deltas weren't applied carefully — fix the spec body, do NOT soften the validation criteria. (This rule is load-bearing — see the discipline notes in the source feedback.)
74
+
75
+ ### 5. Write DELTAS-APPLIED.md
76
+
77
+ Use `templates/deltas-applied.md`. The audit table records every delta from every source — APPLY, CLARIFY, DEFER, REJECT — with one row per delta. Future revision passes read this file to know which deltas have already been processed.
78
+
79
+ ### 6. Update the spec's front-matter citation conventions list
80
+
81
+ If the spec has a "Citation Conventions" section (or similar), confirm `[revised per ...]` is listed as a recognized citation form. If not, add it.
82
+
83
+ ### 7. Closeout
84
+
85
+ Per the standard closeout ritual:
86
+
87
+ - Append a one-line entry to `THREAD_LOG.md` pointing at the closeout file.
88
+ - Write `closeouts/<YYYY-MM-DD>-spec-deltas.md` using `templates/closeout-template.md`.
89
+ - Update `status.yaml` only if a delta closed an `open_questions` or `carry_forward` entry — do NOT change `current_phase` (stays `complete`).
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
+
92
+ ## What to avoid
93
+
94
+ - **Don't rubber-stamp.** A delta list is a *proposal*. The spec-delta session decides.
95
+ - **Don't soften the spec's validation criteria** to make the post-edit spec pass. If the validation degrades, the spec body is wrong, not the criteria.
96
+ - **Don't edit deltas in the source files.** The spike report (or defect addendum, or wherever the delta came from) is read-only. DELTAS-APPLIED.md is the audit; the spike report is the evidence.
97
+ - **Don't change status.yaml's current_phase.** This is post-pipeline work; the pipeline is `complete`.
98
+ - **Don't apply deltas across spec sections without reading the neighbors.** A claim in §3.2 may depend on a claim in §3.1; editing one without the other produces silent contradictions.
99
+
100
+ ## Output template
101
+
102
+ Use `templates/deltas-applied.md` for the audit table.
@@ -0,0 +1,143 @@
1
+ # Architecture Map
2
+
3
+ <!--
4
+ Output template for the architecture phase.
5
+ Fill in each section. Remove placeholder text. Keep the section headers.
6
+ Mark every conclusion as: fact / strong inference / open question.
7
+ -->
8
+
9
+ ## System Intent
10
+
11
+ <!-- One paragraph: what does this system do, who is it for, and what problem does it solve? -->
12
+
13
+ ## Layer Map
14
+
15
+ <!--
16
+ List each layer, package, or module. For each:
17
+ - Name
18
+ - Role (core semantics / protocol or normalization / persistence or state / UI or rendering / integration adapter / product shell)
19
+ - Key responsibilities
20
+ - What it depends on
21
+ - What depends on it
22
+
23
+ Call out dependency cycles explicitly.
24
+ Mark packages that are wrappers around shared internals.
25
+ -->
26
+
27
+ ### Package Inventory
28
+
29
+ | Package / Module | Role | Public Entrypoints | Key Dependencies | Runtime Surface |
30
+ |---|---|---|---|---|
31
+ | | | | | |
32
+
33
+ ### Dependency Direction
34
+
35
+ <!-- Describe the dependency graph. Which layer is the stable base? Where do cycles exist? -->
36
+
37
+ ## Public Surfaces
38
+
39
+ <!--
40
+ List every boundary the outside world touches:
41
+ - Binaries and CLI commands
42
+ - Exported libraries and public types
43
+ - Network or RPC interfaces
44
+ - File formats and persistent artifacts
45
+ - User-facing screens or workflows
46
+ -->
47
+
48
+ ## Runtime Lifecycle
49
+
50
+ <!--
51
+ How does the system start, run, and stop?
52
+ - Boot sequence
53
+ - Main event loop or request handling
54
+ - Shutdown and cleanup
55
+ - Background tasks or scheduled work
56
+ -->
57
+
58
+ ## Concurrency Model
59
+
60
+ <!--
61
+ How does the system handle concurrent work?
62
+ - Threading model (single-threaded, thread pool, async/await, actor model, goroutines)
63
+ - Event loop or reactor pattern
64
+ - Shared state and synchronization (locks, channels, atomic operations)
65
+ - Connection pooling and resource management
66
+ - Rate limiting or backpressure mechanisms
67
+ - Performance-critical paths and known bottlenecks
68
+
69
+ Mark portability hazards: concurrency models rarely translate 1:1 across languages.
70
+ -->
71
+
72
+ ## Build and Packaging
73
+
74
+ <!--
75
+ How is the system built and distributed?
76
+ - Build tool(s) and build scripts
77
+ - Multi-stage or multi-target builds
78
+ - Output artifacts (binaries, containers, packages, bundles)
79
+ - CI/CD pipeline (if visible from repo)
80
+ - Platform-specific packaging (npm, pip, cargo, Docker, etc.)
81
+
82
+ If the build pipeline is complex, write detailed notes to the secondary output
83
+ at findings/build-and-deploy/build-and-deploy.md instead.
84
+ -->
85
+
86
+ ## Porting Priorities
87
+
88
+ <!--
89
+ Which parts matter most for a reimplementation?
90
+ - core: required for the system to function
91
+ - important: required for parity on major workflows
92
+ - optional: valuable but not needed for first viable port
93
+ - incidental: source-specific ergonomics
94
+ -->
95
+
96
+ | Component | Priority | Rationale |
97
+ |---|---|---|
98
+ | | | |
99
+
100
+ ## Durable State
101
+
102
+ <!--
103
+ Config files, environment variables, auth material, session files,
104
+ logs, caches, databases, generated artifacts.
105
+ -->
106
+
107
+ ## Open Questions
108
+
109
+ <!-- Items that are still genuinely unknown — need a runtime test, maintainer decision, or spec ruling.
110
+ NOT items deferred to a later phase in this pipeline (those go in Carry-Forward).
111
+ Each entry: { id, kind, description, deferred_reason }. See workflow/status.yaml schema. -->
112
+
113
+ | ID | Kind | Description | Deferred Reason |
114
+ |---|---|---|---|
115
+ | | | | |
116
+
117
+ ## Carry-Forward
118
+
119
+ <!-- Items deferred to a specific later phase whose rubric is the right place to close them.
120
+ Each entry: { id, kind: defer-to-phase, target_phase, description, deferred_reason }.
121
+ Mirror these into workflow/status.yaml under this phase's carry_forward list. -->
122
+
123
+ | ID | Target Phase | Description | Deferred Reason |
124
+ |---|---|---|---|
125
+ | | | | |
126
+
127
+ ---
128
+
129
+ ## Validation
130
+
131
+ <!-- Fill in this table per workflow/VALIDATE.md. The rows below match the full pipeline.
132
+ Adjust rows to match your active pipeline's completion_criteria if using a variant. -->
133
+
134
+ | # | Criterion | Result | Evidence |
135
+ |---|-----------|--------|----------|
136
+ | 1 | The system intent is documented. | PASS / PARTIAL / FAIL | |
137
+ | 2 | The layer map and dependency direction are documented. | PASS / PARTIAL / FAIL | |
138
+ | 3 | Public surfaces are identified. | PASS / PARTIAL / FAIL | |
139
+ | 4 | Runtime lifecycle, concurrency model, and porting priorities are summarized. | PASS / PARTIAL / FAIL | |
140
+ | 5 | Findings are marked with evidence levels. | PASS / PARTIAL / FAIL | |
141
+
142
+ **Validated by:** [session identifier or date]
143
+ **Overall:** PASS / PASS WITH GAPS / FAIL