I0806 — Make the session rules doctrines, with retention and archiving
Finish the session rules: the record and lifecycle rules are declared in share/standard/majordomus/ and dispatched by doctor and watch; what remains is a reference to a record that does not exist, retention over a declared cap, and policy-driven archiving that never deletes and never overwrites.
DONE wave 4 · p1 · implementation profile · runs alone
Part of M003 — A session is a durable envelope, and knowledge is compiled from what is already canonical.
Objective
Finish the session rules: the record and lifecycle rules are declared in share/standard/majordomus/ and dispatched by doctor and watch; what remains is a reference to a record that does not exist, retention over a declared cap, and policy-driven archiving that never deletes and never overwrites.
Why
A rule enforced by an inline check in one command is the declared-but-not-wired failure this tool measures in other people's repositories. Every enforced rule here is declared in the registry and dispatched from it, or it is not enforced.
Current state
Measured on master 4090b2b8ae, 2026-10-08. Two session rules are declared in share/standard/majordomus/rules and dispatched by doctor and watch: majordomus.session-records (validator session_records, test/cases/63_session_records.sh) and majordomus.session-lifecycle (validator session_lifecycle, test/cases/54_session_lifecycle_hooks.sh), landed in e9ffa54f1c. Doctor reports an episode left open past session.stranded_after. Not on master: the policy (.ai/repo/policy.yaml since bd7cb2a579) carries retention caps for checkpoints, handovers and the ledger and none for sessions; share/allow/policy.txt lists no session retention key; majordomus.retention-caps does not report sessions; lib/session.sh has no archiving. history --rotate remains the precedent for retention that archives rather than deletes and refuses to overwrite an existing archive.
Desired state
The session rules that exist stay declared and dispatched. The policy carries a session retention cap and whether archiving is enabled, its keys are in the policy allowlist, and majordomus.retention-caps reports sessions alongside checkpoints and handovers. A session naming a checkpoint that does not exist is reported, naming both. Archiving happens only when a command asks for it.
Scope
- share/standard/majordomus/
- share/allow/policy.txt
- share/skeleton
- lib/session.sh
- lib/doctor.sh
- lib/watch.sh
- .ai/repo/policy.yaml
- test/cases/63_session_records.sh
Out of scope
- Any background or automatic maintenance
- Deleting a record under any circumstance
Dependencies
What waits on this
Acceptance criteria
- majordomus.session-records and majordomus.session-lifecycle appear in the rule list with a validator that exists, and doctor proves each reaches the command that claims to run it
- A malformed closed record fails doctor and drifts watch, and the finding carries a reproduce command
- A session naming a checkpoint path that does not exist is reported, naming both
- Archiving moves records without deleting them and refuses to overwrite an existing archive
- A session left open longer than the policy allows is reported by watch and does not block anything
Validation
- bash test/run.sh 63_session_records
- bin/majordomus doctor
- bin/majordomus watch
Evidence required
- session_doctrines_wired
Evidence
| covers | type | command | result | at commit |
|---|---|---|---|---|
| session_doctrines_wired | test | test/run.sh 63_session_records 2985_session_records_are_capped_and_archived 54_session_lifecycle_hooks | tests: 3 passed, 0 failed, 0 skipped at master 97c4521f91 (2026-10-14 19:15-19:28Z). (1) majordomus.session-records (validator session_records) and majordomus.session-lifecycle (validator session_lifecycle) are declared in share/standard/majordomus/manifest.yaml and dispatched by doctor and watch since e9ffa54f1c; case 54 drives the wiring. (2) A malformed closed record fails doctor and drifts watch with a reproduce command: case 63. (3) A record naming a checkpoint or handover this checkout no longer has is reported naming both: case 2985. (4) majordomus session archive moves records into archive/, deletes nothing, and refuses when archiving is off or a name is already archived: case 2985, delivered by ebe15d2e483. (5) An episode open past session.stranded_after is reported by validator lifecycle (rule majordomus.lifecycle-observed, enforced_by doctor and watch, not check or finish; lib/doctor.sh mj_validate_lifecycle), so it blocks nothing. | 97c4521 |
Risk
An open session is normal for most of its life, so the staleness rule has to be advisory. A blocking check on an open session would refuse work during the episode it is meant to describe.
Timeline
- started
- 2026-10-14T19:34:23Z
- verified
- 2026-10-14T19:35:35Z
- completed
- 2026-10-14T19:35:58Z
Those three fields, the evidence above and the state of the dependencies are all the status is made of. There is no status field to disagree with them.
Canonical record: .ai/repo/project/issues/I0806.yaml. Read it back with majordomus plan show I0806.