Skip to content

feat(lifecycle): rule lifecycle with a person gate in the CLI - #701

Merged
davesheffer merged 2 commits into
mainfrom
feat/decision-lifecycle
Nov 26, 2026
Merged

davesheffer merged 2 commits into
mainfrom
feat/decision-lifecycle

Conversation

@davesheffer

Copy link
Copy Markdown
Owner

Summary

Rule lifecycle with a person gate in the Hunch CLI: draft, active, challenged, retired. Person-only actions (confirm, clear a challenge, replace, retire) exit 4 without a TTY or HUNCH_PERSON_TOKEN. Used by the Nuryel memory control plane.

Checks

  • npm test: 5117 tests, 5057 pass, 3 fail, 40 skipped, 17 todo. Failures: the known e2e merge pair (also on main) and "existing shared attach merges safely…", which passes alone on base and branch (flake under load).
  • critic-risk (security) reviewed.

Residuals

  • The person path skips the cross-home lookup.
  • Review-memory preflight misses corrupt files.
  • The kept guard still sets spawned_constraint.
  • A 0-byte tombstone counts as "unknown".
  • Summary prints draft wording.
  • Capture callback typed void.
  • Rotation race; replaceRule is not atomic.

🤖 Generated with Claude Code

Rules carry status draft|active|retired, an optional challenge, and the
session/run that wrote them. Only a person (an interactive terminal or a
verified HUNCH_PERSON_TOKEN) can approve a draft, clear a challenge, replace,
retire or edit a rule; any agent can challenge. A draft warns but never
blocks, and a retired rule is not enforced.

Without a verified person, `hunch test`, `record-bug` and review-memory
capture write drafts and never overwrite an existing rule in either the
public home or the private overlay, including a record file the loader
skips. MCP review_imported_adr decline and record_correction of an active
rule are gated the same way.

The gate is a guard against agent mistakes, not a security boundary
against a same-user program (docs/person-actions.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hunch Ready Ready Preview Nov 26, 2026 7:27am UTC

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Hunch — Engineering Memory Guard

⛔ Invariants directly in scope

  • [warning] The agent hook must never block an edit on failure: any error exits 0 and never denies; after the event is recognized it emits at most one 'grounding unavailable' context line, unrecognized input emits nothing — con_03a0b94b2e
    • in: src/cli/index.ts, src/core/hookpolicy.ts
    • A hook crash must not break the user's edit flow — but silence made dead wiring look like the model forgetting Hunch (2026-09-12 diagnosis); one context line keeps the edit flowing and the failure visible
  • [blocking] Forward-migrate raw JSON to the current schema BEFORE Zod validation; never silently drop unmigratable records — con_947c578b2c (advisory: record is stale)
    • in: src/core/migrate.ts, src/store/jsonStore.ts
    • Prevents silent record loss on schema change
  • [warning] The MCP server must stay client-agnostic: all assistants point to the same .hunch/ graph; no Claude-only behavior in the server — con_e04226bd05
    • in: src/mcp/server.ts
    • Cursor/VS Code/Codex share one memory
  • [warning] Use a TDD approach for the memory home policy work: write the failing test first, run it and see it fail for the right reason, then implement until green — con_c195e0d533
    • in: src/store/hunchStore.ts
    • David asked for TDD mid-build (2026-10-25) after part 1 had started code-first; red-then-green evidence proves each behavior is actually exercised, which matters for a fail-closed, backward-compat routing change.

ℹ️ Nothing here is a direct, high-confidence, non-stale blocking invariant — not blocking this PR.

🧠 Hunch · engineering memory · run hunch why <file> for the full reasoning.

📜 Hunch Constitution — 2 policy receipt(s)

  • ✅ pol_01cf084e1e satisfied — symbol:renderAdoptedDoc does not reach symbol:writeFileAtomic
    • receipt: sha1:4646de79e180c53e4861add6b2fd5b5a00ad2d24
  • ✅ pol_3f3aee11ad satisfied — symbol:src/store/db.ts:openDb does not reach external:better-sqlite3
    • receipt: sha1:5928397c97ad6833d47edb52233f59068b7823bd

The matrix verifier ran the candidate CLI as anonymous non-TTY agents,
so record-constraint produced drafts under the new person gate and the
correction-policy upgrade could not be proved. Each matrix actor now
gets a random per-run person token registered in a store outside its
home, wired through the test-only person-home preload. The product
person gate is unchanged. The preload is bound into the matrix release
coverage so a change to it is tied to the matrix lane.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@davesheffer
davesheffer merged commit 1062a85 into main Nov 26, 2026
25 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 26, 2026

This branch was successfully deployed

1 active deployment
Preview — 8403322d Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant