Skip to content

fix(apps): trace aws-control's job records by kind when it is disabled - #33286

Merged
bolichen97 merged 1 commit into
mainfrom
fix/33163-job-sdk-disable-read
Nov 9, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/33163-job-sdk-disable-read

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Disabling aws-control names each of its stale job runs with its kind in the audit trail, and leaves its finished runs out, instead of tracing every record as unreadable.

When an app is disabled, the Job SDK writes one job_killed_on_disable audit line for each record it is about to delete that was still running. For aws-control every record that is not live gets an unreadable stale line, finished backups included, and no line carries a kind.

Why it matters

That trace is the only lasting answer to "which runs did this disable cut off". For aws-control it names files, says every one of them was unreadable and stale, and cannot say which backup kind was interrupted. Anyone reading the audit after a disable is told something false about runs that had already finished.

Not a goal

What changed (motivation → approach → change)

Every aws-control record read as unreadable because the disable scan read the SDK's own store through safe_read_file_bytes_nolink, the read built for agent-chosen paths. Its path screen refuses the directories the security lists protect, and aws-control's data dir is one of them, so the app's own job records were refused like an agent's request would be.

The scan in JobSDK.remove_all_async opens each record with jsonl_util.open_regular_nofollow and keeps the other checks the old read made on the opened file: a link at the record's name, a non-regular, hardlinked or oversized file, and a file outside the jobs dir (the dir as it resolved when the scan started) are still traced as unreadable. The path screen now depends on where the jobs dir resolves:

Where the jobs dir resolves Path screen A record in a protected location
Its own place under the data home (config_dir()), the operator's links at or above the home resolved waived read, and traced by kind
Anywhere else, such as through a link below the data home kept traced as unreadable

A stale aws-control record gets its kind='…' stale line and a finished one gets none, as in any other app.

The facade kiro_crew.apps.job_sdk keeps offering FileTooLargeError and safe_read_file_bytes_nolink, which the scan no longer calls, because both are in its frozen public inventory (test/campaign_facade_inventories/kiro_crew.apps.job_sdk.json). The scan opens records through the same _open_regular_nofollow binding the retention sweep uses.

Backwards compatibility

Compatible: the trace lines keep their shapes and every other app's records read as before; records under a protected app data dir, which the path screen refused, are parsed and traced by kind when the jobs dir sits at its own place under the data home.

Removes nothing: the disable deletes the same records and writes the same kinds of lines; the scan reads the records the path screen refused instead of tracing them as unreadable.

Tests

Test (test/test_job_sdk.py::TestDisableTrace) What it pins
test_a_protected_app_data_dir_still_traces_each_record_by_kind[False] (new) With the store in aws-control's data dir, it first checks the agent-facing read refuses that directory, then disables with one stale and one finished record and expects exactly one line, the stale run with kind='backup'.
test_a_protected_app_data_dir_still_traces_each_record_by_kind[True] (new) The same, with the default data home reached through a linked host home.
test_a_jobs_dir_linked_into_a_protected_dir_traces_each_record_unreadable (new) Another app whose jobs dir is a link to aws-control's jobs dir traces the stale record it reaches there as unreadable stale, never by kind.

Both directory links are made with make_dir_link (a junction on Windows), so the link cases run on an unelevated Windows shell instead of skipping. The existing link, corrupt, permission-denied and stale-versus-finished tests in the same class pin the checks the read keeps.

Proof: PROVEN test/test_job_sdk.py::TestDisableTrace::test_a_protected_app_data_dir_still_traces_each_record_by_kind[False], test/test_job_sdk.py::TestDisableTrace::test_a_protected_app_data_dir_still_traces_each_record_by_kind[True] (head 11905ae)

Determinism: the three new test ids passed 20 of 20 runs at -n0, and all 72 tests of test_job_sdk.py passed in three shuffled orders (seeds 4817, 22903, 31337). The related backend set (446 tests, including test_campaign_facades_base_public_names.py and test_job_sdk_retention.py) passes at -n auto --dist loadgroup.

Manual verification

N/A — unit coverage sufficient: the tests drive remove_all_async against the real protected path under a temporary data home, which is the whole reachable path.

Related Issues

Closes #33163

Built on #33196 (merged), whose retention sweep reads the same store; this PR does not change that sweep.

Sibling sweep

Swept: git grep -nE "safe_read_file_bytes_nolink(|safe_read_file_bytes(|safe_read_file(" -- 'src/kiro_crew/apps/.py' 'src/kiro_crew/apps/**/.py'
Sibling: src/kiro_crew/apps/job_sdk.py -- changed here
Sibling: src/kiro_crew/apps/builtins/aws_control/crew/packaging/pipeline/crew.py -- not affected -- reads agent specs from the crew source for an export bundle, where the screen is wanted
Sibling: src/kiro_crew/apps/builtins/code_review_sage/sage_lib/store.py -- not affected -- its data dir is not on the security lists

Pattern harvest

Rule candidate: review-prompt
Pattern: a component reading files it owns through the agent-facing read, whose path screen refuses that component's own protected directory

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

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 8, 2026 16:42
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 11905aea6e62690ded4bda2bb4a2a445aab4c26b touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@bolichen97
bolichen97 enabled auto-merge (squash) November 8, 2026 16:44
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks. The waiver is generic and only applies to the SDK's own store at its configured path under the data home. It keeps the nofollow, regular-file, hardlink, size and containment checks, so a linked jobs dir still gets the path screen.

Notes

  • job_sdk.py now imports hooks._opened_path_within_root, a private helper from another module. A small public helper in hooks/pinned_fs that wraps "open the store's own file, checked, without the sensitive-path screen" would stop a third reader from copying this authorize closure. The retention sweep in feat(apps): cap how many finished job records a kind keeps #33196 reads the same store and may need it too.

[DESIGN-REVIEWED] 11905ae

Description read

[DESCRIPTION-READ] 13a08abe730b74a124f57ae9ef4df44c797b2078643251c68c8844465746c3d5

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 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 11905aea6e62690ded4bda2bb4a2a445aab4c26b — 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. The fix reaches the cause: the disable scan was reading the SDK's own store through the agent-facing read, whose path screen refuses aws-control's protected data dir.

What this change ships

Inventory (4 items) — 4 justified

Intent: when aws-control is disabled, the audit trail should truthfully name which of its runs were cut off, by kind. FIX (#33163).

  1. Disabling aws-control now logs each stale run with its kind instead of as unreadable stale — justified
  2. Runs that had already finished no longer get an audit line when aws-control is disabled — justified
  3. A jobs dir reached through a link below the data home still gets the security screen and still logs unreadable — justified
  4. The disable scan opens records with the same no-follow open the retention sweep uses — justified

[FIRST-PRINCIPLES-REVIEWED] 11905ae

Description read

[DESCRIPTION-READ] f3d1cfd9c56dd39724693932350f390429d9bb2119214a97c7ce476bd65170cb

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 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 11905ae

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

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

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 11905aea6e62690ded4bda2bb4a2a445aab4c26b and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 11905ae

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

@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 8, 2026
@bolichen97
bolichen97 force-pushed the fix/33163-job-sdk-disable-read branch from 5fe9169 to 2306f28 Compare November 8, 2026 21:40
@bolichen97

bolichen97 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor Author
  • A linked jobs directory bypasses credential-path protection span=7909c656e6a0

fixed in 2306f28: the disable scan waives the sensitive-path screen only when the jobs dir resolves to its own place under the data home (realpath(config_dir()) plus its path below the home); any other resolution keeps is_sensitive_canonical_path on each opened record's real path.
A link at apps/<app>, its data or its jobs dir, into a credential dir or another app's protected dir, therefore reads nothing sensitive there: each record traces unreadable, as the old reader did.
Pinned by test_a_jobs_dir_linked_into_a_protected_dir_traces_each_record_unreadable, red on 5fe9169 and green on 2306f28; test_a_protected_app_data_dir_still_traces_each_record_by_kind[True] keeps the goal on a host whose home is a symlink.

[operator: bolichen97]

@bolichen97
bolichen97 force-pushed the fix/33163-job-sdk-disable-read branch from 2306f28 to 5a55179 Compare November 8, 2026 23:56
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Directory-link cases skip despite an available portable helper span=8fab883ec707

fixed in 5a55179: both directory links the new tests stage (the linked host home of [True] and the notes jobs dir linked into aws-control's store) are made with make_dir_link, and both requires_symlinks marks are gone, so an unelevated Windows shell runs them on a junction instead of skipping.
Class swept in test/test_job_sdk.py (symlink_to(.*target_is_directory): those two were the only directory links; the remaining requires_symlinks case links a record FILE, which a junction cannot stage.
The first-principles note's dead FileTooLargeError / safe_read_file_bytes_nolink import is dropped in the same head, and the production comment names no app.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 8, 2026
@bolichen97
bolichen97 force-pushed the fix/33163-job-sdk-disable-read branch from 5a55179 to b17ffb0 Compare November 9, 2026 04:47
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto main 456d804 (after #33196 merged in src/kiro_crew/apps/job_sdk.py), now head b17ffb0.

  • Backend shards red on 5a55179 (Linux shard 1, Windows shard 2, Coverage Gate as their echo): this PR's own defect, not a flake. test/test_campaign_facades_base_public_names.py::test_every_base_public_name_resolves_on_its_facade[kiro_crew.apps.job_sdk] and ::test_a_rebound_name_is_the_object_its_home_module_holds failed because the previous head dropped the facade's FileTooLargeError / safe_read_file_bytes_nolink re-exports, which are in the frozen inventory test/campaign_facade_inventories/kiro_crew.apps.job_sdk.json. Fixed in b17ffb0: the facade keeps both names (# noqa: F401), and the scan opens records through the _open_regular_nofollow binding feat(apps): cap how many finished job records a kind keeps #33196 added, so there is one binding rather than two. This reverses the First Principles note from round 2 that called those imports dead. They are facade surface.
  • Conflict resolution: I kept both sides. feat(apps): cap how many finished job records a kind keeps #33196's retention sweep (_iter_runs_nolink) is unchanged, and the disable scan's containment and sensitive-path screen are unchanged.
  • Retrospective (round 3, run inline): the PR adds two mechanisms. (1) The opened-descriptor containment callback on open_regular_nofollow replaces the screened read, and the goal depends on it, so it stays. (2) The screen is waived only for a jobs dir at its own place under the data home. GPT span 7909c656e6a0 added it, and removing it would bring back that credential-path bypass, so it stays. Nothing was removed.
  • Local gates on b17ffb0: black, subprocess-encoding, isort, flake8, mypy (4365 files), comment-history, brand, line-cap and flake ratchet all pass. The related backend set passes (446). prove.py reports PROVEN.

@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 9, 2026

@buluoray buluoray 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.

Approving. The disable scan reads the SDK's own job records through open_regular_nofollow instead of the agent-facing read, so aws-control's stale runs are traced by kind and finished runs get no line. The sensitive-path screen is waived only when the jobs dir resolves to its own place under the data home, and otherwise fails toward screened (apps/job_sdk.py:1351-1358, 1392-1398; test/test_job_sdk.py:1464-1525). Agent reads are not loosened.

@bolichen97
bolichen97 force-pushed the fix/33163-job-sdk-disable-read branch from b17ffb0 to 1187a78 Compare November 9, 2026 08:39
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto main (086256f) to pick up #33695, which fixes the Static Ratchet Gate red (test/test_pid_reader_ratchet.py, 9 vs 8 owner-marked readers) that main carried; the patch is byte-identical to b17ffb0 (git range-diff reports =). Locally: the seven source-only ratchet files (174 passed), test_job_sdk.py + test_job_sdk_retention.py green, flake8/isort/mypy/black gate clean, prove.py PROVEN on 1187a78. CI re-running.

@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 Nov 9, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 3) on 1187a78 is red on main, not on this diff: test/test_review_repair_routing_skill.py::test_slim_skills_do_not_regrow_duplicate_guidance_or_wire_model_ids[kirocrew-worktree-dev-16000] asserts 16004 <= 16000. That file is 16004 bytes on origin/main since #33084, and this PR does not touch it. The fix is #33795 (open). This PR waits for #33795 and then rebases onto it. No rerun, because the red is deterministic.

@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 9, 2026
Disabling an app writes one job_killed_on_disable line per stale record
before deleting the records. The scan read each record through the
agent-facing read, whose path screen refuses the security lists'
protected app data dirs, aws-control's among them, so every non-live
aws-control record was traced as unreadable, finished runs included.

The scan now opens each record with jsonl_util.open_regular_nofollow
and keeps the descriptor checks that read made: a link at the name, a
non-regular, hardlinked or oversized file, or one outside the jobs dir
is still unreadable. The path screen is waived only for a store at its
own place under the data home; a store reached through a link below
the home keeps it, so its records in a protected location stay
unreadable.

Closes #33163
@bolichen97
bolichen97 force-pushed the fix/33163-job-sdk-disable-read branch from 1187a78 to 11905ae Compare November 9, 2026 13:50
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto main 52a2ebb to pick up #33795, the fix for the main-only red on Backend Tests (3.12, 3) / (Windows) (3) (test_slim_skills_do_not_regrow_duplicate_guidance_or_wire_model_ids[kirocrew-worktree-dev-16000]: kirocrew-worktree-dev/SKILL.md at 16004 > 16000 bytes; this PR does not touch that file). The diff is unchanged (+120/-24 in job_sdk.py and test_job_sdk.py). The Proof line was re-run on head 11905ae and is PROVEN. Round retrospective: the authorize callback and the sensitive-screen waiver are kept, since both are needed for the goal and Design and First Principles pass. CI re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 9, 2026
@bolichen97
bolichen97 merged commit 44085fc into main Nov 9, 2026
154 of 157 checks passed
@bolichen97
bolichen97 deleted the fix/33163-job-sdk-disable-read branch November 9, 2026 15:24
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 9, 2026
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.

Job SDK: disabling aws-control audits every one of its job records as unreadable

2 participants