Repository navigation
feat(project-brain): report staleness and shadowed initiatives at session start - #232
Merged
Merged
Conversation
… SessionStart hook Extract registry resolution into Resolve-RegisteredInitiative and share one line-count function. When an in-repo brain wins, append a notice naming a registered initiative that also matches the cwd but was not loaded. When a registered initiative loads, append a line listing active initiatives past stale_after (first 8, oldest first) and any STATUS.md over the size cap. Both advisory paths use an inner try/catch so a scan or resolver failure can only omit the line, never drop the loaded context. Staleness dates are injected so tests do not depend on the clock.
…tension The Pi before_agent_start extension shells out to session-start.ps1 and forwards additionalContext verbatim, so the shadow and staleness lines flow through with no logic change. Add Pester cases that drive the real script with a fixture brain and assert both lines reach the Pi message, and note the forwarding in the extension header.
…adow-precedence ADR Teach the Initiative close step to move the index row into an Archived section with the closed date and to fix the relative paths that break when a folder moves one level deeper. New areas scaffold an empty Archived section. Document the two new hook lines in Loading, add the Codex resolve-and-read shadow check, and record keeping in-repo brain precedence with a shadow notice as an ADR.
The registry-resolution tests overrode only USERPROFILE to point the child at a fixture brain. On Linux the shell derives the home dir from HOME, so the child read the real (empty) brains.json path and the shadow and staleness assertions failed on the Ubuntu CI job. Set both HOME and USERPROFILE at each override site and restore both, and guard the Windows-only Volta AppData/Local directory creation behind an IsWindows check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The SessionStart hook now reports two conditions it did not surface before:
stale_after(first 8, oldest first, then+N more) and anySTATUS.mdover the size cap, emitted when a registered initiative loads..claude/brain/wins, it names a registered initiative that also matched the cwd but was not loaded.Why
A 2026-09-17 brain review found three gaps. Stale
STATUS.mdfiles were invisible when no live worktree matched their glob (one was 58 days paststale_after, with two passed deadlines and no follow-up). An in-repo.claude/brain/silently shadowed a registered initiative for at least one session and caused rework. Archived initiatives dropped out of the index because the close procedure deleted their rows. The hook and skill text close these without anyone having to remember a manual step.Changes
session-start.ps1: extract registry resolution intoResolve-RegisteredInitiative; share one line-count function between the loaded-STATUS warning and the oversize scan; addGet-StaleInitiativeandFormat-StaleNotice; append the shadow notice (path 1) and the staleness line (path 2), each behind its own inner try/catch so a scan or resolver failure omits the line rather than dropping the loaded context.## Archivedsection with the closed date and fixes the relative paths that break when a folder moves one level deeper; new areas scaffold the section; the Loading section documents both hook lines; Codex gets a resolve-and-read shadow check; a new ADR records keeping in-repo precedence with a shadow notice, and its rejected alternatives.Verify
Invoke-Pester -Path tests\project-brain-session-start.Tests.ps1, tests\pi-project-brain-autoload.Tests.ps1Invoke-ScriptAnalyzer -Path . -Recurse -Settings .\PSScriptAnalyzerSettings.psd1is clean.C:\Users\jin-y\dotfiles, start a session inE:\HollardInsuranceRetailand compare the staleness line torg -n "^stale_after:" E:\HollardInsuranceRetail\brain\initiatives\*\STATUS.md.The hook stays fail-safe: every error path exits 0 with no output.