Skip to content

I0805 — Read sessions back with a divergence label

Implement `session list`, `session show <id>` and `session latest`, each resolving with the established rule — same repository, same worktree, same branch, then same branch — and each printing the existing divergence label of the record against current git.

DONE wave 3 · p1 · implementation profile · runs alone

Part of M003 — A session is a durable envelope, and knowledge is compiled from what is already canonical.

Objective

Implement `session list`, `session show <id>` and `session latest`, each resolving with the established rule — same repository, same worktree, same branch, then same branch — and each printing the existing divergence label of the record against current git.

Why

A closed session from a rewritten branch that is presented as current knowledge is the failure the divergence vocabulary already exists to prevent. Reusing that vocabulary rather than inventing a second one is the whole point of having it.

Current state

mj_resolve_latest implements the two-tier rule for checkpoints and handovers, and mj_git_label produces exact, advanced, diverged and different_context. No command reads a session.

Desired state

list prints sessions newest first with their labels; show prints one record whole; latest prints the newest session that resolves for this worktree and branch, and reports absence as absence. A diverged or different_context record is labelled as such on every one of them.

Scope

  • lib/session.sh
  • bin/majordomus
  • test/cases/62_session_divergence.sh

Out of scope

  • Knowledge
  • Any repository-wide resolution across worktrees

Dependencies

What waits on this

Acceptance criteria

  • Sessions list in chronological order, and the order is not taken from file modification time
  • Two sessions written inside the same second order deterministically
  • A record whose recorded head is not an ancestor of HEAD is labelled diverged wherever it is printed
  • A session from another branch is never offered as latest
  • Every one of these commands leaves git status byte-identical

Validation

  • bash test/run.sh 62_session_divergence

Evidence required

  • divergence_labelled

Evidence

coverstypecommandresultat commit
divergence_labelledtesttest/run.sh 62_session_divergenceone case passed, and the mutation that removes the ledger tiebreak fails it. The case proves absence is answered on all three views; that a record reads exact then advanced as history moves forward; that a rewritten history makes list, show and latest all say diverged and print a warning; that a session from another branch is never offered as this branch's latest while --all shows it labelled different_context; that a malformed record is skipped with a warning and not fatally; and that every view leaves the working tree byte-identical. Ordering comes from the record and the ledger rather than the filesystem: touching an old record does not reorder the list, and the two close events are swapped in the ledger so filename order and ledger order disagree4fd8083

Risk

Reusing mj_resolve_latest requires the session record to have the same front-matter shape as a checkpoint. If the record is pure YAML instead, a second resolver appears, and two resolution rules is exactly the thing the resolution section of the documentation refuses.

Timeline

started
2026-09-04T18:01:49Z
verified
completed
2026-09-04T18:10:47Z

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/I0805.yaml. Read it back with majordomus plan show I0805.