Skip to content
Merged
41 changes: 41 additions & 0 deletions .changeset/35143-flow-publish-checks-second-batch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
'@objectstack/lint': minor
'@objectstack/spec': patch
---

fix(lint)!: ten publish-time checks for flows that save and do not run — seven refuse the publish, three warn

Clause-②: yes (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up #36718

<!-- adr-0087: registered publish-refuses-flows-that-save-and-do-not-run -->

**BREAKING** for the publish of a flow that carries one of the seven errors below: it was accepted before and is refused now, with the fix named in the finding. The schema is unchanged and stored flows are not rewritten or refused at boot; the refusal comes at the next publish, and from `os validate` / `lint` / `compile` / `build`.

Seven errors, run by the runtime publish gate and the CLI:

- `flow-trigger-object-missing`: a record-triggered flow with no `objectName` registers its hook with no object, so it fires on writes to every object; a blank `objectName` is refused too, because the engine will not register a hook on an empty name and the flow never starts.
- `flow-condition-option-label`: a start condition compares a select field with one of its option labels (`record.stage == 'Closed Lost'`) where the row holds the option value (`closed_lost`), so it is never true. Reported only when the label is that field's own comparand (`F == 'L'`, `F != 'L'`, `'L' == F`, or a member of `F in [...]`); judged only when the field's options are inline in this stack.
- `flow-time-relative-shadowed`: a `timeRelative` block under a record `triggerType` never sweeps, because a record trigger wins.
- `flow-time-relative-key-misplaced`: `filter` or `maxRecords` written beside `timeRelative` is ignored; the sweep reads them only inside the block.
- `flow-time-relative-date-field-invalid`: a `timeRelative.dateField` the swept object does not have, or that is not a `date` / `datetime` field, matches no record. Judged only when the stack declares the object; `created_at` / `updated_at` count as datetime fields.
- `flow-node-write-unknown-option`: a create / update node writes a select field a literal no option carries; the record validator refuses it `invalid_option` on every run. When the literal is an option's label, the finding names its value.
- `flow-node-write-date-helper-text`: a create / update node writes a date field the text of a helper call (`'today()'`); the validator refuses it `invalid_date`. The fix is a CEL value envelope, `{ dialect: 'cel', source: 'isoDate(today())' }`.

Three warnings, which refuse nothing and make `os validate --strict` exit 1 as any warning does:

- `flow-schedule-timezone-missing`: a schedule or time-relative cron with no `timezone` runs in UTC.
- `flow-subflow-unknown` (CLI only, new rule `validateFlowSubflowTargets`): a `subflow` / `map` node names a flow this stack and its packages do not carry. The publish gate sees one flow at a time, and another package may ship the called flow, so it is not judged there.
- `flow-create-update-pair`: an after-create flow and an after-update flow on the same object with the same nodes; one flow on `triggerType: 'record-after-write'` does both (on the create run `previous` is null). Judged on the CLI, where the stack holds both flows.

## FROM → TO

- a start node `{ triggerType: 'record-after-update' }` with no `objectName` → `{ triggerType: 'record-after-update', objectName: 'deal' }`.
- `record.stage == 'Closed Lost'` → `record.stage == 'closed_lost'`.
- `triggerType: 'record-after-update'` plus `timeRelative` → keep the one the flow means.
- `{ timeRelative: {...}, filter, maxRecords }` → `{ timeRelative: { ..., filter, maxRecords } }`.
- `fields: { stage: 'Closed Lost' }` → `fields: { stage: 'closed_lost' }`.
- `fields: { due_on: 'today()' }` → `fields: { due_on: { dialect: 'cel', source: 'isoDate(today())' } }`.

New exports from `@objectstack/lint`: `validateFlowSubflowTargets` and the rule ids `FLOW_TRIGGER_OBJECT_MISSING`, `FLOW_CONDITION_OPTION_LABEL`, `FLOW_TIME_RELATIVE_SHADOWED`, `FLOW_TIME_RELATIVE_KEY_MISPLACED`, `FLOW_TIME_RELATIVE_DATE_FIELD_INVALID`, `FLOW_SCHEDULE_TIMEZONE_MISSING`, `FLOW_SUBFLOW_UNKNOWN`, `FLOW_NODE_WRITE_UNKNOWN_OPTION`, `FLOW_NODE_WRITE_DATE_HELPER_TEXT`, `FLOW_CREATE_UPDATE_PAIR`. `@objectstack/spec` adds only the upgrade-guide entry `publish-refuses-flows-that-save-and-do-not-run`.
4 changes: 2 additions & 2 deletions content/docs/automation/flows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3029,7 +3029,7 @@ export const renewalReminder: Flow = {
// run acts as its own record's organization) and not read under
// `single`. See "The acting organization" below.
organization: '<sys_organization.id>',
// schedule: { type: 'cron', expression: '0 8 * * *' } // optional; defaults to daily 08:00 UTC
// schedule: { type: 'cron', expression: '0 8 * * *', timezone: 'UTC' } // optional; defaults to daily 08:00 UTC
},
},
{ id: 'notify_owner', type: 'notify', label: 'Notify Owner' },
Expand Down Expand Up @@ -3094,7 +3094,7 @@ it runs as**, on the start node's `config`, beside the cadence it scopes:

```typescript
config: {
schedule: { type: 'cron', expression: '0 8 * * *' },
schedule: { type: 'cron', expression: '0 8 * * *', timezone: 'UTC' },
organization: 'org_msokm9oaz0cal87q', // a sys_organization.id
}
```
Expand Down
2 changes: 1 addition & 1 deletion content/docs/deployment/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ os compile --json # JSON output for CI pipelines
→ Normalizing stack definition...
→ Lowering inline handlers...
→ Validating protocol compliance...
→ Running author-time rules (77)...
→ Running author-time rules (78)...
→ Checking that every required capability has a provider installable in this edition...
→ Collecting package docs (ADR-0046)... 0 collected
→ Writing artifact...
Expand Down
2 changes: 1 addition & 1 deletion content/docs/deployment/validating-metadata.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ A clean run walks the registry and reports timing:
Config: /path/to/support-desk/objectstack.config.ts
Load time: 21ms
→ Validating against ObjectStack Protocol...
→ Running author-time rules (77)...
→ Running author-time rules (78)...
→ Checking that every required capability has a provider installable in this edition...
→ Checking package docs (ADR-0046)...

Expand Down
2 changes: 1 addition & 1 deletion content/docs/getting-started/build-with-claude-code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ visible: 'status != "resolved"'
◆ Validate
────────────────────────────────────────
→ Validating against ObjectStack Protocol...
→ Running author-time rules (77)...
→ Running author-time rules (78)...

✗ Author-time rules failed (1 issue)
• stack · action 'resolve_ticket' visible: bare reference `status` — a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ On the flow's START node `config`, beside the cadence it scopes:

```ts
config: {
schedule: { type: 'cron', expression: '0 8 * * *' },
schedule: { type: 'cron', expression: '0 8 * * *', timezone: 'UTC' },
organization: 'org_msokm9oaz0cal87q',
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ config: {
filter: { status: 'active' },
},
// optional sweep cadence — defaults to daily at 08:00 UTC
schedule: { type: 'cron', expression: '0 8 * * *' },
schedule: { type: 'cron', expression: '0 8 * * *', timezone: 'UTC' },
}
```

Expand Down
2 changes: 1 addition & 1 deletion content/docs/ui/react-pages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ objectstack validate
────────────────────────────────────────
→ Loading configuration...
→ Validating against ObjectStack Protocol...
→ Running author-time rules (77)...
→ Running author-time rules (78)...
→ Checking that every required capability has a provider installable in this edition...
→ Checking package docs (ADR-0046)...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const ExchangeRateSyncFlow = defineFlow({
type: 'start',
label: 'Daily at 06:00',
config: {
schedule: { type: 'cron', expression: '0 6 * * *' },
schedule: { type: 'cron', expression: '0 6 * * *', timezone: 'UTC' },
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/app-todo/src/flows/task.flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const TaskReminderFlow: Flow = {
// `objectName` into the record-change binding only), so the key would be
// stored and never read. The sweep names its object where it reads, on the
// `get_record` step below.
{ id: 'start', type: 'start', label: 'Start (Daily 8 AM)', config: { schedule: '0 8 * * *' } },
{ id: 'start', type: 'start', label: 'Start (Daily 8 AM)', config: { schedule: { type: 'cron', expression: '0 8 * * *', timezone: 'UTC' } } },
{
id: 'get_upcoming_tasks', type: 'get_record', label: 'Get Tasks Due Tomorrow',
// `limit > 1` is the declared way to make this a LIST read (`find`, not
Expand Down Expand Up @@ -164,7 +164,7 @@ export const OverdueEscalationFlow: Flow = {

nodes: [
// No `objectName` here either: see `todo_task_reminder`'s start node.
{ id: 'start', type: 'start', label: 'Start (Daily 9 AM)', config: { schedule: '0 9 * * *' } },
{ id: 'start', type: 'start', label: 'Start (Daily 9 AM)', config: { schedule: { type: 'cron', expression: '0 9 * * *', timezone: 'UTC' } } },
{
id: 'get_overdue_tasks', type: 'get_record', label: 'Get Severely Overdue Tasks',
// `limit > 1` = LIST read; the undeclared `getAll` was never read (#4277).
Expand Down
16 changes: 16 additions & 0 deletions packages/lint/src/authoring-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ import { validatePageSourceStyling } from './validate-page-source-styling.js';
import { validateCapabilityReferences } from './validate-capability-references.js';
import {
validateFlowApiTriggerSecret,
validateFlowSubflowTargets,
validateFlowTriggerReadiness,
} from './validate-flow-trigger-readiness.js';
import { validateApprovalApprovers } from './validate-approval-approvers.js';
Expand Down Expand Up @@ -1659,6 +1660,21 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [
// GET → edit → PUT passes, and a secretless `api` flow is refused at `/meta`
// with this id instead of being stored for the engine to refuse at
// registration.
// #35143 — a `subflow` / `map` node calling a flow this stack does not
// define. CLI only: the runtime gate's flow snapshot holds just the written
// flow, so every call to another stored flow would read as unknown there.
// Advisory, with the sibling unknown-object hedge: another installed package
// may ship the called flow.
{
name: 'validateFlowSubflowTargets',
tier: 'advisory',
input: 'normalized',
commands: ALL,
source: 'packages/lint/src/validate-flow-trigger-readiness.ts',
surfaces: CLI_ONLY,
surfaceReason: RUNTIME_NEEDS_FULL_SNAPSHOT,
run: (stack) => validateFlowSubflowTargets(stack),
},
{
name: 'validateFlowApiTriggerSecret',
tier: 'gating',
Expand Down
Loading
Loading