Repository navigation
feat(crew-log): read-only kirocrew-crew-log MCP server over the crew log - #11909
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify a loopback browser request bearing a forged, invalid [DESIGN-REVIEWED] e6acbba |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify on a live gateway that a cookie-authed loopback request is refused at all four What this change shipsInventory (10 items) — 10 justifiedIntent: let an agent read the crew log (fenced from its file tools) through a sanctioned read-only door, so crew-log features can be verified without a human running
Lens checks that held: not product shape (opt-in, default agent unchanged — no lens-9 trigger). Not a duplicate: [FIRST-PRINCIPLES-REVIEWED] e6acbba |
Opus 4.8 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 5.6 Review — ✅ human override acceptedHuman judgment by @chenmingwei23 overrides the GPT 5.6 finding for This comment is updated in place on each push. The model was not re-run because an authorized human decision supersedes it. False positive or not applicable? A repository writer can comment: |
89c669e to
ef66e3e
Compare
|
@edit-5737498528.md |
|
@edit-5737498640.md |
|
@edit-5737498754.md |
|
@edit-5737498876.md |
|
ef66e3e to
1ffd0a0
Compare
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
1ffd0a0 to
e38cdb8
Compare
|
self-added: yes
|
e38cdb8 to
18788b4
Compare
BLOCKED -- needs a maintainer scope decision, not an overrideGPT's blocking finding on The chain, verified
With the key readable, strict session identity is mintable in-sandbox:
One thing the review did not name
Why this is a scope decisionThe forgery is not introduced here. That also undercuts the security paragraph in this PR's own description. It argues the The two options, with what each costsA. Ship B. Close the residual on I lean A, because it makes this PR true on its own terms today and does not ask a Not doingNo Everything else on this head is green: 74 lanes success, 11 skipped, Design / First |
The crew log is fenced from the agent so a session cannot alter its own audit trail. That stays. What it also did was make the log unverifiable by anyone but the operator with a shell, because reading was fenced along with writing. This adds a standalone, assignable, read-only MCP server of three tools over the gateway's own routes: list the session logs, page one, read a fold. No write tool exists and the set is ratcheted so none can be added. Authorization lives in the endpoints: the caller's own unit needs a strict session identity, and any wider read needs the owner at a dashboard tab. Refs #11549
20e3e41 to
e6acbba
Compare
|
/ai-review override gpt e6acbba: the residual is pre-existing on main and documented as carried in AGENTS.md:112 (the sandbox exposes trust/sel_hmac.key, so the same forged identity already reaches session_read_message, cron and computer); it is now tracked for a main-side fix in #11963, and this PR adds a consumer behind the owner-only gate with SEL audit rather than the hole itself; approved by the repository owner. |
Human judgment recorded@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
|
The override recorded on What the residual is: Why it is not scoped here: that resolver is the authorization input for Two findings from the same review round are real but were left for a later head, because any push
|
…log (kirodotdev#11909) The crew log is fenced from the agent so a session cannot alter its own audit trail. That stays. What it also did was make the log unverifiable by anyone but the operator with a shell, because reading was fenced along with writing. This adds a standalone, assignable, read-only MCP server of three tools over the gateway's own routes: list the session logs, page one, read a fold. No write tool exists and the set is ratcheted so none can be added. Authorization lives in the endpoints: the caller's own unit needs a strict session identity, and any wider read needs the owner at a dashboard tab. Refs kirodotdev#11549
Problem / Motivation
The crew log is fenced from the agent on purpose. The sandbox hides
crew-log/from the agent's view and
_CREW_SECRET_LEAVESfences the agent's file tools, so asession cannot read another unit's history or forge a line into its own. That is
the right call for an append-only audit trail and it stays.
The cost lands somewhere the fence was not aiming at. Nobody developing the crew
log can verify it. Every check, did the emitter write that entry, does the fold
count what it should, which types does a real session produce, is a round trip
through the one person with a shell and
jq. Reading was never the thing the fenceprotected, but it was fenced along with writing.
The gateway already serves the log read-only over REST (#11558) and already
resolves a slot key to the unit its work is landing in (#11185). What was missing
was a door an agent can walk through.
Why it matters
The person who most needs to read a crew log is the one building on it, and that is
the one reader with no way in. The effect is not a missing convenience: it is that
every crew-log feature ships on evidence someone else had to fetch by hand, which
is slower and weaker than evidence the change's own author can produce.
A crew log carries full message bodies, and the justification rests on the gate,
not on the payload.
message/receivedandmessage/sentrecord the text itself,and a body too large for one line is split across
message/chunkentries the citingentry names, so the whole transcript is reconstructable from the log. Other entry
types are narrower than that -
context/composedis char and token counts,request/configuredis a sha256, a tool call is a parameter summary - but thetranscript-bearing types are not. What makes the grant safe is that
session_read_messageinkirocrew-dashboardalready returns a peer session'sfull transcript to an agent the owner granted it, and these reads answer the same
class of content behind a STRICTER caller test: the caller's own unit needs a
strict session identity, and anything wider needs the owner's own non-restricted,
non-app dashboard session.
The integrity boundary is untouched. No write tool exists and none may be
added, the tool set is ratcheted to three read names, so adding one fails a test
rather than shipping. The fence is byte-identical:
_CREW_SECRET_LEAVESand thesandbox placeholder are not in this diff. The gateway remains the log's only writer.
What changed
A new opt-in MCP server,
kirocrew-crew-log, insrc/kiro_crew/mcp_crew_log.py,with three read-only tools:
crew_log_list(one row per session log, optionally with the per-type histogram),crew_log_read(a range of entries, citations resolved,datatrimmed, capped at200 rows and 64 KiB with
next_fromwhen cut), andcrew_log_projection(one ofthe five folds and its seq). Each takes a raw unit id, a session or slot key, or
self. Every refusal is a typed code.Four routes back them under
/api/crew-log/: the listing, key resolution, oneunit's page, one unit's fold. The two #11558 browser routes are unchanged and stay
cookie-only; the new prefix is the internal-caller door, and both call the same page
reader, now shared in
crew_log/read.py. The new prefix is STRICT internal, and thehandler refuses a caller that arrives without the internal secret. Those are two
facts, not one: strict membership hard-denies a NON-loopback caller, but a loopback
request with no secret header still falls through to cookie auth and reaches the
handler, so the handler's own refusal is what keeps the owner test from becoming a
second way into another session's history from any authenticated page.
Authorization is in the endpoints:
selfneeds a strict identity, anything widerneeds an owner dashboard session, and a headless, channel-bound, app-owned or
incognito caller is refused with a reason. Every read is SEL-audited under the
action names the browser routes already use.
Every request the server makes carries the calling session's STRICTLY resolved key,
resolved once per tool call and sent on each leg, so a caller the gateway cannot
name reads nothing at all. That is load-bearing rather than tidy: the lenient
resolver walks
/procancestors, a subagent lives under its spawner's process tree,and the spawner is commonly the owner's own tab, so a leniently-resolved key would
present an owner identity for a subagent's call and the wider-read rule would admit
it.
The server is assignable only, so no session pays context for it unless its own
spec grants it.
docs/reference/crew-log/reading-from-an-agent.mdcarries theone-line grant and the table of codes.
Registering a managed server means naming it in every registry that already names
its siblings, and a half-registered one is the failure mode:
agent.py(the managedspec,
opt_in, noautoApprove),mcp_cleanup.py(the opt-in split doctor reads),mcp_discovery.py(subcommand, tool module, caller-aware set),cli.py(themcp-crew-logverb),mcp_gateway/stub.py(stubbable subcommands),cli_doctor.py(strict-identity servers),mcp_core.py(the reflexive-toolregistry, because
selfcalls the strict gate),onboarding_import.py(managednames are never imported from a runtime the user is leaving),
token_auth.py(known internal callers),
validation.py(the three tool schemas),dashboard/server.py(/api/crew-logas a strict-internal prefix),dashboard/routes/sessions.pyanddashboard/handlers/__init__.py(the routes),and
docs/feature-map/README.md(the row for the new agent-facing reads).Tests
test/test_mcp_crew_log.py(48) covers the ratcheted tool set, the threeunitforms, the strictly-resolved key on every request leg, every typed code, the row
shape, and the caps.
test/test_crew_log_routes.pygains 36 covering the two newroutes, one refusal per caller class, the audit action names, and the proxy's own
tool/calledlanding in the calling session's log. 124 pass together, and 470across every suite that pins a registry this touches.
Five mutation checks, each verified red: removing the endpoint's
forbiddenbranchreds 11 tests; raising the 200-entry cap to 5000 reds 2; dropping the strict-identity
gate reds 3; letting a single
full=Truerow bypass the byte cap reds 1; leavingreturnedunrewritten on a cut page reds 1.Sibling ratchets updated as the conscious paired edits they ask for: known internal
callers, the worker-unassignable set, the internal-secret call-site scan. Gates:
black, isort, flake8, mypy on changed files,
check_black_formatting.py,check_comment_history.py,check_feature_map.py, docs_lint, brand gate.Pattern harvest
Three reusable pieces.
make_mocked_request's defaultappis a MagicMock, sorequest.app.get("state")answers a fresh mock whose every attribute is truthy. An app-ownership check tested
against it "finds" an owning app for the person, and the gate reads green against a
fiction. A handler test that reads state needs a real
web.Application.Running
blackon a file listed in.github/black-baseline.txtreformats far morethan the edit: 174 lines here, one of which moved a
# nosemgrep:pragma off theline it suppresses and turned SAST red. A one-line registry edit to a baselined file
should be made by hand and left unformatted.
onboarding_import._CORE_MANAGED_MCP_NAMEShad every always-on managed server andneither opt-in one. This adds
kirocrew-workbeside the new name rather thanleaving an identical gap open next to a test that closes it.
no linked issue: #11549 is the crew-log rename this PR's vocabulary follows, not an issue this closes.
Refs #11549