Repository navigation
Description
What to build
Every agent session a Command runs is named by a typed session kind instead of a free string. The kind decides three things today spread over three modules: the session's Session log name, the Command record stage it enters, and which thirdshift logs <command> --session <word> words select it. After this change one module owns all three, so a new kind of session cannot be added with no Command-record stage, a mis-spelt log name, or a --session word that finds nothing.
Behaviour stays exactly as it is: the same Session log file names, the same Command record stages (including today's Resume rule), the same --session selection, the same progress lines and Model evidence. Only the seam moves.
Acceptance criteria
- One session-kind module defines every kind of session thirdshift runs: Implementation (
implement), Spec review (spec-review), the numbered Repair (repair-<n>), Security review (security-review), Architecture review (architecture-review), Security audit (security-audit), the numbered Security reproduction (security-reproduction-<n>) and Security fix publishing (security-fix-publishing), each of them also as its Resume (<kind>-resume). - That module writes a kind's Session-log token, reads one back from a log name, gives the Command record stage it enters, and says whether a
--sessionword selects it. Nothing else in the crate builds or parses a session kind string. - Running a session takes the typed kind: every caller (Delivery's opening session, the Repair loop's numbered Repair, the Architecture review, and each Security run session) passes one, and no caller formats
repair-{n}orsecurity-reproduction-{n}itself. - The Command record's stage for a session comes from the kind through an exhaustive match: the ladder of string comparisons that ends by silently recording no stage is gone.
- The stage table is preserved: a Resume of Implementation, Spec review, a Repair or Security review enters the
Resumestage; a Resume of the Architecture review, Security audit, a Security reproduction or Security fix publishing keeps its own kind's stage. -
--sessionselection is preserved: a word selects a Session log whose token is that word, whose kind without-resumeis that word, or, forrepair, any numbered Repair or its Resume. A log name whose token the module cannot read is still selected by an exact match of its token. - Unit tests on the session-kind module cover: every kind's token round-trips with and without
-resume; the full stage table; the--sessionrules above; and malformed tokens (repair-,repair-x, an unknown word) reading back as no kind. - Below the seam, the token stays a plain label: the harness session call, the session's progress lines and the Model evidence kept beside each Session log carry the same strings as today, so existing log files and Model evidence still read.
-
docs/code-navigation.md's Session log / Resume row names the session-kind module as the owner of session kinds and their stages. -
cargo testpasses, with the existing integration tests (Session log names,show/logs --session, Command record stages) unchanged.
Blocked by
None (can start immediately).
Decisions
- A typed kind, not a table of string constants. The friction is that three readers re-derive meaning from the string (the Command record stage,
--sessionselection, the log-name decoder) and the stage reader endselse { return; }, so a new kind silently gets no stage. Constants would keep the readers' string matching; an enum makes the stage mapping exhaustive and compile-checked. - The numbered kinds carry their number. Repair and Security reproduction are the only kinds whose token includes a number; carrying it in the kind lets the Repair loop's budget and the Security reproduction hand over a kind rather than format a string.
- Resume is a flag beside the kind, not a kind of its own. A Resume is always of exactly one kind and only adds
-resumeto its token; the session runner already decides when one starts. A flag keeps the kind set flat and lets the stage rule read "resumed and one of these kinds → Resume". - Preserve today's Resume stage rule exactly, inside the module. Resumes of the Architecture review and the Security run's sessions keep their own stage while others enter
Resume. That is current behaviour the Command record andstatusalready show; changing it is not this refactor's job, and keeping it in one exhaustive match makes it visible. - The module lives with sessions, and the logs module reads it. The producers already hold the session runner; the logs module gains a dependency on it for the stage and
--sessionrules. The log-name decoder keeps owning file-name syntax (stamp, token, suffix) and keeps returning the raw kind token; the session-kind module only reads that token. - The seam is the session runner's interface. Typed above it (callers, the runner, the Command record stage); a plain label below it (the harness adapters, progress lines, Model evidence), because those only display or persist the token and their files must keep reading.
- Unreadable tokens stay tolerated. Session logs on disk from older thirdshift versions may carry a token no kind matches;
--sessionstill selects them by exact token, as now, and they record no stage, as the decoder already tolerates them. - Launch policy stays separate. The session's purpose (ordinary, code review, Security…) is not derived from the kind: Security fix publishing's purpose depends on the record, and code review is detected from the prompt. Folding purpose in would change behaviour.
- No glossary or ADR change. The kinds are named by existing glossary terms (Repair, Resume, Spec review, Security review, Architecture review, Security audit); "session kind" is an implementation term, like Ticket board, and goes in the domain-to-code index only. The decision is easy to reverse, so it needs no ADR.
- One Ticket. About ten producers, three readers and their tests, all mechanical once the module exists; it fits one session.
Testing decisions
- The session-kind module's interface is the test surface: round-trip, stage table,
--sessionrules and malformed tokens are unit tests there, replacing the need to drive a whole Run to see a stage recorded. - Existing tests that pass kind strings to the session runner or expect
repair-<n>in the Repair loop's recorded calls change to the typed kind; integration tests asserting log file names and--sessionselection stay as they are, as the proof nothing on disk changed.
Architecture review
Strength: Strong · Dependencies: in-process
Files: src/session.rs, src/session/recording.rs, src/logs.rs, src/logs/owner.rs, src/logs/reading/selection.rs, src/logs/command_record.rs, src/delivery.rs, src/delivery/repair_loop.rs, src/pass.rs, src/security/audit.rs, src/security/reproduction.rs, src/security/review.rs, src/security/fixing.rs
Before
flowchart LR
Delivery -- "implement / spec-review" --> Sessions
RepairLoop[Repair loop] -- "repair-n" --> Sessions
Architect[Architecture review] -- "architecture-review" --> Sessions
Security[Security run] -- "security-*" --> Sessions
Sessions -- "kind string" --> Stage[Command record stage ladder]
Sessions -- "kind string" --> LogName[Session log name]
LogName -.re-parse.-> Selection[--session selection]
classDef leak stroke:#dc2626,stroke-width:2px;
class Stage,Selection leak
After
flowchart LR
Delivery --> Sessions
RepairLoop[Repair loop] --> Sessions
Architect[Architecture review] --> Sessions
Security[Security run] --> Sessions
subgraph Kind[Session kind]
direction LR
token --> stage
token --> selects
end
Sessions --> Kind
LogName[Session log name] --> Kind
Selection[--session selection] --> Kind
classDef deep stroke-width:3px;
class Kind deep
Problem: session kinds are strings formatted by eight producers and re-parsed by three readers; a new kind silently records no Command-record stage.
Solution: one session-kind module owns each kind's token, its stage and its --session rule; callers pass the typed kind.
Wins
- Locality: kind rules in one module
- Exhaustive stage match, no silent drop
- Tests hit one interface
- Callers stop formatting log tokens
Activity