You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(api): move cron expression parsing into packages/cron - #2788
First slice of the apps/api/src/services split (stream C of the agent-context work, idea 01M7H32EK6S4E31EHWVSJSENR5). Seam map for the whole directory: SAM idea 01M7HXHPQ46H3YK0GC9Q2QHAFF.
apps/api/src/services/cron-utils.ts moves unchanged into a new package, packages/cron (@simple-agent-manager/cron). It is the five-field cron parser behind triggers: validateCronExpression, cronToNextFire, cronToHumanReadable. Its 40-case unit test moves with it. The 10 worker importers and 6 worker tests now import the package, and no re-export is left at the old path: a shim with no importers would be dead code (#2681 kept shims only to avoid editing hundreds of importers).
Package template from PR #2681: dist/ resolution, a single public entry point, an AGENTS.md, boundaryRules lint coverage (automatic for packages/**), and the build order in CLAUDE.md, rule 08 and the local-development guide. The package depends only on @simple-agent-manager/shared.
Effect on rule loading. On first access, the moved file loaded 271.5 KB from 36 path-scoped rules in apps/api. In packages/cron it loads 12.7 KB from 1 rule. Each of the 36 is decided in the table under Validation. Measured with parseRuleFile/compilePattern from scripts/quality/agent-instructions.ts. pnpm quality:agent-context-budget --check passes, and the indexes were regenerated with --write after rebasing onto #2790.
Why cron and not text-to-speech. TTS (services/tts*.ts) was the first pick and was tried. It needs @mastra/core and workers-ai-provider. For a new importer, pnpm resolved their peer dependencies differently (zod@4.6.7 against the worker's locked 4.5.4), which creates a second instance of each library in the worker bundle. Fixing that means pinning peer versions inside the package or turning the LLM call into a port, so it is not a pure move. Recorded on the seam map.
Validation
pnpm lint (via pnpm check:fast, passed)
pnpm typecheck (API typecheck passed)
pnpm test (see notes)
Additional validation run (if applicable)
N/A: no sweep/cron/alarm candidate selection changed (the cron sweep is untouched; only its import path changed)
Pure-move evidence:
cron-utils.ts is byte-identical to main (diff <(git show bfe2b96e7:apps/api/src/services/cron-utils.ts) packages/cron/src/cron-utils.ts prints nothing; Git reports a 100% rename).
Every other source diff is an import specifier, plus the import re-sorting ESLint applied.
Worker bundle (wrangler deploy --dry-run): 32,560,747 bytes before, 32,560,844 after. The cron module's code in the bundle is identical with whitespace removed. The +97 bytes are path comments and the two per-module polyfill init calls that wrangler adds to every bundled module. The source maps differ only in apps/api/src/services/cron-utils.ts becoming packages/cron/src/{index,cron-utils}.ts.
Tests: 40 cron cases moved (40 pass in the package). The 5 repointed worker unit test files (41 cases) and tests/workers/cron-trigger-sweep.test.ts (19 cases) pass. Test case count is unchanged.
No wrangler.toml, D1 or Durable Object migration, route, binding or environment change.
Rule-by-rule scoping decision
On main 30ae952ae, the first read of apps/api/src/services/cron-utils.ts loaded 271.5 KB from 36 path-scoped rules. After this PR, packages/cron/src/cron-utils.ts loads 12.7 KB from 1 rule (73, which #2790 scoped to every .ts, .tsx, .go and .sql file). Each of the 36 rules is a decision, not a default. The package has no I/O, no D1, DO, KV or fetch, no Env, no routes, no auth, no settings and no runtime state. Its inputs are strings and a Date; its outputs are a validation result, an ISO string or a description. The code that does the I/O around it stays in apps/api, where every one of these rules still loads: request validation in schemas/triggers.ts, D1 writes in services/trigger-create.ts, the sweep in scheduled/cron-triggers.ts. The launch rules (constitution and no hardcoded values, 81 work bounds, quality gates) still apply to packages/cron.
Rule
Decision for packages/cron
Why
06 API patterns
not added
Hono routes, middleware and Workers bindings; the package has none.
24 no duplicate implementations
not added
Its point is one canonical implementation. Moving the parser keeps it the only one, and the rule still loads for every caller in apps/api.
26 project chat first
not added
UI and navigation; no surface here.
27 VM agent staging refresh
not added
VM agent binaries.
31 migration safety
not added
No D1 or DO migrations or SQL.
32 CF API debugging
not added
No Cloudflare resources.
34 VM agent callback auth
not added
No routes or auth.
40 sentinel rows excluded from counts
not added
No D1 counts.
43 long-running MCP tools
not added
No MCP tools; routes/mcp/trigger-*.ts stay in apps/api.
44 dual-write migrations
not added
No storage.
45 DO concurrency mutex
not added
No Durable Objects and no await; every function is synchronous.
47 control-loop I/O budget
not added
The control loop is the cron sweep in apps/api/src/scheduled/cron-triggers.ts, which keeps this rule. The package's only loop (cronToNextFire) does no I/O and is bounded at 2 × 525,600 iterations; launch rule 81 (work bounds) covers that and still applies.
49 capture prerequisites before async completion
not added
No async code.
50 list-read row fault isolation
not added
No row reads.
51 runtime boundary validation
not added
Its subject is turning unknown external JSON, rows and fetch responses into typed values. The package receives typed strings. The untrusted request body is parsed by the valibot schemas in apps/api/src/schemas/triggers.ts (cronExpression, cronTimezone), which keep this rule. validateCronExpression errors echo only the caller's own expression back, never another tenant's data or a secret.
51 server-side node-class gates
not added
No placement or identity.
52 model catalog lifecycle
not added
No models.
53 scheduled-handler isolation and liveness signals
not added
The scheduled handler and its step isolation live in apps/api (scheduled/cron-triggers.ts, index.ts), which keep this rule. The parser computes no idleness or staleness.
55 runaway-cost emergency ops
not added
No spend.
57 write-only cross-boundary state
not added
No state.
58 terminal verdicts
not added
No verdicts.
61 guards cover every runtime
not added
Runtime-specific guards for VM and container; the parser is runtime-independent.
61 per-cycle budget counters
not added
No counters.
63 widening a table deletes an auth check
not added
No schema.
65 capped selection must rank and disclose
not added
No selections or caps.
66 ownership handoff
not added
No ownership.
67 shared predicates that trigger actions
not added
The parser's predicates decide whether a minute matches an expression; the actions (firing a trigger) are in apps/api, which keeps this rule.
68 event-scoped filter predicates
not added
No event filters.
69 aggregate capacity at final reservation
not added
No capacity.
69 emergency config coverage
not added
No configuration. The minimum interval is passed in by the caller (trigger-create.ts reads CRON_MIN_INTERVAL_MINUTES, default DEFAULT_CRON_MIN_INTERVAL_MINUTES from shared).
70 flag flips verify deployed value
not added
No flags or Worker vars.
71 tightening a column
not added
No schema.
72 error categories match the recovery action
not added
Covers provider and HTTP errors. validateCronExpression returns a result that trigger-create.ts turns into a 400 (errors.badRequest) in apps/api.
Applies to every .ts file. The package has no update or merge helper; cronToNextFire's optional after defaults to now and overwrites nothing.
75 external API check-then-act
not added
No external API.
77 library extension points
not added
No library extension points.
Staging Verification (REQUIRED for all code changes — merge-blocking)
Staging deployment green
Live app verified via Playwright (verified through the live API with a token-login session instead; no UI change)
Existing workflows confirmed working
New feature/fix verified on staging
Infrastructure verification completed — N/A: no infra changes (no cloud-init, VM agent, DNS, TLS or deploy script change)
Mobile and desktop verification notes added for UI changes — N/A: no UI change
Staging Verification Evidence
staging2 (sammy2.party), head 99bbfa0cb, 2026-11-17 ~00:45Z. Deploy run 43988624033 succeeded: queue, lease, Validate Configuration, Deploy to Cloudflare and smoke-tests all passed. Signed in by workload identity. GET /health returned 200. As staging2-agent-admin, the trigger list returned cronHumanReadable: "Every 15 minutes" for two existing */15 * * * * triggers. That value is computed by cronToHumanReadable from @simple-agent-manager/cron in the deployed Worker (services/trigger-read.ts).
The write path (validateCronExpression, cronToNextFire on create and update) cannot be exercised there: trigger create and edit refuse agent sign-in sessions by design (assertNotAgentSignInSession in routes/triggers/crud.ts: 403 Agent sign-in sessions cannot create credentials or grant access). staging2's only other session token is the workflow-only SMOKE_TEST_TOKEN. No test resources were created, and the lease was released (run 43990835091).
Primary staging (sammy.party), head 99bbfa0cb, 2026-11-17 04:39-05:33Z. Deploy run 44018692314 succeeded: queue, lease, Validate Configuration, Deploy to Cloudflare and smoke-tests all passed. The write-path check (create, list, update, invalid expression, every-minute, delete) did not run. The normal-session test token is only usable through SAM exec_with_secrets; in a plain shell it is a placeholder, and token-login returned 401 for that reason. SAM's MCP tools were disconnected from the session for the whole lease, so the lease was released unused (run 44024945939) and the branch is queued again. (Superseded by the run below.)
Primary staging (sammy.party), head 5ba2eb30e (rebased on main 1ed27436c), 2026-11-17 19:52Z. Write path verified. Deploy run 44158298531: queue, lease, Validate Configuration and Deploy to Cloudflare passed; the staging deployment record shows 5ba2eb30e. Signed in with the primary test user's token-login session (through SAM exec_with_secrets), then in project 01KWHD8XS7MQ7R6KWXJYRHDVH4:
Step
Result
Create cron trigger 0 9 1 1 * UTC
201, nextFireAt2027-01-01T09:00:00.000Z, cronHumanReadable "At 9:00 AM on day 1 of the month in Jan"
List triggers
200, same description
PATCH to 30 6 * * 1
200, nextFireAt2026-11-23T06:30:00.000Z (next Monday), "At 6:30 AM on Monday"
400 "Schedule fires too frequently (every ~1 minutes). Minimum interval is 15 minutes."
Create with 61 * * * *
400 "Invalid value in minute: 61 (valid: 0-59)"
Delete the test trigger
200 (nothing left behind)
validateCronExpression, cronToNextFire and cronToHumanReadable all ran from @simple-agent-manager/cron in the deployed Worker.
Changes since the last review round (takeover by task 01M7N5Q1YTKVCRNMKDJKN9G760): rebased twice onto main. The .sonarcloud.properties conflict was resolved by keeping both new exclusions. Commit 5ba2eb30e trims this PR's launch-context addition to 68 bytes (shorter CLAUDE.md line; cron dropped from the rule 08 diagram, where it implied the worker module packages depend on it; both build-order sentences still list it), because Code Quality Checks failed at 210,107 bytes against the 210,000 ceiling after the rebase. Docs only, no code change.
UI Compliance Checklist (Required for UI changes)
N/A: no UI change.
UI Screenshot Evidence
N/A: no UI change.
End-to-End Verification (Required for multi-component changes)
Data flow traced from user input to final outcome with code path citations
Capability test exercises the complete happy path across system boundaries
All spec/doc assumptions about existing behavior verified against code
If any gap exists between automated test coverage and full E2E, manual verification steps documented below
Data Flow Trace
Trigger create (routes/triggers/crud.ts, MCP routes/mcp/trigger-create-tool.ts) → services/trigger-create.ts (validateCronExpression, cronToNextFire) → D1 triggers.next_fire_at. Read paths: services/trigger-read.ts, routes/mcp/trigger-tool-shared.ts and operation-ports.ts (cronToHumanReadable). Cron sweep: scheduled/cron-triggers.ts (cronToNextFire). All of these now import @simple-agent-manager/cron, which the worker bundles from packages/cron/dist.
Untested Gaps
N/A: behaviour is unchanged and covered by the moved unit tests plus the worker route, sweep and workers-pool tests; staging covers the deployed bundle.
Post-Mortem (Required for bug fix PRs)
N/A: not a bug fix.
Specialist Review Evidence (Required for agent-authored PRs)
All local reviewers completed and findings addressed before merge
If any reviewer did NOT complete: needs-human-review label added and merge deferred to human (N/A: all completed; the first run stopped at a usage limit and the same reviewers were resumed)
Reviewer
Status
Outcome
task-completion-validator
ADDRESSED
No CRITICAL/HIGH. MEDIUM: scripts/quality/ast-checks.ts scanned the file before the move, so it now scans packages/cron/src (fece83e). LOW: task file ticked, with evidence and the rule 51 decision recorded (fece83e).
architecture-reviewer
ADDRESSED
No CRITICAL/HIGH; boundary judged sound (shared -> cron -> api, coherent subject, wiring matches scheduler-core). MEDIUM: apps/web/src/pages/automation/editor/cron.ts has an older, partial parser of its own. Moving the web editor onto the package changes web behaviour, so it is recorded as a follow-up on the seam map idea, not done in a pure move. MEDIUM: the dated blog post keeps its historical path (see Documentation & Specs). LOW: AGENTS.md wording fixed (fece83e).
cloudflare-specialist
PASS
Turbo ^build and the api^... filters build the package with no named step; Miniflare and vitest aliases need no entry; every sibling-package list is covered. INFO (ast-checks) addressed in fece83e.
CodeRabbit Review Evidence (Required for agent-authored PRs)
CodeRabbit requested when the PR was marked ready for review
Waited about 15 minutes (or until a skip, rate-limit or quota reply)
Either CodeRabbit reviewed and no CodeRabbit feedback is unresolved, or it did not review and the observed outcome is recorded below
CodeRabbit Notes
Requested 14:39Z with the coderabbit-review label when the PR was marked ready; the label workflow ran and CodeRabbit replied "Review triggered". It reviewed 30ae952ae..fece83e2a and approved, with "No actionable comments were generated" and merge risk "Minimal". Its summary calls the plain-text package diagram in .claude/rules/08-architecture.md (which predates this PR) a non-blocking format issue. It opened no thread, and converting the diagram is outside a pure move.
After the takeover rebases and the launch-budget trim (5ba2eb30e, pushed 18:50-19:13Z), CodeRabbit posted no incremental review within the wait; its approval stands and no CodeRabbit thread is unresolved.
CI note: on run 43887945119 (fece83e2a), Test web (2/2) failed once on SecretRequestCard.test.tsx (waitFor timed out after its 1 s default; the PR touches no web code). It passed locally and on rerun, so all checks are green. The flake is tracked as SAM idea 01M7JF5EBFQCGS7H7QN089YMFH.
Exceptions (If any)
Scope: None
Rationale: N/A
Expiration: N/A
Agent Preflight (Required)
Preflight completed before code changes
Classification
external-api-change
cross-component-change
business-logic-change
public-surface-change
docs-sync-change
security-sensitive-change
ui-change
infra-change
External References
N/A: no external API; internal reorganisation following PR #2681 and tasks/archive/2026-11-12-worker-modularization.md ("Package template").
Codebase Impact Analysis
packages/cron/ (new): src/cron-utils.ts (moved from apps/api/src/services/cron-utils.ts), src/index.ts, tests/unit/cron-utils.test.ts (moved from apps/api/tests/unit/services/).
apps/api/src: import path only in operation-ports.ts, routes/tasks/crud.ts, routes/triggers/crud.ts, routes/mcp/trigger-create-tool.ts, routes/mcp/trigger-tool-shared.ts, routes/mcp/trigger-tools.ts, scheduled/cron-triggers.ts, services/trigger-create.ts, services/trigger-read.ts, services/trigger-status.ts.
apps/api/tests: import or vi.mock path only in six test files.
Wiring: apps/api/package.json, pnpm-lock.yaml, .github/workflows/ci.yml and e2e-smoke.yml path filters, the quality:runtime-boundary-semantics scope in package.json, the scripts/quality/ast-checks.ts scan scope.
CLAUDE.md (structure, build order), .claude/rules/08-architecture.md (package graph, build order), apps/www/src/content/docs/docs/guides/local-development.md (build order), packages/cron/AGENTS.md (new), regenerated rule indexes. No spec changes. Blog post sams-journal-two-features-one-day.md keeps its historical path.
Constitution & Risk Check
Principle X (simplicity): a leaf package with one dependency, no ports and no shims. Principle XI (no hardcoded values): unchanged code; the minimum interval still comes from DEFAULT_CRON_MIN_INTERVAL_MINUTES in shared. Risk: the deployed bundle must contain identical cron logic. Checked by bundle comparison above and by the staging trigger check.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The cron utilities are exposed through a new workspace package. API modules and tests now import them from that package. CI filters, quality checks, and repository documentation include the package.
Changes: Cron Package Extraction
Layer / File(s)
Summary
Package entry point and tooling packages/cron/*, tasks/active/*
The package defines its metadata, build and test configuration, and public exports for cronToHumanReadable, cronToNextFire, and validateCronExpression. Package guidance, utility tests, and an extraction task document are added.
API and test imports apps/api/package.json, apps/api/src/*, apps/api/tests/*
The API adds the workspace dependency. API code and tests import cron utilities from @simple-agent-manager/cron instead of the local cron utility module.
The extraction preserves the cron utilities’ public interface and wires their package into supported build and test paths. No material merge-blocking defect is established; the remaining diagram-format issue is non-blocking.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "refactor(api): move cron expression parsing into packages/cron" matches the main change. The PR moves cron-utils.ts (validateCronExpression, cronToNextFire, cronToHumanReadable) and its uni…
Description check
The description follows the repository template closely. It has a Summary that explains the problem and intended change, and it includes validation evidence (lint, typecheck, tests, bundle comparison)…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "refactor(api): move cron expression parsing into packages/cron" matches the main change. The PR moves cron-utils.ts (validateCronExpression, cronToNextFire, cronToHumanReadable) and its unit tests from apps/api into the new packages/cron package, and repoints importers. The title is concise, specific, and follows a conventional-commit style.
Full details: Description check
Explanation
The description follows the repository template closely. It has a Summary that explains the problem and intended change, and it includes validation evidence (lint, typecheck, tests, bundle comparison). It fills in the Staging Verification, UI, E2E, Post-Mortem, Specialist Review, CodeRabbit, and Agent Preflight sections, and marks N/A where appropriate. Several staging checkboxes are unchecked and marked Pending, and the CodeRabbit evidence is incomplete. These gaps are expected for an open PR that has not yet been staged or reviewed, and the required structure is otherwise present.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the cron by moonlit light Three helpers hop into a package neat The API calls them from their home Tests follow close along the path CI watches as the changes land Then I nibble clover, pleased and calm
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
No successful run was found on main (1ed2743) during the generation of this report, so f5a116b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
First slice of the apps/api/src/services split (seam map: SAM idea
01M7HXHPQ46H3YK0GC9Q2QHAFF). services/cron-utils.ts moves unchanged to
packages/cron; its unit test moves with it. The ten worker importers and six
worker tests import @simple-agent-manager/cron instead of the old path.
No re-export is left behind.
Wiring: apps/api dependency, CI path filters, runtime-boundary scope, build
order in CLAUDE.md, rule 08 and the local-development guide, a package
AGENTS.md, regenerated rule indexes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-ups for the cron package move: the API AST checks scanned
cron-utils.ts before the move, so they now scan packages/cron/src as they do
the other worker packages. AGENTS.md says who consumes the package, and the
task file records the evidence and the rule 51 decision.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SonarCloud counts packages/cron/tests/unit/cron-utils.test.ts as new code
after the move, and its repeated test blocks (102 lines, unchanged from the old
path) failed the new-code duplication gate. Tests are excluded from CPD by
policy (sonar-project.properties); automatic analysis needs the exact path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…udget
Claude Code launch context reached 210,107 bytes against the 210,000 ceiling
after rebasing onto main. Shorten the CLAUDE.md structure line and drop cron
from the rule 08 diagram, where it implied the worker module packages depend
on it; both build-order sentences still list cron. Net launch addition is now
68 bytes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First slice of the
apps/api/src/servicessplit (stream C of the agent-context work, idea01M7H32EK6S4E31EHWVSJSENR5). Seam map for the whole directory: SAM idea01M7HXHPQ46H3YK0GC9Q2QHAFF.apps/api/src/services/cron-utils.tsmoves unchanged into a new package,packages/cron(@simple-agent-manager/cron). It is the five-field cron parser behind triggers:validateCronExpression,cronToNextFire,cronToHumanReadable. Its 40-case unit test moves with it. The 10 worker importers and 6 worker tests now import the package, and no re-export is left at the old path: a shim with no importers would be dead code (#2681 kept shims only to avoid editing hundreds of importers).Package template from PR #2681:
dist/resolution, a single public entry point, anAGENTS.md,boundaryRuleslint coverage (automatic forpackages/**), and the build order inCLAUDE.md, rule 08 and the local-development guide. The package depends only on@simple-agent-manager/shared.Effect on rule loading. On first access, the moved file loaded 271.5 KB from 36 path-scoped rules in
apps/api. Inpackages/cronit loads 12.7 KB from 1 rule. Each of the 36 is decided in the table under Validation. Measured withparseRuleFile/compilePatternfromscripts/quality/agent-instructions.ts.pnpm quality:agent-context-budget --checkpasses, and the indexes were regenerated with--writeafter rebasing onto #2790.Why cron and not text-to-speech. TTS (
services/tts*.ts) was the first pick and was tried. It needs@mastra/coreandworkers-ai-provider. For a new importer, pnpm resolved their peer dependencies differently (zod@4.6.7against the worker's locked4.5.4), which creates a second instance of each library in the worker bundle. Fixing that means pinning peer versions inside the package or turning the LLM call into a port, so it is not a pure move. Recorded on the seam map.Validation
pnpm lint(viapnpm check:fast, passed)pnpm typecheck(API typecheck passed)pnpm test(see notes)Pure-move evidence:
cron-utils.tsis byte-identical to main (diff <(git show bfe2b96e7:apps/api/src/services/cron-utils.ts) packages/cron/src/cron-utils.tsprints nothing; Git reports a 100% rename).wrangler deploy --dry-run): 32,560,747 bytes before, 32,560,844 after. The cron module's code in the bundle is identical with whitespace removed. The +97 bytes are path comments and the two per-module polyfill init calls that wrangler adds to every bundled module. The source maps differ only inapps/api/src/services/cron-utils.tsbecomingpackages/cron/src/{index,cron-utils}.ts.tests/workers/cron-trigger-sweep.test.ts(19 cases) pass. Test case count is unchanged.wrangler.toml, D1 or Durable Object migration, route, binding or environment change.Rule-by-rule scoping decision
On main
30ae952ae, the first read ofapps/api/src/services/cron-utils.tsloaded 271.5 KB from 36 path-scoped rules. After this PR,packages/cron/src/cron-utils.tsloads 12.7 KB from 1 rule (73, which #2790 scoped to every.ts,.tsx,.goand.sqlfile). Each of the 36 rules is a decision, not a default. The package has no I/O, no D1, DO, KV or fetch, noEnv, no routes, no auth, no settings and no runtime state. Its inputs are strings and aDate; its outputs are a validation result, an ISO string or a description. The code that does the I/O around it stays inapps/api, where every one of these rules still loads: request validation inschemas/triggers.ts, D1 writes inservices/trigger-create.ts, the sweep inscheduled/cron-triggers.ts. The launch rules (constitution and no hardcoded values, 81 work bounds, quality gates) still apply topackages/cron.packages/cronapps/api.routes/mcp/trigger-*.tsstay inapps/api.await; every function is synchronous.apps/api/src/scheduled/cron-triggers.ts, which keeps this rule. The package's only loop (cronToNextFire) does no I/O and is bounded at 2 × 525,600 iterations; launch rule 81 (work bounds) covers that and still applies.unknownexternal JSON, rows and fetch responses into typed values. The package receives typed strings. The untrusted request body is parsed by the valibot schemas inapps/api/src/schemas/triggers.ts(cronExpression,cronTimezone), which keep this rule.validateCronExpressionerrors echo only the caller's own expression back, never another tenant's data or a secret.apps/api(scheduled/cron-triggers.ts,index.ts), which keep this rule. The parser computes no idleness or staleness.apps/api, which keeps this rule.trigger-create.tsreadsCRON_MIN_INTERVAL_MINUTES, defaultDEFAULT_CRON_MIN_INTERVAL_MINUTESfromshared).validateCronExpressionreturns a result thattrigger-create.tsturns into a 400 (errors.badRequest) inapps/api..tsfile. The package has no update or merge helper;cronToNextFire's optionalafterdefaults to now and overwrites nothing.Staging Verification (REQUIRED for all code changes — merge-blocking)
Staging Verification Evidence
staging2 (
sammy2.party), head99bbfa0cb, 2026-11-17 ~00:45Z. Deploy run 43988624033 succeeded: queue, lease, Validate Configuration, Deploy to Cloudflare and smoke-tests all passed. Signed in by workload identity.GET /healthreturned 200. Asstaging2-agent-admin, the trigger list returnedcronHumanReadable: "Every 15 minutes"for two existing*/15 * * * *triggers. That value is computed bycronToHumanReadablefrom@simple-agent-manager/cronin the deployed Worker (services/trigger-read.ts).The write path (
validateCronExpression,cronToNextFireon create and update) cannot be exercised there: trigger create and edit refuse agent sign-in sessions by design (assertNotAgentSignInSessioninroutes/triggers/crud.ts:403 Agent sign-in sessions cannot create credentials or grant access). staging2's only other session token is the workflow-onlySMOKE_TEST_TOKEN. No test resources were created, and the lease was released (run 43990835091).Primary staging (
sammy.party), head99bbfa0cb, 2026-11-17 04:39-05:33Z. Deploy run 44018692314 succeeded: queue, lease, Validate Configuration, Deploy to Cloudflare and smoke-tests all passed. The write-path check (create, list, update, invalid expression, every-minute, delete) did not run. The normal-session test token is only usable through SAMexec_with_secrets; in a plain shell it is a placeholder, and token-login returned 401 for that reason. SAM's MCP tools were disconnected from the session for the whole lease, so the lease was released unused (run 44024945939) and the branch is queued again. (Superseded by the run below.)Primary staging (
sammy.party), head5ba2eb30e(rebased on main1ed27436c), 2026-11-17 19:52Z. Write path verified. Deploy run 44158298531: queue, lease, Validate Configuration and Deploy to Cloudflare passed; the staging deployment record shows5ba2eb30e. Signed in with the primary test user's token-login session (through SAMexec_with_secrets), then in project01KWHD8XS7MQ7R6KWXJYRHDVH4:0 9 1 1 *UTCnextFireAt2027-01-01T09:00:00.000Z,cronHumanReadable"At 9:00 AM on day 1 of the month in Jan"30 6 * * 1nextFireAt2026-11-23T06:30:00.000Z(next Monday), "At 6:30 AM on Monday"* ** * * * *61 * * * *validateCronExpression,cronToNextFireandcronToHumanReadableall ran from@simple-agent-manager/cronin the deployed Worker.Changes since the last review round (takeover by task
01M7N5Q1YTKVCRNMKDJKN9G760): rebased twice onto main. The.sonarcloud.propertiesconflict was resolved by keeping both new exclusions. Commit5ba2eb30etrims this PR's launch-context addition to 68 bytes (shorterCLAUDE.mdline;crondropped from the rule 08 diagram, where it implied the worker module packages depend on it; both build-order sentences still list it), because Code Quality Checks failed at 210,107 bytes against the 210,000 ceiling after the rebase. Docs only, no code change.UI Compliance Checklist (Required for UI changes)
N/A: no UI change.
UI Screenshot Evidence
N/A: no UI change.
End-to-End Verification (Required for multi-component changes)
Data Flow Trace
Trigger create (
routes/triggers/crud.ts, MCProutes/mcp/trigger-create-tool.ts) →services/trigger-create.ts(validateCronExpression,cronToNextFire) → D1triggers.next_fire_at. Read paths:services/trigger-read.ts,routes/mcp/trigger-tool-shared.tsandoperation-ports.ts(cronToHumanReadable). Cron sweep:scheduled/cron-triggers.ts(cronToNextFire). All of these now import@simple-agent-manager/cron, which the worker bundles frompackages/cron/dist.Untested Gaps
N/A: behaviour is unchanged and covered by the moved unit tests plus the worker route, sweep and workers-pool tests; staging covers the deployed bundle.
Post-Mortem (Required for bug fix PRs)
N/A: not a bug fix.
Specialist Review Evidence (Required for agent-authored PRs)
needs-human-reviewlabel added and merge deferred to human (N/A: all completed; the first run stopped at a usage limit and the same reviewers were resumed)scripts/quality/ast-checks.tsscanned the file before the move, so it now scanspackages/cron/src(fece83e). LOW: task file ticked, with evidence and the rule 51 decision recorded (fece83e).shared -> cron -> api, coherent subject, wiring matches scheduler-core). MEDIUM:apps/web/src/pages/automation/editor/cron.tshas an older, partial parser of its own. Moving the web editor onto the package changes web behaviour, so it is recorded as a follow-up on the seam map idea, not done in a pure move. MEDIUM: the dated blog post keeps its historical path (see Documentation & Specs). LOW: AGENTS.md wording fixed (fece83e).^buildand theapi^...filters build the package with no named step; Miniflare and vitest aliases need no entry; every sibling-package list is covered. INFO (ast-checks) addressed in fece83e.CodeRabbit Review Evidence (Required for agent-authored PRs)
CodeRabbit Notes
Requested 14:39Z with the
coderabbit-reviewlabel when the PR was marked ready; the label workflow ran and CodeRabbit replied "Review triggered". It reviewed30ae952ae..fece83e2aand approved, with "No actionable comments were generated" and merge risk "Minimal". Its summary calls the plain-text package diagram in.claude/rules/08-architecture.md(which predates this PR) a non-blocking format issue. It opened no thread, and converting the diagram is outside a pure move.After the takeover rebases and the launch-budget trim (
5ba2eb30e, pushed 18:50-19:13Z), CodeRabbit posted no incremental review within the wait; its approval stands and no CodeRabbit thread is unresolved.CI note: on run 43887945119 (
fece83e2a),Test web (2/2)failed once onSecretRequestCard.test.tsx(waitFortimed out after its 1 s default; the PR touches no web code). It passed locally and on rerun, so all checks are green. The flake is tracked as SAM idea01M7JF5EBFQCGS7H7QN089YMFH.Exceptions (If any)
Agent Preflight (Required)
Classification
External References
N/A: no external API; internal reorganisation following PR #2681 and
tasks/archive/2026-11-12-worker-modularization.md("Package template").Codebase Impact Analysis
packages/cron/(new):src/cron-utils.ts(moved fromapps/api/src/services/cron-utils.ts),src/index.ts,tests/unit/cron-utils.test.ts(moved fromapps/api/tests/unit/services/).apps/api/src: import path only inoperation-ports.ts,routes/tasks/crud.ts,routes/triggers/crud.ts,routes/mcp/trigger-create-tool.ts,routes/mcp/trigger-tool-shared.ts,routes/mcp/trigger-tools.ts,scheduled/cron-triggers.ts,services/trigger-create.ts,services/trigger-read.ts,services/trigger-status.ts.apps/api/tests: import orvi.mockpath only in six test files.apps/api/package.json,pnpm-lock.yaml,.github/workflows/ci.ymlande2e-smoke.ymlpath filters, thequality:runtime-boundary-semanticsscope inpackage.json, thescripts/quality/ast-checks.tsscan scope.apps/api/src/operation-ports.tson lines away from the moved import; Git merges them cleanly.Documentation & Specs
CLAUDE.md(structure, build order),.claude/rules/08-architecture.md(package graph, build order),apps/www/src/content/docs/docs/guides/local-development.md(build order),packages/cron/AGENTS.md(new), regenerated rule indexes. No spec changes. Blog postsams-journal-two-features-one-day.mdkeeps its historical path.Constitution & Risk Check
Principle X (simplicity): a leaf package with one dependency, no ports and no shims. Principle XI (no hardcoded values): unchanged code; the minimum interval still comes from
DEFAULT_CRON_MIN_INTERVAL_MINUTESin shared. Risk: the deployed bundle must contain identical cron logic. Checked by bundle comparison above and by the staging trigger check.🤖 Generated with Claude Code
Summary by CodeRabbit