@davesheffer/hunch 1.32.7 → 1.33.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 (60) hide show
  1. package/README.md +102 -206
  2. package/dist/cli/index.js +2 -0
  3. package/dist/cli/integrations.js +4 -1
  4. package/dist/cli/serve.js +28 -2
  5. package/dist/cli/state.d.ts +3 -0
  6. package/dist/cli/state.js +150 -0
  7. package/dist/cli/update.js +6 -2
  8. package/dist/client/state.d.ts +82 -14
  9. package/dist/client/state.js +16 -2
  10. package/dist/client/stateProof.d.ts +4 -0
  11. package/dist/client/stateProof.js +17 -0
  12. package/dist/constitution/behaviorEvaluator.js +1 -1
  13. package/dist/constitution/schema.d.ts +2 -2
  14. package/dist/core/automaticReviewMemory.d.ts +5 -0
  15. package/dist/core/conventionDelivery.d.ts +8 -0
  16. package/dist/core/conventionDelivery.js +52 -0
  17. package/dist/core/fieldProvenance.d.ts +8 -0
  18. package/dist/core/fieldProvenance.js +72 -0
  19. package/dist/core/recordVisibility.d.ts +9 -0
  20. package/dist/core/recordVisibility.js +25 -0
  21. package/dist/core/stateCanonical.d.ts +3 -0
  22. package/dist/core/stateCanonical.js +34 -0
  23. package/dist/core/stateContract.d.ts +122 -7
  24. package/dist/core/stateContract.js +26 -31
  25. package/dist/core/stateDelivery.d.ts +3 -3
  26. package/dist/core/stateDelivery.js +10 -1
  27. package/dist/core/stateHttp.d.ts +280 -0
  28. package/dist/core/stateHttp.js +17 -0
  29. package/dist/core/stateProof.d.ts +13 -0
  30. package/dist/core/stateProof.js +34 -0
  31. package/dist/core/stateRecords.d.ts +127 -0
  32. package/dist/core/stateRecords.js +48 -0
  33. package/dist/core/types.d.ts +146 -4
  34. package/dist/core/types.js +8 -2
  35. package/dist/extractors/git.js +3 -10
  36. package/dist/integrations/health.d.ts +2 -1
  37. package/dist/integrations/health.js +53 -16
  38. package/dist/mcp/server.js +10 -4
  39. package/dist/serve/app.d.ts +2 -0
  40. package/dist/serve/app.js +71 -30
  41. package/dist/serve/config.d.ts +16 -0
  42. package/dist/serve/config.js +27 -7
  43. package/dist/serve/operator.d.ts +4 -0
  44. package/dist/serve/operator.js +223 -0
  45. package/dist/serve/stateProof.d.ts +15 -0
  46. package/dist/serve/stateProof.js +105 -0
  47. package/dist/store/changeLedger.d.ts +6 -0
  48. package/dist/store/hunchStore.d.ts +4 -2
  49. package/dist/store/hunchStore.js +18 -19
  50. package/dist/store/stateAccess.d.ts +13 -0
  51. package/dist/store/stateAccess.js +85 -0
  52. package/dist/store/stateBinding.d.ts +13 -18
  53. package/dist/store/stateBinding.js +161 -52
  54. package/dist/store/stateCapture.js +10 -2
  55. package/dist/store/stateError.d.ts +12 -0
  56. package/dist/store/stateError.js +12 -0
  57. package/dist/store/statePartition.d.ts +9 -0
  58. package/dist/store/statePartition.js +30 -0
  59. package/package.json +6 -2
  60. package/server.json +3 -3
package/README.md CHANGED
@@ -1,289 +1,185 @@
1
1
  # Hunch
2
2
 
3
- ## Agents are probabilistic. Organizations need deterministic state. Hunch is the state layer between them.
3
+ ## A shared record for AI agents: what was decided, what happened, and what still needs doing.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@davesheffer/hunch?color=2742ff&label=npm)](https://www.npmjs.com/package/@davesheffer/hunch)
6
6
  [![GitHub stars](https://img.shields.io/github/stars/davesheffer/hunch?color=2742ff&label=%E2%98%85%20star)](https://github.com/davesheffer/hunch)
7
7
  [![license](https://img.shields.io/npm/l/@davesheffer/hunch?color=2742ff)](LICENSE)
8
8
 
9
- Every employee is getting an agent. Each one reads the code, the CRM, the mail thread, the chat, and forms its own opinion about what was decided, what was done and what is still owed. Two agents, two slightly different realities. Neither is wrong. Both are guesses, made fresh, from raw material.
9
+ A new agent session should not mean explaining the project all over again. A second agent should be able to check a recorded decision, see the evidence behind completed work, and find an outstanding commitment.
10
10
 
11
- An organization cannot run on guesses. It runs on state: this was decided, this rule is in force, this action happened and was verified, this promise is due Thursday, this summary is current and rests on these sources. Hunch holds that state in git, refuses it when it contradicts, and delivers it to Claude, Codex, Cursor, Copilot, Windsurf, Antigravity and any other MCP client before the agent answers or edits.
11
+ Hunch keeps that record in Git and makes the relevant parts available to your agents. It started with **engineering memory**: why code exists, which approach failed before, and which rules a change must preserve. It also ships a **state server** for sharing decisions, action records, and commitments across authorized organization, team, user, and repository scopes.
12
12
 
13
- **Hunch started as engineering memory for coding agents** and still is: why the code is shaped this way, which alternative already failed, what an odd-looking line protects, what depends on the code about to change, and which trusted decisions, fixes and architectural boundaries a change must preserve. The same graph now holds organizational state for operations agents too (see [Deterministic organizational state](#deterministic-organizational-state)).
13
+ The goal is simple: agents working from the same maintained record, with sources they can inspect. Hunch supplies memory and checks; the assistant still does the work.
14
14
 
15
- ## Why Hunch, not another memory layer
15
+ ## Start with your coding assistant
16
16
 
17
- Memory optimizes recall. State optimizes refusal. Hunch competes for the deterministic state layer from the organizational side, and every point below is a property you can verify in this repository rather than a claim:
18
-
19
- - **Git is the source of truth.** Every fact is a JSON file under `.hunch/`, every change a commit: diffable, PR-reviewable, revertable, mergeable, never locked in a vendor database. SQLite is only a derived index.
20
- - **Refusal, not convergence.** One live decision per topic. A second contradicting record is refused at write time with the incumbent named, and a supersede target must still be open. Diverging writes are not merged later.
21
- - **Organization drawers with a key per agent.** Repository, user, team and organization partitions; the bearer key resolves the principal and decides visibility before anything is looked up.
22
- - **Receipts and commitments are facts.** What was actually done in an external system, verified or not, and who owes what by when, readable by any agent with the key.
23
- - **Never Twice.** A human correction becomes an enforced rule, not a one-session memory. Nothing blocks until a human deliberately trusts a precise rule and opts into strict enforcement.
24
- - **The code spoke.** Decisions, constraints and bug lineage are checked against the code deterministically, with no model in the block path. No state-layer peer has it.
25
-
26
- ## Start in five minutes
27
-
28
- Requires Node 22.13+ and a Git repository.
17
+ Requires **Node 22.13+** and a Git repository.
29
18
 
30
19
  ```bash
31
20
  npm i -g @davesheffer/hunch
32
21
  cd your-repo
33
22
  hunch init
34
- hunch backfill --since 90d # optional: seed memory from recent history
35
- ```
36
-
37
- Reload your coding assistant, then ask a normal question:
38
-
39
- > Why is this built this way?
40
-
41
- `hunch init` indexes the repository, installs local lifecycle hooks and connects supported assistants without replacing their existing configuration. The next session receives the relevant story with its sources, not a giant transcript or generic prompt wall.
42
-
43
- Lifecycle coverage depends on the harness; MCP connectivity alone does not establish automatic grounding or enforcement.
44
-
45
- To update Hunch and configured harness pins for the current repository:
46
-
47
- ```sh
48
- hunch update
23
+ hunch backfill --since 90d # optional: draft memory from recent history
49
24
  ```
50
25
 
51
- Agents receive an instruction to run this when you ask **“update Hunch”** in generated Hunch guidance. Restart active harnesses afterward.
52
-
53
- Check integrations after upgrading Hunch or switching assistants:
26
+ Reload your assistant, then ask:
54
27
 
55
- ```sh
56
- hunch integrations check
57
- hunch integrations repair-pins
58
- hunch integrations check --harness claude --probe --require mcp
59
- hunch integrations check --harness codex --require context,edit-blocking
60
- ```
28
+ > Why is this built this way, and what should I preserve when changing it?
61
29
 
62
- Capabilities are reported as **verified**, **advisory-only**, **unsupported** or **untested**. `--require` fails unless every named capability is verified. `mcp` is verified by a fresh-server probe; hook capabilities become verified only from lifecycle events actually delivered to Hunch's hook on the expected version within the last 30 days (machine-local evidence, the same trust level as the served ledger), so a repository whose agent has actually run shows it, and one that only has configuration does not.
63
-
64
- Codex CLI 0.153+ gets a native lifecycle adapter (`.codex/hooks.json`: session orientation, prompt task IDs from `turn_id`, `apply_patch` pre-edit grounding and strict denial, native `Bash`/`PowerShell` post-tool observation, Stop cards); project-layer hooks load only for a trusted project and must be trusted once in Codex with `/hooks`. Failure capture is certified only by an explicit failed-tool lifecycle event; a successful `PostToolUse` observation does not prove it. The opt-in `--probe` verifies a fresh MCP process, not whether an existing host session or model actually followed the memory.
65
-
66
- Use `hunch integrations check` in CI to prevent pin drift; add `--require` for capabilities your workflow cannot operate without.
67
-
68
- ## One evidence loop, not another model
69
-
70
- ```text
71
- Git history + ADRs + corrections + tests + repository conventions
72
-
73
-
74
- Hunch's evidence graph
75
- / │ \
76
- engineering memory Project DNA reviewed landscape
77
- \ │ /
78
-
79
- role-shaped, budgeted context delivery
80
-
81
-
82
- Claude / Codex / Cursor / any MCP agent
83
-
84
-
85
- deterministic change receipt
86
- ```
30
+ `hunch init` indexes the code, configures supported assistant integrations, and adds memory instructions while preserving existing settings. For Codex hooks, review and trust the commands in `/hooks`, then start a new session. **Memory is advisory by default.** Blocking requires an explicitly trusted rule and strict enforcement.
87
31
 
88
- Hunch is not the agent and is not the workflow engine. The model thinks; Hunch holds deterministic, evidence-backed state about the project and validates what must remain true.
32
+ Hunch works with Claude Code, Codex, Cursor, VS Code/Copilot, Windsurf, Antigravity, and other MCP clients. Automatic context and hook coverage vary by assistant; a connected MCP server alone does not prove they are running. [Check your integration](https://www.hunchmemory.com/docs#update).
89
33
 
90
- ## What Hunch understands
34
+ ## What you get today
91
35
 
92
- | Layer | What it adds |
36
+ | Need | How Hunch helps |
93
37
  | --- | --- |
94
- | **Engineering Memory** | Decisions, rejected alternatives, corrections, bug lineage, findings and rationale a future session would otherwise miss. |
95
- | **Code Graph** | Symbols, calls, imports, dependencies, components, blast radius and architectural reachability across supported languages/configuration. Memory itself works with any language. |
96
- | **Project DNA** | Revision-specific, evidence-backed observations about how a repository communicates and works: vocabulary, contribution habits, review expectations, engineering conventions and culture. |
97
- | **Engineering Landscape** | Durable links from product/capability to system, repository, service, interface, data, delivery resources, runbooks, ownership, dashboards and SLOs. |
98
- | **Validated Delivery** | The smallest relevant evidence for the current builder/reviewer/architect, with provenance, currentness, omissions, authority and a content-addressed receipt. |
99
- | **Native Change Proof** | A sealed exact-change artifact binding revisions, DNA, base/result graphs, memory, blast radius, conformance, guard verdict and explicit gaps without granting workflow authority. |
100
- | **Change Gate + Constitution** | Deterministic checks for trusted constraints and architectural intent. Policies are compiled, proved, inspected and explicitly activated by a human. |
101
-
102
- Readable JSON in `.hunch/` is the repository-scoped source of truth. SQLite is a fast, rebuildable projection. Git keeps the state portable, reviewable and reversible.
103
-
104
- ## Project DNA: help the agent work like it belongs here
105
-
106
- Project DNA is Hunch's evidence-bound model of **how a repository communicates and works**. It is not a persona, does not impersonate a maintainer and does not turn frequent behavior into policy.
107
-
108
- The deterministic baseline reads an exact Git revision, bounded commit history and committed convention files. The current release can also accept bounded, caller-authorized pull-request/review evidence. Every evidence batch is validated and sealed; raw collaboration text does not enter the profile.
109
-
110
- Each trait keeps its category, confidence, freshness, repository revision and evidence hash. Hunch can include only the relevant DNA in normal context, explain how an artifact matches repository conventions and show profile change between revisions.
111
-
112
- ```bash
113
- hunch dna inspect
114
- hunch dna context
115
- hunch dna diff <older-ref> <newer-ref>
116
- ```
117
-
118
- DNA may shape orientation, terminology and advisory Project Match checks. It cannot create or override a decision, constraint, finding, conformance rule, policy or permission.
119
-
120
- Read the [Project DNA contract](docs/project-dna.md) and broader [Project DNA vision](docs/project-dna-engine.md).
38
+ | Stop explaining old decisions | Saves decisions, rejected alternatives, bug history, corrections, and open findings with their sources. |
39
+ | Understand a change before making it | Connects memory to code symbols and dependencies; shows affected code and recorded architectural intent. |
40
+ | Keep agents informed across sessions | Delivers a focused brief for a task through MCP and supported lifecycle hooks. |
41
+ | Check the rules your team chose | Evaluates supported constraints and code relationships without a model in the blocking path. |
42
+ | See what happened during a task | Separates delivered memory, the agent's reported use, rule results, and observed command results in a contribution report. |
43
+ | Share project memory with teammates | Keeps repository memory in Git, with an optional dedicated private memory repository. |
44
+ | Share work state across agents | Serves authorized records through HTTP, MCP, the state CLI, and typed TypeScript and Python clients. |
45
+ | Inspect what the agents know | A read-only browser view shows current records, commitments, completed work and writer-supplied citations. |
46
+ | Keep access and conventions explicit | Optional per-record audiences, key-bound credentials and sourced conventions use the same state contract. |
47
+
48
+ For example, a team fixes a logout bug by keeping sessions on the server. Months later, an agent proposes removing that code. Hunch can surface the original reason and rejected alternative before the edit. A supported, trusted rule can flag the conflict; strict mode can block it. Recording the lesson and configuring the integration are what make this possible.
121
49
 
122
50
  ## Day-to-day
123
51
 
124
52
  | Command | Use it for |
125
53
  | --- | --- |
126
- | `hunch context "<task>" --profile builder` | Get a bounded builder/reviewer/architect brief before work starts |
127
- | `hunch why <file-or-symbol>` | See decisions, bugs, constraints and blast radius behind code |
128
- | `hunch structure [target]` | Inspect indexed repository shape without repeated search rounds |
129
- | `hunch findings [scope]` | Inherit known-but-unfixed gaps instead of rediscovering them |
130
- | `hunch check --working` | Review the current tree against trusted project rules |
131
- | `hunch conform` | Prove the code still satisfies recorded architectural intent |
132
- | `hunch impact origin/main` | See the dependency and memory surface of a branch |
133
- | `hunch compare branch-a branch-b` | Rank candidate changes by invariant/decision conflicts |
134
- | `hunch prove origin/main --public-only` | Produce a publication-safe `hunch.change-proof/1` artifact for an exact committed change |
135
- | `hunch landscape review` | Inspect a hash-bound repository landscape without writing authority |
136
- | `hunch task start "<title>"` · `hunch report <id> --html` | See what Hunch contributed to a task: the lesson recalled, the agent's stated application, whether the lesson's own rule held on the changed files, and the command Hunch observed — separate evidence grades, in a local evidence view |
137
- | `hunch now` | See recent memory and live decision-backed roadmap |
138
- | `hunch escalations` | See questions that genuinely require a human answer |
139
- | `hunch doctor` | Diagnose setup, provider, index or overlay problems |
140
-
141
- When you are ready for deterministic enforcement:
54
+ | `hunch context "<task>" --profile builder` | Get a focused brief before starting |
55
+ | `hunch why <file-or-symbol>` | Understand decisions and past bugs behind code |
56
+ | `hunch structure [target]` | Inspect indexed files and symbols |
57
+ | `hunch findings [scope]` | See known gaps that still need work |
58
+ | `hunch impact origin/main` | See what a branch could affect |
59
+ | `hunch check --working` | Check current changes against recorded rules |
60
+ | `hunch conform` | Check supported architectural relationships |
61
+ | `hunch now` | Read recent decisions and the recorded roadmap |
62
+ | `hunch doctor` | Diagnose setup and storage problems |
63
+
64
+ For enforcement after reviewing and trusting the relevant rules:
142
65
 
143
66
  ```bash
144
67
  hunch firmness strict
145
68
  hunch check --staged --strict
146
69
  ```
147
70
 
148
- Captured memory cannot silently hard-block on its own.
71
+ Generated notes, observed habits, and imported documents do not silently gain blocking authority.
149
72
 
150
- ## Deterministic organizational state
151
-
152
- Repository memory solves one version of a larger problem, and since 1.25.0 Hunch ships the larger one.
73
+ ## Update without losing your settings
153
74
 
154
- As organizations give every employee an agent that can work across CRM, email, messaging, repositories and other tools, the agents become probabilistic writers/readers of the same organization. If each one independently reconstructs what was decided, what was already done or what is still owed, the organization gets multiple conflicting realities.
75
+ From each repository that uses Hunch:
155
76
 
156
- Hunch is the deterministic state layer between those agents and the organization:
77
+ ```bash
78
+ hunch update
79
+ ```
157
80
 
158
- > **Agents are probabilistic. Organizations need deterministic state. Hunch is the state layer between them.**
81
+ Or ask your agent to **“update Hunch.”** The command installs the latest release, aligns configured integration pins, repairs known legacy launch commands, and refreshes Hunch instructions. It preserves unrelated settings and intentionally disabled hooks.
159
82
 
160
- The target is **one product, one authorized state graph and one versioned state contract** across repository, user, team and organization scopes.
83
+ - A standalone npm project keeps Hunch in its existing dependency section at an exact version. Without a repository dependency, the global CLI is updated. Add `--global` to update both.
84
+ - For other package managers or workspaces, update the dependency with that package manager, then run `hunch integrations repair-pins`.
85
+ - Restart or reconnect active assistants. In Codex, open `/hooks` to review and trust changed commands, then start a new session. A changed version pin changes the command and requires renewed trust.
161
86
 
162
- The state it holds:
87
+ Verify the setup:
163
88
 
164
- - decisions currently in force;
165
- - verified action receipts / what was done;
166
- - commitments and due-state;
167
- - entities and relationships;
168
- - code/system changes with proof;
169
- - repository/user/team/org DNA;
170
- - derived current state with exact dependencies/invalidation.
89
+ ```bash
90
+ hunch integrations check
91
+ hunch integrations check --harness codex --probe --require mcp
92
+ hunch integrations check --harness codex --require context
93
+ ```
171
94
 
172
- Agents continue to own live connector mechanics. Hunch must **not** become a managed proxy that fetches Gmail, CRM, WhatsApp or GitHub on an agent's behalf.
95
+ The first command checks configuration. The probe starts a fresh MCP process and reads memory. The context check requires observed hook delivery on the expected version, so run it after the new assistant session begins. `--require` fails when the named capability is not verified; none of these checks proves that a model followed the advice.
173
96
 
174
- Instead:
97
+ ## See what Hunch contributed
175
98
 
176
- ```text
177
- Hunch deterministic state
178
- ↑ ↓
179
- agent -> deterministic action gate -> connector -> source system
180
- ```
99
+ Task reports answer: what memory reached this task, what did the agent say it used, and what checks actually ran?
181
100
 
182
- Hunch may hold durable state **about** external work with credential-free provenance pointers, but should not mirror raw source-system contents into a universal cache.
101
+ The normal agent instructions request a completion card with a link to a local evidence report. You can also inspect reports directly:
183
102
 
184
- The first real-world pilot is **Sofia**, a working operations agent over CRM, Gmail and WhatsApp. Sofia's approved actions, follow-ups, customer/source relationships and cited summaries map naturally to action receipts, commitments, entities/relationships and dependency-bound state.
103
+ ```bash
104
+ hunch task list
105
+ hunch report <task-id> --html
106
+ ```
185
107
 
186
- The pilot measures whether Sofia and a second, different agent stop re-deriving contradictory state when the deterministic state is delivered before they answer or act. First live number (2026-09-12, one user): after one CRM read, the next status questions were answered from held state under a receipt, 0 of 3 without a source; the [roadmap](ROADMAP.md) carries the gate table.
108
+ A delivered lesson, an agent's claim, and a passing test are different evidence. Hunch keeps them separate. Automatic presentation depends on the host following the task lifecycle; missing evidence stays unverified. [Read the reporting guide](docs/task-reports.md).
187
109
 
188
- ### The state contract, shipped
110
+ ## Share one living repository memory with your team
189
111
 
190
- As of 1.25.0 the contract exists as code: `nuryel.state/1` — three verbs (`read` under the
191
- delivery envelope's receipt, `write` with provenance and an idempotency key, `subscribe` to a
192
- strictly ordered change stream) over five new record facets: action receipts, commitments,
193
- derived state that names what it rests on, external entities and their relationships. Ids are
194
- derived from a record's facts, a replay returns the original, a second live decision on a topic is
195
- refused with the incumbent named, and derived state without dependencies is not state. Each scope
196
- keeps a git-native change ledger under `.hunch/changes/`; organization, team and user partitions
197
- are homed in an overlay, never in a repository. The MCP server binds it as `nuryel_capabilities`,
198
- `nuryel_read`, `nuryel_write` and `nuryel_subscribe`; every other transport will call the same
199
- store binding. Contract and evidence: [docs/nuryel-state-contract.md](docs/nuryel-state-contract.md).
112
+ One maintainer connects a dedicated private Git repository:
200
113
 
201
- As of 1.26.0 the state layer is also **served**: `hunch serve --config <file>` hosts organization,
202
- team, user and repository partitions over HTTP on loopback with the same three verbs. A served
203
- partition is a directory whose `.hunch/partition.json` names the scope it is; the bearer token
204
- resolves the principal and grants come from the config only. `hunch serve init --partition
205
- user:david --root <dir> --principal sofia@david` declares a partition and mints a token. The typed
206
- client is `import { createStateClient } from "@davesheffer/hunch/state"`. This folds the separate
207
- Hunch Memory service into Hunch.
114
+ ```bash
115
+ hunch shared --repo git@github.com:acme/project-hunch-memory.git
116
+ git add .gitignore .hunch/team.json
117
+ git commit -m "chore: connect shared Hunch memory"
118
+ git push
119
+ ```
208
120
 
209
- As of 1.27.0 a fourth verb, `records`, lists a subject's records for the first writers, and the per-scope ledger compacts and merges across clones. As of 1.28.0 reads are a union across writers, a supersede target must still be open (two racing writers can no longer leave two current records), state records are searchable and delivered by subject, and subjects are keyed by the external record rather than by the agent. Proven on an emulated organization: three agents over ten clinics and a generated year of mail, chat and CRM, one organization drawer, 96 cited summaries, 24 verified receipts, 24 commitments, zero contradictions.
121
+ Teammates install Hunch, pull the code, and run `hunch init`. Normal Git access controls the shared repository. Credentials, local clone paths, and private overlays stay out of the committed pointer. Use `hunch shared --sync` to retry synchronization; add `--no-auto-commit` when captures should wait for explicit sync.
210
122
 
211
- As of 1.30.0 subject identity is by external reference: one active entity per external record per partition, a subject written as an entity's external key refused with the entity id named, reads resolving one explicit hop — so two agents over one CRM record land on one subject. Replay determinism is a check, not a claim: `hunch serve replay --partition <kind:id>` (or `--root <dir>`) folds a partition's ledger into the state it implies and compares it hash for hash to the records on file, exits 1 on any divergence, runs inside `hunch drift` when the partition has a ledger, and runs on every agent-farm run; and a human correction outranks later agent writes — a record a human confirmed is never overwritten or superseded by an agent or service principal (replay, stale-with-cause and closure by receipt are the only agent moves, each keeping the human's provenance).
123
+ This shares a project's engineering memory. The state server below adds authenticated access across multiple scopes.
212
124
 
213
- Read [Deterministic organizational state](docs/deterministic-state.md), the [roadmap](ROADMAP.md) and the dated [competitive landscape](docs/competitive-landscape.md).
125
+ ## Deterministic organizational state
214
126
 
215
- ### Naming
127
+ A coding agent needs to know why a module exists. An operations agent may need to know whether a customer action was completed or who owes the next follow-up. Both need a maintained record they can check.
216
128
 
217
- The product is still **Hunch**. A possible hosted-platform name, **Nuryel**, is intentionally deferred until the state contract and Sofia pilot have evidence. Rename work is not the deliverable.
129
+ Hunch ships `hunch serve`: a self-hosted HTTP service for organization, team, user, and repository records. A configured identity determines which scopes an agent may access. Optional record audiences further restrict access; optional key-bound credentials require proof from the configured private key on each request.
218
130
 
219
- ## Share one living repository memory with your team
131
+ Open `/operator` on your server to inspect current records, completed work and commitments in a read-only browser view. Writer-supplied citations can point to an exact summary field or text passage and its recorded sources. They show traceability; they do not prove that a source supports a claim.
220
132
 
221
- The current release can keep a team's **repository-scoped** memory in a dedicated private Git repository, separate from the code.
133
+ Agents can use the same contract through MCP, `hunch state read|write|records|subscribe`, the `@davesheffer/hunch/state` TypeScript client, or the [Python client](docs/python-state-client.md). The Python package is built and tested from this repository; it is not yet published to PyPI. [Scoped conventions](docs/scoped-conventions.md) let a person record sourced user, team or organization preferences. Those preferences remain advisory and do not silently become blocking rules.
222
134
 
223
- Today Hunch does not host that shared Git repository; teammates/CI use normal Git access and one maintainer connects it:
135
+ Records can describe decisions, action outcomes, commitments, entities, relationships, and summaries that name their dependencies. Actions retain their status, including unknown or unverified outcomes. Repeated writes have stable identities, conflicting current decisions are refused, and confirmed human records receive protections against agent overwrites. These are defined checks on structured records; Hunch cannot establish every fact in the outside world on its own.
224
136
 
225
- ```bash
226
- npm i -g @davesheffer/hunch@1.32.2
227
- hunch shared --repo git@github.com:acme/project-hunch-memory.git
228
- git add .gitignore .hunch/team.json
229
- git commit -m "chore: connect shared Hunch memory"
230
- git push
231
- ```
137
+ This is what **deterministic state** means here: explicit rules govern the stored record, rather than having each agent reconstruct it from scratch. Git holds the durable data; SQLite is a rebuildable index. The server binds to loopback and requires deployment and agent integration by its operator. Hunch does not provide a managed CRM or email connector service.
232
138
 
233
- Teammates then install the same version and run:
139
+ [Set up and understand the state server](docs/deterministic-state.md) · [State contract and client reference](docs/nuryel-state-contract.md) · [Upgrade to 1.33](docs/upgrade-1.33.md)
234
140
 
235
- ```bash
236
- npm i -g @davesheffer/hunch@1.32.2
237
- git pull
238
- hunch init
239
- hunch doctor
240
- ```
141
+ ### The vision, and what is still being tested
241
142
 
242
- The committed pointer contains a credential-free repository locator and branch. Local clone paths, preferences and private overlays stay ignored. MCP sessions refresh shared memory at tool boundaries; failed pushes can be retried by later capture or `hunch shared --sync`.
143
+ The vision is continuity across people, tools, and agents: an operations agent records a customer issue, a coding agent finds the relevant decision and fixes the cause, and the operations agent closes the commitment using evidence of the fix.
243
144
 
244
- Use `hunch firmness off` to pause hook enforcement without deleting history. Use `hunch shared --repo <url> --no-auto-commit` when captures should remain local until explicit `hunch shared --sync`.
145
+ The underlying memory and state tools ship today. The broader claim—that different agents reliably use that shared state and avoid contradictory work—is still being measured in the Sofia pilot. Simulated results and a limited live pilot are not proof of that outcome across organizations. The [roadmap](ROADMAP.md) tracks the remaining acceptance gates.
245
146
 
246
- This existing Git-sharing feature is not the same thing as the planned organization/team/user state service. The roadmap extends the git-native model rather than declaring today's shared-memory repository to be an organization control plane.
147
+ **Hunch remains the product name.** The `nuryel.state/1` protocol and `nuryel_*` tool names are existing technical identifiers; a possible future rename is undecided.
247
148
 
248
- ## Trust boundaries that stay visible
149
+ ## Project DNA: help the agent understand how the project works
249
150
 
250
- - **Local-first today.** Repository Hunch works without a hosted service or telemetry. Git remains the repository-scoped authority.
251
- - **Hosted state is a roadmap extension, not a shipped claim.** Organization/team/user state will require authenticated scope/visibility, idempotency and durability while preserving git-native truth.
252
- - **Private when needed.** `hunch private --repo <url>` keeps sensitive repository reasoning in a separate overlay; public CI/documentation remain public-only.
253
- - **Human authority.** Observations, generated drafts, imported ADRs, discovered landscape records and proved policy candidates do not silently become trusted truth.
254
- - **Deterministic core.** Indexing, retrieval receipts, currentness, conformance, Project DNA discovery and policy evaluation do not require a model.
255
- - **Agents own execution.** Hunch state does not silently grant connector permissions, send messages or become a source-system proxy.
256
- - **No surprise synthesis bill.** Optional drafting can use a selected Claude Code, Codex or Cursor subscription CLI, a local OpenAI-compatible endpoint or deterministic fallback. Public remote endpoints require explicit opt-in.
257
- - **Traceable releases.** npm packages and the VS Code extension are content-addressed, verified against public registries and tied back to exact source tags.
151
+ Project DNA describes observed repository conventions: terminology, contribution habits, review expectations, and engineering patterns. Engineering memory records decisions and their reasons. Both can inform a task, but frequent behavior does not become policy.
258
152
 
259
- ## What changed after v1.19
153
+ ```bash
154
+ hunch dna inspect
155
+ hunch dna context
156
+ hunch dna diff <older-ref> <newer-ref>
157
+ ```
260
158
 
261
- The v1.19 correction-search benchmark remains scoped evidence, but it no longer describes the whole product.
159
+ Profiles retain their revision, sources, confidence, and freshness. [Project DNA contract](docs/project-dna.md) · [Broader DNA vision](docs/project-dna-engine.md)
262
160
 
263
- - **v1.20 one validated path from reason to result.** Role-shaped context, reviewed Engineering Landscape fragments, exact change identity, PHP graph support and hash-bound ADR review moved source, provenance, currentness, omissions and human authority through one delivery contract.
264
- - **v1.21 — Project DNA.** Hunch gained deterministic, revision-specific repository profiles, bounded DNA context delivery, explainable Project Match checks and auditable profile deltas.
265
- - **v1.22 — authorized collaboration evidence.** Hosts can contribute bounded PR/review evidence to Project DNA through a typed, sealed contract without raw collaboration persistence or policy-authority change.
266
- - **v1.23 — native change proof and proof-carrying evidence work.** Exact Git change identity, graph before/after, decisions/constraints, blast radius and Change Gate result can be bound into a sealed evidence artifact without granting authority.
267
- - **v1.25 – v1.30 — the state layer.** `nuryel.state/1` as code, `hunch serve` partitions, union reads, subject identity by external reference, replay determinism, human corrections outranking agent writes.
268
- - **v1.32 — see what Hunch contributed.** Task contribution reports: what was delivered, what the agent reports it applied, what a rule verified, what a command observed; concise card, local evidence view.
161
+ ## Your data and your authority
269
162
 
270
- See the [changelog](CHANGELOG.md) for release detail and the [roadmap](ROADMAP.md) for active work.
163
+ - Repository use is local-first and needs no hosted Hunch account. Shared memory uses Git access; the optional state server uses configured identities and grants.
164
+ - `hunch private --repo <url>` keeps sensitive project reasoning in a private overlay. Public exports and CI should use public-only views.
165
+ - Drafting can use a selected coding-assistant subscription, a local endpoint, or the deterministic fallback. Public metered endpoints require explicit opt-in. [Synthesis and billing](https://www.hunchmemory.com/docs#synthesis).
166
+ - Agents keep responsibility for external actions and connector permissions. A stored record does not authorize an email, deployment, or CRM change.
167
+ - npm and editor releases use separate publication gates with package integrity and provenance checks.
271
168
 
272
169
  ## Learn more
273
170
 
274
171
  - [Full documentation](https://www.hunchmemory.com/docs)
275
172
  - [Copy-paste cookbook](https://www.hunchmemory.com/cookbook)
276
- - [Turn PR review threads into scoped review rules](docs/review-memory.md)
277
- - [Keep agent launches with the initiating provider](docs/agent-origin.md)
173
+ - [Task contribution reports](docs/task-reports.md)
278
174
  - [Deterministic organizational state](docs/deterministic-state.md)
279
175
  - [Project DNA](docs/project-dna.md)
280
176
  - [Native change proof](docs/change-proof.md)
281
- - [The autonomy ladder](docs/autonomy-ladder.md)
282
- - [Task contribution reports](docs/task-reports.md)
177
+ - [Engineering Landscape](docs/engineering-landscape.md)
178
+ - [Review memory](docs/review-memory.md)
179
+ - [Agent-origin handling](docs/agent-origin.md)
180
+ - [Autonomy ladder](docs/autonomy-ladder.md)
283
181
  - [Autonomous development](docs/autonomous-development.md)
284
- - [Local cookbook](docs/cookbook.md)
285
- - [Engineering Landscape Graph](docs/engineering-landscape.md)
286
- - [Hunch roadmap](ROADMAP.md)
182
+ - [Changelog](CHANGELOG.md) · [Roadmap](ROADMAP.md)
287
183
  - [VS Code extension](vscode-extension/README.md)
288
184
  - [Architecture benchmark](bench/architectural-conformance.md)
289
185
  - [Contributing](CONTRIBUTING.md)
package/dist/cli/index.js CHANGED
@@ -26,6 +26,7 @@ import { looksLikeCorrection, CORRECTION_NUDGE } from "../core/correction.js";
26
26
  import { HUNCH_VERSION } from "../core/version.js";
27
27
  import { registerIntegrationCommands } from "./integrations.js";
28
28
  import { registerTaskReportCommands } from "./taskReport.js";
29
+ import { registerStateCommands } from "./state.js";
29
30
  import { registerServeCommands } from "./serve.js";
30
31
  import { registerUpdateCommand } from "./update.js";
31
32
  import { registerReviewMemoryCommands } from "./reviewMemory.js";
@@ -164,6 +165,7 @@ registerIntegrationCommands(program, () => {
164
165
  });
165
166
  registerTaskReportCommands(program, () => { const { store, root } = storeFor(); return { store, root }; });
166
167
  registerServeCommands(program);
168
+ registerStateCommands(program);
167
169
  registerUpdateCommand(program);
168
170
  registerReviewMemoryCommands(program, (records, repository, privateOnly) => {
169
171
  const { store, root } = storeFor();
@@ -26,11 +26,14 @@ export function registerIntegrationCommands(program, refreshGrounding) {
26
26
  process.exitCode = 1;
27
27
  });
28
28
  integrations.command("repair-pins")
29
- .description("Align existing exact-version pins and refresh existing Hunch instructions; preserves other settings and does not enable hooks")
29
+ .description("Align pins, repair known Hunch launch commands and refresh instructions; preserves other settings and does not enable hooks")
30
30
  .action(() => {
31
31
  const root = findRoot();
32
32
  const files = repairIntegrationPins(root);
33
33
  console.log(files.length ? `Updated ${files.length} integration file(s): ${files.join(", ")}. Reconnect active MCP sessions.` : "Integration pins already aligned.");
34
+ if (files.includes(".codex/hooks.json")) {
35
+ console.log("Codex: open /hooks to review and trust the changed commands, then start a new session. Command changes require renewed trust; Hunch does not grant it automatically.");
36
+ }
34
37
  const grounding = refreshGrounding();
35
38
  if (grounding.length)
36
39
  console.log(`Updated Hunch instructions: ${grounding.join(", ")}. Reconnect the agent to load task reporting instructions.`);
package/dist/cli/serve.js CHANGED
@@ -1,6 +1,8 @@
1
+ import { readFileSync, statSync } from 'node:fs';
2
+ import { proofPublicKey } from '../core/stateProof.js';
1
3
  import { resolve } from "node:path";
2
4
  import { createServeApp } from "../serve/app.js";
3
- import { initServeConfig, partitionFor, readServeConfig } from "../serve/config.js";
5
+ import { initServeConfig, partitionFor, readServeConfig, writeServeConfig } from "../serve/config.js";
4
6
  import { compactLedger } from "../store/changeLedger.js";
5
7
  import { HunchStore } from "../store/hunchStore.js";
6
8
  import { hunchPaths } from "../core/paths.js";
@@ -32,11 +34,23 @@ export function registerServeCommands(program) {
32
34
  // reverse proxy that terminates TLS and auth of its own. Folded-in decision from Hunch Memory.
33
35
  app.listen(port, "127.0.0.1", () => {
34
36
  console.log(`hunch ${HUNCH_VERSION} serving nuryel.state/1 on http://127.0.0.1:${port} — ${config.partitions.map((p) => scopePath(p.scope)).join(", ")} (${config.principals.length} principal(s))`);
37
+ console.log(`Shared state view: http://127.0.0.1:${port}/operator`);
35
38
  });
36
39
  const stop = () => { app.close(() => { app.closeStores(); process.exit(0); }); };
37
40
  process.on("SIGINT", stop);
38
41
  process.on("SIGTERM", stop);
39
42
  });
43
+ serve.command("revoke")
44
+ .description("Revoke a principal credential; current servers reload the config before each request")
45
+ .requiredOption("--principal <id>", "principal whose credential to revoke")
46
+ .action((opts) => {
47
+ const { file, ...config } = readServeConfig(resolve(serve.opts().config ?? DEFAULT_CONFIG));
48
+ if (!config.principals.some(p => p.id === opts.principal))
49
+ throw new Error('principal is not configured');
50
+ config.principals = config.principals.filter(p => p.id !== opts.principal);
51
+ writeServeConfig(file, config);
52
+ console.log(JSON.stringify({ revoked: opts.principal }));
53
+ });
40
54
  serve.command("compact")
41
55
  .description("Compact a served partition's change ledger: keep the newest N events, move the floor up; subscribers below the floor resynchronize")
42
56
  .requiredOption("--partition <kind:id>", "the partition whose ledger to compact")
@@ -105,6 +119,8 @@ export function registerServeCommands(program) {
105
119
  .requiredOption("--root <dir>", "directory whose .hunch/ holds the partition (created if missing)")
106
120
  .option("--config <file>", `serve config to create or extend; default ${DEFAULT_CONFIG}`)
107
121
  .option("--principal <id>", "principal to add or rotate, granted this partition")
122
+ .option("--proof-key-file <file>", "bind this token to an Ed25519 public PEM or JWK key")
123
+ .option("--public-origin <origin>", "external HTTPS origin of the reverse proxy; required for key-bound tokens")
108
124
  .option("--kind <kind>", "principal kind: human | agent | service", "agent")
109
125
  .option("--grant <kind:id...>", "additional partitions to grant the principal (must be served by this config)")
110
126
  .option("--port <n>", "port to record in a new config")
@@ -120,10 +136,20 @@ export function registerServeCommands(program) {
120
136
  const port = parent.port ?? opts.port;
121
137
  const scope = parseScopeArg(opts.partition);
122
138
  const grants = [scope, ...(opts.grant ?? []).map(parseScopeArg)];
139
+ let proofKey;
140
+ if (opts.proofKeyFile) {
141
+ if (!opts.principal)
142
+ throw new Error('--proof-key-file requires --principal');
143
+ const stat = statSync(opts.proofKeyFile);
144
+ if (!stat.isFile() || stat.size > 8192)
145
+ throw new Error('public proof key must be a regular file of at most 8 KiB');
146
+ proofKey = proofPublicKey(readFileSync(opts.proofKeyFile, 'utf8'));
147
+ }
123
148
  const result = initServeConfig({
124
149
  file: configFile, scope, root: resolve(opts.root),
125
- ...(opts.principal ? { principal: { id: opts.principal, kind: opts.kind, grants } } : {}),
150
+ ...(opts.principal ? { principal: { id: opts.principal, kind: opts.kind, grants, proofKey } } : {}),
126
151
  ...(port ? { port: Number(port) } : {}),
152
+ ...(opts.publicOrigin ? { publicOrigin: opts.publicOrigin } : {}),
127
153
  });
128
154
  if (opts.json) {
129
155
  console.log(JSON.stringify({ config: configFile, partition: result.partition, token: result.token }));
@@ -0,0 +1,3 @@
1
+ /** JSON CLI over the existing HTTP client. The server owns authorization and state rules. */
2
+ import type { Command } from 'commander';
3
+ export declare function registerStateCommands(program: Command): void;