instinct-cli 0.3.6

Local memory for AI coding agents: an MCP server and CLI that gives Claude Code, Codex, Cursor and any MCP client the one lesson that fits. Lessons that keep failing go quiet.
# Q5: observed checks and verified feedback

Status: implementation contract for the next M2/M3 increment, not a released feature. Pure receipt replay remains untrusted supplied-fact reproducibility; it cannot earn a check-verified hit by itself.

## Platform support

Observed checked hits currently require Unix. On Windows they return `check-verified hits are not supported on this platform; nothing recorded` before opening the bank or acquiring its lock. Ordinary feedback and pure checks remain supported. macOS observation permits only the explicitly documented OS temp/config aliases above the named root; arbitrary user symlinks are still rejected.

## First supported check

A lesson can be explicitly attached to a versioned `artifact-inventory/v1` policy. This is the existing bounded read-only staging adapter, not an arbitrary script, regex execution, shell command or model assertion. Attaching a check does not alter recall or evidence_status, run observation, or earn a hit.

CLI:

```
instinct check attach --lesson ID --store BANK --input policy.json
instinct hit ID --check --root ABS --trusted-staging --outcome-id KEY --store BANK
```

`attach` policy uses the existing artifact policy fields and exact scope. A stored assumption never grants access: attachment may store `trusted_quiescent_staging`, but hit requires the current caller's explicit `--trusted-staging`. Missing acknowledgement errors before observation. `--root` is required on every verified hit and never stored as an executable grant. Root scope is checked by the existing adapter; failed/incomplete/unsupported/output-error observation records **no hit**.

The attached scope must exactly equal the lesson's five scope fields (omitted dimensions normalized only as legacy unscoped fields); do not broaden a project/persona/machine-scoped lesson. At verified-hit time use the current CLI/MCP scope and `eligibility::scope_check`, preserving quarantine/expiry restrictions. No scope mismatch can be overridden by the attachment or request. Checks for absent/retired lessons fail.

CLI attachment requires explicit store for clarity in the first version; other commands retain existing default-store behavior. New `--check` without an attachment is an error, never a fallback to claimed feedback. `miss --check` is an error. Empty/whitespace observation keys are rejected. Normal `hit`/`miss` without `--check` remain byte-identical.

## Storage and transaction boundary

Use `<bank>.capabilities.hxdb` via existing private journal primitives, with a versioned attachment event containing lesson ID, immutable lesson-content fingerprint, exact scope, adapter/check revision, canonical policy and its digest. No plaintext secrets or root paths in normal display; sidecar remains private. Binding a changed lesson with a reused ID must invalidate the attachment. Duplicate identical attachment is idempotent; replacing policy is explicit new revision and changes its fingerprint.

Attachments also carry `bank_binding`, a domain-separated SHA-256 of the canonical bank location. Copied sidecars and moved banks require an explicit `check attach` in the destination before a new verified hit; the refusal prints a reattach command accepting an approved policy on stdin. Relative and absolute spellings of the same location agree. A bank reached through a symlink binds to its canonical target: moving that target requires reattachment, while renaming the symlink does not change the binding. The sidecar is still located beside the supplied bank path, so an alias must also have its attachment sidecar available there. Older attachments without this field also require reattachment. Ordinary lesson reads and claimed feedback remain unchanged.

A trusted local writer can edit the metadata; this binding is not authentication.
Replacing a bank at the same path is not a new identity.
The private location digest is not a secret-hiding guarantee and must not be published as anonymous data.

Keep verified outcomes atomic in the existing bank's single `hit` journal event: add optional namespaced check receipt metadata only for the new path. This avoids separate receipt/hit writes. Older readers must still count that event as a hit but must not claim verification; no new legacy state enum. A validated attachment is a prerequisite, not a second transaction to commit alongside the hit.

Acquire the existing bank identity lock for attachment and verified feedback, with a fixed lock order (bank before sidecar). Do not invoke existing `op_mark` while already holding its lock; factor only the common append helper if needed, preserving old behavior/output. Observation is bounded; holding the identity lock during observation prevents in-process attachment/lesson changes, not external filesystem mutation. Re-read attachment and lesson identity under the same lock before recording.

A verified hit event carries:
- existing kind/id/ts/note/outcome_id fields;
- `check_verification` version, adapter revision, policy/lesson fingerprints, full scope, observation key;
- SHA-256 of the canonical observed inventory/result and a compact receipt that explicitly says `authorization: not_evaluated` and `evidence_origin: adapter_observed`;
- caller `trusted_quiescent_staging` premise, not a claim of atomic snapshot or causality.

Do not label the pure caller-reported receipt as adapter-observed. Use the existing digest primitives and explicit canonical framing. The receipt binds the actual adapter-produced data, lesson ID/content, attachment revision, current scope and outcome key. Root identity may be fingerprinted locally but never grants future access. Detailed private observation is not automatically exported.

Verified feedback remains an explicit mark for the existing outcomes learner; it must suppress duplicate automatically inferred feedback just as an ordinary explicit hit does. Do not hide it from `outcomes::explicit_marks` or invent a new observation-key namespace that would count the same outcome twice.

Idempotency: the same observation key recorded on this lesson counts once. An existing claimed hit cannot be silently upgraded to verified by retry. A conflicting verdict or a reused key with a different attached revision/context must be rejected or explicitly reported as already-recorded without mutation. No second credit. Consolidated lessons must obey upstream counted-once semantics; rebase/coordinate the upstream outcome fix before final integration rather than reimplementing it inconsistently.

## Evaluation and audit

When no verified events exist, `instinct eval` text/JSON must remain byte-identical to legacy behavior. When verified events exist, append a separate summary: claimed hits versus check-verified hits, with the time window respected. Verified counts require structurally valid event metadata bound to the same event/observation key and an applicable recognized check revision. Retractions remove the corresponding credit. Do not count quarantined or invalid verification records as trustworthy receipts; malformed metadata is reported, not silently promoted.

Derive the verified subset in the same consolidation fold that awards total credit, not a second journal fold with subtly different retry/retraction rules. Extend its internal mark/visitor metadata while keeping existing count semantics and legacy callback behavior unchanged. Verification requires the complete supported metadata shape, matching event outcome key and current lesson-content fingerprint. Cross-lesson supersede transfer or changed content conservatively downgrades that credit to claimed; never transfer a verification claim merely because scopes match. Mixed claimed/verified reports for one consolidated outcome are claimed unless every live contributing mark remains validly bound. Retractions and disputed observations follow the existing fold; no second vote. Prefer a provenance-aware fold visitor over adding fields to snapshot-serialized Discovery until compatibility is proven. Windowed eval counts use the same event timestamps selected by consolidation. Report downgrades separately when present.

The total existing hit count includes both kinds once; check-verified is a subset, not an additional hit. This means 'the named predicate passed on observed evidence under stated assumptions', not 'the lesson caused success' or 'future actions are safe'. Direct bank writers are trusted local principals; checksums are not signatures against a malicious bank owner.

### Summary schema for this increment

Only when a `check_verification` event marker exists in the selected bank, add a top-level `verification` object to eval JSON with `schema: instinct.verified-feedback-summary/v1`, `claimed_hits`, `check_verified_hits`, `downgraded_hits`, and `invalid_records`. Hit values are windowed surviving consolidated credits. `check_verified_hits` is a subset of total hits; `claimed_hits = total_hits - check_verified_hits`; `downgraded_hits` is a subset of claimed hits whose original verification no longer binds. `invalid_records` counts structurally invalid verification metadata in the selected window, not extra hit credit. Text adds a concise matching section. With no marker, emit no new keys or lines, preserving exact legacy output.

## MCP boundary

Add `check: true` and `outcome_id` to feedback as opt-in fields; ordinary requests unchanged. A server launched with an explicit `INSTINCT_CHECK_ROOT` grant may perform the read-only adapter for that exact root only. No request or attached lesson can supply/widen the server grant. The call must supply `trusted_staging: true`; missing server grant errors before I/O. `paid_off:false` with check true is rejected. The request's note 'it worked' never substitutes for the check.

Attachment MCP support can remain unavailable in the first slice: local owner CLI attaches policies. If added, it needs an independently explicit local-owner mutation grant, not automatic model authority. All new routing uses `super::` compatible with the existing WASM inclusion; native observation remains unavailable on WASM. No real harness configuration is edited by implementation/tests.

## Independent acceptance before implementation results

1. Bank lesson, attach allowlist/required policy; actual extra hidden file; `hit --check --note 'it worked'` returns failed check and hit count stays zero.
2. Fix only fixture inventory; verified hit succeeds exactly once and has receipt; retry gives no extra hit.
3. A claimed hit remains claimed; retry cannot promote it. No attachment/missing grant/false assumption/wrong scope/expired/quarantined lesson -> no hit.
4. Check failure, abstention, missing/unreadable root, symlink bypass variants and output limits leave bank+sidecar unchanged except initial lock-file creation where documented.
5. Policy/lesson content changes invalidate prior binding. Outcome reuse with changed policy does not earn credit.
6. Existing no-check CLI/MCP outputs and evaluation are byte-identical against baseline for same deterministic fixture (control clocks where needed).
7. Eval splits verified/claimed without double-counting, respects window/retractions and upstream supersede behavior.
8. Two concurrent verified requests with the same key earn one hit, one receipt event.
9. CLI/MCP parity, default-denied MCP root, no root override from JSON, no raw private content in receipt summary.
10. JSONL and native bank migration preserve counts and evidence binding; old-reader compatibility tested, never assumed.

No public publish/PR is authorized by this contract. The lead receives a reviewed local patch, base SHA and per-file manifest after gates pass.