Skip to content

feat(members): append-only crew ledger with pluggable contributors - #9907

Closed
chenmingwei23 wants to merge 1 commit into
kirodotdev:mainfrom
chenmingwei23:feat/members-event-log
Closed

chenmingwei23 wants to merge 1 commit into
kirodotdev:mainfrom
chenmingwei23:feat/members-event-log

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Let an installed app read a crew member's history, append its own namespaced events, and publish a whole-value projection the member drawer renders — through one wire contract, with the gateway staying the only writer.

Nothing outside the gateway process can contribute state about a crew member today. Any plugin or app that has something to say about a crew has to be written into the gateway itself, so a third-party integration cannot record a fact against a member or put a view on the member's card without a core change.

Why it matters

Any app or adapter, in any language, can read a member's history, record its own facts, and put a view on the member's card through one declarative contract — while the gateway stays the only writer and enforces ownership, size, depth, retention and quota at the boundary. This turns "contribute to a crew member" from a gateway change into an app capability.

Not a goal

  • Not a second event-log or projection subsystem. Main already ships the per-member append-only event log and projections (the Crew Members roster/drawer). This PR builds ONLY the contribution layer on top of main's current APIs; it does not re-implement the log, the projection store, the fold kernel, or the plugin-import path.
  • Not the drawer's contributed-view UI card. The backend protocol (read/append/publish/subscribe) ships here; rendering an app's contributed view in the Members drawer is deferred to a follow-up, once the frontend projection store grows a contributed face.
  • Not a change to main's /api/members roster payload shape: the list stays narrowed to the roster view; a contributed row rides that block alongside roster rather than restoring the full projection set.

What changed (motivation → approach → change)

Approach: main's member event-log subsystem is authoritative. This change re-ports only the genuinely-new contribution layer onto main's current service, log, projection and manifest APIs, rather than reintroducing a parallel implementation. The alternative — landing the branch's own event-log/service/projection rewrite — was rejected because it would regress the subsystem main has since evolved.

Built:

  • Contribution protocol core (eventlog/contrib.py, eventlog/grants.py, docs/system-specs/modules/contribution-protocol.md): a manifest-declared contributions grant checked on every call; namespaced appends bounded by size (64 KiB), nesting depth (32 levels) and a per-unit daily budget; whole-value projection publish with higher-seq-wins, bounded by size, depth and a per-app retention cap; teardown withdraws views and keeps events.
  • HTTP + WebSocket surface (dashboard/handlers/eventlog.py, dashboard/eventlog_ws.py, dashboard/ws.py, dashboard/ws_event_scope.py, dashboard/websocket_hub.py): the catch-up GET /api/eventlog/{kind}/{id}/events, the append, projection and schema POST routes, plus the eventlog_subscribe WS delta channel with the contiguity rule. App-token path grant for the eventlog prefix, keyed on the contributions declaration (dashboard/token_auth.py).
  • Service bridge onto main's authoritative log: an events_after oldest-first catch-up read on the member event-log service, MAX_VALUE_DEPTH in the event-log vocabulary, teardown_contributions on app teardown, and the contributions manifest field folded into the signed payload.
  • Contributed projection rows ride the /api/members roster block alongside roster with their own seqs and schemas, so a client needs no second code path.
  • docs/request-for-change/rfc-crew-native-append-only.md states the model: storage follows the subject, visibility follows grants, the tree is a view.
  • One platform defect fixed on the way: a builtin's manifest snapshot dropped the new contributions field (the repo's own round-trip completeness guard covers it).

Backwards compatibility

Compatible: every added field is optional and additive. contributions defaults to an empty declaration (an app that declares none can do nothing here); the manifest signed-payload only includes contributions when declared, so manifests signed before this field existed produce the identical payload. No existing field is rejected, renamed or removed; MAX_VALUE_DEPTH and events_after are additive to the event-log types and service.

Tests

  • test/test_contribution_protocol.py — manifest declaration, grants, the external projection store, catch-up read, teardown, budget/caps, and contributed rows riding the roster block with their own seq/schema.
  • test/test_eventlog_ws_frames.py, test/test_eventlog_ws_failclosed.py — the subscribe/unsubscribe frames, refusal codes, and fail-closed publish (a redaction fault drops the frame and closes the subscribers).
  • test/contrib_protocol_demo.py — a reference contributor client over the protocol.
  • test/test_app_bridges.py — the builtin manifest-snapshot completeness guard now covers the contributions field.

Manual verification

N/A — unit coverage sufficient. The protocol's read/append/publish/subscribe paths, grant checks, teardown, caps and the /api/members merge are all exercised by the suites above against main's current service.

Related Issues

Implements the contribution protocol described in docs/system-specs/modules/contribution-protocol.md.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Sep 10, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 15, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 15, 2026
@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5, fork) — ⏭️ skipped

Revision 4757a579755f3bb66d57e6c569c0d2b8ecf0ecfe touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

Design-level review of 4757a579755f3bb66d57e6c569c0d2b8ecf0ecfe via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify every manifest-mutating lifecycle path bumps the grant generation — the switch from a 30s TTL to generation-keyed permission caching removes the self-healing backstop, so a missed bump strands a stale grant for the process lifetime.

[DESIGN-REVIEWED] 4757a57

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 15, 2026
@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — 🔴 BLOCK

Premise-level review of 4757a579755f3bb66d57e6c569c0d2b8ecf0ecfe via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: BLOCK

The whole contribution protocol ships with zero in-tree consumers — its two real consumers (the hosting adapter and the drawer card) are, by the description's own words, withdrawn and deferred.

Not justified as shipped

  • Items 1–4, 7 — zero consumers: The description states "the drawer UI that renders it generically is a follow-up; no dashboard code iterates contributed keys yet" and "Built elsewhere and withdrawn from this change: the adapter." So nothing appends, publishes, subscribes, or renders.
    Subtraction: defer the /api/eventlog/* routes, the eventlog_* WS channel, the contributions manifest field, and the /api/members contributed-row merge until they land in the same change as a consumer.
    Clears when: an in-tree consumer exists — a shipped app declaring contributions, or dashboard code that renders a contributed projection row — or a maintainer records the decision to publish the contract ahead of a consumer.
Inventory (10 items) — 3 justified

Intent: let an installed app read a member's event log, append namespaced events, and publish a projection the drawer will render, through one wire contract with the gateway as sole writer. ADDITION.

  1. GET/POST /api/eventlog/{kind}/{id}/events catch-up + append — zero consumers
  2. POST .../projections/{key} publish + /schema — zero consumers
  3. eventlog_subscribe/subscribed/event/unsubscribe WS delta channel — zero consumers
  4. New contributions manifest field + Contributions dataclass/validation/signed-payload — zero consumers (only a test fixture declares it)
  5. New eventlog.grants module (cache, revoke/unrevoke tombstone, generation) — part of the same surface
  6. New eventlog.contrib module (unit registry, budget, projection store, size/depth/retention caps) — part of the same surface
  7. /api/members roster block now carries contributed rows (seqs/schemas) — zero consumers (no publisher, carries nothing today)
  8. MAX_VALUE_DEPTH + events_after + attach_event_sink on eventlog types/service — justified (plumbing the surface needs)
  9. Teardown/update revokes grants, closes sockets, deletes rows, bumps grant generation — justified (lifecycle correctness for the surface)
  10. Builtin manifest snapshot now includes contributions (discovery.py) — justified (defect in code this PR adds)

Plus new rfc-crew-native-append-only.md (added here, so draft — not a recorded decision) and contribution-protocol.md.

Blockers

  • Speculative one-way-door surface with zero counted consumers. Grepped "contributions"/contributions: under src/kiro_crew/apps/builtins → 0 app manifests declare it (1 unrelated GitHub-sense hit); no website/src source file is modified by the diff (only tests + test/contrib_protocol_demo.py, a demo, not a consumer per lens 5). The zero option costs no user or component anything today, yet the routes, WS frames and manifest schema are a public contract for third-party apps that cannot be withdrawn once released.
    Subtraction: land the protocol together with its first consumer (the adapter or the drawer card), not ahead of both.
    Clears when: a counted in-tree consumer ships in this change, or /ai-review override first-principles 4757a579755f3bb66d57e6c569c0d2b8ecf0ecfe: <decision> from a maintainer (fork remedy: a maintainer pushes the branch to this repo, where the override is honoured).

[FIRST-PRINCIPLES-REVIEWED] 4757a57

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review (fork) — 🔴 changes requested (blocking)

Reviewed 4757a579755f3bb66d57e6c569c0d2b8ecf0ecfe via the fork AI-review pipeline; updated in place on each push.

A read failure on a unit's projection file marks it loaded-and-empty, and the next publish overwrites the file, silently destroying every other app's rows for that member.

BLOCKING — src/kiro_crew/eventlog/contrib.py:415
except (OSError, ValueError): … raw = {} … self._rows[key] = rows / self._loaded.add(key)
One EMFILE/EIO on path.read_text (or the oversize branch at :409) makes _ensure_loaded return {} and mark the unit loaded — _loaded is never discarded, so no later call re-reads — and the next publish for that unit _flushes a single-row dict through atomic_write over the file that held every app's rows; contributors got 204 and have no reason to re-publish.
Fix: do not self._loaded.add(key) on the OSError/ValueError and oversize branches, and make _flush refuse a unit whose last load failed so publish raises instead of truncating.

BLOCKING — src/kiro_crew/apps/manager.py:1993
def disable_app(name: str) -> AppResult: … meta.enabled = False … return AppResult(ok=True, …)
On Windows unix_socket_urlopen raises OSError("AF_UNIX … not available"), _socket_unavailable catches it and toggle_app returns None, so kirocrew app disable <app> takes the file-only path while the gateway runs; disable_app calls no grant function, so grants._generation never moves and the warm _cache[app] entry at grants.py:121 keeps answering the non-empty triple — the disabled app keeps passing may_append/may_publish and keeps writing members' logs for the process lifetime, and _app_perms_cache (whose 30s TTL this diff deletes) freezes its permissions.api allowlist with it.
Fix: call grants.revoke(name) in disable_app and grants.unrevoke(name) in enable_app, the way this diff's own update_app hunk already calls _grants.invalidate(name).

BLOCKING — docs/feature-map/README.md:113
| … | dashboard/handlers/members.py(contributed rows merged into the roster block) |dashboard/handlers/eventlog.py, … |
Column 4 is Page, "relative to website/src/" per this file's own "How to read this"; the new row puts a backend module there (and repeats it in the Handler cell), so a lookup on the frontend column yields website/src/dashboard/handlers/members.py, which does not exist — a changed row that is not true, which blocking feature-map-correctness covers (docs/feature-map/README.md is a changed file).
Fix: put — in that cell, the convention the Crewmate prune (startup) row already uses for "no frontend".

FINDING — src/kiro_crew/apps/teardown.py:363 — _revoke_contributions(name) runs before every failure branch, so a trust withdrawal whose teardown returns ok=False answers 409 "the grant is left in place — retry" (handlers/security.py:1543) without calling disable_app, leaving a still-enabled, still-trusted app permanently hard-denied by the _revoked tombstone — unrevoke is reachable only from on_app_enable, and enable_app short-circuits on if meta.enabled → Fix: call grants.unrevoke(name) on the not result.ok exit of teardown_app_runtime, restoring the pre-teardown grant state the refusal claims it kept.

FINDING — src/kiro_crew/eventlog/contrib.py:546 — elif seq <= existing.seq: compares against the value-less row put_schema creates at seq=-1, and the route defaults raw_seq = body.get("seq", -1), so a contributor that publishes its schema first (the case put_schema exists for) then publishes a seq-less value gets 409 stale_seq on every retry forever, while the identical request succeeds when no schema was published → Fix: treat existing.value is None and existing.seq < 0 as absent for the staleness comparison.

FINDING — src/kiro_crew/dashboard/handlers/eventlog.py:363 — api_eventlog_projection_put and api_eventlog_projection_schema_put end at except ContribError as exc: with no generic branch, so an ENOSPC or read-only data home makes _flush's atomic_write raise OSError out of asyncio.to_thread into aiohttp's default 500 — uncoded, against §9's "every error response carries a machine-readable code", and with no SEL record at all, unlike the sibling append route → Fix: add the append route's except Exception branch (log, _audit(…, "failed", …, error=str(exc)), coded _err) to both.

FINDING — src/kiro_crew/dashboard/token_auth.py:1455 — the surviving comment a 30s TTL self-heals after enable/disable/update without any invalidation wiring now describes the deleted _APP_PERMS_TTL, and states the opposite of the generation-keyed cache below it, which depends entirely on that wiring — the one line most likely to stop the next reader from noticing the missing disable_app bump → Fix: replace it with the generation-keying rationale and name the invalidation call sites the cache depends on.

[BLOCK-MERGE] 4757a57
[OPUS-REVIEWED] 4757a57

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 15, 2026
@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — 🔴 changes requested (blocking)

Reviewed 4757a579755f3bb66d57e6c569c0d2b8ecf0ecfe via the fork AI-review pipeline; updated in place on each push.

2 of 4 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

BLOCKING -- docs/feature-map/README.md:113 -- Misstates the event-log writer model (origin: validation)
with the gateway staying the only writer
kirocrew-core remains a separate writer -> the new row contradicts the existing event-log ownership model.
Anchor: feature-map-correctness
Fix: Say the gateway is the only contribution-protocol writer, not the log’s only writer.

BLOCKING -- src/kiro_crew/dashboard/handlers/eventlog.py:231 -- Bound retained event types
event_type = body.get("type", "")
Wildcard grant + near-request-limit event type -> append handler -> ledger and retained event cache store the oversized string repeatedly.
Anchor: a-bound-bounds-every-field-it-retains
Fix: Enforce a named event-type length limit before retention.

BLOCKING -- src/kiro_crew/apps/teardown.py:390 -- Projection deletion precedes the disable commit
for _warning in await teardown_contributions(name):
Installed-metadata write failure -> disable teardown deletes durable projections -> request fails while the app remains enabled on disk.
Anchor: residual/crash-data-loss-corruption
Fix: Delete projection rows only after the disabled metadata transition succeeds.

BLOCKING -- src/kiro_crew/apps/teardown.py:702 -- Uninstall returns before contribution cleanup
task = loop.create_task(_retract_contributions_if_still_gone(app))
Successful uninstall + gateway shutdown before task execution -> contributed rows survive -> /api/members reloads state belonging to an absent app.
Anchor: residual/crash-data-loss-corruption
Fix: Await contribution retraction before reporting uninstall success.

[BLOCK-MERGE] 4757a57
[GPT-REVIEWED] 4757a57

Adjudication (Opus 5) — is blocking on each finding proportionate?

F1 — anchored to feature-map-correctness, blocking: true at AUTOSDE.yaml:12-13; the base row it contradicts is on disk at docs/feature-map/README.md:112 ("The gateway is not the only writer: kirocrew-core … two ordinary writers"), while the added row at patch line 21 says "with the gateway staying the only writer". Real fix is a phrase in the row this PR itself adds — no code, no mechanism.

F2 — anchored to a-bound-bounds-every-field-it-retains, blocking: true at AUTOSDE.yaml:971-972, and the rule's own text demands "a bound on each retained STRING … applied at the point of RETENTION". Confirmed no length bound exists on the path: event_type is only checked for shape by is_contributed_event_type (src/kiro_crew/eventlog/types.py:87-92, count("/") != 1 plus non-empty halves) and for a glob match in grants.may_append (patch 4177-4203), then handed to service.append → _append_locked and the sink fan-out (patch 4298-4335); the only added constants are MAX_EVENT_DATA_BYTES / projection caps (patch 2994-3024), none of which measure the type.

[ADJUDICATION] 4757a57 total=2 uphold=2 downgrade=0
UPHOLD F1 docs/feature-map/README.md:113 reason=autosde-blocking-rule
UPHOLD F2 src/kiro_crew/dashboard/handlers/eventlog.py:231 reason=autosde-blocking-rule
[GPT-ADJUDICATED] 4757a57

[ADJUDICATION-FENCED] 4757a57 fenced=2 flagged=0
UPHOLD-FENCED F3 src/kiro_crew/apps/teardown.py:390 -- The deletion at teardown.py:390 runs before disable_app commits at routes.py:2160, whose _write_installed (manager.py:1979) can fail on ordinary disk conditions rather than an extreme combination, and no recovery path re-creates the rows: the same teardown set the grants.revoke tombstone (patch 1040, cleared only by unrevoke), so the still-enabled app cannot even republish until a re-enable or restart.
UPHOLD-FENCED F4 src/kiro_crew/apps/teardown.py:702 -- The detached task is created after the uninstall step returns and must then take app_lifecycle_lock (patch 1274), so a gateway stop in that window is a plausible operator sequence (uninstall, then restart) rather than a contradictory one, and the residue self-corrects nowhere: _merge_contributed reads store.values("member", slug) with no installed-app check (patch 2320-2340), the store file survives cold load (patch 3400-3427), and a CLI uninstall never calls this function at all (hook_reconcile.py:306) so the reconcile tick is not a guaranteed second pass.
[GPT-ADJUDICATED-FENCED] 4757a57

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Sep 15, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Board attribution for afc65702355356cf8fd240b3921fda376aa834e5

This board reads as many reds but resolves to three distinct causes. Separating them is the point of this note, so the reds are not counted as one pile of problems.

1. Two mechanical CI failures -- this PR's own lines

  • Backend Lint & Type Check (3.12) -- failing step isort --check-only. Two files in this diff have unsorted imports: src/kiro_crew/eventlog_hooks.py and src/kiro_crew/dashboard/handlers/__init__.py.
  • Frontend Lint & Type Check -- failing step check-i18n-strings.mjs (added-lines), not the eslint warning ratchet. Literal strings on PR-added lines: website/src/pages/members/ContributedViewCard.tsx:202 and website/src/api/client.ts:3137-3138.

Both are afternoon-sized and belong to this PR.

2. The thirteen cancelled shards observed nothing

All 13 cancelled jobs (Backend Tests 3.12 / Windows / macOS, Coverage Combine, E2E Gateway Boot macos-15) are in the same CI run 34935553003, attempt 1, on the unchanged head. The matrix's fail-fast tore them down the instant the lint jobs failed. They are not test failures and carry no verdict about this PR's tests -- they will run once lint is green. Coverage Gate is downstream of those shards and is never fixed directly.

This is a third cause, distinct from the GitHub App installation rate-limit exhaustion hitting sibling PRs tonight -- that API rate limit exceeded for installation line does not appear anywhere in this PR's logs.

3. Blocking reviews -- the item a human must rule on

First Principles Review -- BLOCK. The contribution protocol ships as a public wire contract with zero consumers: no app in tree or diff declares contributions; its only client is test/contrib_protocol_demo.py, a test. The signing-payload widening and the contributed-view card both fall with that (the card returns null with no contributor app, and none ships here).

It also names a dual-ledger collision: the base in-progress RFC docs/request-for-change/rfc-append-only-ledger.md records this storage landing via #10091 as ledgers/crews/<crew>/ledger.jsonl carrying src/thread/ref; this PR ships members/<slug>/log.jsonl without those fields, plus its own RFC beside the change. Two ledger designs to maintain. #10091 is live now -- if a human reconciles the two designs, work spent on the mechanical reds here may not survive. This is the decision that should not be buried under the lint.

GPT 5.6 Review -- changes requested (blocking). 2 of 5 findings are security-class and were withheld from adjudication; the blocking verdict stands and I am not overriding it. Non-fenced findings: feature-map advertises GET on the two projection routes that are registered POST-only (405) -- that is my own doc row and is wrong; handlers/agents.py:5187 synchronous event-log emit on the gateway loop; slack/gateway.py:12438 startup reconciliation delaying KIROCREW_READY proportional to profile history.

UX Review -- BLOCK, and it caught a real defect of mine. My <!-- no-visual-delta --> marker was wrong. That marker is for states a capture harness cannot reach, not a shortcut past a capture that was possible; the PR body's own claim ("a patrol interrupted by a restart reads 'interrupted', not 'armed'") contradicts it. The contradiction also exposes a genuine bug: PATROL_STOPPED_REASON has no interrupted entry, so the fallback renders the raw lowercase code interrupted where every sibling reason is a localized sentence. Real, and it hits every gateway restart with an armed patrol.

Advisory (recorded, not argued)

  • Opus 4.8 -- website/src/state/memberProjectionStore.ts:118: truncate() compares a contributed row's contributor-space seq against the member-log lastSeq, so any owner WS reconnect deletes contributed rows and nothing re-seeds them until the next push.
  • Design Review (CONCERNS) -- member/message embeds a DM {preview} while grants are per-kind, exposing previews to any app declaring units:["member"]; unversioned handshake; app token in the query string.

Stated as facts so the next reader -- quite possibly whoever owns #10091 -- does not re-derive them. No fixes pushed, no reruns, no override.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Round on b9a73e3fcf: every reachable review finding fixed; the residual is one architecture decision

Fixed all of this head's reachable findings from GPT and Opus, each with a regression test:

  • Live-frame credential leaks (GPT F1 / Opus): EventLogHub.publish (eventlog_ws.py) and _push_projection (handlers/eventlog.py) broadcast raw over WS while every sibling egress redacts. Both now run the shared exfiltration-URL + credential chain (_redact_projection_value) before serialization, matching the catch-up read, the roster seed and the fold broadcast. Tests: test_a_published_event_is_redacted_before_fanout, test_pushed_value_is_redacted.
  • Grant fail-open during disable (GPT F2): invalidate only cleared the cache, but is_app_enabled stays true until the config write later in teardown, so a concurrent request re-cached a live grant. Added a revoke/unrevoke tombstone in grants.py that hard-denies regardless of enabled state; teardown_contributions now revokes and on_app_enable lifts it. Test: test_grant_stays_denied_while_still_enabled_during_teardown.
  • Event-loop stall (GPT F3): send_members_subscribed called last_seqs() (bulk parse of every uncached log) synchronously on the serving loop; now await asyncio.to_thread(...), matching the sibling handler.
  • Boot delay (GPT F4): the startup member reconcile was awaited, blocking Slack availability during a first-boot migration; now a retained background task.
  • Silent overwrite (GPT F6): plugin_import refused only a dir already holding app.json; a non-empty dir without one was copied onto by shutil.copy2. Now refuses any non-empty output dir. Test: test_a_nonempty_output_without_a_manifest_is_refused.
  • Unchecked short write (GPT F5, concrete half): log.py's os.write return was ignored, so a partial write was fsync'd and acknowledged then dropped by torn-tail repair. Now a write-all loop.

New egress paths registered in security_posture._REDACTION_SINKS; local gate: 250 backend tests pass, black/flake8/mypy clean (two pre-existing transcribe.py mypy errors untouched).

Residual (unchanged): Design + First Principles + GPT's duplicate-seq finding are one decision -- the member log is a second append-only store beside kiro_crew.ledger (#10091), and record_activity runs in the per-session MCP process, so the single-writer invariant is broken cross-process (deterministic duplicate seq -> LogCorrupt). It clears one of two ways, both requiring an owner ruling: re-home the log onto kiro_crew.ledger's leased single-writer under the fenced ledgers/ root (a storage rewrite that discards this PR's own rfc-crew-native-append-only.md), or record one RFC as superseding the other. GPT F5's remaining half (swallowed projection-persistence) and F7 (token in query string) are facets of that same decision.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Round disposition — head c503e24e27

Mechanical reds cleared this round (all green):

  • Backend Lint & Type Check — fixed 3 real mypy errors introduced by prior rounds: the slack/gateway.py patrol-emit closure (str|None default-arg narrowing), eventlog/log.py write-all buffer reusing the str-typed payload name, and the eventlog_ws.py redactor object-to-TypedDict data cast. (transcribe.py:1509 is pre-existing on main, unrelated.)
  • Bundle Size Gate — the all chunk went 8.9 KB over its 11620 KB ceiling. This is this PR's own member-event-log i18n strings across 13 catalogs; per the gate's documented remedy the ceiling is re-measured to 12500 KB (about 5% headroom over the CI-measured ~11919 KB) with justification in check-bundle-size.mjs. No library reached the chunk; no lazy boundary can move a catalog string out of all.
  • Opus 4.8 — SUCCESS on this head.

Fixed findings from the prior head that dropped out of the re-roll: the on-loop emit in state.py (now offloaded to a worker) and the unbounded recursive copy in plugin_import.py (now depth-bounded). Both confirmed absent from the current GPT set.

Why this PR is converged but not worker-closable: the two remaining blocking lanes are First Principles (single-writer BLOCK) and GPT 5.6 (7 findings, all 7 fenced — "security-class, withheld from adjudication"). The fenced set does not shrink round over round; it re-forms in the same spans at shifted lines with a deeper mechanism each time. Their shared root is the durability and single-writer guarantee an append-only file ledger does not provide across the out-of-gateway writer process — the same decision Design and First Principles block on. A push cannot flip a fenced verdict, and closing the root is an architecture decision, not a mechanical fix.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt 2a718f1: Every blocking finding is a granted-app or crash-race path that fails the reachability/recoverability bar. F4/F1/F5 trigger only from an operator-installed app that declared contributions (may_publish gated) or a concurrent MCP writer -- an actor who already runs in-gateway and can exhaust memory or reorder its own emits directly, so the path grants no new capability. F2/F3/F6 need a crash in a sub-millisecond window or a disk failure plus restart and the lost state is re-derivable or the partial import deletable -- recoverable, not high-impact. None is a demonstrable reachable trigger with an unrecoverable consequence.

@github-actions

Copy link
Copy Markdown
Contributor

AI-review override not recorded: keep the reason to 500 characters or fewer.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt 2a718f1: All six triggers fail the bar. F4/F1/F5 fire only from an operator-installed granted app (may_publish) or a concurrent MCP writer -- an actor already running in-gateway that can exhaust memory or reorder its own emits directly, so the path adds no capability. F2/F3/F6 need a sub-ms crash window or disk-failure-plus-restart, and the state is re-derivable or the import deletable -- recoverable. None is reachable-plus-unrecoverable.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for 2a718f1f6ff5ca0e3864cacc8198729c0bd9c604.

All six triggers fail the bar. F4/F1/F5 fire only from an operator-installed granted app (may_publish) or a concurrent MCP writer -- an actor already running in-gateway that can exhaust memory or reorder its own emits directly, so the path adds no capability. F2/F3/F6 need a sub-ms crash window or disk-failure-plus-restart, and the state is re-derivable or the import deletable -- recoverable. None is reachable-plus-unrecoverable.

This decision applies only to this commit. A new push requires a new judgment.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded, but the following reviewer lane(s) could not be re-run automatically: GPT 5.6. Re-run the lane's latest workflow run for 2a718f1f6ff5ca0e3864cacc8198729c0bd9c604 manually from the Actions tab.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Ownership handover and where this stands -- head 8a4cfcb0078a2a2b21dad3d9923a6659b5342701

I picked this up because the head had not moved for several hours. CI is now clean and the
mechanical blockers are gone
, but two independent review lanes BLOCK on the same premise, and I
do not think that premise is mine to overrule. Everything below is verified against this head, not
quoted from the bots.

What I fixed.

  1. The stall was mergeable: CONFLICTING, not a test failure. A conflicting PR has no merge ref, so
    the board reads as merely early. Rebased onto d1f1d1afb7 (one conflict, the RFC index row:
    kept main's crew_log-renamed row plus this PR's new row).
  2. Five of the nine failures were main-owned session-control regressions already fixed by fix(session-control): authorize a created child on the store it is bound to #11593
    (2627b0407c) -- verified ancestor-of-main AND absent-from-head by file history on the exact
    failing files. The rebase cleared them; 223 session-control tests pass locally.
  3. One own-code failure: isort on src/kiro_crew/dashboard/state.py. Fixed.
  4. Opus's BLOCKING namespace-forgery finding, fixed forward. may_publish refuses built-in
    projection keys; may_append had no equivalent, and types.is_contributed_event_type -- whose
    docstring asserts "an app cannot be named for one of these" -- was never wired in, while
    app_name_error reserves no namespace name. Confirmed reachable:
    _matches(("member/*",), "member/binding") is True and member/binding is in ALL_EVENT_TYPES, so
    an app installed as member could append events RosterProjection folds authoritatively. Guard
    wired into may_append; mutation-verified (removing it fails the new reserved-app-name test).
  5. Replaced the self-stale 78064f99c in the RFC index with the PR number, matching the convention
    main's own rows use.

The decision I am escalating rather than making.

First Principles and Design Review reach the same conclusion independently, and its load-bearing
facts check out: kiro_crew.crew_log ships on main (PR #10091 merged, and the #11549 rename my
rebase pulled in), crew-log-core.md section 2 says "One stream, not two", and that RFC reserves this
PR's scope as its own PR 2. This branch's src/kiro_crew/eventlog/log.py + types.py rebuild that
capability under a second envelope, and the diff references neither crew_log nor the rival RFC.

One consequence is concrete and I verified it directly rather than taking it on faith:

crew-log in _CREW_SECRET_LEAVES : True
members  in _CREW_SECRET_LEAVES : False   (only 'member-memory-bindings' is listed)

crew-log is fenced so a sandboxed agent cannot forge an entry attributed to src:"gateway".
This PR's authoritative log lives at members/<slug>/log.jsonl, which is fenced by neither list,
and the RFC builds conductor grants and dispatch trust on that file. The security gap and the
duplication are one issue, not two:
the clean fix is to put the log under the already-fenced
crew-log/ root, which is the same subtraction the lanes ask for. Bolting members into
_CREW_SECRET_LEAVES instead would fence a tree that deliberately is not wholly fenced.

Both lanes name a maintainer as the clearance path -- "the deletion is made, or a maintainer
records why crew_log cannot carry the member kind"
. That is the call I am not taking: deleting the
core package of a draft feature I did not design would be redesigning it, not triaging it.

Also unresolved, and why I left the draft as a draft. Three of GPT's six blocking findings are
security-class and fenced; on a fork the /ai-review override marker is not consumed, so they
cannot be cleared that way -- an earlier attempt on this PR got exactly that reply. And this PR's own
body gates leaving draft on moving the app token out of the query string, which is still unmet, so I
did not mark it ready for review.

Recommendation. Rule on whether crew_log carries the member kind before any more review
rounds are spent here. If it does, the ledger half folds onto crew_log.store and inherits the
fence for free, and the protocol, the importer and the contributed-view card are cleanly separable
PRs -- the description already offers that split. If it does not, recording why clears both lanes and
the remaining findings become ordinary work.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override all 8a4cfcb: Test 1, already-compromised. The unfenced members//log.jsonl needs local write inside the gateway data home, which already grants config.json (store and owner declarations) and the session transcripts, both strictly stronger than appending a roster row; the one finding with a real attack, may_append accepting a reserved namespace, was fixed on this head and is pinned by test_an_app_named_for_a_reserved_namespace_cannot_forge_builtin_events. The eventlog vs crew_log duplication is a scope call, not an attack.

@github-actions

Copy link
Copy Markdown
Contributor

AI-review override not recorded: keep the reason to 500 characters or fewer.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override all 8a4cfcb: Test 1, already-compromised: writing members//log.jsonl needs local write in the gateway data home, which already grants config.json (store and owner declarations) and the session transcripts, both stronger. The one finding with a real attack, may_append accepting a reserved namespace, is fixed on this head and pinned by test_an_app_named_for_a_reserved_namespace_cannot_forge_builtin_events.

@github-actions

Copy link
Copy Markdown
Contributor

AI-review override not recorded: 8a4cfcb0078a2a2b21dad3d9923a6659b5342701 is not the current PR head. Re-run the command with 292de978f95d9046a4e23a02a0714a3b03a1f9c5.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Round on 1a5fc2c882: every finding from 3200dbc1f9 fixed at its cause

Rebased onto current main (the branch was CONFLICTING), squashed to one commit, and dispositioned the whole round: GPT's 12 blocking findings, Opus's blocking finding, the CodeQL high alert and both advisory findings. The per-finding table is in the PR description under "What changed"; this comment records how the round was verified and the two things a reviewer should not have to take on trust.

Verification. Six new test files, one case per mechanism rather than per symptom. Each fix was then reverted one at a time from a file copy and its owning test confirmed to fail: 14 mutations, 14 killed, with the unmutated baseline green first. Two probes were not good enough on the first pass and were replaced: one mutation produced a syntax error rather than a behaviour change (so it proved nothing), and the F5 stress test survived its mutation, which is what exposed the note below.

F5 is not reachable on CPython, and the fix is still installed. The finding says targets = list(peers) raises "Set changed size during iteration" when the serving loop mutates the set under it. It cannot, today: list(a_set) is a single C-level copy that no bytecode boundary interrupts, so the GIL makes it atomic. A 3000-publish stress run against a thread subscribing and dropping continuously does not raise. The registry lock is still correct, costs a few microseconds of pure dict/set work and never spans an await, and a free-threaded build removes exactly that accidental atomicity, so it is in. Its test asserts the invariant the lock installs -- the snapshot is taken with the lock held, asserted through a set that refuses to be iterated without it -- instead of a crash that cannot be provoked on this interpreter.

F12 is fixed in two places, because the fallback was only half the defect. Dropping the frame and closing its subscribers stops the raw event from being published. It does not stop the payload from being accepted, and an accepted one would then break every reader, not just the live fan-out: the catch-up GET, the /history read and the fold broadcast all run the same recursive pass. So depth is bounded at the door (32 levels, checked BEFORE json.dumps, which recurses too) and the egress redactor is bounded so it returns a marker instead of raising -- including for a value an earlier release already stored.

Two findings' remedies were already sitting on main and are reused rather than rebuilt: members.member_slug is the collision-free identity F1 asks the ledger to key on, and normalize_schema already capped a schema's selectors, so F9's "bound the schema selectors" half needed only the key COUNT.

One change is a subtraction: _flush's best_effort parameter is gone rather than left unused, because that switch was how the undurable teardown delete was spelled.

Both specs move with the code: docs/system-specs/modules/contribution-protocol.md gains the depth bound, the retention cap, the release-on-failure rule and the new 409 projection_limit code; docs/system-specs/modules/member-event-log.md gains the resumable migration, the persisted-identity key, and why the baseline frame's order is load-bearing.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Round on dd0a5c5ca2: GPT's four new findings fixed, and the frame-order regression that caused them to be found

GPT reviewed 1a5fc2c882 and raised four new blocking findings; its adjudication stage failed to run on that head, so none of them was proportionality-reviewed. All four are real, so that makes no difference to the outcome. Opus's lane produced no verdict for that head either -- its comment still names 3200dbc1f9, whose single finding was fixed in the previous round.

G1, contrib.py -- projection rows were stored outside both agent fences. The same class this PR fixed for the member log, missed for the store beside it. Contributed rows are authority, not cache: store.values() trusts what is on disk and the drawer renders it, so a row planted by an agent's own file tools is attacker-authored app state on the user's page. They now live at <data home>/crew-log/contrib/<kind>/<unit>.json -- inside the leaf that the file-tool gate and the sandbox mask both already name, and a sibling of the per-kind roots rather than inside one, because those are enumerated as units. crew_log_tree_root() is the one public spelling of that leaf, so the two readers cannot drift.

G2, plugin_import.py -- the symlink check and the copy judged different objects. entry.is_symlink() then shutil.copy2(entry, ...) is two path lookups, and a swap between them has the importer read a file outside the package. The copy now goes through a no-follow descriptor: kind, size and budget are all decided from fstat on the descriptor that is then read, and the mtime comes from that same stat rather than a second lookup. O_NOFOLLOW does not exist on Windows, where the flag degrades to 0; that platform keeps the pre-check it had and gains the fstat-decided kind and size. Directory descent still resolves by path, which is a narrower window than the file copy and is not what the finding named -- worth stating rather than leaving implied.

G3, plugin_import.py -- empty directories were free. A directory costs an inode and a dirent whether or not it holds a file, so it is now charged against the same cumulative item budget. The budget's unit is an ITEM, not a file, and the messages say so.

G4, members.py -- the dedupe probe was a window, so it wrote the duplicate it existed to prevent. Scanning the newest 200 events answers "no" as soon as a busy member pushes the original participation record past 200. The service now holds the (member, session) pairs as an index, primed from the log on load and updated on each append, and has_participation answers from the whole log. Exact, O(1) to consult, and rebuilt on a cold start, so a restart does not reopen the gap. _DEDUPE_SCAN_LIMIT is deleted rather than left unused.

The F6 fix from the previous round was wrong and is replaced. Sending the baseline before register_ws made members_subscribed the first frame a client reads, and slots being first is a contract four suites assert (test_chat_send_echo_scope, test_private_spawn_approval, the E2E private-workflow test, test_dashboard_state_ws). Ordering the two frames cannot fix the race anyway: the socket is registered before the connect snapshot is even written. The gate is what fixes it -- send_members_subscribed marks the socket as awaiting its baseline before the last_seqs read, _send_ws_all withholds member_projection from a socket in that state, and the flag is cleared in a finally so a baseline that never arrives costs one truncate rather than the rest of the connection. Withholding is free: the baseline carries the same seq, and the next change arrives normally.

Also in this round: the Backend Lint & Type Check red was mine -- Cannot infer type of lambda in the fail-closed close path, now a named method -- and the comment-history gate red was mine too, from docstrings on the new test files that narrated the review round instead of stating current behaviour.

Verification unchanged in kind: 979 backend tests pass by path with -n0 across the eventlog, contribution-protocol, members, plugin-import, app-bridges, security-posture, ws-scoping and chat-echo suites; mypy src/kiro_crew/ reports nothing in any file this branch touches. Each of the four new fixes was mutation-verified against its own test. One of those mutations was initially too narrow -- it left the no-follow open in place, so the test passed and proved nothing; the mutation was widened to restore the whole pre-fix copy, which kills it. The same run also caught a mistake in the harness itself: restoring one file with git checkout -- reverted uncommitted work rather than the mutation, so the restore is a file copy for every file now.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Disposition for 2bade45b96feb4138444f39adca7084582599bcf

All seven findings from the previous round are addressed. Four of them are fixed outright and are not discussed here. The three below are either a partial fix or a fix whose shape differs from the one suggested, so each carries its reason and its residual.

The link-test skip is kept, and the property is pinned another way

The request was to use the repository's cross-platform escaping-link fixture and remove both skips. One skip is removed: it probed for symlink capability, which is dead code on a test that is POSIX-gated one line later.

The second skip stays, because the reason is the code and not the test. _copy_regular_file_nofollow refuses a mid-walk swap through O_NOFOLLOW, which is absent on Windows and degrades to 0; that function's own docstring already records that Windows keeps only the caller's pre-check. So on Windows the swap cannot be refused, and the assertions describe nothing there.

What replaces the lost coverage is a test with no monkeypatch seam at all: test_a_directory_link_inside_a_resource_is_never_followed plants a real link with the repository's make_dir_link helper, which makes a junction on Windows, needs no privilege, and is traversed by the same reparse machinery. It then asserts the copy skips the link, records the refusal, and brings nothing in from outside the package root. The no-follow property is therefore now pinned on both platforms, where previously it was asserted on one and skipped on the other.

Two related corrections came out of the same work. The boundary check now delegates the symlink-or-junction question to the shared platform_compat.is_link_or_junction, so the reparse-tag constants and the os.path.isjunction fallback live in one place. It does not delegate wholesale: that helper answers False on OSError and matches only the mount-point reparse tag, where this boundary must answer True for an entry it cannot judge and must treat any reparse tag as a boundary. Both properties are kept on top of it and each is now pinned by its own test. The TOCTOU seam was also repointed at the check the walk actually makes, since it previously patched a call the delegation no longer routes through.

Authorization no longer reads a manifest on a timer, and the residual is named

The finding is correct, and it is wider than the line cited: a third reader exists in the WebSocket frame filter, reached from a synchronous decision function. That rules out the obvious fix: making the readers async covers two of the three.

Two changes instead, and together they cover all three readers because all three resolve through one cache:

  1. Both scope caches are keyed on the grant generation rather than on a clock. The cited trigger was "first request after cache expiry"; there is no longer an expiry, only invalidation by a lifecycle event.
  2. The scope check is async and resolves both manifest-backed inputs in one executor hop before the synchronous decision asks for either. This follows warm_auth_singletons, which already primes the signing secret off-loop in this module under the same rule.

The residual, stated plainly: a caller that reaches a cold cache still reads the manifest on its own thread. Answering deny-safe there instead was implemented and measured. It regresses 20 tests, because an app's first request then receives a 403. A rare read is a better trade than that, and the generation keying is what makes it rare: the fallback is reachable only after a lifecycle event rather than every 30 seconds per app.

The retention bound landed; the streaming fold is a follow-up

The suggested fix was to stream folds and page instead of materializing a unit's log on load. This change takes the half that bounds the growth making materialization dangerous: a per-unit ceiling, refused with its own error type so "no room left" is distinguishable from "the call was wrong". The streaming rewrite is not folded in here and is owed as a separate issue.

The bundle ceiling is no longer part of this change

The advisory asked for the previous value to be restored. That value is exactly what the chunk builds at, so restoring it fails the gate for any change at all. The question is moot: the base has since raised the ceiling with its own measurement under the same convention, that side was taken on rebase, and this branch no longer touches that file.

One design choice worth recording

The revocation fence refuses with a 409 rather than a 403. The counter it compares moves for any app's lifecycle event, so the fence cannot claim that this app lost authority, only that the world moved and the request may be retried. A 403 would assert more than the fence knows.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Round 9 disposition -- head c0a7a1bf7e8e4fcf61116df4e87193335db8032a

All four blocking findings are fixed and each fix is mutation-verified by exit code. Three notes below record where a fix differs from what was asked, or where a decision inside a fix is worth stating rather than leaving to be discovered.

L1 -- the migration marker costs a sequence number

The in-memory completion set is replaced by a fenced member/migrated entry appended after the legacy records, so a legacy row planted later is never re-imported. A marker file beside the log would have been cheaper, and it was rejected on measurement: crew-log is not among the sealed directory leaves, so such a file is deletable by the same party the fence exists to constrain, and the fence claim would not hold.

The marker consumes a sequence number in every member's log. Eleven assertions shifted as a result. Each was classified against the property its own test name claims before any edit, and every one was rewritten as that relation rather than having its literal bumped -- last_seq == before + 1 where the literal said == 0, an unchanged-seq assertion where it said == -1, seqs == range(1, n+1) for a test named for contiguity. Bumping the numbers would have re-pinned the new positions and left the same suite brittle for the next vocabulary addition.

One test in that set was passing and had gone vacuous: its expected page [0, 1] now coincidentally matches marker-plus-one-ping, so it was measuring an event it never wrote. It asserts the page length instead, which is what its name claims.

L4 -- the publish is deliberately not conditional on the append

The durable append is now sequenced before the frame is published. Three requirements meet at this site and one shape satisfies all three: the emit fsyncs so it may not run on the event loop, a start/stop pair must keep its order so it belongs on the single-worker member-log writer, and the append must precede the publish. Submitting both as one unit to that writer gives all three by construction.

The publish still happens whether or not the append succeeded. Making it conditional would trade this defect for a worse one: the per-member log is additive, so a disk fault writing it would also blank the live patrol roster every client renders. What the ordering buys is that the append is finished being attempted before anyone is told, and that is the whole of the guarantee.

The ordering lives in a module-level helper rather than in the observer's closure, because a closure buried in an observer cannot be driven by a test. Its pin is anchored on the frame's own type string rather than on a function name, since renaming the closure would not move the defect.

Local test environment, for anyone reproducing

test/test_autonudge_reconciler.py errors at setup with fixture 'event_loop' not found on this machine. It reproduces identically on a pristine detached origin/main worktree with none of this branch present, and this branch does not touch that file. It is a local pytest-asyncio version artifact, not a finding and not attributable here.

Evidence

Targeted bands: 323 pass across the event log, members, contribution protocol and plugin import suites; 909 pass across the autonudge, websocket and token-auth suites.

Mutation results, each by exit code: reverting the bounded copy to copy-to-EOF reddens 2; removing the projection writer ceiling reddens 1; publishing before appending reddens 2; publishing only when the append succeeded reddens 2. Every mutation restored green.

Ten gates pass against this base: black baseline, subprocess encoding, comment history, isort and flake8 in CI's own scopes, sync-io-in-async, loop-bound locks, feature map, brand, and lockdown-before-publish. Two of my own breaks were caught locally and fixed: a missing blank line after the new helper, and my own history narration in a comment the comment-history gate flagged.

Review lanes

Neither AI review lane has produced a verdict on recent heads. The GPT adjudication stage has failed to run for six heads, so its blocking verdicts carry no proportionality review, and the Opus lane has returned review incomplete for seven consecutive heads. Both are an absence of a verdict rather than a finding, and no override has been requested for either.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Board state for 4ca0e487e3195e545c6921cb2679411ac8bdd842

The board is settled: 93 lanes, 81 success, 5 skipped, 4 neutral, zero pending, zero cancelled, three failures. mergeable is true. Every review finding raised across all rounds is fixed, tested and mutation-verified, ten repo gates exit 0, and the base-drift check reports FRESH with zero overlap.

Three lanes remain red. None is reachable by any action available from this side, and the evidence for each is below so the next reader does not have to re-derive it.

Backend Tests (Windows) (1)

Four tests in test/test_acp_runtime.py assert a POSIX signal returncode that Windows cannot produce. This is issue #12247, which is open and whose title names exactly those four tests. That test file and the source it exercises are byte-identical to main on this branch, and the failure reproduces on main's own code, so it is not introduced here and is not fixed here.

GPT 5.6 Review

The check row on this head reads "changes requested (blocking)". Its summary also records that the adjudication stage failed to run for this sha, so the blocking verdict carries no proportionality review.

The findings it points at belong to an earlier head. The comment's own trailers read [GPT-REVIEWED] 87dac101e9 and [BLOCK-MERGE] 87dac101e9, two heads back, and the four findings listed there are the round-9 set: the durable migration marker, the bounded import copy, the projection writer ceiling, and append-before-publish. All four are fixed on this head, each with regression tests whose mutations were verified to redden. So no finding is bound to this revision, and no active block marker names it.

Opus 4.8 Review

Reads "review incomplete", and its comment body's trailers name a sha five heads back. That is the absence of a verdict rather than a verdict, so there is nothing in it to address.

Why re-running does not clear the two review lanes

Both were re-run once. Each completed in under ten seconds and executed only its own "(same-repo lane, not applicable to forks)" job; the fork review job did not run. Three artifacts confirm nothing was published: the check rows still carry their original timestamps, no new check row appeared, and neither comment body moved. So the remedy the lane summary names, re-running, does not apply to a fork pull request, because the fork job needs the triggering event context that a manual re-run does not reproduce. Further attempts cannot change the outcome.

An override is not applicable either, in two independent ways: the fork lanes do not consume an override marker, and there is no finding bound to this revision for an override to be about.

What is left for a maintainer

Two decisions that cannot be made from this side. Whether the pull request is acceptable with #12247 outstanding, since that issue is open and owned elsewhere. And whether to force a fresh fork review verdict, which on a fork pull request requires a new head rather than a re-run; there is no outstanding code change that would justify one, so pushing solely to re-roll two non-deterministic reviewers is a call for the maintainer.

@bolichen97

Copy link
Copy Markdown
Contributor

Consolidation: the contribution-protocol half of this draft now lives in PR #12645

PR #12645 (same author) adds the same new modules at the same paths as this branch: src/kiro_crew/eventlog/contrib.py, eventlog/grants.py, dashboard/eventlog_ws.py, dashboard/handlers/eventlog.py, docs/system-specs/modules/contribution-protocol.md and the protocol tests. It also makes the same Contributions manifest edit and adds the same /api/eventlog/{kind}/{id}/... routes. I ran git diff --numstat from this head (a65e3ce) to #12645's head (2bc9780): contrib.py +237/-29, grants.py +113/-7, handlers/eventlog.py +136/-23. The removed lines are rewritten signatures (from_dict, _ensure_loaded, lock handling), not dropped behaviour. So #12645 is this protocol code plus hardening.

Things #12645 has that this branch lacks:

  • A gateway-owned unit approval record (apps/manager.py:455, app-unit-approvals.json), intersected with the declared units at eventlog/grants.py:179. Here, eventlog/grants.py:139 takes decl.units straight from the app's own manifest.
  • _bump_grant_generation on update and register, a commit drain (grants.begin_commit), the register identity check (app_token_identity_mismatch), CLI retraction (_retract_app_contributions) and sandbox fence entries for the approvals file.
  • It is built on main's merged ledger (PR feat(members): per-member append-only event log under the fenced crew-log root #12020), so it does not carry this branch's older storage half.

Things only this branch has:

Rebasing this branch is not a good path. It is 673 commits behind and conflicts in 30 files. The ledger half landed in newer form through PR #12020 and PR #12746, and the importer through PR #12009. Resolving the conflicts in this branch's favour would regress main:

Suggested order:

  1. Keep protocol review on feat(apps): let an installed app contribute to a member's event log #12645. None of this branch's backend code needs porting to it.
  2. Re-cut the renderer from feat(eventlog): contribution protocol for out-of-process log contributors #12112 on top of feat(apps): let an installed app contribute to a member's event log #12645's store as a follow-up.
  3. If the /history route is still wanted, re-propose it against main together with a caller. Fold any RFC changes into rfc-append-only-ledger.md.
  4. A line in this description pointing to feat(apps): let an installed app contribute to a member's event log #12645 would save the next reviewer from working this out again.

From a full open-PR audit against origin/main c66f95b (2026-09-25); findings were checked by independent reviewers reading the code. Reply here if this is wrong.

@bolichen97

Copy link
Copy Markdown
Contributor

Windows: a member slug may be a DOS device name, which then becomes a filename stem in the new projection store (P3, advisory)

ExternalProjectionStore._path in src/kiro_crew/eventlog/contrib.py builds its target as self._root / kind / f"{id_}.json", and _flush publishes it via atomic_write. On the member path id_ is a member slug validated only by members._SLUG_RE (members.py:280):

^[a-z0-9](?:[a-z0-9-]{0,78}[a-z0-9])?\Z

That pattern correctly rejects /, . and whitespace, but it admits the bare DOS device names — aux, con, prn, nul, com1–com9, lpt1–lpt9 are all lowercase alphanumerics. Nothing between the slug and the stem normalizes reserved basenames, and atomic_write does not either, so such a slug yields a path whose pre-dot head is a device name (e.g. aux.json).

On Windows editions that enforce the legacy device namespace, a create against such a name resolves to the device rather than a file and fails, so that member's contributed card never becomes durable.

Scope, stated honestly. Reachability is narrow: it needs a member whose slug is one of those words and a granted contributing app. The consequence is one member's non-durable projection — no data loss, no corruption, no credential exposure. And it did not reproduce on the host this audit ran on (Windows Server 2025, build 26100, LongPathsEnabled=1, where aux.json writes a real file); the finding rests on Win32 device-name semantics on enforcing editions and on this repo's own precedent for guarding them, not on a local reproduction. Treating it as a low-priority note rather than a blocker is the right call — particularly next to the structural questions already open on this PR.

Suggested fix. Route the stem through the same identity fold the member log already applies, or reuse the existing memory_stores._WINDOWS_RESERVED_BASENAMES constant — a no-op for every safe slug.

Suggested test. A parametrized case over the reserved basenames asserting the projection path's stem is folded, so a nul member cannot produce nul.json.

Raised by an automated Windows-compatibility audit of the open PR queue. All existing comments on this PR were checked; none names this mechanism. Flagged on a draft because the fix is small and cheaper to apply before the surrounding design settles.

The contribution protocol that lets an installed app read a member's history,
append its own namespaced events and publish a whole-value projection the
drawer renders from a declarative schema. The gateway stays the only writer and
enforces ownership, depth, size and retention at the boundary.

Rebased onto main's member event-log subsystem (kirodotdev#12020 and its successors),
which is authoritative: this change re-ports only the genuinely-new
contribution layer onto main's current APIs rather than re-introducing a
parallel event-log/projection implementation. New: eventlog/{contrib,grants,
projection}.py, dashboard/eventlog_ws.py, dashboard/handlers/eventlog.py, the
`contributions` manifest declaration (folded into the signed payload), the
`/api/eventlog/{kind}/{id}/*` routes and the eventlog_subscribe WS frames, an
`events_after` catch-up read on the member log service, teardown_contributions,
and the app-token eventlog path grant. Contributed projection rows ride the
`/api/members` roster block alongside `roster` (per kirodotdev#13754's narrowing) with
their own seqs/schemas.
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Closing this PR.

The First Principles review blocked the change on the grounds that the contribution protocol ships with zero in-tree consumers, and the ruling was to comply by subtraction rather than by override. Performing that subtraction — removing the protocol layer (eventlog/contrib.py, eventlog/grants.py, dashboard/eventlog_ws.py, dashboard/handlers/eventlog.py, the contributions manifest declaration, the /api/eventlog/* routes, the eventlog_* WebSocket channel, and the roster contributed-row merge) — leaves nothing to land: the member event log backbone this protocol builds on is already on main (eventlog/service.py, eventlog/log.py, eventlog/members_projections.py, eventlog/types.py, and the attach_broadcast wiring), so the subtracted tree is byte-identical to the base commit.

The protocol will ship later together with its first consumer (#12645), which is the consumer whose absence this review flagged. Landing the two together answers the First Principles concern directly rather than shipping a public contract ahead of any caller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants