Skip to content

feat(cli): lint the record-change date-equality time anti-pattern at build (#1874) - #1918

Merged
os-zhuang merged 1 commit into
mainfrom
feat/1874-time-relative-antipattern-lint
Jun 15, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
feat/1874-time-relative-antipattern-lint

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Refs #1874.

Framing: this targets the core problem, not the literal feature

The templates are AI-authored, and preventing AI authoring mistakes is the project's core goal. The robust capability for time-relative rules already exists (daily SCHEDULE trigger + range query), so the high-leverage fix for "renewal_alert never fires" is not a new trigger primitive — it's a build-time guardrail that catches the exact mistake the author (AI or human) keeps making, in the same "make silently-wrong metadata loud at build" vein as #1877 / #1870 / #1876.

What it does

objectstack build now emits an advisory WARNING when a record-* flow's start condition compares a date field for EQUALITY against a time function:

end_date == daysFromNow(60)      // ⚠ only fires if the record is written on that exact day
today() != record.start_date

…and points the author at the robust shape: a daily schedule trigger + a range query (get_record where end_date BETWEEN {TODAY()} and {TODAY()+N}).

Precision (low false-positive by design)

  • Flags: equality (==/!=) adjacent to daysFromNow/daysAgo/today/now/date/datetime, either side, on record-* triggers; string or Expression-envelope conditions.
  • Does NOT flag: range comparisons (>=/<= — the correct building block), non-time-field equality, or schedule-trigger conditions.
  • Never fails the build — advisory only (mirrors the dashboard widget-binding warnings). Guides without breaking technically-legal metadata.

Tests

New lint-flow-patterns.ts + 7 unit tests (both equality forms, envelope condition; range/non-time/schedule false-positive guards). @objectstack/cli suite 383 pass; example builds clean (no spurious warnings).

Scope note

This does not implement #1874's declarative time-relative trigger (a future DX feature needing real API design — multi-threshold windows, per-record fan-out, indexed queries for scale, Studio authoring), nor the cross-repo template fixes. It's the AI-authoring guardrail, which is the part that pays off now.

🤖 Generated with Claude Code

…build (#1874)

The templates are AI-authored, so the highest-leverage fix for the "time-relative
rule never fires" class is a build-time guardrail that catches the exact mistake,
not a new trigger primitive (the robust cron+range pattern already exists).

`objectstack build` now emits an advisory WARNING when a `record-*` flow's start
condition compares a date field for EQUALITY against a time function
(`end_date == daysFromNow(60)`, `today() != ...`) — valid CEL, but it only fires
if the record is written on that exact day, so unattended "N days before" rules
never run. The warning steers the author to a daily SCHEDULE trigger + range
query. Range operators (>=/<=) and non-time equality are NOT flagged; the lint
never fails the build (guides, doesn't break legal metadata).

New `lint-flow-patterns.ts` + 7 unit tests (flag equality both sides /
Expression envelope; do-not-flag range / non-time / schedule trigger). Wired into
compile.ts as advisory warnings (mirrors widget-binding warnings). CLI suite 383.

Refs #1874 (the declarative time-relative trigger feature + the cross-repo
template fixes remain separate; this is the AI-authoring guardrail).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 15, 2026 3:11pm

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling labels Jun 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/cli.

15 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/concepts/cloud-artifact-api.mdx (via packages/cli)
  • content/docs/concepts/implementation-status.mdx (via @objectstack/cli)
  • content/docs/concepts/packages.mdx (via @objectstack/cli)
  • content/docs/getting-started/cli.mdx (via @objectstack/cli)
  • content/docs/getting-started/quick-start.mdx (via @objectstack/cli)
  • content/docs/guides/authentication.mdx (via @objectstack/cli)
  • content/docs/guides/client-sdk.mdx (via @objectstack/cli)
  • content/docs/guides/hook-bodies.mdx (via packages/cli)
  • content/docs/guides/packages.mdx (via @objectstack/cli)
  • content/docs/guides/project-scoping.mdx (via @objectstack/cli)
  • content/docs/guides/runtime-services/data-service.mdx (via packages/cli)
  • content/docs/guides/runtime-services/index.mdx (via packages/cli)
  • content/docs/guides/skills.mdx (via packages/cli)
  • content/docs/protocol/objectos/plugin-spec.mdx (via @objectstack/cli)
  • content/docs/protocol/objectos/realtime-protocol.mdx (via @objectstack/cli)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@os-zhuang
os-zhuang merged commit c226e93 into main Jun 15, 2026
14 checks passed
@os-zhuang
os-zhuang deleted the feat/1874-time-relative-antipattern-lint branch June 15, 2026 15:14
os-zhuang added a commit that referenced this pull request Jun 23, 2026
fix(ai-chat): route AI-built apps by packageId, not the app name (ADR-0048) (#1918)

objectui@aa50dc07f55ba8328f5858695678b9f4c67c81f4

This branch was successfully deployed

1 active deployment
Preview — 75525702 Deployed Jun 15, 2026 by vercel[bot]
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant