Skip to content

docs(adr): ADR-0042 security kernel as library code inside qq-core/qq-mcp (SK0) - #163

Closed
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1790291851-security-kernel-adr
Closed

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1790291851-security-kernel-adr

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What changes for users

None (docs only). Opens the security-kernel plan: the Axiom → qq port of fail-closed guarantees (workstream a, integration plan A1–A3).

Why / design

ADR-0042 fixes the integration boundary before any code lands: Axiom's guarantees (hash-linked audit, MCP tool-set pinning/quarantine, approval ledger + bound commit) are ported as qq-native library code in the crates that already own the state (qq-core::sessions::store, qq-core::approval, qq-mcp). No axiom-* dependency, no new crate, no service/socket. The single-owner SQLite store (ADR-0022) is the trust root, so Ed25519 identities, issuer keys and revocations are deliberately not ported; hashing uses SHA-256 via the existing sha2 dependency instead of BLAKE3 (no new dependency; swap is a re-chain). Audit sinking, tenancy and scale stay above qq (ADR-0009).

Also adds:

  • docs/plans/security-kernel.md — slices SK1 (A3, schema 36→37), SK2 (A2, pin on MCP server declarations), SK3 (A1, tool_calls.authorized_by, name/argument-bound start_tool_call, at-most-once), acceptance per slice, and deferred decisions (grant attenuation, chain anchoring).
  • Ledger docs/plans/progress/security-kernel.md; ADR-0042 reserved in root.md (next free: 0043); index rows in docs/adr/README.md, docs/plans/README.md, docs/plans/progress/README.md.

Follow-up PRs SK1 → SK2 → SK3 stack on this branch.

Note: branch name follows the workstream instruction devin/<timestamp>-<slug> rather than the type/ convention in AGENTS.md.

Linear: ENG- (none assigned; workstream dispatched directly)
Slice: docs/plans/security-kernel.md#SK0

How verified

Docs only; no Rust changes.

  • cargo fmt --all -- --check (n/a, no code)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings (n/a)
  • cargo test --workspace (n/a)
  • cargo test -p qq-provider --no-default-features --features test-support (n/a)
  • Manual check: ADR template sections present; links in the three indexes resolve to the new files.

Impact

  • Performance: none
  • Compatibility: PROTOCOL / DESCRIPTOR / store schema unchanged (SK1 and SK3 will bump the schema, additively)
  • Docs: docs/adr/0042-security-kernel-inside-qq.md, docs/plans/security-kernel.md, ledgers/indexes above

Link to Devin session: https://app.devin.ai/sessions/4a83e789a14d4b4190950fb8678d668e
Open in Devin Desktop: https://app.devin.ai/desktop/session/4a83e789a14d4b4190950fb8678d668e?variant=devin
Requested by: @integrate-your-mind


Devin Review

…-mcp (SK0)

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 2 flags

Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

@lg2m

lg2m commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this contribution — the tool-set pinning idea is one we want in QQ, and the reviewed design has now landed as a single integration PR: #194 (feat/eng-939-mcp-pinning-stack, tracking ENG-939). Your authorship is preserved via Co-Authored-By on the commit.

#194 ports the MCP pinning delta from this stack and repairs the issues found in review (details and reproducing probes in the PR description and docs/adr/0046-mcp-tool-set-pinning.md):

  • The docs are rewritten in QQ's own terms against QQ's contracts (ADR-0004 plan identity, ADR-0007 effect-classified approval); references to an external project as QQ's requirements source were not carried over.
  • The per-event audit hash chain and the approval-binding work are not included — see feat(mcp)!: pin MCP tool sets in config and plan identity; enforce at dispatch; add qq mcp inspect #194's "Not in this PR" for the reasons (no consumer/checkpoint/retention contract yet; verifier accepted a cursor rewrite; conflicts with the proposed ADR-0038 event deletion).

This PR will be closed as superseded once #194 merges.

lg2m added a commit that referenced this pull request Sep 26, 2026
… dispatch; add qq mcp inspect (#194)

* feat(mcp)!: pin MCP tool sets in config and plan identity; enforce at dispatch; add qq mcp inspect

An MCP server's tool descriptors are untrusted text the model reads as
instructions, and the server may change them at any time. A server
declaration may now carry `pin`: the SHA-256 tool-set digest (64 hex
digits, validated at load) of the listing an operator reviewed. A pinned
server whose listing digests differently is quarantined: it contributes no
tools, the readiness message names both digests, and every call to it is
refused (`McpCallFailure::Quarantined` -> `HostCallError::Refused`).

This takes over the contributed stack #163 / #165 / #171 and ships only
the MCP pinning delta, repaired against QQ's own contracts (ADR-0046):

- Dispatch-time enforcement. A pinned call resolves the cached listing
  before waiting for a permit, re-checks the listing generation and the
  `list_changed` flag after it, requires the tool to be in that listing,
  and sends exactly one `tools/call` whose enqueue poll runs under a
  synchronous dispatch gate shared with `on_tool_list_changed`,
  `bump_generation`, and `shutdown`. Previously a queued call that passed
  the pin check executed after the server was quarantined.
- Durable identity. `McpServerDescriptor.pin` is recorded and
  `DESCRIPTOR_VERSION` moves 9 -> 10; pinned and unpinned plans no longer
  share a digest.
- Injective digest. Domain `qq-mcp-tool-set-v2` with length-prefixed
  fields replaces the `\0`-separated v1 encoding.
- Whole listings only. Malformed or duplicate tool names fail the listing
  instead of being skipped before hashing; fetches are bounded to 32
  pages, 512 tools, and 1 MiB; a `list_changed` during a fetch discards it.
- Inspection. `McpManager::inspect` and `qq mcp inspect NAME` print the
  live digest and every descriptor as JSON without calling a tool, so the
  digest is reviewed before it is pinned rather than copied out of a
  quarantine error.

The per-event audit hash chain from #165 is not ported: it has no
consumer, checkpoint, or retention contract yet, and its verifier
accepted a cursor rewrite. Approval/argument binding is deferred.

Breaking: `DESCRIPTOR_VERSION` 9 -> 10 invalidates cached plan digests
(recompiled on next load; no store migration). No protocol change.

Verification: fmt, clippy (-D warnings), workspace build and tests, the
minimal qq-provider profile, and `plan_compile` bench within noise of the
baseline (ledger `docs/plans/progress/mcp-pinning.md`).

Closes ENG-939. Supersedes #163, #165, #171.

Co-Authored-By: romy <[email protected]>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(mcp): count listing descriptor bytes without buffering an encoded copy

Codex review on #194: `serde_json::to_vec(tool)` allocated the whole
encoded descriptor before the 1 MiB check, doubling the resident bytes for
a page `rmcp` had already decoded. Measure through a counting `ByteBudget`
writer instead; the write that crosses the budget is rejected and nothing
is allocated. The check now bounds only what it claims to bound; the
transport read limit remains an `rmcp` concern (SSE events are capped at
16 MiB there, stdio lines are unbounded) and is noted in the ledger.

Co-Authored-By: romy <[email protected]>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: romy <[email protected]>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@lg2m lg2m closed this Sep 26, 2026
@lg2m
lg2m deleted the devin/1790291851-security-kernel-adr branch September 28, 2026 05:26
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