Skip to content

test(work-ledger): pin the file fence end to end, document in RFC - #11203

Merged
iamwhatever merged 1 commit into
mainfrom
fix/work-ledger-fence-test-9083
Sep 16, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/work-ledger-fence-test-9083

Conversation

@CrysisDeu

Copy link
Copy Markdown
Contributor

What

Pins the <data_home>/work-ledger/** file fence end to end through the tool gate, and documents the mechanism in the conductor work-ledger RFC (a §Security considerations row and a Phase 2 exit criterion).

Why

#9083 was deferred from the #8855 design review: a worker is a full-capability agent with fs_write, so the tool layer's writer-ownership rule (worker owns status/summary/artifacts/pr; conductor owns acceptance/verdict/state/decision) is only as strong as the file fence under it. A prompt-injected worker that could open items/it_*.json directly would forge state: accepted, gut acceptance before the conductor's evaluator runs, or read a sibling item past read_work_brief's scoping.

Preflight found that the fence itself already shipped in #9152 ("work-ledger" is a directory leaf in _CREW_SECRET_LEAVES in src/kiro_crew/security/paths.py, and in sandbox._CREW_HIDDEN_LEAVES). What the issue asked for and was still missing:

  • a test that drives the gate on real ledger files (the existing test only checks is_sensitive_path on hand-written ~/.kiro/crew/... spellings, which never exercises the KIROCREW_HOME re-anchoring or the store's own writer), and
  • the RFC row "A worker edits the ledger files directly" plus the Phase 2 exit criterion.

How

  • test/test_work_ledger_tools.py: new test_a_worker_edit_of_its_own_item_file_is_refused_and_the_store_still_writes. Dispatches the two-conductor two-worker fixture, then drives HookManager.on_tool_call with tool_kind="edit" on the worker's item file, its binding file and the conductor record, and tool_kind="read" on its own and a sibling's item. Every call is TOOL_DENY with a sensitive-path reason. It then asserts the sanctioned writers still reach the same file: the worker's work_report route and the conductor's apply_conductor_action("decide") both land, and the bytes change. The suite's KIROCREW_HOME override is asserted to be outside ~/.kiro/crew, so the test proves the override anchoring, not the default spelling.
  • Shell writes (echo >, python -c) are deliberately not text-matched by the gate (is_sensitive_bash_command says why); the OS sandbox mask is the shell-side control and the existing _CREW_HIDDEN_LEAVES assertion covers it. The new test's docstring says so.
  • docs/request-for-change/rfc-conductor-work-ledger.md: §Security considerations gains the row naming both planes (file-tool fence via _CREW_SECRET_LEAVES -> _SENSITIVE_HOME_DIRS -> is_sensitive_path -> hooks.on_tool_call; sandbox mask via _CREW_HIDDEN_LEAVES), why it is read AND write, why it is a directory leaf, and why the store's atomic_write is unaffected. Phase 2 exit criteria gain the corresponding bullet.

No production code changes.

Tests

  • timeout 900 python3 -m pytest -n0 test/test_work_ledger_tools.py -x -q -> 51 passed.
  • Mutation check: commenting out the "work-ledger" leaf in _CREW_SECRET_LEAVES turns the edit decision into allow and the new test fails with assert 'allow' == 'deny'; restoring it passes.
  • Not red on the unmodified base by construction: the fence already exists on main, so the regression test is pinned by mutation rather than by base failure.
  • black, isort, flake8, scripts/check_black_formatting.py (post-commit), scripts/check_comment_history.py: all clean.

Other

Backend-only test and docs change, no user-visible UI; labeled no-screenshots.

Co-assignee on the issue is @iamwhatever; no branch or PR from them covered this, so this PR takes the residual items only.

Pattern harvest

Not generalizable: a fence-specific test and RFC row for one directory leaf; the mechanism it pins already exists and is covered generically for the sensitive-path floor.

Closes #9083

…he RFC

The `work-ledger` directory leaf is on the sensitive-path floor and the
sandbox mask, but the only test was a spelling check against hand-written
`~/.kiro/crew/...` paths, and the RFC's security section had no row naming
the mechanism. A worker is a full-capability agent with `fs_write`, so the
tool layer's writer-ownership rule rests on this fence.

- Drive `hooks.on_tool_call` against the real item, binding and conductor
  files of a dispatched worker under the suite's `KIROCREW_HOME` override:
  edit and read are both refused, and the worker's route plus the
  conductor's store action still write the same file. Mutation-verified:
  commenting out the `work-ledger` leaf turns the edit into `allow`.
- RFC §Security considerations: add "A worker edits the ledger files
  directly", naming both planes (file-tool fence, sandbox mask) and why
  shell command text is not matched.
- RFC Phase 2 exit criteria: add the fence criterion.

Closes #9083
@CrysisDeu CrysisDeu added the no-screenshots PR has no visual delta; screenshot gate exempt label Sep 16, 2026
@CrysisDeu
CrysisDeu requested review from a team and buluoray September 16, 2026 05:24
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of df6045638875218e0cccbd349f932b70f2b32f8d — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] df60456

@github-actions

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed df6045638875218e0cccbd349f932b70f2b32f8d — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] df60456

Verdict parsed from the review's SHA-scoped output markers for commit df6045638875218e0cccbd349f932b70f2b32f8d.

False positive or not applicable? A repository writer can comment:
/ai-review override fable df6045638875218e0cccbd349f932b70f2b32f8d: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of df6045638875218e0cccbd349f932b70f2b32f8d and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] df60456

False positive or not applicable? A repository writer can comment:
/ai-review override gpt df6045638875218e0cccbd349f932b70f2b32f8d: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 16, 2026

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved after a full read of the diff on the current head: the change matches the linked issue and body, every load-bearing claim was spot-checked against main, tests pin the behaviour, all review lanes are clean and nothing is left undisposed on this head.

@iamwhatever
iamwhatever merged commit 82db4d2 into main Sep 16, 2026
118 of 127 checks passed
@iamwhatever
iamwhatever deleted the fix/work-ledger-fence-test-9083 branch September 16, 2026 07:00
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 16, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…he RFC (kirodotdev#11203)

The `work-ledger` directory leaf is on the sensitive-path floor and the
sandbox mask, but the only test was a spelling check against hand-written
`~/.kiro/crew/...` paths, and the RFC's security section had no row naming
the mechanism. A worker is a full-capability agent with `fs_write`, so the
tool layer's writer-ownership rule rests on this fence.

- Drive `hooks.on_tool_call` against the real item, binding and conductor
  files of a dispatched worker under the suite's `KIROCREW_HOME` override:
  edit and read are both refused, and the worker's route plus the
  conductor's store action still write the same file. Mutation-verified:
  commenting out the `work-ledger` leaf turns the edit into `allow`.
- RFC §Security considerations: add "A worker edits the ledger files
  directly", naming both planes (file-tool fence, sandbox mask) and why
  shell command text is not matched.
- RFC Phase 2 exit criteria: add the fence criterion.

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

Labels

no-screenshots PR has no visual delta; screenshot gate exempt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

work-ledger: deny agent file writes under <data_home>/work-ledger/ (Phase 2)

2 participants