Skip to content

feat: identity-signed audit + Berget/Grunden providers + shared-memory recall - #167

Merged
sandstream merged 6 commits into
mainfrom
claude/headroom-kit-integration-cmjw7t
Jun 29, 2026
Merged

sandstream merged 6 commits into
mainfrom
claude/headroom-kit-integration-cmjw7t

Conversation

@sandstream

@sandstream sandstream commented Jun 28, 2026 •

Copy link
Copy Markdown
Owner

Description

Three additive, backward-compatible changes on the integration branch.

1. Identity-signed audit entries + signature verify

Asymmetric attribution on top of the .kit-audit.jsonl hash chain + HMAC anchor. When a local kit identity exists, each appended line is signed (kid + Ed25519 sig over the line hash). Best-effort/append-safe; verifyAuditChain excludes sig/kid from the hashed remainder so mixed signed/unsigned/legacy logs still verify. New verifyAuditSignatures(); kit audit verify reports the tally and fails on a forged signature. localPublicKeys() builds the trust map (current + rotated keys). Docs: AUDIT_ATTESTATION.md §2.5.

2. Berget AI + Grunden.ai as known providers

berget/grunden (EU-sovereign, OpenAI-compatible inference) added to the service registry with canonical key names so kit secrets treats them as known, vault-resolved keys. Catalog-only by design (no unique package signal — keying on openai would misattribute every OpenAI user). Agent-backend wiring + a Berget Code gate adapter deferred.

3. Curated shared memory folded into recall (memory design gap #1)

kit memory search now also searches the committed .kit/shared/memory.jsonl tier and surfaces matching team decisions/conventions above raw transcript hits (--json → { messages, shared }). SessionStart recovery re-injects the project's most recent durable shared decisions (kinds decision/convention/security/status) via recentDecisions(). Project-local, deterministic, fail-open.

Type of Change

  • New feature (non-breaking)
  • Documentation update

Testing

  • Added new tests
  • All tests pass (npm test) — 1886 pass / 0 fail; run-security-check.mjs PASS (19 ok)

Verified live: kit memory share → kit memory search surfaces the curated decision above raw hits; --json returns { messages, shared }.

Breaking Changes

None / N/A — all three changes are additive and backward-compatible. (memory search --json gains a wrapping object { messages, shared } vs a bare array; experimental surface.)

🤖 Generated with Claude Code

https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg

claude added 3 commits June 28, 2026 07:32
Agent gate coverage (7 agents) + the first 3.0 primitive (kit identity).
Additive minor — no breaking changes to any stable surface. See CHANGELOG.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
Add the asymmetric ATTRIBUTION layer on top of the hash chain (integrity)
and HMAC anchor. When a local `kit identity` exists, each appended
`.kit-audit.jsonl` line is signed: kit signs the line `hash` and attaches
non-hashed `kid` + `sig` (Ed25519). Best-effort and append-safe — no
identity means entries are written exactly as before, and a signing
failure never blocks the append.

- audit.ts: appendChained best-effort signs via signLineHash(); verifyAuditChain
  excludes sig/kid from the hashed remainder (mixed signed/unsigned/legacy logs
  still verify); new pure verifyAuditSignatures(content, resolvePubkey) returning
  {total, signed, verified, invalid, unverifiable, unsigned, ok}. Forged sig =>
  hard fail; unknown/absent key => fail-open.
- identity.ts: localPublicKeys() builds a kid->pubkey trust map from the current
  identity plus archived rotated (.bak) records.
- commands/audit.ts: `kit audit verify` reports the signature tally and fails on
  a forged signature.
- docs/AUDIT_ATTESTATION.md §2.5 + CHANGELOG Unreleased.
- Tests: chain stays valid with sig/kid present, signed entries verify, forged
  sig fails, unknown key is unverifiable (fail-open), legacy keyless is unsigned-ok,
  localPublicKeys resolves current + rotated keys.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
Add `berget` and `grunden` (EU-sovereign, OpenAI-compatible inference) to
the service registry with their canonical key names and where to get them,
so kit's secrets layer treats them as known, vault-resolved keys.

Catalog-only by design: both are consumed through the `openai` SDK with a
custom base URL, so there is no unique package/file signal to auto-detect
on — keying on the `openai` dep would misattribute every OpenAI user.
Generic kv-secret redaction already covers BERGET_API_KEY/GRUNDEN_API_KEY,
so no new redaction pattern is needed.

Agent-backend wiring (point an agent's OpenAI-compatible base URL at these
providers) and a Berget Code gate adapter are deferred to future work.

Tests: both entries expose their *_API_KEY and declare no auto-detection;
a plain `openai`-SDK repo does not auto-detect either provider.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
@sandstream sandstream changed the title feat(audit): identity-signed audit entries + signature verify feat: identity-signed audit entries + Berget/Grunden as known providers Jun 28, 2026
…ntegration-cmjw7t

# Conflicts:
#	CHANGELOG.md
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

Wire the committed .kit/shared/memory.jsonl tier into the recall paths
(memory design gap #1):

- `kit memory search` now also runs searchShared() and surfaces matching
  team decisions/conventions ABOVE raw transcript hits. `--json` returns
  `{ messages, shared }` (was a bare hits array). Project-local even under
  `--global` (shared memory travels with the repo). Fail-open.
- SessionStart recovery re-injects the project's most recent durable shared
  decisions (kinds decision/convention/security/status; notes/how-built
  excluded) via new exported `recentDecisions(root, limit)`, so a resumed
  session regains the SETTLED context, not only the last few raw turns.

Deterministic, zero-LLM, fail-open throughout (a missing/broken shared
store never breaks recall). Tests cover durable-kind filtering, newest-first
ordering, the limit, and the empty-store fail-open path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream sandstream changed the title feat: identity-signed audit entries + Berget/Grunden as known providers feat: identity-signed audit + Berget/Grunden providers + shared-memory recall Jun 29, 2026
Decision lifecycle for the curated shared tier (memory design gap #2).
Append-only: a change is a NEW entry that supersedes/reverses an old id;
`active` stays implicit (absent field) so pre-lifecycle entries are
byte-identical and diffs stay clean.

- shared.ts: SharedEntry/ShareInput gain status/supersedes/reverses;
  shareEntry persists them only when non-default. New pure helpers
  effectiveStatus (explicit status wins, else referenced-by-later ⇒
  superseded/reversed; reverses outranks), activeShared, formatAge.
- commands/memory.ts: `kit memory share --supersedes/--reverses/--status`
  (validates the referenced id exists); `kit memory area`/`search` badge
  superseded/reversed entries + show the chain and age; area --json carries
  the effective status.
- hook.ts: SessionStart recovery surfaces only ACTIVE durable decisions
  (recentDecisions → activeShared) with age, so a resume sees the decision
  HEAD, not a graveyard.

Surfacing shows facts (status, age, supersedes-chain); the relevance call
stays human (zero-LLM, deterministic). Tests cover supersede/reverse
resolution, reverses>supersedes precedence, explicit-status, the active
filter, age bucketing, and recovery exclusion of superseded decisions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit ae25384 into main Jun 29, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants