Skip to content

fix(apps): require permissions.cron when a manifest declares crons - #19231

Merged
cruisercohen merged 2 commits into
mainfrom
fix/11040-require-cron-permission
Oct 12, 2026
Merged

cruisercohen merged 2 commits into
mainfrom
fix/11040-require-cron-permission

Conversation

@cruisercohen

@cruisercohen cruisercohen commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: An app that ships scheduled crons says so in its permissions block, so the permissions an operator reviews before installing describe everything the app runs unattended.

An app manifest can declare crons without "cron": true under permissions. Manifest validation never reads the grant and neither does cron registration, so those schedules register, fire and are removed whether or not it is declared. The permissions block then understates what the app does on its own, and the repo's own kirocrew app init --cron scaffold, the full-app example and the manifest reference's Full Example all ship that shape.

Why it matters

A schedule runs agent prompts or commands with nobody watching, and every run can cost model usage. permissions is where an operator reads what an app may do before installing it, so an app that can schedule work without saying so there is under-declared at the point of consent.

Not a goal

  • Enforcing the rule when an installed app loads. An app installed before it declared the grant keeps loading and firing its crons.
  • A warn-first release or a new non-fatal warning channel through manifest validation.
  • Changing what permissions.cron gates at runtime (ctx.cron), or how disabling an app cleans up its crons.

What changed (motivation → approach → change)

Gap → design choice → change.

  • Gap: permissions.cron gates only whether ctx.cron is built. Nothing ties it to manifest crons.
  • Design summary (options weighed):
    • A, chosen: require the grant when a manifest is admitted (install, update, self-registration), as a hard error that names the fix. Fix the repo's scaffold, example and reference in the same change. Already-installed apps are untouched until their next update, so no warning channel is needed.
    • B, rejected (the fallback if maintainers prefer zero author impact): do not require it, and document permissions.cron as covering only runtime ctx.cron. Docs-only and non-breaking, but it leaves an unattended capability undeclared in permissions.
    • C, rejected: a warn-first release, then a hard error. It needs a new non-fatal warning channel through manifest validation and every caller of it, for one rule.
  • Change:
    • apps/manifest.py: cron_permission_error() and CRON_PERMISSION_REQUIRED_ERROR. AppManifest.validate() adds one error when crons is non-empty and permissions.cron is not literally true: crons is declared but permissions.cron is not: add "cron": true under "permissions" in app.json. Install and update reach this through their existing source validation, so a refused update leaves the installed version in place.
    • apps/manager.py register_external_app: applies the same rule to a self-registered manifest. Self-managed apps re-register on every launch, so a re-registration at the version already on record, whose recorded manifest already lacked the grant, is treated as a relaunch and accepted. A new version, a first registration, or a relaunch that drops a grant it had is refused.
    • apps/scaffold.py: app init --cron writes "permissions": {"cron": true}.
    • apps/registry_pipeline/install.py: a self-managed registry install now fails with the registration's error when register_external_app refuses the manifest, and the previous checkout is put back. Before this, the branch reported success and kept the new checkout, so the cron-grant refusal would never reach the user.
    • Docs: the full-app example and the manifest reference's Full Example declare the grant. The crons section, the permissions.cron row and the validation rules state the requirement. The app-dev skill (kirocrew-app-dev) says the same.

Breaking change for app authors. A manifest with a non-empty crons and no "cron": true under permissions is refused at install, at update and at self-registration of a new version. The one-line fix is to add "cron": true under "permissions" in app.json. Apps already installed keep working until they are updated.

Backwards compatibility

Breaking: install, update and self-registration refuse a manifest whose crons is non-empty without permissions.cron: true. Writer sweep on origin/main @ ddb399c:

  • kirocrew app init --cron (apps/scaffold.py): writes the grant now.
  • docs/app-kit/examples/full-app/app.json and the manifest reference's Full Example: declare the grant now.
  • Shipped builtins: ops_mission_control is the only builtin with crons, and it already declares the grant.
  • Plugin import (apps/plugin_import.py): its emitted manifest carries no crons.
  • Test fixtures that build cron manifests (test_app_bridges.py, test_app_cli.py, test_app_manifest.py, test_apps_routes_coverage.py): declare the grant now.
  • Third-party manifests outside this repo: they hit the refusal on their next install or update, and the error names the fix.

Reader: apps/discovery.py:discover_builtin_apps -- release -- runs validate() on every boot. Every shipped builtin with crons declares the grant | test_every_builtin_that_ships_crons_declares_the_grant
Reader: apps/manager.py:_validate_source_path (install_app, update_app) -- app -- refuses with the fix, and a refused update leaves the installed version | test_install_refuses_crons_without_the_grant, test_update_refuses_and_leaves_the_installed_app_in_place
Reader: apps/manager.py:register_external_app (POST /api/apps/register, registry pre-registration) -- app -- a same-version relaunch of an app already registered without the grant is accepted | test_relaunch_at_the_recorded_version_keeps_an_app_registered_before_the_rule
Reader: apps/registry_pipeline/install.py:install_from_registry (self-managed branch) -- app -- a refused registration fails the install with its error and restores the previous checkout | test_self_managed_install_fails_when_registration_is_refused
Reader: apps/bridges.py:register_app, reconcile_enabled_app_resources -- release -- never validates, so an installed app without the grant keeps registering its crons | test_an_installed_app_without_the_grant_keeps_registering_its_crons
Reader: apps/plugin_import.py:_convert_into -- app -- emits no crons, so the rule never fires there

Tests

New test/test_app_cron_permission_required.py:

  • Validation: crons without the grant give exactly one error naming the fix. With the grant they are valid. No crons is valid with or without the grant. A grant that is not literal true (false, "true", 1, null) is refused. A cron shipped paused still needs the grant.
  • Install refuses and records nothing. Install with the grant succeeds. Update refuses and the installed version and grant stay as they were.
  • An installed app whose manifest lacks the grant still loads and register_app still registers its cron.
  • Self-registration: a first registration without the grant is refused. One with it is accepted. A same-version relaunch of an app registered without the grant is accepted. A new version without the grant is refused and the recorded version stays. A same-version relaunch that drops the grant is refused.
  • Shipped manifests: the --cron scaffold, the full-app example, the reference's Full Example and every builtin with crons all satisfy the rule.

test_app_scaffold.py checks that --cron writes the grant and that no-cron scaffolds do not. Existing fixtures that build cron manifests declare the grant.

test_external_registry.py::test_self_managed_install_fails_when_registration_is_refused: a self-managed registry install whose registration is refused returns ok: false with the refusal, writes no provenance, and restores the previous checkout.

Without the fix, the refusal, self-registration, registry and scaffold tests fail. Locally all new tests pass, plus the app suites (test/test_app*.py, test/test_apps*.py, builtin app tests, CLI tests, registry install tests). One code_review_sage store-ancestor test fails identically on unmodified main on this host. flake8, isort, mypy, the baselined black gate and the comment-history gate are clean on the touched files.

Manual verification

N/A. Unit coverage exercises each admission path (install, update, self-registration) and the startup registration path directly.

Related Issues

Fixes #11040

Pattern harvest

Not generalizable: a single missing cross-field rule between one manifest section and the grant that names it. The other capability grants (spawn, jobs, sessionApproval) already gate their runtime surface directly.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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.

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

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 362211bea0e87032068add3f00604c2309044b44 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check one thing before merge: a self-managed registry install now fails and rolls back on every registration refusal, including admission and trust-repository ones, not only the missing cron grant.

[DESIGN-REVIEWED] 362211b

Description read

[DESCRIPTION-READ] 4935ad2c3b563bb06cca855cae75fc68d83122e8d458bea61063e2489363f5f4

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 Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of 362211bea0e87032068add3f00604c2309044b44 — 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/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The breaking install refusal targets authors, but the gap is the consent display reading a self-declared flag instead of the manifest's crons.

Not justified as shipped

  • Item 1 — symptom-level: the stated harm is "under-declared at the point of consent". But the operator's pre-install view, AppDetailPage.tsx:1981, shows Cron only {app.manifest.permissions.cron && …}. The crons list (:2041) appears only app.installed. Refusing manifests patches what authors write, not what the display reads.
    Subtraction: drop the refusal in cron_permission_error/validate() and show the Cron badge on permissions.cron || crons.length > 0. That removes items 2 and 3.
    Clears when: a maintainer picks the breaking refusal over a derived display. The description itself says option B is the choice "if maintainers prefer zero author impact".
  • Item 2 — rides along: exists only to soften item 1. Goes with it.
  • Item 3 — rides along: needed only so item 1's refusal reaches the user. It also turns every other registration refusal into a failed install.

What this change ships

Inventory (6 items) — 3 justified

Intent: make the permissions an operator reviews before installing name an app's scheduled jobs. Presented as a FIX; it is an ADDITION (a new admission rule).

  1. Install, update and self-registration refuse a manifest that has crons but no permissions.cron — symptom-level
  2. Same-version relaunch of an already-registered app missing the grant is still accepted — rides along
  3. Self-managed registry install now fails and restores the old checkout when registration is refused — rides along
  4. app init --cron scaffold writes "cron": true — justified
  5. Full-app example and manifest reference's Full Example declare the grant — justified
  6. Docs and app-dev skill state the requirement — justified

[FIRST-PRINCIPLES-REVIEWED] 362211b

Description read

[DESCRIPTION-READ] bfc5e1187b10b2fe83a999e6f3f36f8c6a253670ea2b1d1e260412db92ddd7c8

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 Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 362211b

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

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

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 362211bea0e87032068add3f00604c2309044b44 and found no blocking issues.

This comment is updated in place on each push.

Review details

FINDING -- src/kiro_crew/apps/registry_pipeline/install.py:2506 -- An unpinned same-origin update leaves the pulled revision checked out after registration refusal, contradicting “finally puts the previous checkout back” -> Fix: qualify the comment to say that only moved-aside checkouts are restored.
[GPT-REVIEWED] 362211b

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

Install, update and self-registration refuse a manifest whose crons is non-empty without "cron": true under permissions, with an error that names the fix. Load time is unchanged, so an app installed before it declared the grant keeps loading and firing its crons until its next update. The app init --cron scaffold, the full-app example and the manifest reference now declare the grant.

Fixes #11040
… refused

The self-managed branch of install_from_registry reported success and kept the new checkout even when register_external_app refused the manifest. A refused registration now fails the install with its error, so a manifest that schedules crons without the cron grant surfaces the fix, and the previous checkout is put back beside the unchanged record.
@cruisercohen
cruisercohen force-pushed the fix/11040-require-cron-permission branch from 4ba6000 to 362211b Compare October 12, 2026 02:17
@cruisercohen
cruisercohen marked this pull request as ready for review October 12, 2026 02:43
@cruisercohen
cruisercohen requested review from a team and KiroCrewCaptain as code owners October 12, 2026 02:43
@cruisercohen
cruisercohen enabled auto-merge (squash) October 12, 2026 02:44
@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 Oct 12, 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.

Approved at head 362211b: PR Readiness is green, no open change requests, and the review lanes passed. (AI-assisted review at bolichen97's request.)

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.

Require permissions.cron at manifest validation when crons is non-empty (deferred remedy 2 of #10997)

2 participants