Contract — ADR-007 ADR file post-state
This task ships exactly one new file plus an index update. No source code, no migrations, no test changes. The deliverable is an Architecture Decision Record draft (status: proposed) that the human or PM can accept, reject, or amend.
File post-state
| Path | Operation | Notes |
|---|---|---|
docs/architecture/decisions/ADR-007-eta-session-lifecycle.md |
Create | New ADR; numbering reserved (ADR-001–006 exist; 007 is the next free slot). |
docs/architecture/decisions/index.md |
Update | Add one row to the Index list pointing at ADR-007. Keep the existing ADR-006 row + See-also section unchanged. |
docs/audits/adr-007-eta-session-lifecycle-audit.md |
Already created | Step 1 artefact. |
docs/contracts/adr-007-eta-session-lifecycle-contract.md |
This file | Step 2 artefact. |
docs/packets/adr-007-eta-session-lifecycle-packet.md |
Created in Step 3 | Section outline. |
docs/verification/adr-007-eta-session-lifecycle-verification.md |
Created in Step 5 | Deliverable checklist. |
No source files (src/**) modified. No data/** modified. No .agents/**, .claude/**, CLAUDE.md, AGENTS.md, colibri-system.md, or other CANON files touched.
ADR shape — required sections (per dispatch deliverable spec)
The ADR must carry:
- Standard frontmatter.
title,description,tags,type: adr,round(this round),status: proposed,parent: Architecture Decision Records,updated: 2026-05-06,nav_order: 70. Match ADR-005 / ADR-006 frontmatter shape byte-for-byte except for the obvious value changes. - Title heading + status block. Bold-labelled block listing Status, Date, Round, Supersedes, Superseded by — same shape as ADR-005 lines 15-19.
- §Context. Explain the three gaps (C1, #6, #7) concretely with code citations carried over from the audit. State why they are tackled together.
- §Decision. Pick exactly one option for each of the three gaps. Cross-reference between gaps so the choice reads coherent.
- §Alternatives Considered. At least three options per gap, with a tradeoff note for each. Format as one subsection per gap.
- §Consequences. Subsections Positive / Negative / Neutral covering runtime, schema, test, and migration impact.
- §Implementation. Files, migrations, tests, and behavior changes at a level a future executor can split into 5-step tasks. Name the migration filename, the new column names, the new trigger names.
- §Verification. Concrete checklist Sigma can run to confirm the ADR’s intent was implemented faithfully when the follow-up task ships.
- §References. Cross-links to ADR-004, ADR-005, ADR-006, the writeback protocol doc, and the audit for this ADR.
Decision-shape requirements
For each gap the §Decision must:
- State the chosen option in one sentence.
- Cite the migration / file / function the choice changes.
- Explicitly call out the deferred parts (what Phase 1+ adds on top).
The recommended cohesive choice from the dispatch packet:
| Gap | Recommended option | Notes |
|---|---|---|
| C1 (wiring) | Optional session_id on thought_record input + INSERT |
Minimum-viable, opt-in. Not breaking — old callers omit it. |
| #6 (post-finalize guard) | SQLite trigger enforce_post_finalize_guard on thought_records insert/update |
Schema-level enforcement. Migration 007_post_finalize_guard.sql. |
| #7 (ζ↔η coupling) | Per-record back-pointer column thought_records.anchored_in_root set inside merkle_finalize transaction |
Bidirectional lookup without a new MCP tool. Preserves ADR-004 14-tool lock. |
The contract requires the ADR to either adopt this triple or argue (in §Alternatives Considered) why a different cohesive triple is better. A divergent recommendation must address the same three gaps with options that do not conflict with each other.
Style requirements
- Prose-grade. Each §section opens with at least one paragraph of running prose before any list or table.
- Match ADR-005 voice: declarative, single-letter-concept references (η, ζ, β), explicit phase boundaries.
- Greek letters in prose: η, ζ, β. Code paths in backticks. Cross-ADR refs use
[ADR-NNN](ADR-NNN-slug.md)link format (relative within the decisions folder). - Code citations use the form
path/to/file.ts:LINEmatching the audit and CLAUDE.md §7 conventions. - Word count target: 1800–2700 words (ADR-005 is ~1900, ADR-006 has more — the three-gap surface justifies the upper end).
Out of scope (must NOT appear in the ADR file)
- Implementation code. The ADR proposes; follow-up tasks implement.
- Migration SQL bodies (the ADR names the migration and lists the columns/triggers, but does not paste the SQL).
- Test code. The ADR can describe the test class names but must not include Jest source.
- Renumbering of existing ADRs. ADR-001..006 are stable.
- Edits to
colibri-system.md, CLAUDE.md, AGENTS.md, or any concept doc. - Any file outside
docs/architecture/decisions/and the four 5-step chain folders.
Acceptance criteria for the ADR’s §Decision
| Criterion | Pass condition |
|---|---|
| Status | Proposed (NOT Accepted) — the ADR is a draft for review |
| Decision per gap | Each gap C1, #6, #7 has exactly one option labelled “Decision” |
| Cross-references | The three decisions reference each other where they interact (e.g., the trigger must respect nullable session_id) |
| Alternatives | ≥ 3 alternatives per gap, each with a one-line tradeoff |
| Implementation | Names migration 007_post_finalize_guard.sql (or whatever the chosen number is) + lists each new column/trigger |
| Verification | A concrete grep / SQL / test-name check Sigma can run |
Build / lint / test gate
npm run build && npm run lint && npm test must pass on the worktree. No source changes means tests should be untouched at 1357 (post-R83). Verification step will confirm.
Commit pattern (per CLAUDE.md §6)
| Step | Commit prefix | Subject form |
|---|---|---|
| 1 | audit(adr-007-eta-session-lifecycle): |
inventory surface |
| 2 | contract(adr-007-eta-session-lifecycle): |
behavioral contract (this commit) |
| 3 | packet(adr-007-eta-session-lifecycle): |
execution plan |
| 4 | feat(adr-007-eta-session-lifecycle): |
propose ADR-007 η session lifecycle |
| 5 | verify(adr-007-eta-session-lifecycle): |
test evidence |
Five separate commits in worktree .worktrees/claude/adr-007-eta-session-lifecycle on branch feature/adr-007-eta-session-lifecycle.