@thebassclef/lite 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +85 -4
  3. package/dist/cli.cjs +1610 -0
  4. package/dist/cli.js +1587 -0
  5. package/dist/index.cjs +4 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +4 -0
  8. package/package.json +51 -3
  9. package/substrate/.bassclef/lite-manifest.json +1794 -0
  10. package/substrate/.claude/agents/architect.md +70 -0
  11. package/substrate/.claude/agents/builder.md +114 -0
  12. package/substrate/.claude/agents/designer.md +156 -0
  13. package/substrate/.claude/agents/reviewer.md +88 -0
  14. package/substrate/.claude/hooks/artifact-ingestion-gate.sh +357 -0
  15. package/substrate/.claude/hooks/assert-verify-steering.sh +77 -0
  16. package/substrate/.claude/hooks/bassclef-source-config-validate.sh +215 -0
  17. package/substrate/.claude/hooks/bassclef-sync.sh +634 -0
  18. package/substrate/.claude/hooks/compound-noun-scrub.sh +292 -0
  19. package/substrate/.claude/hooks/kiss-expansion-inject.sh +69 -0
  20. package/substrate/.claude/hooks/plain-english-steering.sh +156 -0
  21. package/substrate/.claude/hooks/post-skill-friction-check.sh +177 -0
  22. package/substrate/.claude/hooks/post-skill-telemetry.sh +62 -0
  23. package/substrate/.claude/hooks/pre-build-gate.sh +511 -0
  24. package/substrate/.claude/hooks/pre-commit-gate.sh +452 -0
  25. package/substrate/.claude/hooks/session-end.sh +433 -0
  26. package/substrate/.claude/hooks/session-reflection.sh +303 -0
  27. package/substrate/.claude/hooks/skill-body-grade-gate.sh +219 -0
  28. package/substrate/.claude/hooks/skill-body-intent-drift.sh +107 -0
  29. package/substrate/.claude/hooks/skill-step-list-check.sh +171 -0
  30. package/substrate/.claude/hooks/state-validate.sh +271 -0
  31. package/substrate/.claude/hooks/substrate-clarity-gate.sh +1110 -0
  32. package/substrate/.claude/hooks/temperance-gate.sh +147 -0
  33. package/substrate/.claude/hooks/testing-tier-enforce.sh +233 -0
  34. package/substrate/.claude/hooks/turn-prose-grade-measure.sh +219 -0
  35. package/substrate/.claude/hooks/turn-prose-kiss-check.sh +434 -0
  36. package/substrate/.claude/hooks/vocabulary-migration-check.sh +171 -0
  37. package/substrate/.claude/hooks/whereami-utc-gate.sh +142 -0
  38. package/substrate/.claude/luminaries/alan-cooper.md +170 -0
  39. package/substrate/.claude/luminaries/alistair-cockburn.md +140 -0
  40. package/substrate/.claude/luminaries/amazon-pr-faq.md +34 -0
  41. package/substrate/.claude/luminaries/ash-maurya.md +121 -0
  42. package/substrate/.claude/luminaries/bill-buxton.md +210 -0
  43. package/substrate/.claude/luminaries/charles-sanders-peirce.md +150 -0
  44. package/substrate/.claude/luminaries/david-ogilvy.md +192 -0
  45. package/substrate/.claude/luminaries/don-norman.md +173 -0
  46. package/substrate/.claude/luminaries/edward-tufte.md +179 -0
  47. package/substrate/.claude/luminaries/eric-evans.md +160 -0
  48. package/substrate/.claude/luminaries/frederick-brooks.md +50 -0
  49. package/substrate/.claude/luminaries/gang-of-four.md +157 -0
  50. package/substrate/.claude/luminaries/jason-fried-dhh.md +46 -0
  51. package/substrate/.claude/luminaries/jesse-james-garrett.md +154 -0
  52. package/substrate/.claude/luminaries/john-ousterhout.md +94 -0
  53. package/substrate/.claude/luminaries/karl-popper.md +132 -0
  54. package/substrate/.claude/luminaries/kent-beck.md +168 -0
  55. package/substrate/.claude/luminaries/linus-torvalds.md +218 -0
  56. package/substrate/.claude/luminaries/martin-fowler.md +164 -0
  57. package/substrate/.claude/luminaries/michael-feathers.md +125 -0
  58. package/substrate/.claude/luminaries/michael-nygard.md +118 -0
  59. package/substrate/.claude/luminaries/robert-c-martin.md +164 -0
  60. package/substrate/.claude/luminaries/saltzer-schroeder.md +194 -0
  61. package/substrate/.claude/luminaries/sophia-prater.md +193 -0
  62. package/substrate/.claude/luminaries/stephen-toulmin.md +131 -0
  63. package/substrate/.claude/rules/artifact-ingestion.md +179 -0
  64. package/substrate/.claude/rules/assert-only-after-verify.md +137 -0
  65. package/substrate/.claude/rules/blocked-items.md +146 -0
  66. package/substrate/.claude/rules/branching.md +28 -0
  67. package/substrate/.claude/rules/commit-conventions.md +22 -0
  68. package/substrate/.claude/rules/context-engineering.md +202 -0
  69. package/substrate/.claude/rules/context-management.md +85 -0
  70. package/substrate/.claude/rules/destructive-operations.md +69 -0
  71. package/substrate/.claude/rules/diagnosis.md +38 -0
  72. package/substrate/.claude/rules/guardrails.md +73 -0
  73. package/substrate/.claude/rules/identifier-leak-prevention.md +104 -0
  74. package/substrate/.claude/rules/lite-manifest-schema-change-discipline.md +98 -0
  75. package/substrate/.claude/rules/oo-ad-entry-point.md +117 -0
  76. package/substrate/.claude/rules/operator-facing-prose.md +196 -0
  77. package/substrate/.claude/rules/plain-english-discipline.md +154 -0
  78. package/substrate/.claude/rules/pr-body-shape.md +317 -0
  79. package/substrate/.claude/rules/pr-strategy.md +167 -0
  80. package/substrate/.claude/rules/sdlc-gates.md +149 -0
  81. package/substrate/.claude/rules/session-artifacts.md +236 -0
  82. package/substrate/.claude/rules/state-schema-validation.md +162 -0
  83. package/substrate/.claude/rules/whereami-load-bearing.md +202 -0
  84. package/substrate/.claude/rules/writing-craft-discipline.md +92 -0
  85. package/substrate/.claude/skills/build/SKILL.md +640 -0
  86. package/substrate/.claude/skills/decompose/SKILL.md +280 -0
  87. package/substrate/.claude/skills/diagnose/SKILL.md +297 -0
  88. package/substrate/.claude/skills/howdoi/SKILL.md +105 -0
  89. package/substrate/.claude/skills/ia-model/SKILL.md +108 -0
  90. package/substrate/.claude/skills/interaction-design/SKILL.md +112 -0
  91. package/substrate/.claude/skills/interpret-input/SKILL.md +180 -0
  92. package/substrate/.claude/skills/kiss/SKILL.md +449 -0
  93. package/substrate/.claude/skills/launch/SKILL.md +924 -0
  94. package/substrate/.claude/skills/lean-canvas/SKILL.md +332 -0
  95. package/substrate/.claude/skills/longrun/SKILL.md +426 -0
  96. package/substrate/.claude/skills/luminary/SKILL.md +481 -0
  97. package/substrate/.claude/skills/ogilvy-writing-audit/SKILL.md +177 -0
  98. package/substrate/.claude/skills/onboard-repo/SKILL.md +2190 -0
  99. package/substrate/.claude/skills/pattern-review/SKILL.md +99 -0
  100. package/substrate/.claude/skills/personas/SKILL.md +207 -0
  101. package/substrate/.claude/skills/promote/SKILL.md +283 -0
  102. package/substrate/.claude/skills/requirement/SKILL.md +98 -0
  103. package/substrate/.claude/skills/retro/SKILL.md +117 -0
  104. package/substrate/.claude/skills/riff/SKILL.md +114 -0
  105. package/substrate/.claude/skills/roadmap-reconcile/SKILL.md +163 -0
  106. package/substrate/.claude/skills/session-end/SKILL.md +309 -0
  107. package/substrate/.claude/skills/session-log/SKILL.md +299 -0
  108. package/substrate/.claude/skills/skills/SKILL.md +228 -0
  109. package/substrate/.claude/skills/spec/SKILL.md +105 -0
  110. package/substrate/.claude/skills/sprint/SKILL.md +392 -0
  111. package/substrate/.claude/skills/stage/SKILL.md +384 -0
  112. package/substrate/.claude/skills/state-a-problem/SKILL.md +185 -0
  113. package/substrate/.claude/skills/temperance/SKILL.md +108 -0
  114. package/substrate/.claude/skills/use-case/SKILL.md +417 -0
  115. package/substrate/.claude/skills/user-stories/SKILL.md +268 -0
  116. package/substrate/.claude/skills/value-prop/SKILL.md +251 -0
  117. package/substrate/.claude/skills/verify/SKILL.md +160 -0
  118. package/substrate/.claude/skills/whereami/SKILL.md +307 -0
  119. package/substrate/AGENTS.md +79 -0
  120. package/substrate/CLAUDE-lite.md +85 -0
  121. package/substrate/CODE_OF_CONDUCT.md +28 -0
  122. package/substrate/CONTRIBUTING.md +177 -0
  123. package/substrate/README.md +173 -0
  124. package/substrate/SECURITY.md +19 -0
  125. package/substrate/architecture/decisions/ADR-029-release-pipeline.md +79 -0
  126. package/substrate/architecture/decisions/ADR-031-non-breaking-changes-adopter-discipline.md +139 -0
  127. package/substrate/architecture/decisions/ADR-032-adopter-sync-dispatcher-architecture.md +192 -0
  128. package/substrate/architecture/decisions/ADR-039-release-tagging-scheme.md +145 -0
  129. package/substrate/architecture/decisions/ADR-040-planning-skill-vocabulary-and-lite-profile.md +155 -0
  130. package/substrate/architecture/decisions/ADR-044-unified-skill-body-template.md +162 -0
  131. package/substrate/lib/clean-artifacts-sweep.sh +112 -0
  132. package/substrate/lib/code-comment-discipline.sh +144 -0
  133. package/substrate/lib/composer-preflight.sh +459 -0
  134. package/substrate/lib/hook-inject.sh +255 -0
  135. package/substrate/lib/luminary-pick.sh +96 -0
  136. package/substrate/lib/output-discipline.sh +143 -0
  137. package/substrate/lib/rewrite-check.sh +214 -0
  138. package/substrate/lib/state.sh +1372 -0
  139. package/substrate/lib/telemetry.sh +205 -0
  140. package/substrate/lib/tier-check.sh +138 -0
  141. package/substrate/lib/tier-dependency-audit.sh +933 -0
  142. package/substrate/presence/install/bassclef-hook-connect.sh +178 -0
  143. package/substrate/presence/install/bassclef-sync.dispatcher.template.sh +841 -0
  144. package/substrate/presence/install/bassclef-sync.template.sh +2076 -0
  145. package/substrate/presence/install/schedule-auto-save.cron.sh +88 -0
  146. package/substrate/presence/install/schedule-auto-save.taskscheduler.md +122 -0
  147. package/substrate/scripts/aggregate-telemetry.sh +217 -0
  148. package/substrate/scripts/analyze-tier-dependencies.sh +239 -0
  149. package/substrate/scripts/generate-lite-manifest.sh +489 -0
  150. package/substrate/scripts/generate-tier-manifest.sh +28 -0
  151. package/substrate/scripts/intent-drift-check.sh +456 -0
  152. package/substrate/scripts/lite-manifest-drift-check.sh +146 -0
  153. package/substrate/scripts/render-lite-manifest-doc.sh +150 -0
  154. package/substrate/standards/bassclef-configs-schema.md +232 -0
  155. package/substrate/standards/bassclef-evolution.md +143 -0
  156. package/substrate/standards/bassclef-internal-jargon.md +244 -0
  157. package/substrate/standards/bassclef-managed-sentinel.md +96 -0
  158. package/substrate/standards/bassclef-source-config.md +228 -0
  159. package/substrate/standards/deferred-actions-schema.md +204 -0
  160. package/substrate/standards/docs-sync-allowlist.md +76 -0
  161. package/substrate/standards/graceful-exit.md +227 -0
  162. package/substrate/standards/hook-idempotency.md +102 -0
  163. package/substrate/standards/lite-manifest-schema-changes.md +75 -0
  164. package/substrate/standards/luminary-problem-patterns.md +481 -0
  165. package/substrate/standards/ogilvy-writing-rules.md +225 -0
  166. package/substrate/standards/opener-discipline.md +96 -0
  167. package/substrate/standards/operator-facing-prose-discipline.md +201 -0
  168. package/substrate/standards/project-directory-layout.md +276 -0
  169. package/substrate/standards/release-tagging.md +137 -0
  170. package/substrate/standards/sdlc-compliance.md +286 -0
  171. package/substrate/standards/secrets-lifecycle.md +210 -0
  172. package/substrate/standards/security-scanner-adapter.md +145 -0
  173. package/substrate/standards/skill-output-discipline.md +90 -0
  174. package/substrate/standards/state-spine.md +511 -0
  175. package/substrate/standards/tech-stack-config.md +109 -0
  176. package/substrate/standards/tier-dependency-analysis.md +167 -0
  177. package/substrate/standards/tier-runtime-deps/lite.md +57 -0
  178. package/substrate/standards/tier-tag-schema.md +155 -0
  179. package/substrate/standards/whereami-schema.md +301 -0
  180. package/substrate/standards/writing-guide.md +213 -0
  181. package/substrate/templates/deferred-action-template.md +45 -0
  182. package/substrate/templates/whereami-template.md +101 -0
@@ -0,0 +1,149 @@
1
+ ---
2
+ tier: lite
3
+ description: Universal SDLC gates — pre-build temperance + diagnose, post-build /verify, observed-failure chain. Stack-specific globs live in per-language siblings under standards/sdlc-gates/.
4
+ ---
5
+
6
+ # SDLC Gates
7
+
8
+ Universal SDLC discipline applicable to any stack. The temperance + diagnose + verify chain is language-agnostic; the specific globs that scope the rule to source files live in per-language siblings under `standards/sdlc-gates/`. The loader (future ticket) reads adopter's `tech_stack.lang` from `.claude/bassclef-configs.jsonc` and applies the matching sibling's globs in addition to this rule.
9
+
10
+ When no sibling exists for the adopter's language, the universal gates below still apply — the rule fires methodologically even without glob-based file scoping.
11
+
12
+ ## Per-stack siblings
13
+
14
+ | Adopter's `tech_stack.lang` | Sibling loaded |
15
+ |---|---|
16
+ | `typescript` | `standards/sdlc-gates/typescript.md` |
17
+ | `python` | `standards/sdlc-gates/python.md` *(future — file `/promote` to author)* |
18
+ | `ruby` | `standards/sdlc-gates/ruby.md` *(future)* |
19
+ | `go` | `standards/sdlc-gates/go.md` *(future)* |
20
+ | `none` or unset | universal gates only; no glob-based scoping |
21
+
22
+ When the matching sibling does not exist, the universal gates below apply; sibling-specific globs are skipped until the operator declares the stack and a sibling ships.
23
+
24
+ ## Pre-Build (before writing code) — HOOK ENFORCED (BLOCKING)
25
+
26
+ The `pre-build-gate.sh` hook enforces these as hard blocks (exit 2)
27
+ on PreToolUse Edit / Write / MultiEdit. Per bassclef#1060 the gate
28
+ flipped from advisory (banner + exit 0) to blocking after an audit
29
+ showed 0 of 15 PRs had temperance markers. Methodology-only failed.
30
+
31
+ Override paths per gate: `SKIP_TEMPERANCE=1` and `SKIP_DIAGNOSE=1`
32
+ (logged via trace-helper).
33
+
34
+ 1. **Temperance** — fires at **scope-decision boundaries**, not
35
+ per-branch. You must state your approach before the gate clears.
36
+ BLOCKS first edit on non-stacked branches until a marker exists
37
+ at `state/markers/temperance/<branch-slug>.marker`. Stacked
38
+ branches auto-suppress (the scope decision was made at
39
+ manifest-write time).
40
+
41
+ Scope-decision boundaries (where the gate IS load-bearing):
42
+ - Session kickoff (autonomous or `/longrun` start)
43
+ - Phase boundary (last WS in a phase transitions to merged →
44
+ next phase's premise re-engaged)
45
+ - Post-compaction recovery (context just compacted; have I drifted?)
46
+ - Scope-drift detection (a WS exceeds time budget × 1.5 → pause and
47
+ re-anchor)
48
+ - First edit per branch IF branch is NOT declared in any stack
49
+ manifest (non-stacked work fallback)
50
+
51
+ When the current branch IS declared in a `docs/stacks/*.md` or
52
+ `docs/branch-stacks/*.md` manifest, per-branch temperance is
53
+ **suppressed** — the scope decision was made at manifest-write
54
+ time. Phase-level firings cover the actual decision points.
55
+ Per bassclef#272.
56
+
57
+ Auto-fire mechanisms (session-kickoff, phase-boundary,
58
+ post-compaction, scope-drift detection) ship with the `/longrun`
59
+ skill (bassclef#274). Until then, the operator + agent fire
60
+ temperance manually at those boundaries.
61
+ 2. **Diagnosis** — fires on ALL fix/ branches. You must run /diagnose
62
+ (Is/Is Not + Five Whys + Hypothesis) before writing any fix code.
63
+ The hook blocks until diagnosis evidence exists.
64
+ 3. SDLC checkpoint — spec current? diagrams need updating?
65
+ 4. Requirements → tickets — log before coding
66
+
67
+ ## Observed failure → temperance → diagnose (MANDATORY)
68
+
69
+ Any time you observe a failure — regardless of source — fire this chain:
70
+
71
+ 1. Temperance (pause before reacting):
72
+ - Is this expected? Is this worth investigating?
73
+ - Am I about to brute-force a retry instead of understanding?
74
+
75
+ 2. Diagnose (if the failure is real):
76
+ - Is / Is Not
77
+ - Five Whys to root cause
78
+ - Hypothesis + test plan
79
+ - THEN fix
80
+
81
+ This applies to ALL failure sources:
82
+ - Tool output (CI logs, tsc errors, test failures, deploy logs)
83
+ - Failures you caused (pushed code → CI broke → fix before moving on)
84
+ - User-reported failures (text, screenshots, logs)
85
+ - Server logs you read
86
+
87
+ Do NOT rely on hooks alone. You are responsible for recognizing failures
88
+ in all forms and firing the temperance → diagnose chain yourself.
89
+
90
+ ## Post-Build (before committing — EACH task, not batched)
91
+
92
+ Run /verify for the change type. Do not batch-build then batch-verify.
93
+
94
+ Before committing, ask yourself:
95
+ - Did I add or modify an exported function? → It needs a test.
96
+ - Did I change query logic or selection behavior? → Test it.
97
+ - Can I extract the logic into a pure function? → Do it, then test it.
98
+
99
+ "I'll add tests later" is never acceptable.
100
+
101
+ INSTEAD: tests ship with the code in the same commit. If the test is
102
+ hard to write, that's a signal the implementation needs decomposing —
103
+ fix the design first, then the test follows naturally.
104
+
105
+ ## Bassclef Evolution Check (non-bassclef repos only)
106
+
107
+ Before committing **any methodology or configuration change** in an app repo,
108
+ ask: "Is this local or global?"
109
+
110
+ ### What triggers the check
111
+
112
+ Not just `.claude/` — any change that establishes a pattern other repos
113
+ might need:
114
+
115
+ | Change | Examples | Why it matters |
116
+ |--------|----------|---------------|
117
+ | `.claude/` files | skills, rules, hooks, agents | Direct substrate changes |
118
+ | `settings.json` | model routing, permission defaults, hook config | Global agent behavior |
119
+ | `package.json` scripts | new dev commands, lint configs, build patterns | Workflow conventions |
120
+ | Hook scripts | pre-commit, pre-push, CI scripts | Process enforcement |
121
+ | Config files | `.eslintrc`, `tsconfig`, `prettier`, `.env.example` | Standards compliance |
122
+ | New workflow patterns | testing approaches, deployment scripts, seed patterns | Methodology evolution |
123
+
124
+ ### The check
125
+
126
+ 1. Is this general (applies to any project) or app-specific?
127
+ 2. If general → run `/promote` to create a `bassclef-evolution` issue
128
+ 3. Log the promotion and continue with current work.
129
+
130
+ INSTEAD of waiting for promotion to merge: file the issue and
131
+ keep moving. Promotion lands on its own cadence; current work
132
+ doesn't block on it.
133
+
134
+ 4. If unsure → promote. It's cheaper to reject a promotion than to
135
+ rediscover the pattern later in another repo.
136
+
137
+ ### Common miss: settings.json
138
+
139
+ Settings changes are the most commonly missed. When an app repo modifies
140
+ agent behavior, model routing, permission patterns, or hook configuration
141
+ in `settings.json`, that's almost always a global decision wearing local
142
+ clothes. The pre-commit hook flags these.
143
+
144
+ INSTEAD of dismissing the warning: read the flagged change, decide
145
+ local-vs-global, run /promote if global. Warnings are signal, not noise.
146
+
147
+ ## Architect Review
148
+
149
+ Run /architect-review every 10 commits or before any launch.
@@ -0,0 +1,236 @@
1
+ ---
2
+ tier: lite
3
+ globs: ["*"]
4
+ description: Session artifacts — chronicle + journal entries at every phase transition and session end
5
+ ---
6
+
7
+ In ALL configurations (operator-gated, orchestrator-gated, sequential, parallel), these artifacts are mandatory.
8
+ They fire regardless of whether /autonomous is active.
9
+
10
+ ## Bassclef-side note — telemetry is local-only (bassclef#1205)
11
+
12
+ When this rule fires INSIDE bassclef itself (not adopter repos):
13
+ chronicles and state markers are written but NOT git-tracked. The paths
14
+ `chronicle/` and `state/markers/` are gitignored in bassclef's repo
15
+ per bassclef#1205. Iteration telemetry stays on the operator machine
16
+ and is destined for bassclef-upstream long-term per memory
17
+ `project_bassclef_private_to_bassclef_upstream`.
18
+
19
+ INSTEAD of pushing chronicles + markers to bassclef-public: write
20
+ them locally for operator continuity, commit only artifacts that
21
+ belong in the public substrate (skills, rules, hooks, standards,
22
+ ADRs). The brand-team Google Doc push (per the journal step below)
23
+ preserves shareable content without coupling bassclef's git history
24
+ to specific adopter sessions.
25
+
26
+ This applies to bassclef's own repo only; adopter repos keep
27
+ chronicles + markers tracked per their own configuration.
28
+
29
+ ## Backfill before current (MUST — applies to all artifacts below)
30
+
31
+ Before writing ANY session artifact (chronicle, journal entry, release notes):
32
+ 1. Check when the last entry was written
33
+ 2. Check how many sessions/commits/days are missing since then
34
+ 3. If there are gaps: backfill them FIRST, in chronological order (oldest first)
35
+ 4. THEN write the current session's artifact
36
+
37
+ This prevents out-of-order content in append-only destinations (Google Docs)
38
+ and ensures no session is silently skipped.
39
+
40
+ ## Chronicle (MUST — every phase transition + session end)
41
+
42
+ Before ending any session or completing any phase transition:
43
+ 1. Check: when was the last chronicle entry? How many commits since?
44
+ 2. If ≥3 commits since last entry: backfill the missing chronicle(s) FIRST
45
+ 3. Then write the current session's chronicle
46
+ 4. Chronicle location (per `standards/project-directory-layout.md`):
47
+ - App repos: `docs/chronicle/`
48
+ - Bassclef: `chronicle/` (root level)
49
+ - If the directory doesn't exist, create it per the standard.
50
+ 5. **Use the bassclef template** — `templates/chronicle-template.md`.
51
+ Do NOT invent ad-hoc section structures for "narrative closeouts" or
52
+ similar shapes. The /chronicle and /session-end SKILLs both reference
53
+ this template; ad-hoc chronicles silently drop the Gate Evidence
54
+ section (bassclef#298 root cause).
55
+ 6. **Populate the Gate Evidence section** — MUST, not optional. This
56
+ is the authoritative input for the 5-session gate-compliance counter.
57
+ Auto-populate script is in the template. Skipping it produces the
58
+ "0% compliance / no data" failure mode that pre-commit-gate.sh now
59
+ blocks mechanically (bassclef#298). Override only if you have an
60
+ explicit valid `n/a` reason per `standards/sdlc-compliance.md`
61
+ §"Gate skip justifications".
62
+ 7. Verify the file exists after writing AND `grep -qiE "^## Gate (E|e)vidence"`
63
+ confirms the section is present.
64
+
65
+ ## journal entries (SHOULD — session start + every notable decision or handoff)
66
+
67
+ ### At session start (SHOULD — backfill before new work)
68
+
69
+ Before starting any new work, check for journal entry gaps:
70
+ 1. Read the most recent draft in `docs/operator-private/journals/`
71
+ 2. Read chronicles since that draft date
72
+ 3. If any session produced a notable decision, trade-off, or insight:
73
+ backfill drafts NOW, oldest first, push to Google Doc
74
+ 4. Then proceed with session work
75
+
76
+ This fires at session start, not just session end, because session-end
77
+ is where drafts get dropped — the agent runs out of context, the hook
78
+ times out, or the session dies. Catching it at the START of the next
79
+ session is the safety net.
80
+
81
+ ### At session end and handoffs
82
+
83
+ At every role handoff, phase transition, or session end, ask:
84
+ "Did this session/phase/handoff produce a notable decision, trade-off,
85
+ or insight worth sharing?"
86
+
87
+ If yes:
88
+ 1. Check for gaps: when was the last journal entry? Are there missed
89
+ sessions that owed drafts? Backfill those FIRST, oldest to newest.
90
+ 2. Create docs/operator-private/journals/ if it doesn't exist
91
+ 3. Write draft to docs/operator-private/journals/YYYY-MM-DD.md
92
+ 4. Push to Google Doc — push in chronological order (oldest first):
93
+ Read the Google Doc ID from `substrate.config.md` field `journal_doc_id`.
94
+ If not configured there, check project memory for the doc ID.
95
+ If neither exists, skip the push and keep drafts local in docs/operator-private/journals/.
96
+ When configured — prefer `--dir` for batch pushes (script sorts by filename):
97
+ npx tsx ~/src/sunj-labs/poa/scripts/push-to-gdoc.ts --dir [drafts dir] --doc-id [ID from substrate.config.md]
98
+ For single new draft:
99
+ npx tsx ~/src/sunj-labs/poa/scripts/push-to-gdoc.ts --file [draft path] --doc-id [ID from substrate.config.md]
100
+ To fix out-of-order doc (clear + re-push sorted):
101
+ npx tsx ~/src/sunj-labs/poa/scripts/push-to-gdoc.ts --dir [drafts dir] --replace --doc-id [ID from substrate.config.md]
102
+ 5. Verify both the local file and Google Doc push succeeded
103
+
104
+ High-value moments for journal entries:
105
+ - Scope kills (Shaper cutting features)
106
+ - Architecture choices (Architect choosing boring tech)
107
+ - Process insights (what broke, what worked, what surprised)
108
+ - Design pushback (Designer vs PM)
109
+ - Quantified results (N agents, M minutes, K artifacts)
110
+
111
+ Every draft file MUST include an **audience recommendations table**:
112
+
113
+ | Post | Primary audience | Hook strength | Publish priority |
114
+ |------|-----------------|--------------|-----------------|
115
+
116
+ Target audiences: PE partners, executive search leaders, board-level
117
+ operators, CPTOs, technical founders, eng leaders/managers.
118
+ Rate hook strength (weak/medium/strong/very strong/strongest).
119
+ Recommend a publish sequence with rationale.
120
+ Note overlapping posts and recommend which to publish vs hold.
121
+
122
+ ## Wiki-as-we-go discipline (SHOULD — at /longrun closeout, per bassclef#1208)
123
+
124
+ At every `/longrun closeout`, ask:
125
+
126
+ > Did this run produce material surface changes that need a wiki refresh?
127
+
128
+ Discriminator list — any YES means wiki-refresh is owed:
129
+
130
+ - New, renamed, or retired skill
131
+ - New, renamed, or retired hook
132
+ - New, renamed, or retired rule
133
+ - New, renamed, or retired standard or ADR
134
+ - Changes to `/onboard-repo` Phase 2.x discovery surfaces
135
+ - New entries in `standards/bassclef-internal-jargon.md` (wordlist amendments)
136
+ - New entries in `standards/bassclef-source-consumers.json` (anonymizer registry)
137
+
138
+ If yes, either:
139
+
140
+ 1. **Add wiki edits to the closeout PR** when the change is small and ships in the same window. Wiki repo is separate; commit + push the wiki-side changes with a cross-ref to the bassclef PR, and note the wiki commit hash in the closeout PR body.
141
+ 2. **File a wiki-refresh follow-on ticket** when wiki changes are larger or need separate review. The ticket cites the bassclef PR(s) that introduced the substrate change and the wiki pages that need updating.
142
+
143
+ If no, note "no wiki refresh owed" in the closeout chronicle so a future reader sees the question was asked.
144
+
145
+ INSTEAD of letting the wiki drift quietly: ask the discriminator question at every closeout. The wiki is the cold-adopter front door; drift there is the most operator-visible failure mode.
146
+
147
+ ## Session-rescue + memory-proposal (MUST — abrupt stop safety net)
148
+
149
+ When the Stop hook fires with unfinished MUST-tier obligations,
150
+ `.claude/hooks/session-end.sh` writes a
151
+ `docs/deferred-actions/<ts>-session-rescue.md` entry automatically.
152
+ The next session surfaces it as `BLOCKED: deferred-action` via
153
+ `60-deferred-actions.sh` and resolves per the entry's Command section.
154
+
155
+ ### What the hook checks
156
+
157
+ Two signals trigger a rescue write (bassclef #239 hardening, 2026-04-21):
158
+
159
+ 1. **Chronicle freshness** — at least one file in `chronicle/` or
160
+ `docs/chronicle/` has been written or modified within the last 24
161
+ hours. This is **session-relative**, not UTC-calendar-date-relative:
162
+ a chronicle dated yesterday written at 23:50 UTC still satisfies
163
+ the obligation when the next Stop fires at 00:10 the following day.
164
+ 2. **Clean working tree** — `git status --porcelain -u` returns empty,
165
+ OR the only uncommitted paths are session-rescue entries the hook
166
+ itself wrote on a prior firing (self-output suppression). Real
167
+ content (any non-rescue path) still fires rescue.
168
+
169
+ Both signals together close the self-amplifying loop that prior
170
+ shapes produced (UTC calendar-date check + rescue-entry counting as
171
+ uncommitted work → auto-save → Stop → rescue → loop; see
172
+ `chronicle/2026-04-21-session-rescue-loop.md`).
173
+
174
+ This is additive to the obligations above — chronicle + journal entries
175
+ continue to be first-line duties. Rescue is the safety net for cases
176
+ where those weren't completed (context exhausted, OS interruption,
177
+ sandbox teardown, explicit abort).
178
+
179
+ ### Memory proposals from ephemeral sessions
180
+
181
+ Mobile and cloud-web sessions cannot write to
182
+ `~/.claude/projects/.../memory/` — the operator's real home is
183
+ unreachable from the sandbox. When such a session identifies a memory
184
+ entry worth adding:
185
+
186
+ 1. Copy `templates/memory-proposal-template.md` to
187
+ `docs/deferred-actions/<ts>-memory-<topic-slug>.md`
188
+ 2. Fill in the target path, proposed frontmatter + body, MEMORY.md
189
+ index line
190
+ 3. Commit with the session's normal artifact flow
191
+
192
+ Next desktop session sees it as `BLOCKED: deferred-action` (requires
193
+ `memory-write` capability), reviews, applies verbatim or edits first,
194
+ and `git mv`'s to `completed/` per the deferred-actions protocol.
195
+
196
+ See `.claude/rules/deferred-actions.md` for the full lifecycle.
197
+
198
+ ## Cloud and degraded environments
199
+
200
+ In cloud (Claude Code web), CI runners, and fresh clones, the Stop hook
201
+ may not fire or may be killed before completing. This is not an excuse
202
+ to skip artifacts — it is a reason to be proactive.
203
+
204
+ When operating in a cloud or degraded environment:
205
+
206
+ 1. **Do not wait for hooks** — invoke /session-end explicitly before ending
207
+ the session.
208
+
209
+ INSTEAD of assuming the Stop hook will fire: type `/session-end`
210
+ yourself when the session is at a natural close. Hooks are unreliable
211
+ in cloud / ephemeral / CI environments.
212
+ 2. **Must tier first** — write the chronicle and commit locally before
213
+ attempting any network operation (push, Google Doc). Network may not
214
+ be available or may timeout.
215
+ 3. **Journal-entry Google Doc push** — requires a service account key that is
216
+ not available in cloud. Write the draft to `docs/operator-private/journals/` and
217
+ skip the push step. Note "push pending — service account unavailable"
218
+ in the draft frontmatter.
219
+ 4. **Stop hook timeout** — if the app repo's `settings.json` has a timeout
220
+ on the Stop hook, it MUST be at least 30 seconds (see session-end SKILL.md).
221
+ A 5-second timeout will kill `git push` silently.
222
+
223
+ INSTEAD of silently accepting a too-short timeout: file a ticket to
224
+ fix it. If you discover a timeout shorter than 30s, surface it.
225
+ 5. **Graceful degradation order**:
226
+ - Chronicle (local, always possible) → commit checkpoint → git push
227
+ (may fail) → journal entry local (always possible) → Google Doc push
228
+ (may fail in cloud)
229
+ - Phase 1 (local artifacts) MUST complete even if Phase 2 (network) fails
230
+
231
+ ## This rule exists because
232
+
233
+ Agents forget to write session artifacts in long sessions, especially
234
+ after context compaction. Putting this in rules/ ensures it loads into
235
+ every session at every level. The choreography doc has the full protocol;
236
+ this rule is the reminder that fires regardless of mode.
@@ -0,0 +1,162 @@
1
+ ---
2
+ tier: lite
3
+ description: State-spine entity writes MUST conform to their JSON Schema.
4
+ ---
5
+
6
+ # State Schema Validation
7
+
8
+ State-spine entity writes MUST conform to their JSON Schema. The
9
+ `state-validate.sh` PreToolUse hook enforces this mechanically: any
10
+ Edit/Write to a state-spine path is validated against the entity's
11
+ schema; failure BLOCKs the write.
12
+
13
+ This rule is the methodology layer. The hook is the mechanical layer.
14
+ Both load-bearing.
15
+
16
+ ## When this rule fires
17
+
18
+ Any Edit/Write/MultiEdit to a path matching a state-spine entity per
19
+ `standards/state-spine.md` §"Storage format — four shapes":
20
+
21
+ - **Shape A** (singleton JSON authoritative): `docs/whereami.json`,
22
+ `substrate.config.json`, `docs/preview-state/<slug>.json`
23
+ - **Shape B** (markdown + YAML frontmatter): `docs/iteration-bets/*.md`,
24
+ `docs/roadmaps/*.md`, `docs/stacks/*.md`, `docs/decompositions/*.md`,
25
+ `docs/personas/*.md`, `docs/deferred-actions/*.md`, `chronicle/*.md`,
26
+ `docs/chronicle/*.md`
27
+ - **Shape C** (pure JSON): `state/markers/*/*.json`,
28
+ `docs/sessions/*.json`, `docs/input-artifacts/*.json`,
29
+ `state/template-instances/*.json`, `state/inbox/*.json`,
30
+ `state/stack-templates/*.json`
31
+ - **Shape D** (pure YAML at sibling-repo root): `*/bassclef-platform.yml`
32
+ (typically `~/src/<github_org>/platform-config/bassclef-platform.yml`)
33
+
34
+ Non-spine paths pass through (e.g., README, source code, narrative
35
+ markdown without YAML frontmatter, docs that aren't governed by the
36
+ spine).
37
+
38
+ ## What the hook validates
39
+
40
+ | Storage shape | Extraction | Schema validates |
41
+ |---|---|---|
42
+ | A | reads whole JSON file | the entity object |
43
+ | B | extracts YAML frontmatter, converts to JSON | the frontmatter object |
44
+ | C | reads whole JSON file | the entity object |
45
+ | D | reads whole YAML file, converts to JSON | the entity object |
46
+
47
+ In all four cases, validator: `ajv-cli` draft-2020-12 with format
48
+ support (per ADR-015 single-format).
49
+
50
+ ## What the hook does NOT validate
51
+
52
+ - **Markdown body content** of Shape B entities. Body sections (Procedure,
53
+ Acceptance, Sources read, narrative descriptions) are operator-readable
54
+ documentation; the schema doesn't constrain them.
55
+ - **Cross-entity reference dangling.** `state_reference_check` (in
56
+ `lib/state.sh`) is the read-time check; the hook validates that the
57
+ `references` array's items conform to the reference shape (typed
58
+ `{type, id, anchor?}`), not that every referenced entity exists. A
59
+ dangling reference is a read-time concern, not a write-time one.
60
+ - **Hash-as-index integrity.** Deferred to spine v1 per bassclef#316.
61
+ - **Migration scripts** writing to state files during one-shot
62
+ migrations (e.g., WU-4) — these explicitly bypass via
63
+ `SKIP_STATE_VALIDATE=1` because they're bootstrapping prior shapes
64
+ into the spine.
65
+
66
+ ## What happens when validation fails
67
+
68
+ The hook BLOCKs the write (exit code 3, structured stderr message).
69
+ Output includes:
70
+
71
+ - Entity type (which schema was applied)
72
+ - Path being written
73
+ - ajv error details (which field, which constraint, which line)
74
+ - Three resolution paths:
75
+ 1. Fix the data to match the schema (preferred)
76
+ 2. Update the schema if it's wrong (requires PR review)
77
+ 3. Override with `SKIP_STATE_VALIDATE=1` (logged; rare; not for normal work)
78
+
79
+ The agent receiving the BLOCK should treat it as a `BLOCKED:` per
80
+ `.claude/rules/blocked-items.md` — surface to operator, resolve, do
81
+ not silently retry without diagnosis.
82
+
83
+ ## When to override
84
+
85
+ `SKIP_STATE_VALIDATE=1 <command>` is logged to stderr. Use only:
86
+
87
+ - **One-shot migration scripts** (WU-4 pattern) — bootstrapping prior
88
+ shapes into the spine; the data may not yet conform until migration
89
+ completes
90
+ - **Schema is genuinely wrong** AND a fix-the-schema PR is in flight
91
+ AND blocking on validation would block the schema fix itself
92
+ - **Emergency rescue** when the hook itself is broken (substrate-defect
93
+ recovery)
94
+
95
+ NOT for:
96
+
97
+ - "I'll fix the data later" — fix it now or document as a deferred
98
+ action
99
+ - "The schema is too strict" — file an amendment PR, don't bypass
100
+ - Routine work that happens to fail validation — the validation
101
+ failure is the signal that something's wrong
102
+
103
+ ## When to update the schema
104
+
105
+ If the hook BLOCKs and the data is genuinely correct (the schema is
106
+ overly restrictive), open a PR amending the schema:
107
+
108
+ 1. Edit `standards/state-spine/schemas/<entity>.schema.json`
109
+ 2. Update `standards/state-spine.md` if the entity catalog or
110
+ storage-shape table changes
111
+ 3. Validate the schema itself compiles cleanly under
112
+ `ajv compile --spec=draft2020 --strict`
113
+ 4. Re-run `bash .claude/hooks/tests/state-validate.test.sh` to ensure
114
+ no regressions
115
+ 5. Note the rationale in the PR body (what the schema previously
116
+ forbade that should be allowed; why)
117
+
118
+ Schema changes are themselves state changes — review accordingly.
119
+
120
+ ## Relationship to other rules + standards
121
+
122
+ - `standards/state-spine.md` — entity catalog + storage shapes (defines
123
+ what gets validated and how)
124
+ - `standards/state-spine/schemas/*.schema.json` — the schemas this
125
+ rule enforces
126
+ - `standards/state-spine-contract.md` — accessor contract; mutations
127
+ via `state_<entity>_add/set/update_status` accessors invoke this
128
+ validator before writing
129
+ - `.claude/rules/accessor-library-discipline.md` — paired with this
130
+ rule; together they enforce read-side + write-side discipline
131
+ - `.claude/rules/blocked-items.md` — BLOCK protocol the hook fires
132
+ (resolve or explicitly defer)
133
+ - `.claude/hooks/state-validate.sh` — the mechanical implementation
134
+ - `.claude/hooks/tests/state-validate.test.sh` — test coverage
135
+ - `architecture/decisions/ADR-015-state-schema-format.md` — JSON Schema
136
+ only for v0; this hook uses ajv-cli per that decision
137
+ - bassclef#298 — chronicle Gate Evidence drops; this hook + Chronicle
138
+ schema together make that failure class structurally impossible
139
+ - bassclef#295, #296 — other defects from the four-incident set that
140
+ the spine v0 (incl. this rule) retires
141
+
142
+ ## Enforcement
143
+
144
+ - **Hook**: `.claude/hooks/state-validate.sh` — fires on PreToolUse
145
+ with matcher `Edit|Write|MultiEdit`; wired in `.claude/settings.json`
146
+ - **Methodology**: this rule loads in every session; agents
147
+ self-check before writing state
148
+ - **Test coverage**: `.claude/hooks/tests/state-validate.test.sh` (14
149
+ tests covering all three shapes, override path, tool-name filter,
150
+ pass-through for non-state files)
151
+
152
+ ## Override
153
+
154
+ `SKIP_STATE_VALIDATE=1 <command>` — logged to stderr per existing
155
+ bassclef hook idiom. Use sparingly; document rationale in commit
156
+ message.
157
+
158
+ ## Retirement condition
159
+
160
+ This rule retires only if the state spine retires. The schemas may
161
+ evolve (v1 adds Persona accessor methods; v2+ adds template entities)
162
+ but the discipline of write-time validation persists.