Skip to content

feat(board): governed agent self-tagging via a chat_tag session directive + [BOARD] context line - #7779

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
jeeshofone:feat/7774-board-self-tagging
Sep 16, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
jeeshofone:feat/7774-board-self-tagging

Conversation

@jeeshofone

@jeeshofone jeeshofone commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

A user managing many concurrent sessions has no way to see at a glance what is pending on them versus what agents are still working. Agents cannot participate in board organization at all: no MCP tool can set a workflow-state tag, and an agent cannot even read its own session's tags. The board only stays truthful through manual grooming.

Why it matters

Handoff visibility is the core value of a session board: an agent that finishes its work should be able to tag its own session Review on its last action, so filtering by Review answers "what needs me" across dozens of sessions. Without an agent write path, workflow tags rot the moment the user stops hand-maintaining them.

What changed (motivation → approach → change)

Goal: let agents move their own session between workflow states — under governance, because the board is also the human's tool. Approach chosen (over a backend rules engine and over unrestricted tooling): agents own the judgment of when to move; a fixed backend authorization layer owns who may move what. "Turn ended with nothing actionable ⇒ Review" style inference was deliberately rejected — the agent must explicitly declare the transition. Design discussed in #7774.

Built (v1 of the issue's two-stage plan — self-only, tags-only):

  • chat_tag MCP session directive (mcp_tools/control.py, modeled on set_project; registered in DIRECTIVE_TOOLS; two-layer schema with a custom_validator enforcing at-least-one of set_state/add/remove). Applied in session_directive_apply.py through the existing tags_write_lock → validate_folder_tag_ids → save_slot_off_loop chokepoint, with fresh slot.tags reads inside the lock and SEL audit (chat.self_tag, allowed/denied).
  • Per-tag agent policy from a protected grants store (chat_tags.agent_tag_policy / agent_tag_grant, backed by the new dashboard/chat_tag_grants.py): add-remove | add-only | none, read from <data home>/tag-grants/agent-tag-policy.json — a NEW dedicated leaf, masked from sandboxed processes (sandbox._CREW_HIDDEN_LEAVES, pre-created at 0700 before every namespace spawn) and fenced from the agent file tools and shell (security._CREW_SECRET_LEAVES), so only the gateway opens the path (GPT review finding: policy fields on agent-writable tags.json rows could be forged and survive restart). Rows carry an HMAC provenance chain keyed under token_signing.key; a key rotation the gateway did not observe quarantines the store (fail closed) rather than trusting it. Writers are the authenticated dashboard tag CRUD only: create mints the out-of-the-box add-remove for workflow-state tags, PATCH re-mints/revokes on a status flip and accepts an explicit agent policy, delete revokes. The boot seed mints rows ONLY for the five code-constant default state ids — never from tags.json, which is agent-writable and must not be promoted into authorization. Upgrade behaviour: an existing install starts with an EMPTY store, so every pre-existing tag resolves human-only until a dashboard PATCH re-mints it (a status double-toggle, or an agent value via the API). A hand-planted id outside the grant grammar (12-hex dashboard id or a default state id) is refused any grant (tag_id_not_grantable). Everything fails closed to none/non-status; remove — including the implicit removal in set_state — requires add-remove.
  • Workflow mutual exclusivity: set_state strips every other status: True tag, keyed on the flag rather than a hardcoded id list so custom status tags participate; a human-only status peer is refused rather than silently stripped.
  • Named refusals (tag_policy_denied:<tag>, unknown_tag:<tag>, no_op) and a success result carrying the resulting tag list — the first agent-readable tag surface. A refusal the store cannot vouch for is named as such: when the grants document is unreadable, gone, or was quarantined this boot and the tag has no row, every store-derived refusal reads tag_grants_unavailable:<tag> instead of a policy/status code, so the agent tells the user the store needs attention rather than reporting a reservation nobody made (chat_tag_grants.store_degraded()).
  • Surface gating: chat_tag added to _USER_SURFACE_DIRECTIVES, so cron/subagent turns are refused.
  • [BOARD] context line (context.py + chat_runner.py): one per-turn line showing the session's tags and which are agent-writable, resolved in chat_runner alongside folder_path so context.py stays free of dashboard/state imports. The closed grant grammar (DEFAULT_TAG_IDS, is_grantable_tag_id) lives in the dependency-free kiro_crew/board_tag_grammar.py so context.py can screen the rail with it without importing kiro_crew.dashboard; chat_tag_grants re-exports it for the mint (pinned by test_grant_grammar_is_dashboard_free_for_context). Only grant-row-backed ids in the closed grant grammar render on this trusted rail; the agent-writable subset is listed beside them.

API changes to declare:

  • POST /api/chat/tags and PATCH /api/chat/tags/{id} now return 400 invalid_status for a non-boolean status where they used to coerce (bool("false") is True, which would have minted authority from a mistyped string). A client that serialised the flag as a string must send a JSON boolean.
  • PATCH returns 400 status_required when an agent value is set on a tag that has no protected row and the request carries no explicit status — the store must record the tag's status bit from the authenticated request, never infer it from agent-writable tags.json. On an upgraded install that is every pre-existing custom tag, so the post-upgrade "grant the agent this tag" PATCH must include status.
  • chat_tag set_state refuses outright (status_identity_unprotected) when the session carries a custom status tag with no identity row in the store: the mutual-exclusivity strip would otherwise have to trust the file's status flag to decide what to remove. Resolution is the same re-mint PATCH. (Default state ids get identity-only rows at boot, so this stop only hits custom status tags after upgrade.)
  • PATCH accepts agent: add-remove | add-only | none. In this v1 that field is API-only: the dashboard's tag manager still sends only status, so a human sets a per-tag agent policy through the authenticated API. The chat_tag tool description names the recovery (status off/on in the tag manager, or a PATCH with explicit status) beside the status_identity_unprotected refusal. The UI control (and a discoverable upgrade re-mint affordance) is the tracked follow-up on feat: agent-driven board organization — governed self-tagging, per-tag agent policy, and a [BOARD] context line #7774; the create-mint default and the status-flip re-mint/revoke are reachable from the existing UI.

Out of scope here (v2, tracked in #7774): folder moves, conductor-over-children, propose-confirm for human-placed state, move budgets/cooldowns.

Tests

New test/test_chat_tag_directive.py (plus test_session_directive.py additions):

  • set_state review replaces an existing workflow tag and returns resulting tags (mutual exclusivity).
  • A none-policy tag is refused tag_policy_denied; an add-only tag adds but refuses removal (asymmetric add/drop).
  • Unknown tag refused unknown_tag; repeated state is no_op.
  • Headless (cron/subagent) surface refused via _USER_SURFACE_DIRECTIVES.
  • Directive registration/forgery-gate coverage (DIRECTIVE_TOOLS).
  • Fixtures set state._tags_authoritative=True mirroring real boot.
  • TestBoardContextLineAssembly: the [BOARD] line as ContextBuilder.build_message emits it — tags plus the agent-writable subset, (none) when all are human-only, omitted when the slot has no tags, ungrantable ids dropped from the rail.
  • Grants store: HMAC provenance, key-rotation quarantine, empty-store upgrade, tag_id_not_grantable, strict-boolean status (test_chat_tags.py).
  • Degraded store: unreadable → tag_grants_unavailable, gone → same, healthy re-seed → policy answers return; a boot quarantine sticks for the process while a re-seeded default keeps its policy answer (test_degraded_store_refuses_as_unavailable_not_denied, test_quarantine_sticks_for_the_boot).
  • Transient reads at boot: a store file that exists but cannot be read this instant (OSError) is NOT quarantined — the boot pass resolves zero grants for this boot and leaves both files untouched; only a successfully read but invalid document is quarantined; the writer path surfaces a transient key-read failure instead of minting a fresh key over the valid one (test_transient_read_error_at_boot_does_not_quarantine[key|store], test_transient_key_read_error_does_not_clobber_the_key_on_write).
  • Bounded reads: the store key and grants document are read through _read_bounded_json (regular file, size-capped) so a file planted in the leaf before the boot that creates the store cannot cost an unbounded read or parse; test_oversized_planted_files_are_quarantined_without_being_parsed.
  • resolve_board_tags skips a malformed vocabulary row (list-valued id) instead of raising and losing the [BOARD] line gateway-wide; DEFAULT_TAG_IDS is pinned equal to the status ids in state._DEFAULT_TAGS.

Suites run locally: test_chat_tag_directive.py, test_session_directive.py, test_chat_slot_project.py, test_mcp_tool_registry.py, test_context_management.py — 179 passed; black gate clean.

Manual verification

N/A — unit coverage sufficient: the directive path, policy matrix, exclusivity, and surface gating are all exercised end-to-end at the applier; the [BOARD] line's assembly is pinned by TestBoardContextLineAssembly against ContextBuilder.build_message.

Related Issues

Part of #7774 (v1; the issue stays open for the per-tag policy UI control and for v2 — folder moves and conductor scope).

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable) — docs/architecture/mcp.md, docs/system-specs/modules/session.md
  • No secrets, credentials, or internal references in the diff

@jeeshofone
jeeshofone requested review from a team and patrigao September 2, 2026 01:25
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — 🟡 CONCERNS

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

Design-Verdict: CONCERNS

On every upgraded install the feature ships dark: default workflow states seed human-only, and the refusal reads tag_policy_denied — a reservation nobody made.

Watch

The upgrade path seeds the five default state ids as ("none", True) identity rows, so an agent's first set_state review on an upgraded install is refused tag_policy_denied — which the tool description tells the agent means "a tag the human reserved for themselves." The PR builds tag_grants_unavailable/store_degraded() precisely so a non-human refusal never masquerades as a human decision, then reintroduces exactly that masquerade for the entire upgraded install base; recovery is an undiscoverable per-tag status double-toggle (the agent policy UI is deferred to #7774). The stated forgery hazard ("user may have deleted those tags") guards against an agent gaining the same authority every fresh install grants by default — near-zero marginal harm bought at the price of a dead headline feature plus a misleading refusal.
Clears when: upgraded installs seed add-remove for the code-constant default state ids, OR the refusal for an upgrade-seeded none row names the upgrade default (its own code, not tag_policy_denied), OR a human explicitly acks the dark-launch trade on #7774.

Suggestions

  • Record the human-approved display name in the grant row at mint time and render it beside the id on the [BOARD] line — for dashboard-minted tags the line currently shows only opaque 12-hex handles, so the agent cannot know which custom lane it is in without burning a no-op chat_tag call, and a name snapshotted from the authenticated PATCH is agent-unwritable by the same construction as the recorded status bit.

[DESIGN-REVIEWED] df9bd33

@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

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

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

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

BLOCKING -- src/kiro_crew/dashboard/chat_tag_grants.py:222 -- Ephemeral secret certifies persistent grants

return hmac.new(token_secret._get_secret(), _KEY_CERT_DOMAIN + key, hashlib.sha256).hexdigest()
Short token_signing.key -> ephemeral secret -> grant write -> restart uses a new secret -> store quarantine and custom grants become unavailable.
Anchor: residual/crash-data-loss-corruption
Fix: Refuse grant-store writes unless the token signing secret is confirmed persisted.
[BLOCK-MERGE] df9bd33
[GPT-REVIEWED] df9bd33

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

I've reviewed the finding, the diff for chat_tag_grants.py, and the actual token_secret._get_secret() persistence path it depends on.

F1 — chat_tag_grants.py:222 (_key_cert under token_signing.key)

  • Harm rung: LOW/MEDIUM — recoverable, visible, and fail-CLOSED (grants are lost, never forged).
  • Conditions required, all confirmed: (a) token_signing.key cannot persist so _get_secret() returns a fresh ephemeral secret — reached only on a degraded filesystem (token_secret.py:519-535 persistently-short/empty → ephemeral; :536-539 unwritable → ephemeral); (b) a grant is minted while ephemeral (chat_tag_grants.py:222, _ensure_store_key); (c) a restart yields a different ephemeral secret; (d) the boot pass quarantines on the now-uncertified key (seed_default_grants, patch 874-888).
  • Recovery, confirmed: default workflow-state rows re-seed automatically on the same boot (seed_default_grants, patch 917-928); custom grants restored by one authenticated dashboard PATCH re-mint; the degraded state surfaces to the agent as tag_grants_unavailable, not tag_policy_denied (session_directive_apply _store_refusal, patch 1489-1492).
  • Rarity: the trigger is a host whose data home cannot persist a 32-byte owner-only file. On any such host every auth cookie/token is already ephemeral and invalidated on every restart, so tag grants also needing re-mint is a negligible marginal degradation — and in the safe direction. The proposed fix ("refuse grant writes until the signing secret is confirmed persisted") only converts "grants lost on restart" into "no grants at all" on that same broken host.

This clears the FLAG bar: the record is complete, the loss is fail-closed and recoverable (so a wrong clearance is not unrecoverable), and the condition set is confined to an already-broken environment a human would plausibly accept.

[ADJUDICATION] df9bd33 total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] df9bd33

[ADJUDICATION-FENCED] df9bd33 fenced=1 flagged=1
FLAG F1 src/kiro_crew/dashboard/chat_tag_grants.py:222 -- Trigger requires an ephemeral token_signing.key (degraded/non-persisting filesystem, token_secret.py:519-539) where all auth is already ephemeral across restarts; the resulting quarantine is fail-closed and fully recoverable (defaults auto-reseed, custom grants re-minted by one dashboard PATCH, surfaced as tag_grants_unavailable), so the residual is one a writer could reasonably accept.
[GPT-ADJUDICATED-FENCED] df9bd33

🏷️ Fenced finding(s) machine-flagged as likely edge case

The security fence keeps these findings blocking regardless of adjudication; the only clearance path is a human override recorded by a repository writer, who must independently verify a rationale before recording it — it is machine-authored, and a wrong override on a security-class finding ships exactly the class the fence exists to stop. (This lane's comment deliberately carries no override command.)

  • F1 src/kiro_crew/dashboard/chat_tag_grants.py:222 — Trigger requires an ephemeral token_signing.key (degraded/non-persisting filesystem, token_secret.py:519-539) where all auth is already ephemeral across restarts; the resulting quarantine is fail-closed and fully recoverable (defaults auto-reseed, custom grants re-minted by one dashboard PATCH, surfaced as tag_grants_unavailable), so the residual is one a writer could reasonably accept.

@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

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

Premise-level review of df9bd336b809a617915028fe6a9afe73bc19468b 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

Fresh installs get agents retagging their own sessions by default — a first-class agent's default behavior, decided in issue #7774, with no RFC on the base.

Not justified as shipped

  • Item 2 — product-shape change without accepted RFC: "workflow states are agent-writable by default on a fresh install" (the tool's own description) ships a default nobody chose.
    Subtraction: shrink the fresh-install seed to identity-only rows (policy="none", as seed_status_identity_rows already mints) so the capability lands default-off behind the existing PATCH grant.
    Clears when: an RFC covering agent self-tagging merged non-draft on the base branch (then push or rebase), or a maintainer pushes this branch to kirodotdev/KiroCrew and records /ai-review override first-principles df9bd336b809a617915028fe6a9afe73bc19468b: <decision>, or the seed is shrunk to default-off.
  • Item 5 — zero consumers: the agent PATCH field is "API-only: the dashboard's tag manager still sends only status" — grep api/chat/tags in website/src shows updateChatTag sends {name, color, order, status}; 0 callers pass agent, and its add-only variant is constructible nowhere else.
    Subtraction: defer the agent field (and add-only) to the PR that ships its tag-manager control; the create-mint and status-flip re-mint already cover the UI-reachable paths.
    Clears when: a counted non-test consumer (the feat: agent-driven board organization — governed self-tagging, per-tag agent policy, and a [BOARD] context line #7774 UI control) lands, or the field is deferred.

What this change ships

Inventory (10 items, capped — refusal codes and revision-CAS details omitted) — 8 justified

Intent: let an agent move its own session between board workflow states under a human-controlled authorization layer — an ADDITION.

  1. Agents can set/add/remove their own session's board tags via a new chat_tag tool — justified
  2. On fresh installs the five workflow states are agent-writable out of the box — product-shape default without a recorded decision
  3. Every tagged session's turns now carry a [BOARD] context line — justified
  4. A new protected tag-grants store (keystone leaf, sandbox-masked, HMAC-chained) holds the authorization — justified
  5. Tag PATCH accepts a new agent policy field — zero consumers (UI never sends it; add-only unreachable elsewhere)
  6. POST/PATCH now 400 on non-boolean status where they coerced — justified
  7. PATCH refuses status_required on rowless tags — justified
  8. Upgraded installs' existing tags all become human-only until re-granted — justified
  9. Cron and subagent turns are refused the directive — justified
  10. Tag delete/update reordered around grant revoke (the "no multi-write compensation" docstring rewritten, with the new hazard named in-diff) — justified

Blockers

  • product-shape change without accepted RFC: agent self-tagging enabled by default on fresh installs. The diff seeds {"policy": "add-remove", "status": True} for every default workflow state (seed_default_grants from state.load_tags), and the base's only agent tagging path pins the opposite standing behavior (chat_auto_tag.py:104, "NEVER apply status/workflow tags"). The base RFC list names nothing covering agent tag writes — the nearest document, rfc-session-tag-change-event.md (draft), declares it a non-goal ("Letting an agent set its own tag is Expose session tagging as an MCP tool for agent-driven lifecycle tracking #3456"). The description's design record is "Design discussed in feat: agent-driven board organization — governed self-tagging, per-tag agent policy, and a [BOARD] context line #7774" — a proposal, not a recorded decision.
    Clears when: an RFC covering agent self-tagging of workflow states is merged non-draft on the base branch and the author pushes or rebases; or a maintainer pushes this branch to kirodotdev/KiroCrew and records /ai-review override first-principles df9bd336b809a617915028fe6a9afe73bc19468b: <decision>; or the fresh-install seed ships identity-only (none) rows so the default is off.

[FIRST-PRINCIPLES-REVIEWED] df9bd33

@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review (fork) — ✅ no blocking findings

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

Review details

Both candidates concern _apply_chat_tag in session_directive_apply.py. Let me verify the falsification of each against the code I read.

Candidate 1 (add-only status tag unreachable): Traced. set_state requires state_policy == "add-remove" (line 1605) because the verb performs a peer-strip that removes other workflow states — remove authority is genuinely needed for that operation. The add path refuses status tags by design (line 1575) so a state isn't appended without stripping peers. The result is a conservative refusal (fail-safe), not an observable wrong outcome: no crash, no data loss, no security-boundary violation, nothing mis-applied. Whether an "add-only" status tag should be enterable is a product/design question, and the candidate's own text concedes it "could not confirm whether add-only status tags are an intended configuration." No (c) grounded to a real harm. Drops below 80.

Candidate 2 (no-op READ path unreachable): Traced. Policy gates (lines 1574–1615) run before the new_tags == current branch (line 1668), so an agent holding only policy="none" tags that issues add=[T] is refused at line 1582–1585 before reaching the READ branch. But the "wrong outcome" is only that a convenience read path returns tag_policy_denied instead of a tag list — and such an agent has no writable tags to change anyway, and already receives its full tag set every turn via the [BOARD] context line (context.py, line ~4626). No harm of a reportable class; the candidate's own confidence is "low" and unverified. Drops below 80.

Neither survives Step 1. No new finding rises to the 80+/(a)(b)(c) bar in the code I opened; the applier's list-valued-id and rebind paths are all guarded, and the write-ordering/crash-atomicity handling in the grants store and CRUD is fail-closed by construction.

No findings.

[OPUS-REVIEWED] df9bd33

@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 2, 2026
@jeeshofone
jeeshofone force-pushed the feat/7774-board-self-tagging branch from 60ab955 to 5a114fe Compare September 2, 2026 03:02
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Review round 1 — all lanes addressed in 5a114fe25dd2440bc9a48f4ba13b7f8a315e39ad

GPT 5.6 blocking #1 (chat_tags.py — invalid agent value falls through to a permissive default): FIXED. agent_tag_policy now fails closed: a present-but-invalid agent value (typo, wrong type) resolves to "none" unconditionally — never to the workflow default. Only an absent field takes the default. Regression tests cover a malformed value on a status tag and a non-string value.

GPT 5.6 blocking #2 / Opus advisory (session_directive_apply.py — add=["review"] bypasses mutual exclusivity): FIXED. The applier now refuses any workflow-state tag (status: True) supplied via add, before any mutation, with a teaching error: Error: status_tag_requires_set_state:<id>. set_state remains the only verb that can change board state, so its peer-strip invariant can't be bypassed. Chose refusal over silently routing through the exclusive path (Opus's alternative) because the directive's design is result-teaches-boundaries — a named refusal tells the model the sanctioned verb. The chat_tag tool schema's add description updated to match. Regression test: add=["review"] on a todo slot refuses and leaves exactly one state.

Design Review concern (default keyed on frozen id set vs described status: True flag): FIXED code-side. The absent-field default now keys on the tag's status: True flag — the same key the mutual-exclusivity logic uses — so the description, the #7774 spec, and both code sites agree, and custom status vocabularies get consistent treatment. Regression test: a custom status: True tag defaults add-remove; a bare well-known id without the flag defaults none.

First Principles concern (per-tag agent field / add-only ship without a product write path): ACKNOWLEDGED, no change. Advisory. The policy field is the governance contract for the v2 follow-up (folder moves, placement locks — staged per #7774), and shipping the chokepoint with the contract keyed in one helper is deliberate; shipping v2's writes without the policy in place would be the unsafe order.

Verified: test_chat_tag_directive.py (18) + test_chat_tags.py (84) + black gate, all green.

@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 2, 2026
@jeeshofone
jeeshofone force-pushed the feat/7774-board-self-tagging branch from 5a114fe to 6c7baf8 Compare September 2, 2026 03:59
@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 2, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Review round 2 — GPT blockings addressed in 6c7baf852be227e4b6d7ac50a93c79f0545bfda8

Blocking #1 (set_state=review, remove=["review"] leaves the session stateless): FIXED, both halves. set_state now requires the requested tag to actually be a workflow state (status: True) — a plain label would have run the peer-strip in exchange for a non-state tag (Error: not_a_status_tag:<id>). And a remove naming set_state's own canonical id in the same call is refused before any mutation (Error: set_state_conflicts_with_remove:<id>), case-insensitively. Regression tests for both.

Blocking #2 (persist not pinned to the authorized transcript): FIXED. The applier now captures slot_history_key(slot) inside the tags write lock before mutating, passes it as expected_history_key to save_slot_off_loop, and on a refused save (rebind or delete-won — the two False cases per that function's contract) rolls the in-memory slot.tags back and returns Error: session_rebound instead of reporting success. This is the same pin the metadata endpoints in chat_handlers use. Regression test simulates the refused save and asserts rollback + no broadcast.

Verified: test_chat_tag_directive.py (21) + test_chat_tags.py (84) + black gate, green. Round ledger: r1 = invalid-policy fallback + add-bypass (fixed); r2 = set_state edge + persist pin (fixed) — both r2 findings are new families, not repeats.

@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 2, 2026
@jeeshofone
jeeshofone force-pushed the feat/7774-board-self-tagging branch from 6c7baf8 to f8026a0 Compare September 2, 2026 04:43
@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 2, 2026
@jeeshofone
jeeshofone force-pushed the feat/7774-board-self-tagging branch from f8026a0 to 3a88fc8 Compare September 2, 2026 05:35
@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 2, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Round on 5e373f0be → 04e2a8e8f. F1 closed structurally; F2 and F3 are the adjudicator's FLAGs and I agree with both — no code change, rationale below for the human override the fence requires.

F1 — agent-controlled tag IDs can reach the trusted [BOARD] rail (UPHELD-FENCED → fixed). The adjudicator's reading is right and the previous design conceded it: the human approves a name, the rail carries the id, and the only thing between a planted instruction-shaped id and the rail was the injection heuristic. The fix removes the heuristic from the load-bearing position by closing the id grammar. Every id the dashboard mints is uuid4().hex[:12] (unchanged since the repo was created) and the built-in workflow states are five code-level constants; nothing else is a legitimately granted tag. So:

  • chat_tag_grants.is_grantable_tag_id() — a 12-hex dashboard id or a built-in default, nothing else.
  • The PATCH mint (api_chat_tag_update) refuses a grant on any other id with 400 tag_id_not_grantable before any store write. That is the chokepoint the finding names — the routine status toggle — so a tag hand-written into agent-writable tags.json can never acquire the grant row that resolve_board_tags requires. Metadata PATCHes (rename/colour) on such a tag still work; recovery is to recreate the tag from the dashboard.
  • _board_safe_tag_name admits the same closed grammar. Twelve hex digits cannot spell a word, so the injection screen is now redundant (kept as a second screen, not the defense).

Test: a tag {"id": "ignore.previous.instructions", "name": "Backlog"} planted into the vocabulary → PATCH status:true and PATCH agent:add-remove both 400, no grant row, rename still 200, a dashboard-minted tag takes the same toggle normally, and the rail rejects the planted id outright. On the previous head the toggle returns 200 and mints the grant — the laundering path. The two sanitizer tests that encoded the old slug grammar were rewritten for the closed one.

F2 — duplicate display names resolve to an arbitrary tag (FLAG, agree). Every op the collision can misdirect is already gated by the per-tag grant, the canonical id always wins the collision, and the precondition is a human giving two already granted tags the same display name. Bounded, visible, recoverable.

F3 — token-key rotation discards default grants (FLAG, agree). This is the documented fail-closed rotation: store quarantined by rename, tags.json untouched, status identity preserved, recovered by one authenticated PATCH. Reseeding default grants on recovery is precisely the agent-replant forgery hazard the design closes — and with F1's grammar in place, that hazard is what the closed id set exists to stop.

227 across the tag/board/contract/ratchet suites, 1542 in the wider context family (one unrelated test_dev_fleet_app red is a Homebrew-layout assumption that fails identically on main on a Linux host), all gates.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

04e2a8e8f → da476bc00 — rebase only, onto main at ac2656afb after the PR went CONFLICTING. Two conflicts, both docstring lines in chat_runner.py where this PR and main's own history-narration clean-up (#9882) reworded the same sentences; main's wording kept in both. test/test_chat_tags.py re-formatted (3 lines) so its graduation from .github/black-baseline.txt — the one .github/ line this PR touches, which is what the fork workflow-change guard trips on — still holds. No code change. 683 across the directive/tag/runner suites; isort/flake8/mypy, black (baseline-aware), comment-history, brand and ACP-boundary gates green. The FLAGGED F1 from the earlier round is unchanged and still held for a maintainer's call; the run itself will need the usual approval click.

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review (fork) — 🟡 CONCERNS

Which legitimate operations does df9bd336b809a617915028fe6a9afe73bc19468b newly refuse? Model proposes, scripts/deny_diff.py decides — updated in place on each push. A script-confirmed regression blocks PR readiness.

the reviewer's own judgement; no confirmed regression

Scope-Verdict: CONCERNS

TIGHTENING: tag-grants added as a directory leaf to security/paths.py::_CREW_SECRET_LEAVES (mirrored in sandbox._CREW_HIDDEN_LEAVES and _CREW_PRECREATE_HIDDEN_DIR_LEAVES) -- it refuses an agent's file tools and spawned commands reading or forging the chat_tag authorization store: "The chat_tag authorization store. Grant rows decide which tags an agent may self-apply, so agent file tools must neither read nor write them; the OS-sandbox counterpart is sandbox._CREW_HIDDEN_LEAVES. Only the gateway opens the path."

ADJUDICATED: 14 candidates, 0 confirmed newly-refused
No confirmed regressions were handed to this review. The candidates probe the boundary of the new leaf: the unfenced siblings the security spec names as routine reads (config.json, tags.json, sessions.db), the parent-directory listing a directory leaf must not fence, the legacy ~/.kirocrew prefix expansion's siblings, the fenced spelling appearing as data (grep/findstr patterns, a repo-relative docs read, a git log path argument), and the maintainers' test lane for this exact feature (test/test_chat_tag_directive.py) in both interpreter spellings.

PLATFORM COVERAGE: posix (8 rows), windows (5 rows), any (1 row). The diff declares the leaf with a POSIX separator relative to two home prefixes and relies on _leaf_segments expansion plus the home/KIROCREW_HOME anchors for the other host; the windows rows probe the sibling reads (type, dir), the search-data shape (findstr), and the feature's test invocation under Windows separators and the .exe interpreter path — the exact assumptions the expansion makes. Windows matters doubly here because the namespace/Seatbelt mask half of this tightening does not exist there, leaving the composite's path fence as the only enforcement. Not probed: UNC spellings of the data home (\\host\c$\Users\...\.kiro\crew\...) — I could not attribute a real operator or code path that reads the data home over UNC, so no row was spent on it; it remains an open question if such an operation exists. Per-leg verdicts are the deterministic fold's to report after capture, not mine.

UNADJUDICATED: Most of this change's strictness lives in guards the shell classifier cannot see; no PASS can rest on the adjudicated set alone.

  • The grants store gate (dashboard/chat_tag_grants.py, reached via the chat_tag MCP directive → session_directive_apply._apply_chat_tag → resolve_grant). Fail-closed everywhere: on every UPGRADED install the boot seeds only policy-none identity rows, so an agent's chat_tag set_state review — the tool's own headline use — is refused tag_policy_denied on every default workflow state until a human PATCHes each tag. A token-key rotation quarantines the store and every custom grant is gone for the process's life. Both are designed costs the PR documents, but they are precisely the "agent stopped working, reporting a pattern instead of a cause" class, and no verdict is available for them. Candidate inputs I would have submitted: chat_tag {"set_state": "review"} on an upgraded install; the same call after a token_signing.key rotation; chat_tag {"add": ["<display name longer than 64 chars>"]} (the new CHAT_TAG_SCHEMA caps items at 64 chars while display names are unbounded, so a long-named tag is reachable only by its 12-char id).
  • The pre-existing tag CRUD, newly stricter (dashboard/chat_tags.py, HTTP PATCH/POST/DELETE). Three new 400/500 classes on an endpoint that existed at base: a non-boolean status ({"status": "true"} from any scripted client previously coerced, now 400 on create and PATCH); tag_id_not_grantable for any tag id outside the closed grammar; status_required for an agent PATCH on a row-less tag; and a degraded grants store now turns tag create/update/delete into 500s that previously touched only tags.json. Candidate inputs: PATCH /api/chat/tags/<id> {"status": "true"}; PATCH {"agent": "add-only"} on a pre-upgrade custom tag; DELETE /api/chat/tags/<id> while the store is quarantined.
  • The [BOARD] rail allowlist (context._board_safe_tag_name + chat_tags.resolve_board_tags): renders only grant-row-backed, grammar-conforming ids. The rail is new in this PR, so nothing is newly refused relative to base, but note the coverage edge: a dashboard-created non-status label never mints a row and is therefore invisible on the [BOARD] line until an agent PATCH mints one.
  • The OS mask (sandbox._CREW_HIDDEN_LEAVES + precreate): mount-level, POSIX-only, no composite verdict possible; the PR's claim that no in-sandbox consumer opens the path is consistent with the base tree I read, but it is asserted, not adjudicated.

[SCOPE-REVIEWED] df9bd33

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 9 classified, 0 newly refused, 9 still allowed.
  • ubuntu-latest (platform posix): 9 classified, 0 newly refused, 9 still allowed.
  • windows-latest (platform windows): 6 classified, 0 newly refused, 6 still allowed.

No candidate flipped from allowed to refused.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

da476bc00 → 31f8c6a7f. F1 (UPHELD → fixed): the chat_tag applier assigned slot.tags without rotating tags_revision, so the board's PUT compare-and-swap (chat_tags.py, base_tags_revision) could not see the agent's change — a human saving from the pre-mutation base overwrote it with no conflict. The applier now uses the same _bump_slot_tags_revision helper the human path uses: the revision rotates with the mutation before the pin-save; on a refused (rebound) save the tags roll back under a FRESH revision, guarded the same way the PUT handler guards its rollback (only while the slot still holds this mutation's value and revision); and the live-alias mirror copies the revision along with the tags, so a board edit composed against an alias compares with the same base. A no-op read still mints nothing. Tests (fail on the previous head): the mutation rotates the revision and a read does not; the rebound rollback lands under a revision that is neither the prior nor the provisional one; the alias carries the requester's revision and a stranger slot keeps its own; and end to end through the tags app, an agent set_state followed by a human PUT on the pre-agent base is a 409 stale_base carrying the agent's tags and revision, while the same edit rebased onto that revision commits. 570 across the directive/tag/runner suites; isort/flake8/mypy, black (baseline-aware), comment-history and brand gates green. The earlier FLAGGED item remains held; the run needs the usual approval.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

@iamwhatever — could a maintainer add allow-fork-workflow-change here? The fork workflow-change guard is the only red that is not a known main-side flake: this PR's sole .github/ change is removing entries from .github/black-baseline.txt for files it makes black-clean (the baseline gate itself demands the prune — check_black_formatting.py fails with "graduated entries to prune" otherwise). No workflow file is touched. Both review lanes are green on the current head.

@iamwhatever

Copy link
Copy Markdown
Contributor

Not approving for now: the Fork workflow-change guard check is failing and the "Documentation updated" checklist box is unchecked, and this adds an agent write path governed by a trust-store permission policy, which I will not sign off on with either of those open.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Thanks — both mechanical items are closed on 781651b49:

  • Fork workflow-change guard: this PR now touches nothing under .github/. The red came from .github/black-baseline.txt losing the test/test_chat_tags.py entry — my additions plus a re-format of two pre-existing lines had made that file black-clean, and the baseline gate then demanded the prune. I have restored those two lines to their original formatting, so the file stays baselined and the guard has nothing to object to. (Worth knowing for other fork PRs: the black gate and the fork guard collide whenever a fork PR happens to make a baselined file clean; the workaround is to leave untouched lines alone.)
  • Documentation: the box is ticked — this PR updates docs/architecture/mcp.md and docs/system-specs/modules/session.md (the directive's contract, the grant policy, the [BOARD] context line). If there is a page you expected to see changed that is not, tell me which.

On the substantive point — an agent write path onto board tags, governed by the grant store — I am not going to argue you into it in a comment. The design as it stands: no tag is writable by an agent unless a human minted an explicit grant row for it (agent: add-only | add-remove); status tags are mutually exclusive so an agent cannot leave a session in two workflow states; the applier refuses headless callers, re-verifies the transcript identity at the commit point, rotates the board's CAS revision so a human edit never silently overwrites the agent's, and audits every decision to the SEL. If the objection is to the existence of the path rather than its guards, say so and I will close this and file the use case (agents self-reporting workflow state on a board) as an issue for a design pass instead.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

781651b49 → 3f412fc2f. GPT F1 upheld and fixed at the seam.

Finding. In the PATCH handler a status flip without an explicit agent minted add-remove unconditionally, so the ordinary form-edit shape — re-send name + status: true — silently widened a human-only none row (or a narrowed add-only) into agent write. That is a governance-ceiling escalation with no operator signal.

Fix. The protected row is read before the policy is derived (it was already read afterwards as the restore point; there is now one read serving both). A status flip keeps the recorded policy whenever a protected record exists; only a tag with no record at all takes the out-of-the-box add-remove — the same default the create path mints, so a plain tag promoted to a workflow state behaves as before. The comment block states the rule.

Test (test_status_patch_without_agent_keeps_the_recorded_policy): none survives a name+status re-send, add-only survives a bare status: true, and a never-minted tag still gets the default. On the previous head it fails with ('add-remove', True) == ('none', True).

571 across the board/directive/runner families; isort/flake8/mypy, black (baseline-aware), comment-history and brand gates green; still no .github/ diff.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

3f412fc2f → 088b34be3. GPT's three findings on the previous head were all FLAGGED (rarity record complete, none upheld). Disposition:

F1 — taken. First-boot ordering in load_tags: the default grants are now seeded before the vocabulary commit, the same crash-atomicity rule the create endpoint already documents. A death between the two leaves inert grant rows and no tags.json, so the next boot is still a fresh install and the defaults come up agent-drivable; the previous order left a durable vocabulary whose next boot read as an upgraded install and seeded an empty store, demoting every default workflow state to human-only. GPT's "permanently ungrantable" overstated it (a dashboard PATCH re-mints), but the reorder is one hoisted block and removes the window. Test test_first_boot_crash_after_the_grant_seed_keeps_defaults_grantable fails on the previous head at the durability inversion (tags.json exists after the crash).

F2 — not taken, by design. A transient token-key read failure past the retry budget quarantines the store (bytes preserved, never deleted) and reseeds trusted constants. Distinguishing that from a real key rotation needs the old key, which is exactly what is gone; certifying an uncertified store would bless a planted one identically. Fail-closed with one authenticated PATCH to re-mint is the intended answer, and it only occurs alongside full session invalidation, which is loud.

F3 — not taken. Two consecutive storage-write failures inside one PATCH (the final mint and the rollback persist) can leave the vocabulary and the grant store inconsistent, but authority only ever collapses toward none/prior, memory rolls back, and the applier refuses a stale status identity. A two-store single transaction is a large coordination change for a double-fault that fails closed; noting it for a maintainer call rather than expanding this PR.

572 across the board/directive/runner families; all gates green; no .github/ diff.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

088b34be3 → b05855dde. GPT's one finding was FLAGGED (not producible: one quarantine per boot, and recovery reseeds a verifying store), but the hardening is two lines, so taken: _quarantine_store appends a counter when its target already exists, so a same-second quarantine never overwrites earlier evidence. Test test_a_same_second_quarantine_never_overwrites_the_earlier_evidence (both copies kept; the previous head keeps only the second). 573 across the board/directive/runner families; all gates green; no .github/ diff.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (175 commits) after the base moved to CONFLICTING: one conflict in sandbox.py's _CREW_PRECREATE_HIDDEN_DIR_LEAVES — main added ledgers, this PR adds tag-grants; both kept. No other changes. Full backend suite 27,063 passed locally (one test_chat_nav xdist-order flake, passes in isolation on this tree and on main); black/isort/flake8/mypy and the black/comment-history/brand/agent-sdk/sync-io gates green.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

cf725c060 → 1f920e6b6. Disposition of the fresh-lane findings on the rebased head:

First-Principles BLOCK — product-shape default without an accepted RFC. Upheld as a process gap, and not something this branch can clear by itself: the fork lane wants either a non-draft RFC on main or a maintainer override. I am opening a separate RFC PR (docs/request-for-change/rfc-agent-self-tagging.md) that records the design of record here — agent self-tagging via chat_tag, the default grants (fresh install: workflow states agent-writable; upgrade: everything human-only until re-minted), the protected tag-grants store and its provenance chain, and the per-tag policy field as API-only in v1 with the UI control as follow-up. Maintainers: merging that RFC as accepted, or recording /ai-review override first-principles on this head, is the call that unblocks this PR.

  • Item 5 (agent PATCH field has no UI consumer) — kept, and now declared: the description records the field as API-only in v1 with the dashboard control tracked on feat: agent-driven board organization — governed self-tagging, per-tag agent policy, and a [BOARD] context line #7774 (also acceptable to the Design lane's second watch item). Not deferred: the create-mint default and the status-flip re-mint/revoke are reachable from the existing UI, and removing the field would strip the only way a human can reserve a tag from agents on this v1.
  • Item 6 (strict-boolean status → 400 undeclared) — upheld: declared under a new "API changes to declare" heading in the description, with the harm it closes.
  • Item 10 (context.py docstring reword rides along) — upheld: reverted; context.py is now additions only.

Design CONCERNS — upheld: the description described the abandoned trust/ TOFU design. Rewritten to the shipped one (tag-grants leaf masked + fenced, HMAC provenance chain under token_signing.key, key-rotation quarantine, empty-store upgrade, tag_id_not_grantable). The "[BOARD] line covered by context tests" claim is now backed: new TestBoardContextLineAssembly drives ContextBuilder.build_message with board_tags and pins the tag list + agent-writable subset, the (none) case, omission when the slot carries no tags, and ungrantable ids dropped from the rail.

Await Fast Gate / Coverage Gate reds were the fork-run approval wait (Fast Gate concluded action_required, so the heavy jobs skipped and the coverage gate failed closed) — a new head re-runs them.

PR test files + context suites 371 passed; black/isort/flake8/mypy and the black/comment-history/brand gates green on the changed files.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

RFC opened as #11175 (docs/request-for-change/rfc-agent-self-tagging.md) — the design of record the First-Principles lane asks for: the defaults (fresh install default-on for the five workflow states; upgrade default-off with an empty store), the tag-grants trust model, the API-only v1 policy field, and the declared status API change. It is status: draft; maintainers accepting it (or recording the override on this head) is what clears the block here.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

First-Principles items 8 and 9 on 1f920e6b6 upheld as undeclared and now declared in the description under "API changes to declare": the 400 status_required PATCH refusal (an agent value on a row-less tag with no explicit status — every pre-existing custom tag after upgrade), and the status_identity_unprotected hard stop in set_state when the session carries a custom status tag with no identity row; both resolve with the same re-mint PATCH. Design lane is PASS on this head. The RFC (#11175) is now filed in-progress per the index vocabulary, so merging it clears the remaining blocker here. Re-pushing the same tree so the description edit is read against a fresh run.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

e6ac7762c → c2c4ef5a5.

Opus FINDING (resolve_board_tags raises on a list-valued id, [BOARD] line silently dropped gateway-wide) — upheld and fixed: by_id now mirrors the applier's guard (isinstance(t, dict) and isinstance(t.get("id"), str)); new test test_board_line_survives_a_malformed_vocabulary_row raises TypeError on the previous head and passes here.

Design CONCERNS — both upheld:

  • the recovery for status_identity_unprotected is now named where the agent (and the human reading the transcript) sees it — the chat_tag tool description's PERMISSION paragraph: toggle the tag's status off and on in the tag manager, or PATCH with an explicit status. The Error: <code>:<id> result shape is unchanged so nothing parsing it moves.
  • DEFAULT_TAG_IDS vs state._DEFAULT_TAGS: pinned equal by test_grantable_defaults_match_the_seeded_default_states (deriving one from the other would pull state.py into the grants module's import graph; the pin fails the moment a sixth default state is added to one side only).

GPT BLOCKING (12-hex syntax taken as dashboard provenance) — the scenario is real but its remedy is a design choice, so I am routing it to the RFC rather than changing the code under it. Path: an agent plants a 12-hex-id row with status: true in agent-writable tags.json; a human then toggles that tag's status in the dashboard (or PATCHes it with status), and the mint gives the agent add-remove on that tag. Two observations: (1) the mint only ever follows an authenticated human action on a tag the human can see in the tag manager — the same action that mints authority for a legitimately created tag; (2) the fix GPT names (record dashboard-created ids in protected state and require that provenance to mint) is exactly right for fresh installs, but it makes every pre-existing custom tag on an upgraded install permanently ungrantable — the recovery becomes "recreate the tag", because a pre-existing legitimate tag and a planted one are indistinguishable to the store. That trade (stricter provenance vs. an upgrade path) is the kind of default #11175 exists to decide, so it is added there as an open question with both options; whichever the maintainers pick lands here as a follow-up push.

FP items — item 5 (add-only has no production constructor) is recorded in the description and the RFC as API-only in v1; the enum stays because the UI follow-up on #7774 is what constructs it. The RFC blocker stands until #11175 merges.

PR test files + registry/context suites 426 passed; black/isort/flake8/mypy and the black/comment-history/brand gates green on the changed files.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

c2c4ef5a5 → f93b85d21.

GPT BLOCKING 1 (unbounded read of a planted .signing-key at boot) — upheld and fixed at class level: the key file AND the grants document (three read sites) now go through one _read_bounded_json(path, limit) — regular-file check, size cap (4 KiB key / 2 MiB store), capped read — so a file planted in the leaf before the boot that creates the store cannot cost an unbounded read or parse. Over the cap is malformed by definition and takes the existing quarantine-and-reseed path. New test test_oversized_planted_files_are_quarantined_without_being_parsed (also asserts nothing over the cap ever reaches json.loads); fails on the previous head.

GPT FINDINGs — both fixed: the applier's identity check now requires et.get("status") is True (a string "false" no longer refuses a state change); the crash-ordering comment no longer claims orphan rows are "pruned on the next load" — it says why they are inert.

Design CONCERNS (layering) — upheld: context.py importing kiro_crew.dashboard.chat_tag_grants broke the PR's own rule. The closed grant grammar (DEFAULT_TAG_IDS, is_grantable_tag_id) now lives in the dependency-free kiro_crew/board_tag_grammar.py; chat_tag_grants re-exports it for the mint so the two cannot drift. test_grant_grammar_is_dashboard_free_for_context pins identity of the objects and the absence of any kiro_crew.dashboard import in context.py.

GPT BLOCKING 2 (compensation failure under disk exhaustion loses a grant) — not changed: the failure mode is a 500 with the grant absent, which is the fail-closed state the store is designed to land in (every tag resolves ("none", False)); recovery is the same authenticated re-mint PATCH as every other loss path, and a startup journal would add a second authorization-bearing file to the trust model for a case whose worst outcome is "human re-grants one tag". Noted, not journaled.

GPT BLOCKING 3 (alias mirroring after the pinned save) — not changed this push: the ordering it proposes (mirror aliases before the pinned save, roll back if refused) touches the shared slot-save path that every directive uses, not just chat_tag; if it is a real stale-flush window it is a class defect of session_directive_apply, and I would rather fix it there against main with its own test than inside this feature. Investigating separately.

Design CONCERNS (no live turn showed the [BOARD] line) — noted; the assembly is pinned at build_message and resolve_board_tags is unit-tested, but a chat_runner-level resolve→build test is a fair ask and is queued behind the RFC decision so the wiring it pins is the final one.

PR test files + registry/context/sandbox suites 1,997 passed; black/isort/flake8/mypy and all repo gates green on the changed files.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

f93b85d21 → 63754e0f1.

First-Principles is now CONCERNS, not BLOCK (the default is "arguably product shape"); it clears with #11175 or the override. Item 6 (agent field has no sender) stays recorded as API-only v1.

Design watch 2 (store-unavailable indistinguishable from a policy denial) — upheld and fixed: chat_tag_grants.store_degraded() reports why the serving snapshot is degraded (unreadable, missing, or quarantined — the last sticks for the life of the process, because the re-seeded store is healthy but every custom grant it held is gone). The applier routes every store-derived refusal through one helper: when the store is degraded and the tag has no row, tag_policy_denied / not_a_status_tag / status_identity_unprotected all become tag_grants_unavailable:<id>, and the tool description tells the agent to send the user to the tag manager rather than report a reservation. A tag that still has a row keeps its real policy answer. Two new tests (unreadable → gone → healthy re-seed; quarantine sticks for the boot); the successful writer install clears the flag.

Design watch 1 (upgrade leaves customized boards degraded, recovery not discoverable) — agreed and disclosed; the fix is the #7774 tag-manager control. Release-note text for the double-toggle recovery belongs with the release that ships this, so I have not put it in this diff.

GPT BLOCKING (journal the cross-store transaction) — as dispositioned on the previous head: the residual state after a compensation failure is fail-closed and self-heals on the next successful PATCH; a startup journal would add a second authorization-bearing file to the trust model. Not re-arguing further here; if a maintainer wants the journal, say so and I will add it.

PR test files + registry/context/sandbox suites 1,999 passed; black/isort/flake8/mypy and all repo gates green on the changed files.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

63754e0f1 → ae7288d87 — one fix, and then this PR pauses for decisions rather than more pushes.

Design watch 2 (security.md has no entry for the tag-grants leaf) — upheld: added the keystone-leaf bullet in the module spec's format (what the leaf holds, why the record is the authorization, both fences + pre-creation, who legitimately opens it, and the store's own defences beneath the fence), and added tag-grants to the enumerated home-prefix list.

GPT BLOCKING (status: false on a row-less attached tag bypasses the identity refusal) — the finding is correct and it is the mirror image of the FINDING that produced the is True check two heads ago: for a row-less tag the ONLY statusness signal is agent-writable tags.json, so either the applier trusts it (and a forged false slips a state past the strip) or it refuses every row-less attached tag (and on an upgraded install set_state refuses on any session carrying an ordinary custom label). Those are the two horns of RFC #11175 open question 3 (trust the human's toggle / require recorded provenance), so I am not flipping the code between them again; the RFC records the choice and this PR follows it.

Remaining reds are all decisions, none of them code I can make on my own:

  1. Default-on agent self-tagging (First-Principles BLOCK) — merge docs(rfc): agent self-tagging on the board — design of record for #7779 #11175 (in-progress) or record /ai-review override first-principles.
  2. Row-less tags: trust tags.json for statusness, or refuse (GPT BLOCK) — RFC docs(rfc): agent self-tagging on the board — design of record for #7779 #11175 Q3; v1 as written is "human action as consent".
  3. Ship dark on upgrade (Design watch 1) — every pre-existing tag human-only until re-minted, recovery via status toggle / API in v1; needs explicit acceptance or the feat: agent-driven board organization — governed self-tagging, per-tag agent policy, and a [BOARD] context line #7774 re-mint control first.
  4. add-only has no shipped producer (FP item 5) — keep as API-only v1 (RFC), or drop the tier.

Until a maintainer answers those on #11175 or here, further pushes only re-run the lanes; I will rebase and follow whatever is decided.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (23 commits) after the base moved to CONFLICTING — one conflict in security.md where main revised the live_target.json bullet next to the new tag-grants entry; both kept. No code changes; the decisions listed above still gate this PR. PR suites 2,040 passed; all gates green.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

f5b56e525 → 7ee71f915. One exception to the hold, because this one is a real defect rather than a decision:

GPT BLOCKING (a transient read error at boot quarantines valid grants) — upheld and fixed at class level. _load_store_key now distinguishes a file that exists but cannot be READ this instant (OSError → new GrantStoreTransientReadError) from one that reads fine but is not a key this module wrote (malformed → (None, False) as before). The boot pass returns without touching either file on a transient error at the key OR the document (zero grants for this boot, store reads degraded, next readable boot finds every custom grant intact); only a successfully read but cryptographically invalid or malformed document is quarantined. The same class existed on the writer path — a transient key read used to look like "absent" and minted a fresh key over the valid one, orphaning every signed row — and now surfaces the failure instead. Three new tests (key/store transient at boot; writer does not clobber the key), all failing on the previous head.

Design's watch (governance layer without its control surface) is decision 3 on the list above and unchanged. The hold on decision-shaped findings stands.

PR suites 2,043 passed; black/isort/flake8/mypy and all repo gates green on the changed files.

… + [BOARD] context line

An agent can now move its OWN session between workflow-state tags (and
add/remove ordinary tags) through a stateless chat_tag session directive,
under backend-enforced governance (issue kirodotdev#7774 v1):

- chat_tag MCP tool (control.py) modeled on set_project; registered in
  DIRECTIVE_TOOLS; applied via session_directive_apply through the
  existing tags_write_lock -> validate_folder_tag_ids ->
  save_slot_off_loop chokepoint, SEL-audited.
- Per-tag agent policy (agent: add-remove | add-only | none) resolved in
  chat_tags.agent_tag_policy; status:True tags default add-remove so the
  workflow set works with no vocabulary migration; user tags default
  human-only.
- set_state enforces workflow mutual exclusivity across all status:True
  tags; refuses (never silently strips) a human-only status peer.
- Named refusals: tag_policy_denied / unknown_tag / no_op; success result
  returns the resulting tag list (first agent-readable tag surface).
- Cron/subagent turns refused via _USER_SURFACE_DIRECTIVES.
- [BOARD] context line injected per turn (tags + agent-writable set),
  resolved in chat_runner alongside folder_path.

Part of kirodotdev#7774 (v1 of 2 — does not close the issue).
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (70 commits) after the base moved to CONFLICTING — one import-order conflict in context.py (main added agent_spec_format beside the new board_tag_grammar import); both kept. No code changes; the decisions listed above still gate this PR. PR suites 2,091 passed; all gates green.

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

Labels

allow-fork-workflow-change fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants