Repository navigation
Conversation
5d14498 to
f523b70
Compare
First Principles Review (Opus 5.5, fork) — 🔴 BLOCKPremise-level review of First-Principles-Verdict: BLOCK
Not justified as shipped
What this change shipsInventory (10 items) — 4 justifiedIntent: let an app installed from a local folder start on its first enable, without an enable/disable loop (FIX, #10583).
Blockers
[FIRST-PRINCIPLES-REVIEWED] bd9cbb4 Description read[DESCRIPTION-READ] b80cd22310041e94e53a2fadb3bae9704b68440ce94a51b3df42cf03fad39e4a That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Running Watch
Suggestions
[DESIGN-REVIEWED] bd9cbb4 Description read[DESCRIPTION-READ] c668b04eb5eb3aafc31fea0e44455988bca57914d5616e5c2c2a99ccc0801b57 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 |
GPT 6.1 Review (fork) — 🔴 changes requested (blocking)Reviewed 5 of 5 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands. BLOCKING --
BLOCKING --
BLOCKING --
BLOCKING --
BLOCKING --
FINDING -- [BLOCK-MERGE] bd9cbb4 Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1: unbounded. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
f523b70 to
d6a15a3
Compare
d6a15a3 to
aa5ab82
Compare
aa5ab82 to
19c659f
Compare
Disposition: rebutted — the behavior change IS the request being fulfilled.
This PR deliberately does not rewrite the publishing guide in the same commit; if the maintainer wants the doc/RFC record updated first, that is a one-line ask and the PR will carry it. |
Disposition: rebutted — the two matchers cover different classes and share no code path.
|
Disposition: fixed
self-added: yes |
19c659f to
2ca714a
Compare
Disposition: fixed
self-added: yes |
bolichen97
left a comment
There was a problem hiding this comment.
Requesting changes: the new onEnable order and the Windows local-install failure are not documented
The First Principles review already covers the local-install onInstall reversal against manifest-reference.md:830,841-842 and publishing-guide.md:143,170-172. No comment yet raises the two effects below.
1. onEnable now runs before registration and backend start, but the docs still say it runs after.
In handle_enable_app the script now runs at src/kiro_crew/apps/routes.py:1632 (script_output = await _run_lifecycle_script(...)). Registration and start moved below it, to routes.py:1742-1744 (reg = await _register_app_off_loop(name) and then start_app_backend). On main the order is register, start, deps, then onEnable. At this head these docs are unchanged:
docs/app-kit/publishing-guide.md:145:onEnableruns "After resources are registered, the backend is started, and dependencies are resolved"docs/system-specs/modules/app-kit-platform.md:177, the owning spec: Enable = "register resources, start backend, resolve dependencies, runonEnable"
Who is affected: execution-trusted third-party gateway apps whose onEnable was written for the documented order. These apps now run their script with no backend whenever none is already running: re-enabling after a disable, enabling after a CLI install, or enabling after a gateway restart that happened while the app was disabled. If the script fails, the enable is rolled back. The first dashboard enable right after an install still finds the backend the install started. No builtin app declares onEnable.
Fix: the reason for the change is already written in the comment at routes.py:1734-1740 (the npm install race). Update both docs in this commit, as AGENTS.md requires for the owning spec, and state the order change in the PR description.
2. On native Windows, a local install of an app that declares onInstall now always fails.
manager.py:1092 runs the hook for every non-registry install, through base_cmd = ["/bin/bash", "-c", safe_script] (manager.py:680). Without /bin/bash, either wrap_argv or the spawn fails. The copied tree is then removed (manager.py:1127) and the install returns on_install_failed, even when trust is granted. On main, install_app "only manages files", so the documented "build first, then install" workflow works on Windows. The new scripted-install tests in TestLocalInstallScript skip on Windows. Registry installs already fail this way, and publishing-guide.md:153-155 documents that for hooks, so this may be acceptable. But it should be a stated decision, not a side effect.
Fix: either skip the local-install hook on hosts where lifecycle scripts cannot run, or document the Windows failure in the corrected local-install docs.
From a full open-PR audit against origin/main c66f95b (2026-09-25); findings were checked by independent reviewers reading the code. Reply here if this is wrong.
5af977e to
367dc0b
Compare
367dc0b to
b4c897e
Compare
|
Triage against origin/main Rebase needed. The branch is 1229 commits behind and conflicts in
The open blockers still apply at |
…on it Local-directory app installs never executed the manifest's setup.onInstall — only the registry path did — so a Node app installed from a folder shipped without node_modules and its backend could never start (kirodotdev#10583). install_app() now runs the script sandboxed in the COPIED app dir, behind the same app_execution_denied gate the registry path uses, and fails the install closed (preserving any restored data/) when the script fails, times out, or the sandbox is unavailable. The dashboard enable route started the backend before onEnable ran, so an onEnable that installs backend dependencies raced the backend's first boot and lost; onEnable (and dependency resolution) now complete before register/start_backend, and a failing script rolls back before any backend process exists. The CLI enable path skipped onEnable entirely, so the route's behavior was unreachable from the terminal; it now mirrors the route including the unsupported-OS skip and the client-install advisory carve-out. Fixes kirodotdev#10583
dodgeblaster
left a comment
There was a problem hiding this comment.
Stewarding review for #10583 (re-verified against origin/main @ 4d5cb477).
The bug this PR targets is real and still present on main. install_app() (now in src/kiro_crew/apps/manager_install.py:125, the entry for kirocrew app install <dir> and POST /api/apps/install) reads no setup/onInstall — git grep for onInstall|setup|run_lifecycle in that file returns nothing. The only execution site remains the registry path (src/kiro_crew/apps/registry_pipeline/install.py:838). The docs document the local skip as intended (docs/app-kit/manifest-reference.md:1008,1020; publishing-guide.md:169,197: "Not run for a local-path install; build first, then install"). So the behaviour the PR changes is a genuine, standing gap.
The approach direction is defensible. The PR runs onInstall on the local path behind the same app_execution_denied(action="install") gate the registry path uses, in the copied app dir (not the developer's source tree), fail-closed, and hardens write_app_secret (unlink-first + O_EXCL|O_NOFOLLOW) against the new "third-party code runs between gateway writes" exposure. That token_auth.py change strengthens rather than loosens the secret-write posture — the right instinct for this feature.
Why I am reviewing, not merging. This cannot land as-is, and the remaining decision is a maintainer's, not a worker's:
- It is a fork PR (
atomsbaza,isCrossRepository: true), so I cannot push a rebase to the head branch and cannot merge it. - It touches sensitive paths (
src/kiro_crew/dashboard/token_auth.py,src/kiro_crew/security_posture.py).Sensitive Change Reviewis failing, which is structural for a fork PR touching those paths — by design, not a code defect. Clearing it requires a maintainer taking the change onto a branch of this repo (preserving authorship viaCo-authored-by:+Supersedes #10599), running the real sandbox, and driving it green. - It is
CONFLICTING/DIRTYagainst current main — the author must rebase before anything else, and only the fork author can push that. CHANGES_REQUESTEDstands (bolichen97, 2026-09-25) and is not cleared by anything a steward can do.- The core design question #10583 was held on is still open for a maintainer: should a local-directory install run
onInstallat all (the documented contract today is that it does not), and if so behind which execution gate and in whichcwd? This PR answers "yes, behind the install execution policy, in the copied dir" — a reasonable answer, but the ruling is the maintainers' to make.
Recommendation. Keep #10583 open (the design decision + the maintainer takeover are not steward actions). If maintainers accept the "local installs run onInstall behind the install execution gate, in the copied app dir" direction, this PR is a strong starting point: take it over onto a repo branch, rebase onto current main, re-run the sensitive-path/sandbox gates, and address the open CHANGES_REQUESTED findings. Scope note matching the PR's own "Not a goal": onUpdate stays unexecuted and the onEnable-before-backend-start ordering is bundled in here — maintainers may want to confirm they want both in one change.
Steward review by a T1/T2 sweep worker. No push, no merge, no admin bypass — a fork PR touching sensitive paths needs a maintainer takeover.
Problem / Motivation
Goal: An app installed from a local directory runs its
setup.onInstallandsetup.onEnablehooks in the order its backend needs, so it starts on the first enable instead of after an install → enable → disable → enable loop.Installing an app from a local directory never executes the manifest's
setup.onInstall. The hook runs on exactly one path —install_from_registry()insrc/kiro_crew/apps/registry.py— so an app installed viakirocrew app install <path>orPOST /api/apps/installships without the artifacts the script is supposed to produce. The concrete symptom from issue #10583: a Node.js backend app installed from a local folder has nonode_modules, its backend dies withERR_MODULE_NOT_FOUNDon every start, and the only recovery is install → enable → disable → enable.Two adjacent gaps in the same lifecycle surfaced while fixing that:
handle_enable_app) started the backend before runningonEnable, so anonEnablethat installs backend dependencies (npm install) raced the backend's first boot and lost — the reporter's second finding, withstat-verified timeline evidence.kirocrew app enable) skippedonEnableentirely, so even after the route behaved correctly the CLI's own "Run: kirocrew app enable " hint still led to an un-startable app.Why it matters
Every third-party app whose manifest uses
setup.onInstallfor dependency installation is broken on the local-directory install path — the path every app developer uses first. The enable race then turns the missingnode_modulesinto a confusing loop (enable fails, re-enable "fixes" it) that looks like flaky infrastructure rather than an ordering bug. The CLI gap means the documented recovery command itself does not do what the dashboard does.Not a goal
update_app: it still runs none and is deferred to its own change.setsid) and rewrites the manifest later; the docs state the limit.What changed (motivation → approach → change)
Observed symptom → root cause:
install_app()insrc/kiro_crew/apps/manager.pyonly managed files — it never readsetup.onInstall; the registry path gates script execution onapp_execution_deniedbefore cloning because a manifest's shell script is third-party code. Running that script inside the app directory also means third-party code now executes between the gateway's own writes, so the change treats everything the script can touch as untrusted afterwards.manager.py—install_app()runssetup.onInstallafter the copy, gated by the sameapp_execution_denied(action="install")check the registry uses (fail-closed before anything registers), through the sharedlifecycle_scripts.run_lifecycle_scriptrunner (sandboxed,cwdset to the copied app dir, never the developer's source tree, whole process group reaped on exit). Failure, timeout, cancellation or interruption fails the install closed:installed.jsonis never written and the copied tree is removed. After the script the gateway re-reads and re-admits the manifest (name, version, admission policy), re-sweeps the gateway-owned root entries (.app_secret,data), andwrite_app_secretunlinks first and opensO_EXCL|O_NOFOLLOW, so a planted link cannot redirect the secret write.data/is copied to a temporary.partial-*name and renamed to.{name}-data-script-backuponly when complete; a half-written copy is never authoritative. Restores and deletions are renames (swap, then trash) rather than in-place deletes, read-only directories are made writable before removal, a link at the app directory or atdatais never followed, and an interrupted install is recovered at the next install entry from the authoritative backup. Leftover non-authoritative backup/trash names are swept at install entry and by a purge uninstall.routes.py— onEnable gates backend start. Dependency resolution and theonEnablescript run beforeregister_app()/start_app_backend(). The route re-reads the manifest under the lifecycle lock, reads it off the event loop, and re-admits it after the script. A failed activation — including a failed re-enable — rolls back to disabled and stops the backend of a gateway app, on both the route and the CLI.cli_commands.py— CLI enable mirrors the route.kirocrew app enablerunsonEnablevia the shared runner, reproduces both platform carve-outs (unsupported-OS skip;installMode: "client"scripts are advisory), re-reads and re-admits the manifest after the script, and rolls back with the same teardown askirocrew app disable(scheduled crons, disable, deregister), also when interrupted.kirocrew app installre-admits afteronInstallbefore registering.onInstalland a gateway-managedonEnablereap leftover members of the script's process group;onEnableof self-managed and client-install apps does not, so those hooks may still start detached work. A script that detaches into a new session (setsid) escapes the reaper; the docs state that post-script re-admission does not defend against it.docs/app-kit/publishing-guide.md,manifest-reference.md,docs/system-specs/modules/app-kit-platform.md) describe the newonInstallbehaviour on local installs, theonEnableorder (before registration and backend start), the rollback-to-disabled rule, the reaping scope, what re-admission compares, and thatupdate_appruns no hook (deferred).Tests
test/test_app_manager.py—TestLocalInstallScript: onInstall runs in the copied dir; the script cannot mutate the source tree; execution-policy denial refuses before the script runs and leaves no metadata; script failure keepsdata/while removing the rest of the copied tree; timeout produces the timed-out failure shape.test/test_app_oninstall_r1.py— each case runs a real script against real filesystem state: a script that re-plants.app_secretas a link cannot redirect the secret write; a script that replacesdatawith a link cannot capture the restore; a TERM-ignoring straggler is killed on timeout and on cancellation during the grace wait; an interrupted install restores the pristine data on retry; a half-written backup is never authoritative; read-only data survives the swap and leaves no leftover copy; purge uninstall sweeps leftover backup names; a failed backup rename returns an error result with data untouched; a link at the app directory is never followed; self-managedonEnablebackground work survives while gateway-managed work is reaped; a failed CLI re-enable runs the full disable teardown; a post-onEnablemanifest rewrite is re-admitted.test/test_app_routes.py— ordering (onEnablebeforestart_app_backend), failingonEnableleaves no backend and a disabled app, failed re-enable rolls back to disabled, manifest re-read under the lifecycle lock, post-onEnabledenial stops a freshly started backend, reaping scope per resource mode.test/test_app_cli.py,test/test_lifecycle_scripts_cov80.py,test/test_spawn_audit.py,test/test_security_posture.py,test/test_enable_deps_resolution.py— CLI enable/rollback, runner timeout and cancellation behaviour, spawn allowlist entry, security-posture log-site census, and the shared fake runner signature.Validation: 662 tests pass across
test_app_routes,test_apps_routes_coverage,test_lifecycle_hooks,test_app_manager,test_app_cli,test_security_posture,test_lifecycle_scripts_cov80,test_app_oninstall_r1,test_spawn_auditandtest_enable_deps_resolution;mypy --platform linux src/kiro_crew,flake8, the black ratchet gate (four files graduated out of the baseline), the comment-history gate andscripts/docs-lint.shpass.Manual verification
N/A — unit coverage sufficient for the ordering and gating logic; the end-to-end npm-install flow requires a real Node toolchain on the host, and the sandbox/policy matrix exercised here is the same one the existing registry-path tests already cover end to end.
Related Issues
Fixes #10583
Pattern harvest
Rule candidate: review-prompt
Pattern: a sync API that returns a result-typed value calling a sandbox helper documented to RAISE (wrap_argv) — the raise escapes the result contract and skips the caller's rollback; convert at the seam and audit new call sites of raising sandbox helpers for the same shape.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)docs/app-kit/publishing-guide.md,docs/app-kit/manifest-reference.md,docs/system-specs/modules/app-kit-platform.mdContribution License Agreement