Skip to content

fix(trigger-schedule): an invalid timeRelative descriptor throws from start so the automation status reads it unbound - #27556

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-27415-time-relative-bind-verdict
Oct 29, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-27415-time-relative-bind-verdict

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #27415

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:时间相对触发器(time_relative)在 timeRelative 描述符不合法时,start 由「记日志后 return」改为「记同一句日志后抛错」,并先撤掉此前已挂的扫描任务。
  • 为什么改:原来 return 被引擎当成绑定成功,GET /automation/_status 对一个根本没挂上的流报 bound: true、没有 unboundCause,与服务器自己的 "not bound" 日志相矛盾;抛错是引擎既有的「绑定失败」通道,schedule 触发器的组织/部署策略拒绝早已这样做。
  • 风险与回滚:只改一个文件的一个分支;合法描述符行为不变。直接调用 TimeRelativeTrigger.start 的宿主在非法描述符上会收到异常(引擎自身已 catch)。回滚即还原本 PR 一个 commit。
  • 先看:packages/triggers/trigger-schedule/src/time-relative-trigger.ts(start 里 !parsed.success 分支,风险在 throw 前的 this.stop)、src/time-relative-bind-status-e2e.test.ts(真引擎状态行的 pin)。
  • 两分钟验证:pnpm --filter @objectstack/trigger-schedule exec vitest run src/time-relative-bind-status-e2e.test.ts,预期 1 passed:非法描述符的流读 bound: false + unboundCause: binding_failure,合法的流读 bound: true。
  • 需要你做的:无,席位落地。

What changes

TimeRelativeTrigger.start refused an invalid config.timeRelative descriptor (both withinDays and offsetDays, an unknown key, schedule nested inside the descriptor) by logging [time-relative] flow 'NAME' has no valid timeRelative descriptor — not bound and returning. FlowTrigger.start returns void, so the engine's activateFlowTrigger read that return as a successful arm and recorded the flow in boundFlowTriggers. The status row (getFlowRuntimeStates(), served by GET /api/v1/automation/_status) then read bound: true with no unboundCause.

The refusal now throws the same sentence it logs. This is the path the trigger's own organization and deployment-policy refusals already take (refuseMissingOrganization / refuseScheduledWorkDisabled in schedule-trigger.ts; the "Why it throws, and does not merely log and return" docblock there describes the mechanism). The engine's existing catch never marks the flow bound, so the row reads bound: false with unboundCause: 'binding_failure', and the boot binding audit lists it. Before throwing, the branch calls this.stop(flowName), as the organization refusal does, so a re-bind with a broken descriptor cannot leave the sweep from an earlier valid bind armed. The warn line text is byte-identical to before, and the level stays warn: a trigger that is not armed is a functional degradation, and the status row now reports it.

No engine change and no FlowTrigger interface change. packages/services/service-automation/** is untouched.

One patch changeset for @objectstack/trigger-schedule.

Tests

  • src/time-relative-trigger.test.ts: the existing "invalid descriptor" case now asserts the throw. A new block covers three invalid shapes (both modes, an unknown key, schedule nested in the descriptor). For each: start throws a message naming the flow, arms no job, and logs the refusal once. Also new: a re-bind with a broken descriptor drops the previously armed sweep, and a control where a valid descriptor does not throw and arms its sweep.
  • src/time-relative-bind-status-e2e.test.ts (new): the real TimeRelativeTrigger registered on the real AutomationEngine. An invalid-descriptor flow reads bound: false, triggerType: 'time_relative', unboundCause: 'binding_failure', with no sweep armed. The valid control flow reads bound: true, has no unboundCause key, and its sweep is armed. The engine-only twin of this pin (engine.test.ts, "ON: a genuine bind failure reads as one on the status row too") lives in service-automation, which is outside this PR's surface. This package already devDepends on that engine, so the pin lives here.
Package test + typecheck at da85763
pnpm --filter @objectstack/trigger-schedule test && pnpm --filter @objectstack/trigger-schedule typecheck
 Test Files  11 passed (11)
      Tests  196 passed (196)
> tsc --noEmit
os-verify-lock: VERDICT command-exit 0

tsc --listFiles counts 11 of the package's *.test.ts files in the program, including the new e2e file.

Ablation (one-shot): the throw replaced by the old return

node scripts/ablation-replace.mjs --file packages/triggers/trigger-schedule/src/time-relative-trigger.ts --anchor 'throw new Error(sentence);' --replacement 'return;' landed (anchor 1 to 0, blob 520bd258c30a to cf719226888f). Both suites then went red:

 Test Files  2 failed (2)
      Tests  6 failed | 60 passed (66)
  x does not bind when the timeRelative descriptor is invalid
  x both windowing modes / an unknown key / schedule nested: start throws ...
  x a re-bind with a broken descriptor drops the sweep the previous bind armed
  x an invalid descriptor reads bound:false with the binding-failure cause; a valid one reads bound:true

Restore leg: blob after restore 520bd258c30a equals the HEAD blob, and git diff HEAD is empty. The trigger is imported by relative path, so the mutation reached the run without a rebuild. The engine resolves through dist/, but its source is unchanged in this diff.

Local gates (derived by dispatch-gates --commands)

57 derived families were run locally, and --ran reconciled 57 of 57. 54 exited 0. check:nul-bytes, check:cross-package-test-inputs, check:test-source-alias and check:engine-double-contract were re-run at da85763 and all exited 0. NOT MEASURED locally, left to CI:

  • check:dual-build-cjs-loads: exit 3, PREREQUISITE NOT MET. It needs every package's dist/.
  • check:query-options-erasure: hit the 300 s local timeout. It is a repo-wide ESLint scan.
  • check:type-check-debt: hit the 300 s local timeout during the whole-repo tsc walk.

The derivation warned that its tree was 7 commits behind origin/main. The 2 stale files are scripts/gen-sdui-reference.mjs and scripts/pm/dispatch-gates.self-test.mjs. Neither reads this diff's paths.

Acceptance notes

  • The schedule trigger's own descriptor refusal has the same log-and-return shape: [schedule] flow 'NAME' has no recognizable schedule descriptor — not bound in ScheduleTrigger.start (schedule-trigger.ts). Under this PR's reasoning that flow also reads bound: true. That file is outside this PR's surface, so the seat has the finding to route.
  • Both triggers' "job service unavailable — not scheduled" branches also return rather than throw. That is a composition gap, a different remedy from a bad descriptor. This is noted only: it was inferred from reading the code and not reproduced.

Verification

Run the two-minute check above. Or, as on the card: boot the showcase with OS_AUTOMATION_SCHEDULED_WORK_ENABLED=1 and OS_ALLOW_UNLINTED_METADATA_WRITES=1, PUT a time_relative flow whose descriptor carries both withinDays and offsetDays, then read GET /api/v1/automation/_status. Expect bound: false with unboundCause: "binding_failure". This live-boot path was not run in this PR, and the e2e pin above covers the same engine row.


Generated by Claude Code

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 1 changed package(s)), so this run has no opinion about the docs.

What this run could not see

Coarse fallback — 2 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json ad3a640e35fe660e3574fdf35b89219e176e964e → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:devx#1 · sunhaolin · session_017xRBcScm27Q3R5mkYLPWdB

席位核对

Verdict: ACCEPT at head da85763fdad297b8aa1d016ae83400f21922a762, reviewed 2026-10-29T16:36Z.

check reading
Shape Draft, base main, Fixes #27415. No other closing keyword. mergeable_state: clean.
Path surface 4 files: time-relative-trigger.ts, two test files, one changeset. +199/-17; 0 governed. No contract face: no spec, no governed text, no accept set narrowed.
Clause-② no, correct.
Changeset @objectstack/trigger-schedule patch. Each sentence matches the diff, including the note that a direct caller of start now sees a throw on a refused descriptor.
Diff read On a failed safeParse, start now drops any previously armed sweep, logs the same warn line, and throws the same sentence. That is the trigger's existing refuseMissingOrganization path, which the engine's catch reads as a binding failure. The valid path is untouched.
Assertions Three invalid shapes: each throws naming the flow, arms nothing, and warns once. A broken re-bind drops the earlier sweep. A valid control does not throw and arms. The engine e2e test reads the real status row: bound: false with unboundCause: 'binding_failure', and the valid control reads bound: true with no cause. The ablation turns 6 cases red.
Dev evidence Package: 196 tests passed, typecheck clean. dispatch-gates --ran: 57 derived, 57 run. mcp_calls 0.
CI on head 34 success, 14 skipped. check-expected-skips --pr 27556 OK.

Answers to the dev report (6496874565):

  • Open question on the PR assignee: this run's dispatch named it, and option A stands for this PR. Reconciling os-dev.md with the relay's pr_create header is a skills-lane text fix, not this PR's.
  • Out-of-scope finding (ScheduleTrigger.start logs and returns on an unrecognised descriptor): unmeasured at a public door. It goes to triage as a finding card with a reach: it must measure, not into this PR.

Landing: ready plus auto-merge through the relay.


Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review October 29, 2026 16:40
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge October 29, 2026 16:40
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit 21e5979 Oct 29, 2026
49 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-27415-time-relative-bind-verdict branch October 29, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

automation: GET /automation/_status reports bound:true for a time_relative flow whose trigger refused to bind it, with no unboundCause

2 participants