Skip to content

fix(update): stop before restarting when the frontend build fails (#25418) - #28697

Merged
bolichen97 merged 1 commit into
mainfrom
fix/update-frontend-build-failure-25418
Nov 4, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/update-frontend-build-failure-25418

Conversation

@buluoray

@buluoray buluoray commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On a source install, an update whose frontend build fails stops before restarting and says where the build output is, instead of restarting onto a new backend that serves the old dashboard bundle.

A source (git checkout) install updates by moving the tree, running npm ci + npm run build in website/, reinstalling the package, and restarting. When the build fails, all three update paths (kirocrew update, the dashboard Update button, and the gateway's auto-apply) still reinstall and restart. The backend is then new while src/kiro_crew/static/dist keeps the old bundle. Where the API shapes differ the UI breaks: the reporter saw every new chat crash with React error #31 after seven updates over two weeks. The build output went to DEVNULL, so nothing explained the failure afterwards.

Why it matters

Anyone running from a source clone (including hosts that ended up there unintentionally, #25417) can be left with a dashboard that crashes on common actions, with no error in gateway.log and no hint that the build was the cause. Repeated updates keep restarting onto the mismatch.

Not a goal

  • Rolling the checkout back to the pre-update revision after a failed build.
  • Running the stale-bundle comparison (dashboard/stale_bundle_guard.py) before the restart.
  • Wheel installs: they ship a prebuilt static/dist and are not affected.
  • Making a second update rebuild a checkout that is already on the new revision (the same holds today after a failed dependency install).

What changed (motivation → approach → change)

Symptom: the update restarts after a failed build, and the build's output is lost. Root cause: build_frontend_sync / build_frontend_async returned None, so callers could not tell built, skipped and failed apart, and npm run build (plus the async install) wrote to DEVNULL.

Change:

  • src/kiro_crew/frontend.py: both helpers return a FrontendBuildResult with outcome built, skipped or failed. skipped keeps today's non-fatal cases (no website/, no npm, edition sources absent). failed covers every attempted build that leaves the previous bundle served: install failed or timed out, npm run build failed or timed out, exit 0 with no new index.html, staging failed, or the staging lock could not be taken. The install and build output now goes to <data home>/logs/frontend-build.log (0600, emptied per run, opened while holding the staging lock). logs/ is writable from inside the agent sandbox while this runs in the unsandboxed gateway, so logs/ is reached through the shared pinned walk (pinned_fs.create_and_open_dir_pinned) and the file is opened O_NOFOLLOW relative to it (platform_compat.open_create_or_existing), emptied only after fstat shows a plain file with one name, and its tail is read back through the same descriptor. A refused destination, or a platform with no pinned walk (Windows, pinned_fs.supports_pinned_walk() false), discards the output as before. In the async helper every log-file step (open, step header, tail read, close) runs through the tracked executor, never on the event loop. This keeps a planted symlink or hard link (for example to security_policy.json) from having that file overwritten. It is a file, not a pipe, so the existing post-kill reap after a timeout still has nothing to drain. failure_message() names the file and its last 20 lines, redacted with kiro_crew.security.redact and capped. Dev Fleet's build_and_stage keeps discarding output (the new build_log parameter defaults to None).
  • Each update path still runs its dependency/release install after a failed build (the tree has already moved, and nothing retries the update, so skipping it would leave a checkout whose next restart dies at import), and then refuses the restart:
    • dashboard/handlers/updates_apply.py: after _venv_pip_install succeeds, calls update_ownership.refuse_restart(...), pushes an error progress card with the message, and returns before the restart.
    • slack/gateway_runtime/update_apply.py (auto-apply): logs an error, runs the release install, then calls refuse_restart(...), pushes the error card when a dashboard is attached, and returns without restarting.
    • cli_server_update.py (kirocrew update): runs the release install, then prints the message and exits 1 without the restart hint.
  • update_ownership.refuse_restart gains import_probe_clears (default True). The two frontend-build refusals pass False: the stale-asset watchdog clears a refusal when an import probe of the supervisor's command succeeds, but that probe says nothing about the bundle, so it must not clear a failed-build refusal. Only a later update that completes clears it.
  • src/kiro_crew/security_posture.py: frontend.py now calls a redactor, so it joins NON_EGRESS_REDACTION_MODULES (scrubbing at capture, the same reason as platform/wheel_engine.py); the update paths that show the message are the output boundary.
  • Docs: docs/system-specs/modules/cli.md (update step 2), docs/system-specs/modules/slack-gateway.md (restart refusals), and docs/guides/install.md (what a failed build during an update does and how to finish it).

Backwards compatibility

Compatible: the helpers gain a return value; the only callers are the three update paths changed here. A build that is skipped still lets the update continue exactly as before.

Removes nothing: no field, key, function or record is removed; an update that used to restart after a failed build now stops, which is the fix.

Tests

  • test/test_frontend_build_log.py (new): sync and async builds report failed on a build error, an install error and a staging failure, built on a published bundle, skipped with no website/ or no npm; the install and build output lands in logs/frontend-build.log (mode 0600 on POSIX); the failure message names the file and carries a redacted tail; an unopenable log still builds with output discarded; a symlinked log, a hard-linked log and a symlinked logs/ are each refused, their target left byte-for-byte unchanged, and the output discarded; with no pinned walk no log is opened at all (the log-content tests are skipped there, and the file passes with supports_pinned_walk forced False); test_the_async_build_touches_its_log_off_the_event_loop checks the async open and tail read run off the loop thread, and reddens when the open is put back on the loop.
  • test/test_dashboard_updates_coverage_apply.py: a failed build pushes one error card naming the log, refuses the restart, and never awaits the reinstall or the restart; a skipped build still reinstalls and restarts.
  • test/test_slack_gateway_update_reset.py: the auto-apply does not install or restart after a failed build and records the refusal; a skipped build still restarts.
  • test/test_stale_asset_watchdog.py: test_a_probe_does_not_clear_a_failed_frontend_build_stay_up -- a REENTERABLE probed verdict keeps a failed-build refusal and the watchdog does not fire; the dashboard and auto-apply failed-build tests also check that a probe-style clear leaves their refusal standing.
  • test/test_cli_server_more_coverage.py: kirocrew update still installs, then exits 1 after a failed build and prints the log path and tail; a skipped build still reports success.
  • Existing stubs that returned None for the build now return a FrontendBuildResult.

Mutation checks, one at a time with a restore between each: replacing each caller's new if build.outcome == "failed": with if False: reddens test_a_failed_frontend_build_reinstalls_but_does_not_restart, test_a_failed_frontend_build_installs_but_does_not_restart and test_frontend_build_failure_installs_then_exits respectively; sending the build back to DEVNULL reddens five tests in test_frontend_build_log.py; returning skipped instead of failed after a failed build reddens test_a_failed_sync_build_reports_failed_and_keeps_its_output; opening the log with a plain link-following os.open and dropping the plain-file check reddens test_a_symlinked_log_is_refused_and_its_target_left_alone, test_a_hard_linked_log_is_refused_and_its_other_name_left_alone and test_a_symlinked_logs_dir_is_refused; letting the probe clear any refusal reddens test_a_probe_does_not_clear_a_failed_frontend_build_stay_up and both callers' failed-build tests; dropping import_probe_clears=False at either caller reddens that caller's failed-build test; opening by name when no pinned walk exists reddens test_without_a_pinned_walk_the_output_is_discarded.

Proof: not provable -- other: the fix adds the FrontendBuildResult type that the new tests import, so prove.py's whole revert only errors at collection; the per-caller mutations listed above redden the named tests instead.

Manual verification

N/A — unit coverage sufficient: each path's decision is driven through its real update worker with only the build, install and restart stubbed. Not run: a real failing npm run build during a live update, and macOS/Windows (unverified there; on Windows the build output is discarded, as on main, because there is no pinned walk).

Related Issues

Closes #25418

Sibling sweep

Swept: git grep -nE "build_frontend_sync(|build_frontend_async(|build_and_stage(" -- src
Sibling: src/kiro_crew/cli_server_update.py -- changed here
Sibling: src/kiro_crew/dashboard/handlers/updates_apply.py -- changed here
Sibling: src/kiro_crew/slack/gateway_runtime/update_apply.py -- changed here
Sibling: src/kiro_crew/apps/builtins/dev_fleet/worktree_ops_sync.py -- not affected -- build_and_stage already returns a bool that becomes the child's exit status

Pattern harvest

Rule candidate: review-prompt
Pattern: a step that can fail returns None, so its caller cannot stop the sequence that follows it

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

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 2, 2026 22:59
@buluoray
buluoray requested a review from CrysisDeu November 2, 2026 22:59
@buluoray
buluoray force-pushed the fix/update-frontend-build-failure-25418 branch from 4b69b17 to 5567e57 Compare November 2, 2026 23:17
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security_posture.py

  • @buluoray posted a complete reasoning template for 95ebe6c.

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

buluoray commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]:

Sensitive change review

  • Head commit: 5567e57
  • What rule changed: security_posture.NON_EGRESS_REDACTION_MODULES gains one entry, frontend.py, with a reason comment. No redaction rule, pattern, sink or sandbox rule changes.
  • Before -> after (what was allowed/blocked, now): before, frontend.py called no redactor. After, it calls kiro_crew.security.redact on the last lines of the npm build log before they go into the update failure message, so the posture test requires the module to be either a registered sink or allowlisted as non-egress. It is allowlisted as non-egress (scrubbing at capture, like platform/wheel_engine.py); nothing that was redacted before is redacted less now.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel's count of egress paths would not include the build-log tail. The tail is still redacted before any update path shows or logs it, so no secret is exposed by the classification; no command is blocked or allowed differently.
  • Evidence checked (which sandbox result proves it): no sandbox rule is touched, so no sandbox run applies. test/test_security_posture.py (57 passed) proves the module is classified; test/test_frontend_build_log.py::test_a_failed_sync_build_reports_failed_and_keeps_its_output proves a credential-bearing registry URL in the build output does not reach the failure message.
  • No regression:
    • Tools still work (which tools/commands were run, result): the targeted suites for the three update paths and the frontend build helpers ran on this head: 315 passed.
    • Backward compatible (old config / old data / old callers still work, how checked): the allowlist only adds a module name; no config or data shape changes. Existing posture tests pass unchanged.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_frontend_build_log.py, test_node_modules_txn.py, test_dashboard_updates_coverage_apply.py, test_slack_gateway_update_reset.py, test_cli_server_more_coverage.py, test_update_wheel_dispatch.py.
  • How to undo: remove the frontend.py entry from NON_EGRESS_REDACTION_MODULES together with the redact call in frontend._build_log_tail, or revert this PR.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the fix goes at the root cause (the build result was untyped and its output discarded), all three update paths refuse the restart the same way, and the only take-away is the changed return type, whose callers are all updated here.

Notes

  • A refusal recorded with import_probe_clears=False lives in process memory, and a second update reports "up to date". Nothing in the product clears it; the documented fix is to rebuild by hand and then restart, which the install guide spells out. A later follow-up could let a successful python -m kiro_crew.frontend stage clear it.

[DESIGN-REVIEWED] 95ebe6c

Description read

[DESCRIPTION-READ] 390eb2a220d383de5f98cecfb94b5bd847d73df969097147490a54a0dcffe5cd

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 95ebe6cf7b397e857ee856c438e78118b8d73c99 — 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. Issue #25418 reports the defect and the tests reproduce it. The fix covers all three update paths, and each extra piece prevents a harm you can name.

What this change ships

Inventory (9 items) — 9 justified

Intent: on a source install, an update whose frontend build fails stops before restarting and says where the build output went, instead of restarting onto a new backend with the old dashboard bundle. This is a FIX.

  1. kirocrew update, the dashboard Update button and the gateway auto-apply refuse to restart after a failed frontend build — justified
  2. kirocrew update exits 1 and prints the failure instead of "updated!" — justified
  3. The dependency/package install still runs after a failed build, so the moved tree stays importable — justified
  4. npm install and build output now goes to logs/frontend-build.log (0600, emptied each run) instead of DEVNULL — justified
  5. The error card and CLI output show the log path and a redacted 20-line tail — justified
  6. The log open refuses a symlinked or hard-linked log and a symlinked logs/, and discards output on Windows — justified
  7. The stale-asset watchdog's import probe no longer clears a failed-build refusal (import_probe_clears=False) — justified
  8. frontend.py joins NON_EGRESS_REDACTION_MODULES — justified
  9. The cli.md spec's "non-fatal on failure" for the build becomes "fatal before restart", and the install guide explains how to recover — justified

[FIRST-PRINCIPLES-REVIEWED] 95ebe6c

Description read

[DESCRIPTION-READ] 75d1420d426a14c58c8ea062919d3b329fbd6801bcc65c2b3a6a492108274769

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 95ebe6c

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

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

@github-actions github-actions Bot added 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: checking Automated validation is still running labels Nov 3, 2026
@buluoray
buluoray force-pushed the fix/update-frontend-build-failure-25418 branch from 5567e57 to 599da58 Compare November 3, 2026 16:19
@buluoray

buluoray commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]:

Sensitive change review

  • Head commit: 599da58
  • What rule changed: security_posture.NON_EGRESS_REDACTION_MODULES gains one entry, frontend.py, with a reason comment. No redaction rule, pattern, sink or sandbox rule changes.
  • Before -> after (what was allowed/blocked, now): before, frontend.py called no redactor. After, it calls kiro_crew.security.redact on the last lines of the npm build log before they go into the update failure message, so the posture test requires the module to be either a registered sink or allowlisted as non-egress. It is allowlisted as non-egress (scrubbing at capture, like platform/wheel_engine.py); nothing that was redacted before is redacted less now.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel's count of egress paths would not include the build-log tail. The tail is still redacted before any update path shows or logs it, so no secret is exposed by the classification; no command is blocked or allowed differently.
  • Evidence checked (which sandbox result proves it): no sandbox rule is touched, so no sandbox run applies. test/test_security_posture.py (57 passed) proves the module is classified; test/test_frontend_build_log.py::test_a_failed_sync_build_reports_failed_and_keeps_its_output proves a credential-bearing registry URL in the build output does not reach the failure message.
  • No regression:
    • Tools still work (which tools/commands were run, result): the targeted suites for the three update paths and the frontend build helpers ran on this head (rebased onto main 5fa4d8b, no change to the sensitive hunk): 482 passed.
    • Backward compatible (old config / old data / old callers still work, how checked): the allowlist only adds a module name; no config or data shape changes. Existing posture tests pass unchanged.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_frontend_build_log.py, test_node_modules_txn.py, test_dashboard_updates_coverage_apply.py, test_slack_gateway_update_reset.py, test_cli_server_more_coverage.py, test_update_wheel_dispatch.py.
  • How to undo: remove the frontend.py entry from NON_EGRESS_REDACTION_MODULES together with the redact call in frontend._build_log_tail, or revert this PR.

@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 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 95ebe6cf7b397e857ee856c438e78118b8d73c99 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 95ebe6c

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

@github-actions github-actions Bot added 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 merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 3, 2026
@buluoray
buluoray force-pushed the fix/update-frontend-build-failure-25418 branch from 599da58 to 968cd66 Compare November 3, 2026 22:17
@buluoray

buluoray commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]:

Sensitive change review

  • Head commit: 968cd66
  • What rule changed: security_posture.NON_EGRESS_REDACTION_MODULES gains one entry, frontend.py, with a reason comment. No redaction rule, pattern, sink or sandbox rule changes.
  • Before -> after (what was allowed/blocked, now): before, frontend.py called no redactor. After, it calls kiro_crew.security.redact on the last lines of the npm build log before they go into the update failure message, so the posture test requires the module to be either a registered sink or allowlisted as non-egress. It is allowlisted as non-egress (scrubbing at capture, like platform/wheel_engine.py); nothing that was redacted before is redacted less now.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel's count of egress paths would not include the build-log tail. The tail is still redacted before any update path shows or logs it, so no secret is exposed by the classification; no command is blocked or allowed differently.
  • Evidence checked (which sandbox result proves it): no sandbox rule is touched, so no sandbox run applies. test/test_security_posture.py (57 passed) proves the module is classified; test/test_frontend_build_log.py::test_a_failed_sync_build_reports_failed_and_keeps_its_output proves a credential-bearing registry URL in the build output does not reach the failure message.
  • No regression:
    • Tools still work (which tools/commands were run, result): the targeted suites for the three update paths and the frontend build helpers ran on this head (rebased onto main b5dfa23; the allowlist entry now sits beside main's new platform/release_apply.py entry, both kept): 482 passed.
    • Backward compatible (old config / old data / old callers still work, how checked): the allowlist only adds a module name; no config or data shape changes. Existing posture tests pass unchanged.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_frontend_build_log.py, test_node_modules_txn.py, test_dashboard_updates_coverage_apply.py, test_slack_gateway_update_reset.py, test_cli_server_more_coverage.py, test_update_wheel_dispatch.py.
  • How to undo: remove the frontend.py entry from NON_EGRESS_REDACTION_MODULES together with the redact call in frontend._build_log_tail, or revert this PR.

@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 3, 2026
@buluoray
buluoray force-pushed the fix/update-frontend-build-failure-25418 branch from 968cd66 to d8a9881 Compare November 3, 2026 22:39
@buluoray

buluoray commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]:

Sensitive change review

  • Head commit: d8a9881
  • What rule changed: security_posture.NON_EGRESS_REDACTION_MODULES gains one entry, frontend.py, with a reason comment. No redaction rule, pattern, sink or sandbox rule changes.
  • Before -> after (what was allowed/blocked, now): before, frontend.py called no redactor. After, it calls kiro_crew.security.redact on the last lines of the npm build log before they go into the update failure message, so the posture test requires the module to be either a registered sink or allowlisted as non-egress. It is allowlisted as non-egress (scrubbing at capture, like platform/wheel_engine.py); nothing that was redacted before is redacted less now.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel's count of egress paths would not include the build-log tail. The tail is still redacted before any update path shows or logs it, so no secret is exposed by the classification; no command is blocked or allowed differently.
  • Evidence checked (which sandbox result proves it): no sandbox rule is touched, so no sandbox run applies. test/test_security_posture.py (57 passed) proves the module is classified; test/test_frontend_build_log.py::test_a_failed_sync_build_reports_failed_and_keeps_its_output proves a credential-bearing registry URL in the build output does not reach the failure message.
  • No regression:
    • Tools still work (which tools/commands were run, result): the targeted suites for the three update paths and the frontend build helpers ran on this head (rebased onto main 0a0f9aa; the allowlist entry sits beside main's platform/release_apply.py entry, both kept; this head also opens the build log with no link followed, after GPT 6.1's finding on 968cd66): 485 passed.
    • Backward compatible (old config / old data / old callers still work, how checked): the allowlist only adds a module name; no config or data shape changes. Existing posture tests pass unchanged.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_frontend_build_log.py, test_node_modules_txn.py, test_dashboard_updates_coverage_apply.py, test_slack_gateway_update_reset.py, test_cli_server_more_coverage.py, test_update_wheel_dispatch.py.
  • How to undo: remove the frontend.py entry from NON_EGRESS_REDACTION_MODULES together with the redact call in frontend._build_log_tail, or revert this PR.

@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: checking Automated validation is still running labels Nov 4, 2026
@buluoray
buluoray force-pushed the fix/update-frontend-build-failure-25418 branch from ab56c65 to b291898 Compare November 4, 2026 15:40
@buluoray

buluoray commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]:

Sensitive change review

  • Head commit: b291898
  • What rule changed: security_posture.NON_EGRESS_REDACTION_MODULES gains one entry, frontend.py, with a reason comment. No redaction rule, pattern, sink or sandbox rule changes.
  • Before -> after (what was allowed/blocked, now): before, frontend.py called no redactor. After, it calls kiro_crew.security.redact on the last lines of the npm build log before they go into the update failure message, so the posture test requires the module to be either a registered sink or allowlisted as non-egress. It is allowlisted as non-egress (scrubbing at capture, like platform/wheel_engine.py); nothing that was redacted before is redacted less now.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel's count of egress paths would not include the build-log tail. The tail is still redacted before any update path shows or logs it, so no secret is exposed by the classification; no command is blocked or allowed differently.
  • Evidence checked (which sandbox result proves it): no sandbox rule is touched, so no sandbox run applies. test/test_security_posture.py (57 passed) proves the module is classified; test/test_frontend_build_log.py::test_a_failed_sync_build_reports_failed_and_keeps_its_output proves a credential-bearing registry URL in the build output does not reach the failure message.
  • No regression:
    • Tools still work (which tools/commands were run, result): the targeted suites for the three update paths and the frontend build helpers ran on this head (rebased onto main 2ccae17; the allowlist entry sits beside main's platform/release_apply.py entry, both kept; this head also opens the build log with no link followed, after GPT 6.1's finding on 968cd66): 541 passed (incl. test_dir_fd_create_race_ratchet.py).
    • Backward compatible (old config / old data / old callers still work, how checked): the allowlist only adds a module name; no config or data shape changes. Existing posture tests pass unchanged.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_frontend_build_log.py, test_node_modules_txn.py, test_dashboard_updates_coverage_apply.py, test_slack_gateway_update_reset.py, test_cli_server_more_coverage.py, test_update_wheel_dispatch.py.
  • How to undo: remove the frontend.py entry from NON_EGRESS_REDACTION_MODULES together with the redact call in frontend._build_log_tail, or revert this PR.

@buluoray

buluoray commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: GPT 6.1's BLOCKING finding on ab56c65 is real. The interrupted path's build_log.close() ran on the event loop and could wait on a worker that outlived the drain. It is fixed in b291898.

  • In the finally of build_frontend_async, the log still open on an interrupted run is handed to _close_log_off_loop, a daemon thread, and never closed on the loop. It is a plain thread, not the executor, because this path runs while the executor may be shutting down with cancel_futures=True.
  • New test: test_an_interrupted_async_build_closes_its_log_off_the_event_loop cancels the build while it runs in a worker and checks the close happens off the loop thread. It passed 10 of 10 runs, and fails when the close goes back on the loop.

@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 Nov 4, 2026
@buluoray
buluoray force-pushed the fix/update-frontend-build-failure-25418 branch from b291898 to be1c299 Compare November 4, 2026 16:01
@buluoray

buluoray commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]:

Sensitive change review

  • Head commit: be1c299
  • What rule changed: security_posture.NON_EGRESS_REDACTION_MODULES gains one entry, frontend.py, with a reason comment. No redaction rule, pattern, sink or sandbox rule changes.
  • Before -> after (what was allowed/blocked, now): before, frontend.py called no redactor. After, it calls kiro_crew.security.redact on the last lines of the npm build log before they go into the update failure message, so the posture test requires the module to be either a registered sink or allowlisted as non-egress. It is allowlisted as non-egress (scrubbing at capture, like platform/wheel_engine.py); nothing that was redacted before is redacted less now.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel's count of egress paths would not include the build-log tail. The tail is still redacted before any update path shows or logs it, so no secret is exposed by the classification; no command is blocked or allowed differently.
  • Evidence checked (which sandbox result proves it): no sandbox rule is touched, so no sandbox run applies. test/test_security_posture.py (57 passed) proves the module is classified; test/test_frontend_build_log.py::test_a_failed_sync_build_reports_failed_and_keeps_its_output proves a credential-bearing registry URL in the build output does not reach the failure message.
  • No regression:
    • Tools still work (which tools/commands were run, result): the targeted suites for the three update paths and the frontend build helpers ran on this head (rebased onto main 32a4327; the allowlist entry sits beside main's platform/release_apply.py entry, both kept; this head also opens the build log with no link followed, after GPT 6.1's finding on 968cd66): 605 passed (incl. test_dir_fd_create_race_ratchet.py).
    • Backward compatible (old config / old data / old callers still work, how checked): the allowlist only adds a module name; no config or data shape changes. Existing posture tests pass unchanged.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_frontend_build_log.py, test_node_modules_txn.py, test_dashboard_updates_coverage_apply.py, test_slack_gateway_update_reset.py, test_cli_server_more_coverage.py, test_update_wheel_dispatch.py.
  • How to undo: remove the frontend.py entry from NON_EGRESS_REDACTION_MODULES together with the redact call in frontend._build_log_tail, or revert this PR.

@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 4, 2026
@buluoray
buluoray force-pushed the fix/update-frontend-build-failure-25418 branch from be1c299 to c8429d1 Compare November 4, 2026 16:36
@buluoray

buluoray commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]:

Sensitive change review

  • Head commit: c8429d1
  • What rule changed: security_posture.NON_EGRESS_REDACTION_MODULES gains one entry, frontend.py, with a reason comment. No redaction rule, pattern, sink or sandbox rule changes.
  • Before -> after (what was allowed/blocked, now): before, frontend.py called no redactor. After, it calls kiro_crew.security.redact on the last lines of the npm build log before they go into the update failure message, so the posture test requires the module to be either a registered sink or allowlisted as non-egress. It is allowlisted as non-egress (scrubbing at capture, like platform/wheel_engine.py); nothing that was redacted before is redacted less now.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel's count of egress paths would not include the build-log tail. The tail is still redacted before any update path shows or logs it, so no secret is exposed by the classification; no command is blocked or allowed differently.
  • Evidence checked (which sandbox result proves it): no sandbox rule is touched, so no sandbox run applies. test/test_security_posture.py (57 passed) proves the module is classified; test/test_frontend_build_log.py::test_a_failed_sync_build_reports_failed_and_keeps_its_output proves a credential-bearing registry URL in the build output does not reach the failure message.
  • No regression:
    • Tools still work (which tools/commands were run, result): the targeted suites for the three update paths and the frontend build helpers ran on this head (rebased onto main 7a4e281; the allowlist entry sits beside main's platform/release_apply.py entry, both kept; this head also opens the build log with no link followed, after GPT 6.1's finding on 968cd66): 607 passed (incl. test_dir_fd_create_race_ratchet.py).
    • Backward compatible (old config / old data / old callers still work, how checked): the allowlist only adds a module name; no config or data shape changes. Existing posture tests pass unchanged.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_frontend_build_log.py, test_node_modules_txn.py, test_dashboard_updates_coverage_apply.py, test_slack_gateway_update_reset.py, test_cli_server_more_coverage.py, test_update_wheel_dispatch.py.
  • How to undo: remove the frontend.py entry from NON_EGRESS_REDACTION_MODULES together with the redact call in frontend._build_log_tail, or revert this PR.

@buluoray

buluoray commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: GPT 6.1's BLOCKING finding on be1c299 is real: the tail was cut by bytes and lines before redact(), so a long PEM key could lose its BEGIN marker. It is fixed in c8429d1.

  • _build_log_tail now redacts the WHOLE log through the same descriptor first, then takes the last 20 lines and caps the characters. A log over _BUILD_LOG_REDACT_MAX_BYTES (8 MiB) gives no tail at all, never a cut before redaction; the failure message still names the log path.
  • New tests: test_a_long_private_key_in_the_output_is_redacted_before_the_tail_is_cut (a 40-line PEM block; no body line reaches failure_message(), and the last npm line still does) and test_a_log_too_large_to_redact_gives_no_tail. Putting back cut-then-redact makes the first one fail.

@buluoray
buluoray force-pushed the fix/update-frontend-build-failure-25418 branch from c8429d1 to 95ebe6c Compare November 4, 2026 16:56
@buluoray

buluoray commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]:

Sensitive change review

  • Head commit: 95ebe6c
  • What rule changed: security_posture.NON_EGRESS_REDACTION_MODULES gains one entry, frontend.py, with a reason comment. No redaction rule, pattern, sink or sandbox rule changes.
  • Before -> after (what was allowed/blocked, now): before, frontend.py called no redactor. After, it calls kiro_crew.security.redact on the last lines of the npm build log before they go into the update failure message, so the posture test requires the module to be either a registered sink or allowlisted as non-egress. It is allowlisted as non-egress (scrubbing at capture, like platform/wheel_engine.py); nothing that was redacted before is redacted less now.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel's count of egress paths would not include the build-log tail. The tail is still redacted before any update path shows or logs it, so no secret is exposed by the classification; no command is blocked or allowed differently.
  • Evidence checked (which sandbox result proves it): no sandbox rule is touched, so no sandbox run applies. test/test_security_posture.py (57 passed) proves the module is classified; test/test_frontend_build_log.py::test_a_failed_sync_build_reports_failed_and_keeps_its_output proves a credential-bearing registry URL in the build output does not reach the failure message.
  • No regression:
    • Tools still work (which tools/commands were run, result): the targeted suites for the three update paths and the frontend build helpers ran on this head (rebased onto main df3be59; the allowlist entry sits beside main's platform/release_apply.py entry, both kept; this head also opens the build log with no link followed, after GPT 6.1's finding on 968cd66): 607 passed (incl. test_dir_fd_create_race_ratchet.py).
    • Backward compatible (old config / old data / old callers still work, how checked): the allowlist only adds a module name; no config or data shape changes. Existing posture tests pass unchanged.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_frontend_build_log.py, test_node_modules_txn.py, test_dashboard_updates_coverage_apply.py, test_slack_gateway_update_reset.py, test_cli_server_more_coverage.py, test_update_wheel_dispatch.py.
  • How to undo: remove the frontend.py entry from NON_EGRESS_REDACTION_MODULES together with the redact call in frontend._build_log_tail, or revert this PR.

@buluoray

buluoray commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: the Backend Tests (3.12, 5) red on 95ebe6c is not from this diff. It is test/test_decisions_end_to_end.py::test_jev_response_reaches_the_assembled_message (3 cases), which also fails on a clean main df3be59, and this PR touches none of its files. It is tracked in #29457, and the fix is #29458 (open). Coverage Gate is red only because that shard is red. This PR will be rebased onto main once #29458 merges.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 4, 2026

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

[operator: bolichen97] Approving at this head. I found no breaking issue.

Checked: the CLI update, the dashboard update and the gateway auto-apply all still run the package install after a failed frontend build, and only the restart is refused, so the running gateway stays up and the new tree stays importable. A skipped build still updates and restarts as before. Every in-repo caller of the build functions handles the new return type. The build log is opened safely and its tail is redacted. Windows falls back to the previous behaviour.

Non-blocking notes:

  • After a failed build the checkout is already on the new revision, so the next update reports "up to date" and the refusal can persist on an unattended host. A persistent notice, or rebuilding on the next update when the last build failed, would make that state easier to notice.
  • update_apply.py passes build.failure_message() to the progress card without the outer redact() the dashboard path applies. The tail is already redacted at capture, so this is consistency only.

AI-assisted, approved by bolichen97

@bolichen97
bolichen97 enabled auto-merge (squash) November 4, 2026 20:44
@bolichen97
bolichen97 merged commit bd682a7 into main Nov 4, 2026
153 of 155 checks passed
@bolichen97
bolichen97 deleted the fix/update-frontend-build-failure-25418 branch November 4, 2026 20:45
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 4, 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.

Source-install updater restarts onto a new backend when the frontend build fails, and discards the npm output

2 participants