Skip to content

Commit 0ce97e0

Browse files
committed
feat(resume): recorded-branch matching + owner exclusion in session resume
session-bridge/SKILL.md: - Branch matching on the RECORDED branch: manifest field — never re-derived from branch or directory names (derivation breaks under collision suffixes, user renames, and date-stripped slug collisions). Prefer the HEAD-matching initiative; list initiative branches when HEAD is on the default branch. - Owner exclusion for parallel worktrees: initiatives whose owner: points at a different checkout are excluded — comparison probe is git rev-parse --show-toplevel vs the recorded owner: after path normalization (trailing slashes, symlinks/WSL). A session inside a worktree auto-resumes that worktree's initiative. - Decision reads initiative-first; Saving/Context/session-end writer sites retargeted to the initiative log (implementation review MAJOR 2 — these two writers were missed by the Phase 5 sweep and would have re-opened the global-file conflict). continue.workflow.md: the manifest scan skips status: abandoned and owner-mismatched cycles, prefers the branch-matching cycle. Spec §G7 (G7.1–G7.3).
1 parent 14c532b commit 0ce97e0

2 files changed

Lines changed: 41 additions & 11 deletions

File tree

core/capabilities/context/session-bridge/SKILL.md

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ Two levels of state, each with a different purpose:
4040
**This is always accurate** because artifacts are created and updated
4141
as part of the workflow. No separate "save" action needed.
4242

43-
### Context: decisions.md
43+
### Context: decision logs
4444

45-
`.sage/decisions.md` is a shared log where both the agent and human
45+
Each initiative's `.sage/work/[initiative]/decisions.md` is the
46+
per-cycle log; the global `.sage/decisions.md` is a shared
47+
cross-initiative log. Both are places where the agent and human
4648
write significant decisions and context. It provides reasoning that
4749
artifact frontmatter doesn't capture — WHY decisions were made,
4850
what alternatives were considered, and what the human's priorities are.
@@ -54,18 +56,37 @@ When resuming work, follow this priority order:
5456
### Step 1: Scan artifacts for state
5557

5658
Scan `.sage/work/` for active initiatives. Read frontmatter from
57-
brief.md, spec.md, or plan.md (whichever exists). Note title, status,
58-
phase. If a plan exists, scan the task checkboxes to understand how
59-
far implementation progressed.
59+
manifest.md, brief.md, spec.md, or plan.md (whichever exists). Note
60+
title, status, phase. If a plan exists, scan the task checkboxes to
61+
understand how far implementation progressed.
6062

6163
This is the source of truth — what artifacts exist tells you where
6264
the project stands.
6365

66+
**Branch matching (git projects):** read the current branch and
67+
match it against the **recorded `branch:` field** in each
68+
initiative's manifest frontmatter (git-discipline records it at
69+
branch creation — match on the recorded field, never re-derive from
70+
branch or directory names). Prefer the initiative whose recorded
71+
branch matches HEAD in the resume menu; if HEAD is on the default
72+
branch while initiative branches exist, list them.
73+
74+
**Owner exclusion (parallel worktrees):** exclude initiatives whose
75+
manifest carries an `owner:` pointing at a different checkout —
76+
compare `git rev-parse --show-toplevel` against the recorded
77+
`owner:` after path normalization (trailing slashes, symlinks).
78+
They belong to another worktree's session. A session opened inside
79+
a worktree auto-resumes that worktree's checked-out initiative by
80+
the same branch-matching rule.
81+
6482
### Step 2: Read decisions for context
6583

66-
If `.sage/decisions.md` exists, read the last 3-5 entries. These
67-
capture recent decisions and direction changes — WHY the project is
68-
in its current state, not just WHAT state it's in.
84+
Read the matched initiative's own decision log first —
85+
`.sage/work/[initiative]/decisions.md` — then the global
86+
`.sage/decisions.md` (cross-initiative decisions; older projects
87+
may have only the global file). Read the last 3-5 entries of each.
88+
These capture recent decisions and direction changes — WHY the
89+
project is in its current state, not just WHAT state it's in.
6990

7091
### Step 3: Verify against the codebase
7192

@@ -84,7 +105,9 @@ State updates happen ONLY at checkpoints (Rule 7), not per-task:
84105

85106
### At each checkpoint:
86107

87-
Prepend significant decisions to `.sage/decisions.md`:
108+
Prepend significant decisions to the initiative's decision log
109+
(`.sage/work/[initiative]/decisions.md`; cross-initiative decisions
110+
go to the global `.sage/decisions.md`):
88111
```markdown
89112
### 2025-03-13 — Token storage decision
90113
Chose httpOnly cookies over localStorage for JWT storage.
@@ -108,7 +131,8 @@ All route handlers throw typed errors; the middleware formats the response.
108131
If the session is ending gracefully (human says "stop", "done for now"):
109132

110133
1. Update artifact frontmatter to reflect current phase
111-
2. Prepend session summary to decisions.md if significant work was done
134+
2. Prepend session summary to the initiative's decisions.md if
135+
significant work was done
112136
3. Report: "**Sage:** Session saved. Type /build to resume next time."
113137

114138
**If the session ends abruptly:** the artifacts in `.sage/work/` and

core/workflows/continue.workflow.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ to remember which workflow or initiative was in progress.
1616
## Step 1: Scan for Active Cycles
1717

1818
Scan `.sage/work/*/manifest.md` for cycles where
19-
`status: in-progress` or `status: paused`.
19+
`status: in-progress` or `status: paused`. Skip cycles whose
20+
manifest carries `status: abandoned`, and skip cycles owned by a
21+
different checkout — an `owner:` field that does not match this
22+
session's `git rev-parse --show-toplevel` after path normalization
23+
(they belong to another worktree's session; see git-discipline).
24+
In a git project, prefer the cycle whose recorded `branch:` field
25+
matches the current branch.
2026

2127
### One cycle found (Zone 2: Approval)
2228

0 commit comments

Comments
 (0)