Skip to content

feat(app-kit): tool gate honours installed apps' credential masks - #37459

Merged
bolichen97 merged 1 commit into
mainfrom
feat/app-seam-gate-adopted-masks
Nov 17, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
feat/app-seam-gate-adopted-masks

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The agent's file tools refuse an installed app's declared credential files, an adopted former built-in's included, exactly as they refuse a shipped built-in's, so moving an app out of the wheel never loosens that fence.

The agent file-tool gate (security.is_sensitive_path and the write gate) read only the shipped built-ins' credentialMasks (credential_masks.declared_crew_leaves(installed=False), a static row list). An installed app's declaration reached the OS sandbox mask and nothing else. Concretely (security finding from the wave-7 pin phase, not overridden): kirocrew-app-ops-mission-control (main 5883fd43d4) keeps its provider tokens in data/secrets/ behind "credentialMasks": ["secrets/"]. After adoption, is_sensitive_path(<home>/apps/ops-mission-control/data/secrets/secrets.json) is False, while today's <home>/ops_mission_control_secrets.json is True: on a host with no sandbox backend, or for any reader that only consults the gate, the adopted store is open.

Why it matters

Adoption must be byte-equivalent for protection (#26967). Without this, pinning Ops Mission Control (and any other former built-in that keeps a credential under credentialMasks) trades a gate-fenced credential for a sandbox-only one, so its next pin PR is blocked on a security regression.

Not a goal

  • Moving the wheel copy's Ops Mission Control store or removing its core rows (ops_mission_control_secrets.json stays fenced: the external repo keeps that file as its downgrade backup). That is fix: move ops secret store under its data dir and declare its mask #34296's lane.
  • Changing what the OS sandbox masks, sensitive_home_dirs(), or any fence derived from it (the ENFORCED harness credential mask, the posture page).
  • Changing adoption-pins.json, the catalog, or any built-in's manifest.
  • Making an installed app.json tamper-proof (the stated residual of §37).

What changed (motivation → approach → change)

Owner ruling 3 in #26967 (comment 6713005850: app-declared masks under the app's own data dir, tightening only) and ruling 6841699202 (no user impact) cover this seam. It follows the shape #33589 gave the write gate for agentReadOnlyDirs.

  • credential_masks.tool_gate_crew_leaves() / tool_gate_home_rows() (ToolGateLeaves): every installed tree's and retained record's masks, at data/ and the move-aside spelling. Fails closed only over the app's own data: an app.json or record that is present but does not read cleanly fences that app's whole data dir (unreadable, no artifact rule); an apps/ that cannot be listed fences apps/. Names come from location, so no row can leave apps/<name>/data/.
  • security.paths._matches_gate_rows, in the read gate, the write gate and the inline worker-thread gate: resolves the path once, matches the static list, then the listed rows, then the artifact rule over _KEYSTONE_ARTIFACT_PARENTS plus the declared leaves' directories. An installed mask costs one anchor lookup; a row the static lists already hold (a built-in's record) is left out. path_contains_sensitive adds the rows to its targets.
  • paths_targets: the write gate's one-off listing becomes _AppRowsListing / _listed_rows, shared by both declarations. Listed on the mc-pathres threads within the rebuild budget (inline for the worker-thread gate), a miss refuses as a stall, a listing is reused for a second, and remember_declaration bumps declarations_generation so a recorded install, adoption, update or uninstall is seen on the next check without a restart. No check is served rows from an earlier generation: it never joins a listing begun before the change, a listing the change overtook is taken again within the same budget, and one overtaken twice refuses as a stall. A pooled listing that starts after KIROCREW_HOME changed refuses rather than list another data home (_list_for_home).
  • App Kit seam level 10 (apps/app_sdk_level.py, mirrored in website/src/app-sdk/sdkLevel.ts): below it an installed app's masks are sandbox-only, so scripts/adoption_pin.py reports any credentialMasks as a level-10 use and a former built-in that declares one is pinned at minAppSdkLevel 10. Level 9 is already in the v0.13.0 release candidates.
  • Specs and docs: app-kit-platform.md §32 / §37, security.md, manifest-reference.md, api-reference.md; security line-budget row.

Built-ins moved onto the seam: none needed. The one shipped declaration (md-notebook state/) already reaches the gate through the static rows, unchanged. No per-app decoupling row shrinks: the only Ops Mission Control credential rows name the data-home root file, which the external repo keeps as its downgrade backup, so they must stay. Follow-up: once this lands, Ops Mission Control is pinned in the next pin PR at minAppSdkLevel 10.

Other seam in this batch: #37492 (permissions.chatLaunch) shares level 10; whichever lands second resolves the level summary lines. Overlap: #34296 (named above; commented there with the repo's data/secrets/ path).

Backwards compatibility

Compatible: only an installed (non-shipped) app that declares credentialMasks, or whose manifest is present but unreadable, gains refusals; no shipped built-in, core row or sandbox mask changes. No adoption pin declares credentialMasks today, so the scanner's new level-10 use refuses no existing pin.

Reader: src/kiro_crew/hooks.py:on_tool_call -- chat|subagent|cron -- the agent's file tools now refuse the declared leaf; intended (test_app_credential_masks_tool_gate.py::TestAnInstalledDeclarationIsFenced)
Reader: src/kiro_crew/apps/backend_sdk/paths.py:contains_sensitive_path -- app -- an app's own sweep rooted at its data dir now sees its masked dir; no adopted app calls it (test_a_bulk_root_above_the_mask_contains_it)
Reader: src/kiro_crew/skills_discovery.py:_iter_skill_files -- chat -- inline gate lists on its own thread, no pool submission (test_an_inline_caller_lists_on_its_own_thread)
Reader: src/kiro_crew/security/paths.py:sensitive_write_path_refusal -- chat|subagent -- agentReadOnlyDirs rows unchanged on the shared listing (test_app_agent_readonly_dirs.py::TestTheDeclarationsAreListedWithinADeadline)
Reader: src/kiro_crew/agent_sdk/tool_gate.py:adapter_hidden_credential_dirs -- subagent -- reads sensitive_home_dirs(), which stays static (test_the_static_view_is_unchanged)
Reader: scripts/adoption_pin.py:_seam_level_uses -- release -- no current pin declares credentialMasks (test_builtin_adoption_pins.py::test_the_pin_tool_finds_every_seam_above_level_one)

Tests

  • test/test_app_credential_masks_tool_gate.py (new): file and directory masks, artifacts and the staged copy fenced on both gates and both prefixes; a fail-closed dir fences no .tmp / .lock beside it; TestWhatAMaskCostsACheck (one path resolution per check, one extra lookup per installed mask, a built-in's record costs nothing, tier names); an adopted former built-in's installed declaration; a directory link into the mask (make_dir_link, a junction on Windows); the bulk-root direction; the static view unchanged; a retained record after uninstall; fail-closed cases (unparseable, misnamed, non-object, invalid entry, corrupt record, unlistable apps/); the negative case that ../, absolute and impostor-named declarations fence nothing outside their own data dir; recorded install/uninstall seen at once, an unrecorded one after expiry; one listing per window on and off the loop; inline caller makes no pool submission; a wedged listing refuses as a stall; a check never joins a listing begun before a recorded change, an overtaken listing is taken again, one overtaken twice refuses, and a pooled listing lists only the home it was taken for.
  • Updated: test_app_agent_readonly_dirs.py (shared listing names), test_builtin_adoption_pins.py (level-10 use), conftest_resets.py + conftest.py (listings reset per test), test_conftest_parts_reach.py (every part fixture is bound by its conftest), test_security_sensitive_paths.py (tier-name scan reads _matches_gate_rows), test/integration/test_boot_smoke.py (the credential_masks._generation counter is a documented second-boot change); test_terminal_handler_completion.py and test_folder_steering.py spy on the global os.scandir, which the gate's apps/ listing also calls, so each now judges only its own directory's listings.
  • Determinism: the new file passed 10 serial repeats, its classes in reversed order, and -n 4 --dist load; the clock is patched, the held listings are Events with bounded waits and a bounded join, the cost tests count calls rather than time them. The four generation tests fail on the parent's _listed_rows (a stall refusal, two unfenced answers, a missing helper) and pass on this head.

Proof: not provable -- other: feat PR; the new tests fail on main because the gate never read installed declarations

Local: the 33 test modules that reference paths_targets, credential_masks or the inline gate, plus test_install_receipt.py, test_facade_mirror_guards.py, test_security_sensitive_paths.py, test_security_gate_liveness.py and the updated modules, at -n 6: green apart from test_the_seatbelt_profile_is_the_golden, which fails identically on a pristine origin/main worktree. test_boot_smoke.py::test_a_second_boot_touches_only_known_module_globals passes with KIROCREW_INTEGRATION=1. mypy, flake8, isort, black, comment-history, brand, harness-parity, line-cap, flake-pattern ratchet and docs-lint gates clean; semgrep is not installed on this host, and no autouse fixture in the new file requests monkeypatch.

Manual verification

N/A. Unit coverage is sufficient: the change is the path gate's decision, which the tests drive directly.

Related Issues

Part of #26967
Ruling: #26967 (comment) (item 3), #26967 (comment)

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|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)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

@bolichen97

Copy link
Copy Markdown
Contributor Author

Campaign note (#26967): authorized by owner ruling 3 (#26967 (comment)) and #26967 (comment). Follow-up once this lands: Ops Mission Control is pinned in the next pin PR at minAppSdkLevel 9 (the pin scanner now reports credentialMasks as a level-9 use). Layout alignment with #34296 posted there: #34296 (comment)

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/paths.py

  • src/kiro_crew/security/paths_targets.py

  • @bolichen97 posted a complete reasoning template for 687e1ed.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 687e1ed54ea2ab2a1415b18c036fe9888499f01a — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check. The only frontend change is the SDK level constant (APP_SDK_LEVEL = 9 → 10), which adds no control, label or state, so no screenshot was needed.

[UX-REVIEWED] 687e1ed

Description read

[DESCRIPTION-READ] 9e62f6fad13f9674faa86646e5e4065d7fac3bddd426d975ae01960d9810825c

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 687e1ed54ea2ab2a1415b18c036fe9888499f01a — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: it closes a real gap between the gate and the sandbox, it only adds refusals, and it reuses the listing that the write gate's agentReadOnlyDirs already runs on.

Notes

  • When the apps/ listing stalls, _matches_gate_rows now refuses every read path, even though no listed row can sit outside apps/<name>/data/. A slow app listing therefore blocks the agent's file tools for unrelated paths like /tmp/x, where before only the write gate was affected. Limiting the stall refusal to paths under <home>/apps/ would keep the fail-closed guarantee and make the failure much smaller.

[DESIGN-REVIEWED] 687e1ed

Description read

[DESCRIPTION-READ] d81fb2d6392f9adc0e8134eb6008e31d8bc8065e2477a1defb779d36d9048ffe

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 687e1ed54ea2ab2a1415b18c036fe9888499f01a — 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 does not.

First-Principles-Verdict: PASS

Nothing blocks. One note: the generation and overtake machinery is more than a 1-second reuse window calls for.

Notes

  • Item 5 — oversized: the old listing accepted "Only a declaration added within this window can be missing from the tool gate". This PR adds _generation, _bump_generation (3 production writers: manager_install.py:854, manager_uninstall.py:202, manager_records.py:787), the two-pass "overtaken" loop in _listed_rows and _list_for_home, all to close a window of at most _APP_ROWS_TTL_SECS = 1.0. Within that second a just-installed app has written no credential yet. Subtraction: drop the generation check and the for _attempt in range(2) retry, and keep the TTL-only reuse the agentReadOnlyDirs listing already ran on.

What this change ships

Inventory (8 items) — 7 justified

Intent: the agent's file tools keep refusing a former built-in's credential files after it moves out of the wheel into an installed app. This is a FIX.

  1. The agent's file tools refuse an installed or adopted app's declared credentialMasks files, both read and write — justified
  2. The .tmp / .lock publish artifacts beside a declared mask are refused — justified
  3. A present but unreadable app.json or record fences that app's whole data directory, and an unlistable apps/ fences apps/ — justified
  4. A bulk directory sweep rooted above a mask now counts it as sensitive (path_contains_sensitive) — justified
  5. A recorded install, update or uninstall retires the cached listing at once, and a listing it overtook is taken again — oversized
  6. The write gate's agentReadOnlyDirs listing is folded into the shared _AppRowsListing — justified
  7. App SDK level goes to 10, and the adoption-pin scanner treats any credentialMasks as a level-10 use — justified
  8. sensitive_home_dirs() stays static, so the sandbox and posture fences are unchanged — justified

[FIRST-PRINCIPLES-REVIEWED] 687e1ed

Description read

[DESCRIPTION-READ] b54966ec3ef83fbc2117e5f59512705713388fb67b75453aeea6a9a86ce05318

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 687e1ed

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 687e1ed54ea2ab2a1415b18c036fe9888499f01a false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does 687e1ed54ea2ab2a1415b18c036fe9888499f01a newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: adjudicated, zero confirmed regressions.

Security scope review -- adjudicated candidates

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

No candidate flipped from allowed to refused.

Scope-Verdict: PASS

Reason: The stricter rule is in the agent's file-tool path gate (read, write, inline and bulk-root checks). The shell deny composite never consults that gate, so no shell candidate can flip, and the classifier has no verdict to give on the guard that actually changed. That guard is named under UNADJUDICATED, and its one plausible over-refusal (a whole app's data/ fenced when its manifest fails to parse) is a narrowing I can argue but not confirm.

TIGHTENING: the agent file-tool sensitive-path gate (paths._matches_gate_rows, now used by sensitive_path_refusal, sensitive_write_path_refusal, is_sensitive_resolved_path and path_contains_sensitive) now also matches rows listed from installed apps' credentialMasks -- the threat is an agent's file tools reading or writing the credential files of an installed or adopted app, which only the OS sandbox masked before: "An installed app's declaration (every installed tree and retained record, so an adopted former built-in's too; seam level 10) reaches the read and the write gate through a listing instead … paths._matches_gate_rows matches credential_masks.tool_gate_home_rows() after the gate's static list".

ADJUDICATED: 17 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: I wrote candidates for posix, windows and any. The diff's platform assumptions are both data-home prefixes (.kiro/crew, .kirocrew), KIROCREW_HOME re-anchoring, and $HOME against USERPROFILE. The posix rows cover ~/.kiro/crew, ~/.kirocrew and "$KIROCREW_HOME" paths. The windows rows cover the same spellings with %USERPROFILE%, $env:USERPROFILE (PowerShell), %KIROCREW_HOME% and \ separators, plus a .venv\Scripts\python.exe test run. The any rows are python3 scripts/adoption_pin.py verify and kirocrew app list. Every path row sits right next to a masked leaf: undeclared siblings, app.json, the apps/ listing. They cannot carry the real boundary, because that boundary is in a gate the shell classifier does not run. I wrote no candidate for the move-aside spelling apps/.<name>-data-tmp/, or for case-folded Windows aliases and 8.3 short names of the new rows.

UNADJUDICATED: The guard is security.paths._matches_gate_rows, fed by paths_targets._app_credential_mask_rows → _listed_rows(_APP_CREDENTIAL_MASK_ROWS) → credential_masks.tool_gate_home_rows() → tool_gate_crew_leaves() → _read_declaration. Inputs reach it through the agent's read/write/edit file tools (sensitive_path_refusal / sensitive_write_path_refusal), through the worker-thread inline check (is_sensitive_resolved_path, used by bulk walks, indexers, folder steering and terminal completion, which the edited tests show), and through the bulk-root check (path_contains_sensitive). These are the legitimate inputs I would have submitted, and none could be classified:

  • Read or edit apps/<name>/data/notes.md while that app's app.json is unparseable or mid-rewrite, has one invalid credentialMasks entry, or carries a name that differs from its folder. _read_declaration returns clean=False, and the whole data/ plus the move-aside folder is refused, including files that are not credentials. This is fail-closed by design, but it is a broader refusal than the named threat. It could be narrowed by fencing only the valid entries plus the invalid entries' parents, instead of all of data/.
  • Any file-tool access under apps/ at all while apps/ exists but cannot be listed (permissions, a stray file at that name). ToolGateLeaves((), ("apps",)) fences every app's data and every app's app.json.
  • Any file-tool check, including workspace files outside the data home, while the listing misses _APP_ROWS_BUDGET_SECS or a recorded install races the listing twice. It refuses as a stall unless a static row matched (test_a_listing_overtaken_twice_refuses_as_a_stall).
  • A pooled listing submitted under one KIROCREW_HOME that runs after the variable changed (_list_for_home). The check refuses as a stall.
  • Bulk-root acceptance of apps/<name>/data when the root folder contains a declared mask (path_contains_sensitive now refuses it; test_a_bulk_root_above_the_mask_contains_it). An indexer pointed at an app's data root loses it.
  • Atomic-write .tmp / .lock artifacts in a declared leaf's directory. For a directory entry like "state/" that directory is data/ itself, so every *.tmp or *.lock an app or agent writes directly in data/ is refused (test_a_directory_mask_covers_everything_beneath_it asserts data/index.lock is fenced).

[SCOPE-REVIEWED] 687e1ed

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 687e1ed54ea2ab2a1415b18c036fe9888499f01a and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 687e1ed

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 687e1ed54ea2ab2a1415b18c036fe9888499f01a false-positive: <reason, 20 to 500 characters>

@KiroCrewCaptain

KiroCrewCaptain commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider thinks the change is probably fine but estimates a 20% chance that this change introduces a defect, above the 12% limit for approving on its own.

The agent's file tools now refuse an installed app's declared credential files, so adopting a former built-in no longer loosens that fence. This covers the read gate, the write gate, the inline worker-thread gate and the bulk-root check. Every recorded install, update and uninstall bumps a generation counter, so the gate drops an older list of declarations on the next check. Tests cover joining an old listing, being overtaken once and being overtaken twice; this fixes the blocking finding from GPT's review of the earlier head. Listed rows can only name paths under the app's own data directory or its staged copy. A manifest or record that can't be read fences only that app's data. sensitive_home_dirs() stays static, the renamed private symbols have no readers left, and the target cache is keyed on list contents. Test coverage is thorough. Residual risks are design trade-offs: a slow apps listing can now refuse ordinary reads as a stall, and some app-side reads gain refusals. I found no concrete regression or fail-open path. Test CI was still pending at review time.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 01e56786ea · 1234 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 15, 2026
@bolichen97
bolichen97 force-pushed the feat/app-seam-gate-adopted-masks branch from 95ebcaf to 5d889cf Compare November 15, 2026 03:59
@bolichen97

Copy link
Copy Markdown
Contributor Author

Review issue 1 — fail-closed fence reached *.tmp / *.lock outside the app's data dir: fixed in 5d889cf

The artifact rule now comes only from declared leaves. credential_masks.tool_gate_crew_leaves() returns ToolGateLeaves(declared, unreadable), and paths_targets._list_app_credential_mask_rows derives artifact parents from declared alone. A directory fenced because its declaration could not be read gets prefix fencing only.
Your probe, re-run with apps/demo/app.json = {not json: apps/.dev-apps.json.lock, apps/x.tmp, apps/demo/app.json.tmp and apps/demo/x.lock are now False. apps/demo/data/* (temps included) stays True, and a neighbour's data stays False. Pinned in test_a_malformed_manifest_fences_only_its_own_data.
On the related point: a directory entry still fences the .lock / .tmp files in data/. That matches the built-ins' static rows (_KEYSTONE_ARTIFACT_PARENTS is derived from directory leaves too), so it stays. manifest-reference.md now says "in the folder that holds each one (for "state/", that is data/)". Pinned by the data/index.lock assertion in test_a_directory_mask_covers_everything_beneath_it.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Review issue 2 — _forget_app_declared_row_listings was never registered: fixed in 5d889cf

The fixture is now in test/conftest.py's from conftest_resets import list. pytest --setup-plan on TestARecordOutlivesTheManifest::test_data_kept_by_an_uninstall_stays_fenced now shows SETUP F _forget_app_declared_row_listings.
The general problem is a fixture defined in a conftest part that its conftest never imports. This was the only case: all 13 parts were checked. The new guard test_conftest_parts_reach.py::test_every_fixture_a_part_defines_is_bound_by_its_conftest keeps it from coming back. Without the import line, it fails and names this fixture.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Review issue 3 — the app pass doubled the read/write gate's cost: fixed in 5d889cf

The fix combines two of your suggestions: one set of candidate forms is reused across the passes, and the leaves the static rows already hold are dropped.

  • One resolution per check. paths._matches_gate_rows resolves the path once (_candidate_forms) and hands that set to the static list, the listed rows and the artifact rule. The artifact rule uses _KEYSTONE_ARTIFACT_PARENTS with the declared leaves' directories added.
  • Covered rows dropped. paths_targets._list_app_credential_mask_rows leaves out every row the static lists already hold. A built-in's record therefore lists nothing.
    Measured per read check, as _candidate_forms / _home_dir_targets calls:
  • no apps: 1/2 (main: 2/2)
  • a built-in's record: 1/2 (PR head: 4/4)
  • an installed state/ mask: 1/3 (PR head: 4/4)
    Pinned by TestWhatAMaskCostsACheck.
    The static list is still matched before the listing is taken, so a wedged pool or a stalled anchor refuses before any wait on the listing. A listing stall still refuses as a stall unless a static row matched.
    I first tried folding the rows into the static list itself. It reordered the listing ahead of the static pass, and test_security_path_gate_under_load and test_security_path_resolve_bounded caught it, so I dropped that approach.

@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 15, 2026
@buluoray

Copy link
Copy Markdown
Contributor

Review notes on head 5d889cf. These are the CI reds that come from this PR's own new code, collected in one place. The GPT 6.1 lane's open finding is not repeated here.

  1. Windows: the test fixture does not redirect the Windows home. New-test stability (windows-latest), job 132693864256: test/test_app_credential_masks_tool_gate.py::TestAnInstalledDeclarationIsFenced::test_at_both_data_home_prefixes[.kiro/crew] and [.kirocrew] fail. The fixture at test/test_app_credential_masks_tool_gate.py:37-50 sets HOME and patches Path.home, but not USERPROFILE, so ~ expands to the runner's real profile on Windows. Setting USERPROFILE too (or using the shared home-isolation fixture) should fix it.

  2. Semgrep: autouse fixtures patch through the shared monkeypatch. SAST (Semgrep), job 132692364657: rule kirocrew.test-autouse-shared-monkeypatch flags the _counted autouse fixtures at test/test_app_credential_masks_tool_gate.py:212 and :274. The rule asks for _floor_monkeypatch there.

  3. Second-boot check: a new module-level counter. Integration (in-process gateway), job 132693864445: test/integration/test_boot_smoke.py::test_a_second_boot_touches_only_known_module_globals reports ('kiro_crew.apps.credential_masks', '_generation'). The counter at src/kiro_crew/apps/credential_masks.py:155 needs a reset entry, or a documented row in _KNOWN_SECOND_BOOT_CHANGES.

@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 Nov 15, 2026
@bolichen97
bolichen97 force-pushed the feat/app-seam-gate-adopted-masks branch from 5d889cf to 01e5678 Compare November 15, 2026 06:47
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 15, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 01e5678
  • What rule changed: the agent file-tool read and write gates (security.paths._matches_gate_rows, used by sensitive_path_refusal, sensitive_write_path_refusal, is_sensitive_resolved_path and path_contains_sensitive) also refuse the credentialMasks leaves of INSTALLED app trees and retained records (an adopted former built-in's included), listed per check by paths_targets._app_credential_mask_rows within the path-resolution budget. The listing is never served from an obsolete declarations generation and a pooled listing lists only the data home it was submitted for.
  • Before -> after (what was allowed/blocked, now): before, only the shipped built-ins' declared leaves (static rows) were refused, so <home>/apps/<app>/data/secrets/secrets.json of an installed app declaring secrets/ was readable by the file tools. After, that leaf, everything beneath it, its .tmp/.lock publish artifacts and the move-aside copy are refused on both gates and both data-home prefixes; an unreadable app.json/record fences only that app's data dir; an unlistable apps/ fences apps/; a listing that misses its deadline, or is overtaken twice by a recorded install, refuses as a stall. Nothing that was refused before is allowed now.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a false refusal on an installed app's own data files (a malformed manifest fences that app's whole data dir), or a brief "could not be verified, try again" refusal while an install is recorded concurrently. No secret is exposed that was fenced before, no core row or sandbox mask changes, and sensitive_home_dirs() (the ENFORCED harness mask, posture page) keeps its static scope.
  • Evidence checked (which sandbox result proves it): no sandbox behaviour changes (the OS sandbox already masked these leaves from the same declaration); the gate decision is proven by test/test_app_credential_masks_tool_gate.py (30 tests) including the negative case that ../, absolute and impostor-named declarations fence nothing outside their own data dir, and the three generation tests that fail on the parent's _listed_rows.
  • No regression:
    • Tools still work (which tools/commands were run, result): the read/write/inline gates run against workspace paths, undeclared siblings, app.json and the data-home root in the tests and are not refused; test_app_agent_readonly_dirs.py shows the write gate's agentReadOnlyDirs listing unchanged on the shared listing; TestWhatAMaskCostsACheck pins one path resolution per check and one extra anchor lookup per installed mask.
    • Backward compatible (old config / old data / old callers still work, how checked): no config or data migration; a host with only the shipped built-ins checks exactly the static lists (test_a_built_ins_own_record_costs_nothing); no current adoption pin declares credentialMasks, so the level-9 scanner use refuses no existing pin (test_builtin_adoption_pins.py).
    • Existing tests (which suites passed on this head): locally the 33 modules referencing paths_targets / credential_masks / the inline gate plus test_security_gate_liveness.py, test_facade_mirror_guards.py, test_paths_facade.py, test_install_receipt.py, test_security_sensitive_paths.py and the integration second-boot witness; CI for this head is running.
  • How to undo: revert this single commit; the gate goes back to the static built-in rows only and the SDK level returns to 8.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Head 01e56786eaaf: Backend Tests (3.12, 6), Backend Tests (Windows) (6), macOS Tests / Backend Tests (macOS) (6) and the Coverage Gate that follows them all fail on the same three nodes, test/metrics/test_kiro_export_destination.py::TestOffOffer::{test_it_is_due_and_changes_nothing,test_the_collection_status_reports_it,test_a_headless_terminal_start_prints_the_line_once}. That is a main red, not this diff: they fail identically on a pristine origin/main worktree at 87b11b5ef2 (this head's base) and at 55b2e4a5e0. It is tracked as #37546 (#37460 and #37463 crossed), and #37545 fixes it. This PR waits for #37545, then rebases onto it. No override is posted for this red.
Every other lane on this head is green so far, including GPT 6.1, Opus, Design, First Principles, UX, SAST, Integration and New-test stability (windows).

@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 Nov 15, 2026
@buluoray

Copy link
Copy Markdown
Contributor

Review passed on this head. Please rebase onto the latest main: the only red tests on this head are main's test/metrics/test_kiro_export_destination.py::TestOffOffer failures (#37546), which #37545 fixed after this run started. The approval will follow once the rebased head is green.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 15, 2026
The agent file-tool gate read only the shipped built-ins' credentialMasks
(a static row list), so an installed or adopted app's declared credential
was fenced by the OS sandbox mask alone. After adoption, Ops Mission
Control's data/secrets/ store would be readable to the agent's file tools
on a host without a sandbox backend, while today's root store is refused.

The read gate, the write gate, the inline worker-thread gate and the
bulk-root check now also match every installed tree's and retained
record's declared masks, with the .tmp/.lock artifacts beside each
declared leaf, listed within the resolver budget, reused for a second
and retired when the gateway records an install, update or uninstall.
Each check resolves the path once for all its lists and matches the
static list before it takes the listing; an installed mask adds one
anchor lookup, and a row the static lists already hold (a built-in's
record) is left out, so a built-in-only host checks what it did. A
manifest or record that is present but does not read cleanly fences that
app's whole data dir, with no artifact rule beside it; an unlistable
apps/ fences apps/. No row can leave the app's own data dir, and
sensitive_home_dirs() keeps only the static rows. The write gate's
agentReadOnlyDirs listing shares the same listing code.

App Kit seam level 10; the pin scanner reports credentialMasks as a
level-10 use, so a former built-in declaring one is pinned at 10.

Part of #26967
@bolichen97
bolichen97 force-pushed the feat/app-seam-gate-adopted-masks branch from 01e5678 to 687e1ed Compare November 17, 2026 09:14
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 17, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 687e1ed
  • What rule changed: the agent file-tool read and write gates (security.paths._matches_gate_rows, used by sensitive_path_refusal, sensitive_write_path_refusal, is_sensitive_resolved_path and path_contains_sensitive) also refuse the credentialMasks leaves of INSTALLED app trees and retained records (an adopted former built-in's included), listed per check by paths_targets._app_credential_mask_rows within the path-resolution budget. The listing is never served from an obsolete declarations generation and a pooled listing lists only the data home it was submitted for.
  • Before -> after (what was allowed/blocked, now): before, only the shipped built-ins' declared leaves (static rows) were refused, so <home>/apps/<app>/data/secrets/secrets.json of an installed app declaring secrets/ was readable by the file tools. After, that leaf, everything beneath it, its .tmp/.lock publish artifacts and the move-aside copy are refused on both gates and both data-home prefixes; an unreadable app.json/record fences only that app's data dir; an unlistable apps/ fences apps/; a listing that misses its deadline, or is overtaken twice by a recorded install, refuses as a stall. Nothing that was refused before is allowed now.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a false refusal on an installed app's own data files (a malformed manifest fences that app's whole data dir), or a brief "could not be verified, try again" refusal while an install is recorded concurrently. No secret is exposed that was fenced before, no core row or sandbox mask changes, and sensitive_home_dirs() (the ENFORCED harness mask, posture page) keeps its static scope.
  • Evidence checked (which sandbox result proves it): no sandbox behaviour changes (the OS sandbox already masked these leaves from the same declaration); the gate decision is proven by test/test_app_credential_masks_tool_gate.py (30 tests) including the negative case that ../, absolute and impostor-named declarations fence nothing outside their own data dir, and the three generation tests that fail on the parent's _listed_rows.
  • No regression:
    • Tools still work (which tools/commands were run, result): the read/write/inline gates run against workspace paths, undeclared siblings, app.json and the data-home root in the tests and are not refused; test_app_agent_readonly_dirs.py shows the write gate's agentReadOnlyDirs listing unchanged on the shared listing; TestWhatAMaskCostsACheck pins one path resolution per check and one extra anchor lookup per installed mask.
    • Backward compatible (old config / old data / old callers still work, how checked): no config or data migration; a host with only the shipped built-ins checks exactly the static lists (test_a_built_ins_own_record_costs_nothing); no current adoption pin declares credentialMasks, so the level-10 scanner use refuses no existing pin (test_builtin_adoption_pins.py).
    • Existing tests (which suites passed on this head): this head is the same change rebased onto main 5c747a0 (seam level 9 to 10, since level 9 is in the v0.13.0 release candidates). Locally, serial: 67 test modules, namely every one that references paths_targets, credential_masks or the read/write gate functions, plus test_security_gate_liveness.py, test_facade_mirror_guards.py, test_paths_facade.py and test_install_receipt.py (6930 passed, 5 skipped); the touched modules plus the adoption-pin, app_sdk_level mirror, manifest and sandbox governance mask suites (1594 passed); mypy, black gate, isort, flake8, line cap, comment-history, brand and docs-lint clean. The integration second-boot witness fails on kiro_crew.hooks._DENIED_STATE_LAST_GOOD, identically on a pristine main worktree, so it is not this change. CI for this head is running.
  • How to undo: revert this single commit; the gate goes back to the static built-in rows only and the SDK level returns to 9.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 17, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving. On head 687e1ed I checked the following. Both the read gate and the write gate now refuse installed and adopted apps' declared credentialMasks, and an unreadable app.json fails closed. Every listed row comes from the app's own location and stays under apps//data, its move-aside, or apps/. sensitive_home_dirs() stays static. The generation and overtake logic never serves or caches a stale listing. The new tests pass, and a mutation pass over 21 of the new invariant lines turned 20 of them red.
Done well: the tests check both sides of every fence. Each refusal comes with a healthy sibling that stays readable, and _fenced_both_ways fails if the two gates ever disagree.
Optional:

  • A stalled apps/ listing makes both gates refuse every path, including paths outside the crew home (paths.py:293-320). Skipping the listing when no candidate form is under /apps would keep the fence and narrow the stall. The Design note on this head is still unanswered.
  • No test covers the KIROCREW_HOME re-check at its call site (paths_targets.py:1293). If you swap the partial(_list_for_home, ...) wiring for the bare lister, all 86 tests in the two touched suites still pass.
  • The body says no adoption pin declares credentialMasks. That is no longer true: #37572 pinned md-notebook at level 8 with state/. #38333 also claims APP_SDK_LEVEL 10, so it would help to name it next to #37492 in the batch note.

@bolichen97
bolichen97 merged commit 382e5b5 into main Nov 17, 2026
114 of 121 checks passed
@bolichen97
bolichen97 deleted the feat/app-seam-gate-adopted-masks branch November 17, 2026 11:14
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 17, 2026
KiroCrewCaptain added a commit to KiroCrewCaptain/kirocrew-app-ops-mission-control that referenced this pull request Nov 17, 2026
Ports every change the built-in got after the af94fac51f sync, so an
adopted record keeps what a built-in user has:

- the ledger's episode import into Crew's memory is skipped while a
  memory provider replaces it (kirodotdev/KiroCrew#37218), through a
  new memory_provider row of the host table; a gateway without the
  resolver indexes nothing
- the Japanese strings without the stray source line breaks
  (kirodotdev/KiroCrew#38368)
- two comment-only changes (kirodotdev/KiroCrew#37469,
  kirodotdev/KiroCrew#37953)

The test pin and docs/spec.md move to KiroCrew main 2e2503671f, and the
fixtures follow the host's scrubber (kirodotdev/KiroCrew#37408) and the
gh PATH probe pin (kirodotdev/KiroCrew#37597). PORTING.md has a row per
core change and records that the pin needs App Kit level 10, where the
agent's file-tool gate fences the credentialMasks directory
(kirodotdev/KiroCrew#37459).

Part of kirodotdev/KiroCrew#26967.

Co-authored-by: KiroCrewCaptain <312312717+KiroCrewCaptain@users.noreply.github.com>
bolichen97 added a commit that referenced this pull request Nov 17, 2026
Agent Worlds and Ops Mission Control now live in their own
repositories under KiroCrewCaptain, carrying every wheel-copy change on
main, with green CI on ubuntu, macOS and Windows. Their rows are the
output of scripts/adoption_pin.py compute and are added to
adoption-pins.json and the _SHIPPED_PINS table, so a host whose record
is builtin-owned moves onto the app's own tree at its next restart and
keeps data/, the app secret, the grants, the crons and enabled.

Agent Worlds is pinned at minAppSdkLevel 8, the level of the
useHostSessions export its page calls. Ops Mission Control is pinned at
10: its tree keeps the provider tokens in data/secrets/ behind a
credentialMasks directory entry, which the agent's file tools fence
from that level (#37459); it copies the data-home root store in on
first read and keeps it as the downgrade copy.

Each wheel built-in app.json version moves to its pinned version, since
a first-adoption pin must equal it (D12). Both repositories declare the
same permissions as their wheel copy (Ops Mission Control adds only the
mask, which narrows), so E9 holds nothing back. The owning specs record
the adoption.

Part of #26967
bolichen97 added a commit that referenced this pull request Nov 17, 2026
Agent Worlds and Ops Mission Control now live in their own
repositories under KiroCrewCaptain, carrying every wheel-copy change on
main, with green CI on ubuntu, macOS and Windows. Their rows are the
output of scripts/adoption_pin.py compute and are added to
adoption-pins.json and the _SHIPPED_PINS table, so a host whose record
is builtin-owned moves onto the app's own tree at its next restart and
keeps data/, the app secret, the grants, the crons and enabled.

Agent Worlds is pinned at minAppSdkLevel 8, the level of the
useHostSessions export its page calls. Ops Mission Control is pinned at
10: its tree keeps the provider tokens in data/secrets/ behind a
credentialMasks directory entry, which the agent's file tools fence
from that level (#37459); it copies the data-home root store in on
first read and keeps it as the downgrade copy.

Each wheel built-in app.json version moves to its pinned version, since
a first-adoption pin must equal it (D12). Both repositories declare the
same permissions as their wheel copy (Ops Mission Control adds only the
mask, which narrows), so E9 holds nothing back. The owning specs record
the adoption.

Part of #26967
bolichen97 added a commit that referenced this pull request Nov 17, 2026
Agent Worlds and Ops Mission Control now live in their own
repositories under KiroCrewCaptain, carrying every wheel-copy change on
main, with green CI on ubuntu, macOS and Windows. Their rows are the
output of scripts/adoption_pin.py compute and are added to
adoption-pins.json and the _SHIPPED_PINS table, so a host whose record
is builtin-owned moves onto the app's own tree at its next restart and
keeps data/, the app secret, the grants, the crons and enabled.

Agent Worlds is pinned at minAppSdkLevel 8, the level of the
useHostSessions export its page calls. Ops Mission Control is pinned at
10: its tree keeps the provider tokens in data/secrets/ behind a
credentialMasks directory entry, which the agent's file tools fence
from that level (#37459); it copies the data-home root store in on
first read and keeps it as the downgrade copy.

Each wheel built-in app.json version moves to its pinned version, since
a first-adoption pin must equal it (D12). Both repositories declare the
same permissions as their wheel copy (Ops Mission Control adds only the
mask, which narrows), so E9 holds nothing back. The owning specs record
the adoption.

Part of #26967
bolichen97 added a commit that referenced this pull request Nov 17, 2026
…8443)

Agent Worlds and Ops Mission Control now live in their own
repositories under KiroCrewCaptain, carrying every wheel-copy change on
main, with green CI on ubuntu, macOS and Windows. Their rows are the
output of scripts/adoption_pin.py compute and are added to
adoption-pins.json and the _SHIPPED_PINS table, so a host whose record
is builtin-owned moves onto the app's own tree at its next restart and
keeps data/, the app secret, the grants, the crons and enabled.

Agent Worlds is pinned at minAppSdkLevel 8, the level of the
useHostSessions export its page calls. Ops Mission Control is pinned at
10: its tree keeps the provider tokens in data/secrets/ behind a
credentialMasks directory entry, which the agent's file tools fence
from that level (#37459); it copies the data-home root store in on
first read and keeps it as the downgrade copy.

Each wheel built-in app.json version moves to its pinned version, since
a first-adoption pin must equal it (D12). Both repositories declare the
same permissions as their wheel copy (Ops Mission Control adds only the
mask, which narrows), so E9 holds nothing back. The owning specs record
the adoption.

Part of #26967
bolichen97 added a commit that referenced this pull request Nov 17, 2026
The md-notebook adoption row was computed at minAppSdkLevel 8 just
before #37459 made any credentialMasks declaration a level-10 use, so
scripts/adoption_pin.py verify now refuses that row. Recomputed at
the same commit with --min-sdk-level 10: only the level changes; the
commit, version and both digests are identical. The _SHIPPED_PINS
table and the md-notebook spec carry the same level.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants