Skip to content

feat(compiler): per-module octane/data contract check (rules 1–4) - #2605

Merged
trueadm merged 175 commits into
mainfrom
feat/data-contract-check
Nov 13, 2026
Merged

trueadm merged 175 commits into
mainfrom
feat/data-contract-check

Conversation

@trueadm

@trueadm trueadm commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Step 1 of the agreed octane/data contract convention: the per-module analysis and rules 1–4. The design was agreed with the user on 2026-11-13. Its note (docs(data): propose a checked convention for data contracts #2602) was closed unmerged, so the rules are stated in the module header and in docs/strong-compiler-checks.md; the broader design discussion is the octane/data RFC, RFC: octane/data for composable reads, mutations, forms, and recovery #2362.
  • New packages/octane/src/compiler/data-contracts.js exports analyzeDataContracts(source, filename), which parses one .ts, .tsx, .js or .tsrx module with the compiler's parser and returns { declarations, uses, diagnostics }.
  • Catalog entries for OCTANE_DATA_CONTRACT_DECLARATION, _MODULE, _ARGUMENT and _ESCAPE, rendered into the generated docs, llms.txt, the MCP copy and octane explain.

Why

  • Steps 2 and 3 (the whole-program pass and the generated octane/data/manifest in the Vite and Rspack plugins, then moving shelf over) need one compiler module that both plugins and octane analyze call. This is that module, unwired.

Changes

  • Rule 1 (declaration): a factory call (entity, read, view, write, feed imported from octane/data) must be the whole initializer of a module-level const, be exported (directly or via export { … }), and carry a string-literal name (or literal first argument for entity) with no spread. Two contracts with one name in the same module are reported here too; duplicates across modules are left to the whole-program pass.
  • Rule 2 (module): a contract declared outside *.data.ts / *.data.js is reported, and a contract module's top level may hold only imports (not octane/server, octane/data/server), types, and const declarations and exports.
  • Rule 3 (argument): sites match by method name (.read, .prefetch, .publish, .forget, .write, .form), imported or local function name (useForm, handle, pages, listen; useWrite is not a site, because it is being dropped from octane/data and every write goes through store.write(contract, input)), or property key (of, creates, patches, removes, put, remove, read), never by the receiver. A contract named directly is a use site. An argument that only contains a contract (conditional, ??, contracts[name]) is reported. An argument that names no contract, such as stream.write(chunk), is not a site.
  • Rule 4 (escape): any other contract reference is reported, except exports, type positions (skipped by forEachRuntimeAstChild), and the object of a property read (books.view.compare, setRead.name).
  • Loop form: the parameter of [a, b].map((x) => …) or for (const x of [a, b]) over an inline array of contract bindings stands for exactly those bindings: its sites record one use per element, and any other use of it is an escape.
  • Which bindings count as contracts: declared ones, plus value imports and namespace imports from a specifier ending .data, .data.ts or .data.js (type-only imports excluded). Scope resolution reuses createLexicalAnalysis, so shadowed names are not mistaken for contracts.
  • Catalog placement: I put the entries in a new data section of the existing strong-diagnostics.js catalog, not a sibling catalog. The catalog already feeds every renderer, the CLI snapshot and the MCP copy. A sibling catalog would mean a second generator, a new docs region, and new lookup paths in octane explain and MCP for four entries. The section title and the catalog header say these codes belong to the data check, not to Strong mode, and docs/strong-compiler-checks.md gets a separate "Data contracts" section that says so. The catalog test now scans for OCTANE_DATA_CONTRACT_* codes too, so a new data code cannot ship without an entry. If the data check gets its own docs page later, only the generator's output targets need to move.

Validation

  • targeted tests: vitest run packages/octane/tests/compiler/data-contracts.test.ts packages/octane/tests/compiler/strong-diagnostics-catalog.test.ts packages/cli/tests/catalog.test.js packages/octane-mcp-server/src: all pass.
  • Failing-first, per rule: with each code's report disabled in turn, DECLARATION fails 1 test, MODULE 2, ARGUMENT 1, ESCAPE 3. With loop aliasing disabled, the shelf server test and the use-site tests fail.
  • Shelf: the contracts.ts content as shelf.data.ts and server.ts (imports renamed) pass with no diagnostics. The server records one handle use per view through the [books, finished, unread].map loop. Run ad hoc against feat/data-one-read, shelf's octane/App.tsrx, react/App.tsx, react/Summary.tsx and mixed/main.tsrx are clean too. shared/session.ts reports escapes for its hand-kept contracts and journal.writes lists, which is intended: the manifest replaces them in step 3.
  • octane explain OCTANE_DATA_CONTRACT_ESCAPE prints the entry.
  • pnpm sync (no further changes), pnpm strong:diagnostics:check, pnpm cli:data:check, pnpm format:files:check, pnpm typecheck:files on the new and changed compiler files.
  • pnpm test, full pnpm typecheck and pnpm format:check: not run locally; left to CI.
  • perf-review: node scripts/perf-review-scan.mjs: no candidates. Compiler-only and unwired: nothing in the runtime, compiled output or plugins calls it yet.
  • concise-code: src +517 −2, most of it the analysis module (~420 lines) and four catalog entries; runtime +0. New file: compiler/data-contracts.js, the one module the spec asks for. New export: analyzeDataContracts, called by the test now and by both plugins in step 2. Alternatives rejected: a sibling catalog (second generator plus CLI and MCP lookups, larger), and reusing strong-mode.js analysis (it runs only on Strong-eligible modules and skips .tsx). Bytes: not applicable.

Risk / follow-ups

  • An import from a *.data.ts module is treated as a contract, because the checker can't see the other module. A non-contract export of a contract module, such as a shared zod schema, used outside a site would be a false ESCAPE. Step 2 can pass the contract module's own declarations to narrow this; I left that option out because it has no caller yet.
  • A .read/.write site whose argument is a parameter or local variable is not reported at the site. The contract can only reach it through a reported escape (helper(setRead), const w = setRead), which keeps the analysis complete without flagging unrelated stream.write(x) calls.
  • The "module with a module server block" import restriction in rule 2 needs other modules' facts, so it moves to the whole-program pass.
  • docs/strong-compiler-checks.md states the four rules inline and links the octane/data RFC (RFC: octane/data for composable reads, mutations, forms, and recovery #2362); nothing in the diff refers to the closed design note.
  • No changeset: nothing reports these codes until the plugins call the check in step 2, which should carry the changeset.

Provenance

  • An agent produced this diff (agent-authored)

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Note

Medium Risk
New compiler analysis and four error codes affect future builds once wired; currently test-only with no runtime/plugin integration in this PR.

Overview
Adds the per-module octane/data contract check as analyzeDataContracts in a new data-contracts.js module. For each .ts/.tsx/.js/.tsrx file it returns contract declarations, use sites, and four new errors: literal exported const declarations in *.data.* modules, inert contract modules, direct contract arguments at store/handler/hook sites, and no “escaping” bindings except allowed import/type/property-read uses (including loop aliases over inline contract arrays).

unwrapTsExpr is exported from descriptor-lowering.js so the checker sees through TS wrappers. The four OCTANE_DATA_CONTRACT_* codes join the existing Strong diagnostics catalog under a separate “data” section (docs, octane explain, MCP, llms.txt regenerated). Shelf-style fixtures and data-contracts.test.ts lock in rules 1–4; the catalog test now requires entries for data contract codes.

The analysis is not yet hooked into Vite/Rspack or octane analyze—that’s planned as a follow-up whole-program/manifest step.

Reviewed by Cursor Bugbot for commit 82b888e. Bugbot is set up for automated code reviews on this repo. Configure here.

trueadm and others added 30 commits November 10, 2026 18:41
…2400)

* feat: let packages declare Strong mode and applications require it

Packages declare Strong in package.json with "octane": { "strong": true }
or a list of paths. compiler.strongDependencies: { require, allow } fails the
build with OCTANE_STRONG_DEPENDENCY when an application module reaches a
non-Strong module in another Octane package or an octane/react boundary. The
walk moves from the CLI into the compiler, so octane analyze previews exactly
what the build rejects.

The six packages the website renders declare their Strong modules, and the
website turns require on with an empty allow list. Its playground version
picker replaces @octanejs/base-ui's Combobox with a local listbox.

Refs #2059

Co-Authored-By: Claude <[email protected]>

* fix: address review on Strong dependency requirement

- Vite plugin: always read octane.config.ts, so strongDependencies is not
  dropped when strong and renderers are both passed inline.
- octane analyze: keep going under require when there are no views, so plain
  application modules are still checked.
- Playground version picker: keep focus in the input on any press inside the
  list, not only on option rows.

Co-Authored-By: Claude <[email protected]>

* fix(website): let the version list's scrollbar scroll

A mousedown preventDefault on the scrolling list also blocked its scrollbar.
The list now takes focus itself (tabIndex -1), and the field closes the popup
only when focus leaves it. Choosing an option returns focus to the input.

Co-Authored-By: Claude <[email protected]>

* fix(website): close the version list through the bubbling onBlur

Octane's onBlur is delegated as focusout, as React's is, and it is the
typed name; onFocusOut is not.

Co-Authored-By: Claude <[email protected]>

* fix(website): return focus to the version input on Escape

The list can hold focus, so hiding it on Escape dropped focus to the page.

Co-Authored-By: Claude <[email protected]>

* fix(compiler): name the Strong dependency code in its message

The printed-code audit rejects interpolating a non-diagnostic `.code`.

Co-Authored-By: Claude <[email protected]>

* test(website): expect the package reason in Strong module status

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
* feat(codemod): migrate verified path-only SVG components

* fix(codemod): trace SVGs through native renderable props

* fix(codemod): follow proven renderable TypeScript wrappers
…2401)

* fix(signals): replay optimistic$ updaters over newer source values

An overlay kept the value its updater produced at write time, so a refetch,
stream value or direct write stayed hidden behind a pending edit, and a
rejected operation's edit survived inside a later operation's value. Keep
each operation's writes and replay them in order over the current source,
as useOptimistic rebases its updates.

* fix(signals): show an optimistic$ overlay that produces undefined
… transaction (#2404)

* fix(data): server-assigned IDs for creates, and one commit per server transaction

A create can name where the server's ID is in its reply. Writes to the new
record wait for the create, are sent with the server's ID, and are refused
unsent if the create is refused. Every view a reply or an optimistic edit
changes is recomputed before any reader is notified.

* fix(data): keep a created record's writes in order across its new ID, and end them on retire
* feat(strong): reject markup outside template output

Strong mode now reports OCTANE_STRONG_VALUE_JSX for JSX returned from a
function, assigned, passed as a prop or argument, or chosen by an
expression, and for @{} blocks stored in objects or chosen by an
expression: each builds an element descriptor. The website, devtools tabs,
and compiled Router document no longer build descriptors on the client.

ErrorBoundary renders a fallback={@{ ... }} body instead of calling it as a
render prop, and the codemod lowers plain-reference && guards in Strong
output to @if/@else.

Refs #2059

* revert(strong): allow value JSX again; keep the ErrorBoundary and document fixes

Value JSX already compiles to a template behind an 'r:' record, so Strong
keeps accepting it. This drops OCTANE_STRONG_VALUE_JSX, the codemod guard
lowering, and the test conversions it required.

Kept: ErrorBoundary renders a fallback={@{ ... }} body instead of calling it,
the compiled Router document leaves server-only html/head/body out of client
builds, DevtoolsDemo's Suspense fallbacks are render bodies, and an MDX page
no longer nests a <p> inside a <p>.
…2408)

* test(data): compare cached responses with a normalized worker store on library journeys

Runs four library journeys and a cold start from storage against octane/data
as merged and a prototype normalized store that evaluates declared views in
a worker. Measures views shown, bytes fetched and persisted, worker traffic,
impossible states and feature code, as promised on #2362.

* test(data): add a normalized design that loads view windows instead of every book

* test(data): refuse journey 3's star by book ID, so the rename cannot let it through
…2407)

* fix(codemod): report bare SVG issuer changes in ordinary components

* fix(codemod): trace bare SVGs selected by component fallbacks

* fix(codemod): check SVG defaults on local destructuring

* fix(codemod): exclude SVG defaults overridden by an inline object
…2409)

* fix(tanstack-router): keep the server document out of browser builds

The compiled Html, Head, and Body read their server-only document
components through #server-document, which resolves to a null stub under
the browser condition. Folding isServer already removed those components
from client chunks, but Rolldown had linked their createScopedElement
import first and kept it exported from the runtime chunk.

Refs #2059

* test(tanstack-router): classify the server document resolution test
* feat(data): read the store as native Octane signal reads

The Octane binding reports each store read to the renderer as a native read
source, so components subscribe as they do to signal$ and query$ and need no
hook slot. The store calls its transport after the synchronous work that
started a load, so a read during render never runs it inside the render.

* fix(data): deliver store changes to Octane readers outside the transition

Native-read notifications honored the ambient transition, so a write inside
startTransition queued its optimistic edit behind the transition. runUrgent
clears the transition context around the notification, as
useSyncExternalStore's scheduleUrgentRender does.
* feat(data): declared lists with view()

A view defines a list by a rule over an entity. It loads its window plus a
margin, shares records with every other view of the entity, and evaluates its
rule locally, so an edit moves a record into, out of or across every view in
the task that made it. A write can name its saved record with `record`, which
views take in place of reloading. The Shelf example moves onto views.

* fix(data): keep paged views within max and wait for edits before reloading short windows

A later page took a left margin on top of a full window, so a page at the
view's max was refused; the margins now give way to the cap. A window that
unconfirmed edits left short reloaded on every new span until they settled;
it now reloads once the server has those edits.
* feat(data): native forms for writes

A write that declares `form` fields can be submitted by a plain HTML form,
which works before hydration and with JavaScript off. `useForm(write, key?)`
gives the form its attributes, hidden fields, pending state, submitted values
and field issues; once hydrated it submits through the store with the write's
optimistic edit. On the server, `forms(request)` runs a native submission and
answers 303, or returns the refusal for the page to render again, and signs
each page's forms for its account. The Shelf example's add and remove move
onto forms, with JavaScript-off and hydration journeys.

* chore(data): format forms files and refresh the example catalog

The new forms module and its tests were untracked when formatted, and the
Shelf journey added to example.json changes the generated catalog and its
e2e shard weights.

* fix(data): let go of a form that unmounted while its submission was in flight

A form handle was released only on unsubscribe while idle, so one that
unmounted mid-submission, as every removed row does, stayed in the store for
the rest of the session. It now also lets go when its submission settles with
no subscribers.
* feat(data): encrypted persistent cache with a size budget

A store given `persist: { storage, partition, key, budget }` saves each
read's confirmed value, and each view's confirmed rows, and starts from them
after a restart with their age kept. Values are encrypted with AES-GCM under a
key from the session, and every name the storage sees is a keyed hash, so
people sharing a browser can neither read nor list each other's values. A
value saved under another shape of its read's output schema, where the
validator describes one, or another `version`, is discarded; one that fails
validation on restore is too. Saves are coalesced per host task and the
partition is purged to its budget, expired values first and then the least
recently used, never one a mounted component shows. The budget defaults to a
size chosen by device memory, data saving and quota. `indexedDBStorage()` and
`memoryStorage()` are included. The Shelf example persists its store.

* fix(data): save reads a write carries back, and count restores as recent use

A write reply's refreshed reads were adopted but never saved, so a reload
within their freshness showed the value from before the write. A restored
value's last use reached only the next storage write, not the order purging
reads, so it could be purged before older unused values.
* feat(codemod): follow SVGs through single-read render locals

* fix(codemod): preserve evaluation and early-return boundaries
…rge in-use values at startup (#2419)

* fix(data): restore values a write marked stale as stale, and never purge in-use values at startup

A write or `invalidate()` marked only the entries in memory, so a value saved
earlier and restored within its freshness showed data from before the write.
Each tag and entity name now keeps the time it was last marked, in its own
encrypted record, and each saved value the time it was saved and the names it
holds; a value marked after it was saved is restored stale.

The startup purge ran before any component had asked for a value, so it could
delete values mounted components were about to restore. It now removes only
expired values; the budget applies from the first save.

* fix(data): save invalidation marks again after a failed save

The marks were flagged saved before the write finished and a failed write was
ignored, so its invalidations were lost and a later restart could show a value
from before the write as fresh. A failed save now leaves them flagged, and the
next save writes them.
* feat(data): durable writes that survive a restart

Writes listed in `persist.journal` are saved to an encrypted journal, in the
cache's storage, before they are sent, and leave it once their outcome is
known. After a restart the store shows each journaled write's edit again and
reads the journal's `receipt` with its operation ID: an applied receipt keeps
the edit, any other rolls it back, and the write is never sent twice. A write
whose receipt cannot be read stays for the next start; one this build no
longer declares, or whose input it no longer accepts, is dropped. `retire()`
clears the journal. The Shelf example's writes are durable.

* fix(data): recover journaled writes in submission order, and retry failed removals

Storage lists the journal by hashed name, so recovered writes came back in an
arbitrary order and a later edit could lose to an earlier one. Each entry now
carries its submission order and recovery sorts by it. A failed removal from
the journal was dropped, so a settled write could come back after the next
start; it is now tried again at the next save.
* fix(codemod): defer mutable SVG clsx guards

* perf(codemod): reuse fixed SVG parameter proofs
* feat(data): server-ordered reads share records with views

A read that selects entities but only the server can order, such as search
results, keeps the order and membership it was sent but now shares records
with the views. Its load gives views any newer copy of a record they hold,
and it shows any copy newer than its own load, from a view, another read or a
write's `record`. A load notifies every read sharing its entities. Copies are
compared by field, and an unchanged projection keeps its identity, so a read
whose shared records did not change keeps its snapshot, even with an edit
pending.

* fix(data): share only records views hold, and tell views and the cache when a read shares one

A server-ordered read inserted every record it carried into the shared table,
so a late one could put back a record a view had since dropped; it now only
updates records the table holds. Reads a write's reply carried back now
notify every read sharing their entities, as a load does. And a read that
gives views a newer copy marks those views for saving.
* feat(codemod): pass workspace stores to deferred local helpers

* fix(codemod): prove the native click output owner
… again (#2429)

The client binding reported each store read to the renderer as a native signal
read. Measured against useSyncExternalStore on the same production app, with
identical renders and DOM, the native path was slower in every step large
enough to measure, and importing it turned on read collection around every
component's render, including ones that read no data. Both bindings now read
snapshots through useSyncExternalStore, as React does; the client entry is
about 3 KB gzipped smaller.
* feat(codemod): migrate native submit event annotations

* fix(codemod): verify forwarded submit event callbacks

* fix(codemod): isolate submit exports and callback slots

* fix(codemod): resolve contextual submit event types

* fix(codemod): keep deferred React submit import types
* fix(codemod): verify workspace store helper dependencies

* fix(codemod): trace runtime class bases in store helpers
domgan-oai and others added 9 commits November 13, 2026 12:50
…er builds and crashes (#2583)

* feat(data): shared tabs fall back to their own store, and survive other builds and crashes

Co-Authored-By: Claude <[email protected]>

* fix(data): serve a tab again when it wakes after being dropped, and count unanswered pings

A silent tab is dropped from feeds but served again if it speaks under the same
generation. A tab detects a lost owner after three unanswered pings rather than
wall-clock silence, so throttled background timers never cause a reconnect, and
pauses its heartbeat while frozen. Format data.mdx.

Co-Authored-By: Claude <[email protected]>

* fix(data): restart the owner's sweep when a dropped tab is served again

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
* fix: preserve shadowed createPortal calls

* fix: keep shadowed portal-spelled callbacks callable
* fix(codemod): report nested React islands in hosted SSR

* fix(codemod): check paired OctaneCompat tags

* fix(codemod): inspect default JSX exports in SSR hosts
Adds compiler/data-contracts.js: parses a .ts, .tsx, .js or .tsrx module and
returns its contract declarations, its contract use sites, and diagnostics for
OCTANE_DATA_CONTRACT_DECLARATION, _MODULE, _ARGUMENT and _ESCAPE, per
docs/data-contract-conventions.md. Sites match by method, import or property
name plus the contract argument, never the receiver, and the bounded .map /
for…of over an inline array of contracts is followed.

The codes get a data section in the diagnostic catalog, so they render into
the generated reference, llms.txt, MCP and octane explain.
@trueadm
trueadm marked this pull request as ready for review November 13, 2026 19:05
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability labels Nov 13, 2026
useWrite is removed from octane/data (spec Decision 6); writes go through
store.write(contract, input).

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No byte growth, no added work, and no timing changes beyond ±3%.

Compares 4abf36402, the merge commit's first parent with 13952cdb8 on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 2.642 2.450 ±0.0% −4.0% … +4.0% ⚪ within noise
octane-tsrx replace 5.583 5.883 +0.7% −6.6% … +6.0% ⚪ within noise
octane-tsrx add 2.558 2.325 −4.1% −6.2% … −0.0% ⚪ within noise
octane-tsrx update 0.091 0.094 +0.0% −2.9% … +2.2% ⚪ within noise
octane-tsrx select 0.006 0.006 −1.7% −4.0% … +1.4% ⚪ within noise
octane-tsrx swap 0.019 0.018 −0.5% −4.0% … +4.1% ⚪ within noise
octane-tsrx remove 0.016 0.016 −0.4% −6.7% … +4.1% ⚪ within noise
octane-tsrx runlots 21.100 21.583 +3.2% +0.5% … +10.0% ⚪ within noise
octane-tsrx select_lots 0.006 0.006 −0.5% −2.0% … +2.4% ⚪ within noise
octane-tsrx clear 39.667 40.858 +0.5% −0.7% … +3.3% ⚪ within noise
octane-jsx run 3.725 3.583 ±0.0% −2.7% … +7.6% ⚪ within noise
octane-jsx replace 6.867 6.700 −1.3% −14.1% … +5.9% ⚪ within noise
octane-jsx add 3.008 3.008 −3.3% −5.7% … ±0.0% ⚪ within noise
octane-jsx update 0.169 0.176 +2.3% +0.4% … +5.4% ⚪ within noise
octane-jsx select 0.079 0.083 +1.7% +0.5% … +4.1% ⚪ within noise
octane-jsx swap 0.126 0.132 +0.6% −1.2% … +3.8% ⚪ within noise
octane-jsx remove 0.114 0.113 +1.7% ±0.0% … +3.6% ⚪ within noise
octane-jsx runlots 25.192 25.658 −0.4% −3.3% … +4.9% ⚪ within noise
octane-jsx select_lots 0.842 0.852 +1.0% −2.2% … +3.0% ⚪ within noise
octane-jsx clear 43.625 43.842 +0.4% −1.4% … +3.1% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 111 measured values.

Public-import reachability bundles (bytes)

No changes across 141 measured values.

Unwrap as/satisfies/!/<T> and parentheses around a site's callee, a loop's
inline array, a contract argument, and a declaration's initializer, reusing
descriptor-lowering's unwrapTsExpr.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Optional-chain sites missed by matching
    • Added OptionalCallExpression and OptionalMemberExpression checks alongside their non-optional counterparts in all four matching locations (visit's call branch, visit's callee check, visit's standalone member checks, and contractsOf's namespace member access), consistent with how the rest of the compiler handles both AST shapes.

Create PR

Or push these changes by commenting:

@cursor push 3513e1f9cc
Preview (3513e1f9cc)
diff --git a/packages/octane/src/compiler/data-contracts.js b/packages/octane/src/compiler/data-contracts.js
--- a/packages/octane/src/compiler/data-contracts.js
+++ b/packages/octane/src/compiler/data-contracts.js
@@ -197,7 +197,7 @@ export function analyzeDataContracts(source, filename) {
 			return (scope && aliases.get(scope)?.get(node.name)) ?? null;
 		}
 		if (
-			node?.type === 'MemberExpression' &&
+			(node?.type === 'MemberExpression' || node?.type === 'OptionalMemberExpression') &&
 			!node.computed &&
 			node.object.type === 'Identifier' &&
 			namespaces.has(node.object.name) &&

@@ -197,7 +197,7 @@ export function analyzeDataContracts(source, filename) {
 			return (scope && aliases.get(scope)?.get(node.name)) ?? null;
 		}
 		if (
-			node?.type === 'MemberExpression' &&
+			(node?.type === 'MemberExpression' || node?.type === 'OptionalMemberExpression') &&
 			!node.computed &&
 			node.object.type === 'Identifier' &&
 			namespaces.has(node.object.name) &&
@@ -269,7 +269,7 @@ export function analyzeDataContracts(source, filename) {
 	};
 
 	const visit = (node, parent, key) => {
-		if (node.type === 'CallExpression') {
+		if (node.type === 'CallExpression' || node.type === 'OptionalCallExpression') {
 			const kind = factoryOf(node);
 			if (kind !== null && !declared.has(node)) {
 				report(

@@ -269,7 +269,7 @@ export function analyzeDataContracts(source, filename) {
 	};
 
 	const visit = (node, parent, key) => {
-		if (node.type === 'CallExpression') {
+		if (node.type === 'CallExpression' || node.type === 'OptionalCallExpression') {
 			const kind = factoryOf(node);
 			if (kind !== null && !declared.has(node)) {
 				report(
@@ -281,7 +281,10 @@ export function analyzeDataContracts(source, filename) {
 			const callee = unwrapTsExpr(node.callee);
 			let index;
 			let name;
-			if (callee.type === 'MemberExpression' && !callee.computed) {
+			if (
+				(callee.type === 'MemberExpression' || callee.type === 'OptionalMemberExpression') &&
+				!callee.computed
+			) {
 				name = callee.property.name;
 				index = METHOD_SITES.get(name);
 				// The bounded loop form: `[a, b].map((contract) => …)`.

@@ -281,7 +281,10 @@ export function analyzeDataContracts(source, filename) {
 			const callee = unwrapTsExpr(node.callee);
 			let index;
 			let name;
-			if (callee.type === 'MemberExpression' && !callee.computed) {
+			if (
+				(callee.type === 'MemberExpression' || callee.type === 'OptionalMemberExpression') &&
+				!callee.computed
+			) {
 				name = callee.property.name;
 				index = METHOD_SITES.get(name);
 				// The bounded loop form: `[a, b].map((contract) => …)`.
@@ -315,8 +318,9 @@ export function analyzeDataContracts(source, filename) {
 				return false;
 			}
 		}
-		const named = node.type === 'MemberExpression' ? contractsOf(node) : null;
-		if (node.type === 'MemberExpression' && named === null && contractsOf(node.object) !== null) {
+		const isMember = node.type === 'MemberExpression' || node.type === 'OptionalMemberExpression';
+		const named = isMember ? contractsOf(node) : null;
+		if (isMember && named === null && contractsOf(node.object) !== null) {
 			// A property read off a contract, such as `books.view.compare`.
 			if (node.computed) walk(node.property, node, 'property', visit);
 			return false;

@@ -315,8 +318,9 @@ export function analyzeDataContracts(source, filename) {
 				return false;
 			}
 		}
-		const named = node.type === 'MemberExpression' ? contractsOf(node) : null;
-		if (node.type === 'MemberExpression' && named === null && contractsOf(node.object) !== null) {
+		const isMember = node.type === 'MemberExpression' || node.type === 'OptionalMemberExpression';
+		const named = isMember ? contractsOf(node) : null;
+		if (isMember && named === null && contractsOf(node.object) !== null) {
 			// A property read off a contract, such as `books.view.compare`.
 			if (node.computed) walk(node.property, node, 'property', visit);
 			return false;

You can send follow-ups to the cloud agent here.

main's history was rewritten (same trees, new SHAs), so this merges against
main's #2598 commit, whose tree matches the branch's earlier base.
The design note (#2602) was closed unmerged, so point at the octane/data RFC
(#2362) and state the four rules where they are enforced and documented.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Name and factory unwraps miss TS wrappers
    • Added !node.method to the Property node condition at line 319, so object shorthand methods whose keys match PROPERTY_SITES are walked normally instead of being incorrectly treated as contract argument positions.

Create PR

Or push these changes by commenting:

@cursor push f5824ee57f
Preview (f5824ee57f)
diff --git a/packages/octane/src/compiler/data-contracts.js b/packages/octane/src/compiler/data-contracts.js
--- a/packages/octane/src/compiler/data-contracts.js
+++ b/packages/octane/src/compiler/data-contracts.js
@@ -316,7 +316,7 @@ export function analyzeDataContracts(source, filename) {
 			walk(node.body, node, 'body', visit);
 			return false;
 		}
-		if (node.type === 'Property' && !node.computed) {
+		if (node.type === 'Property' && !node.computed && !node.method) {
 			const name = node.key.name ?? node.key.value;
 			if (PROPERTY_SITES.has(name)) {
 				if (site(node.value, name)) walk(node.value, node, 'value', visit);

@@ -316,7 +316,7 @@ export function analyzeDataContracts(source, filename) {
 			walk(node.body, node, 'body', visit);
 			return false;
 		}
-		if (node.type === 'Property' && !node.computed) {
+		if (node.type === 'Property' && !node.computed && !node.method) {
 			const name = node.key.name ?? node.key.value;
 			if (PROPERTY_SITES.has(name)) {
 				if (site(node.value, name)) walk(node.value, node, 'value', visit);

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 5c6f32a. Configure here.

A method or callback keyed read/put/of/… that mentioned a contract was
reported as a runtime-chosen argument and its inner sites were dropped.
The argument check now stops at functions, so they are walked as ordinary
code.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website 5c6f32a Commit Preview URL

Branch Preview URL
Nov 13 2026, 07:49 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website-mcp 5c6f32a Commit Preview URL

Branch Preview URL
Nov 13 2026, 07:47 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants