Skip to content

fix(runtime)!: the /share-links dispatcher domain stops emitting a duplicate link/links beside data (#4038) - #4049

Merged
os-zhuang merged 1 commit into
mainfrom
claude/envelope-drift-route-modules-v2zoky
Jul 30, 2026
Merged

fix(runtime)!: the /share-links dispatcher domain stops emitting a duplicate link/links beside data (#4038)#4049
os-zhuang merged 1 commit into
mainfrom
claude/envelope-drift-route-modules-v2zoky

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Closes #4038. The producer-side other half of #3983 — and the cloud sweep that issue was waiting on came back clean, so this is smaller than filed.

What the shim was

Create and list answered with the payload under two keys:

{ success: true, data: link,  link  }   // POST /share-links
{ success: true, data: links, links }   // GET  /share-links

That duplicate existed so readers predating the envelope kept working — which is exactly why objectui's ShareDialog reads body.links ?? body.data. It stayed alive because the other surface for these same paths (the sharing plugin's routes) answered bare, so consumers genuinely needed both.

#3983 moved that surface onto data. The first branch of every ?? then had no producer left, and the duplicate had no reader anywhere.

The sweep #4038 was blocked on

repo result
framework no consumer of these routes at all
objectui ShareDialog already falls through to body.data; nothing else reads them
cloud clean — see below

cloud was the blocker, and I could reach it after all. It touches share-links in exactly two places (objectos-runtime/src/artifact-kernel-factory.ts, service-cloud/src/default-environment-plugins.ts), and both only register SharingServicePlugin into a per-environment kernel with registerShareLinkRoutes: false — precisely so this dispatcher serves the paths. Zero calls to the endpoints, zero body reads, zero body.link / body.links anywhere in the repo.

Shape

route was now
POST /share-links { success, data: link, link } { success, data: link }
GET /share-links { success, data: links, links } { success, data: links }

data is unchanged on both — only the duplicate key is gone. Anything reading body.data, or going through ObjectStackClient.unwrapResponse, sees no difference at all. Only a raw reader of top-level body.link / body.links would move, and there isn't one.

The list route now goes through deps.success(...) like the domain's other three. Create stays hand-builtdeps.success hardcodes status 200 and this route is a 201, which is the same reason /keys hand-builds its own 201, and the same shape it uses. My own issue text said to route both through the helper; that was wrong about the status, and I've corrected it on the issue.

Guard

scripts/check-route-envelope.mjs does not and cannot cover this file — it scans route modules that write via res.json(...), while dispatcher domains return { status, body } for a central sender. So this drift was invisible to that guard by construction, which is worth stating plainly: the guard's 7/0/1 is a claim about route modules, not about every REST body the platform emits.

Three tests in domain-handler-registry.test.ts cover it instead — two per-route, plus a general one asserting no success body carries a top-level key outside success / data / meta, so a new duplicate spelling fails too. Restoring the duplicates fails all three.

What I deliberately did not do

#4038's step 3 said to delete objectui's body.links ?? body.data tolerance, and I'm declining that — correcting my own recommendation.

With both producers converged, that ?? is no longer drift (two live producers disagreeing, which was the actual bug); it's version skew (one producer changed, the consumer still supports the older one). @object-ui/components publishes standalone against peer deps, so dropping it turns "new console, older framework" from working into a silently empty share list — a bad failure mode to trade for removing one ??. Deleting it wants a version gate, which is a larger call than this issue. Noted on #4038 rather than left implicit.

Verification

gate result
@objectstack/runtime 909 passed (65 files)
@objectstack/client 200 passed (14 files)
new tests are load-bearing restoring the duplicates → 3 of 3 fail
check:route-envelope + --self-test 7 conformant / 0 ratcheted / 1 exempt
spec tsc --noEmit · check:docs · check:skill-refs · check:react-blocks all clean
check:error-code-casing · check:console-sha · check:nul-bytes · check:role-word · check:org-identifier all clean
eslint --no-inline-config on changed files clean

No .objectui-sha bump needed — this touches no frontend, so the console pin stays where #4037 left it (check:console-sha confirms it is still in sync).


Generated by Claude Code

…plicate link/links beside data (#4038)

The producer-side other half of #3983. That PR moved the sharing plugin's routes
onto the declared envelope; this removes the compatibility shim the dispatcher
twin had been carrying BECAUSE that surface answered bare.

Create and list answered with the payload under two keys — `{ success: true,
data: link, link }` and `{ success: true, data: links, links }`. The duplicate
existed so readers predating the envelope kept working, which is why objectui's
ShareDialog reads `body.links ?? body.data`. Once #3983 made both surfaces answer
`data`, that first branch had no producer left and the duplicate had no reader in
any repo:

  framework  no consumer of these routes at all
  objectui   ShareDialog already falls through to body.data
  cloud      swept — it only REGISTERS SharingServicePlugin into per-environment
             kernels with registerShareLinkRoutes:false so this dispatcher serves
             the paths; it never calls them and never reads a body

That cloud sweep is what #4038 was waiting on, and it came back clean.

`data` is unchanged on both routes — only the duplicate key is gone, so anything
reading `body.data` or going through `unwrapResponse` sees no difference. The list
route now routes through `deps.success(...)` like the domain's other three. Create
stays hand-built because `deps.success` hardcodes status 200 and this route is a
201 — the same reason `/keys` hand-builds its own 201, and the same shape it uses.
(My own issue text said to route BOTH through the helper; that was wrong about the
status.)

`scripts/check-route-envelope.mjs` does not and cannot cover this file — it scans
route modules that write via `res.json(...)`, while dispatcher domains return
`{ status, body }` for a central sender, so the drift was invisible to it by
construction. Three tests in domain-handler-registry.test.ts cover it instead: two
per-route, plus a general one asserting no success body carries a top-level key
outside success/data/meta. Restoring the duplicates fails all three.

Not touching objectui's `body.links ?? body.data`: with both producers converged
that is version skew, not drift, and dropping it would turn "old framework" from
working into a silently empty share list. Deleting it needs a version gate, which
is a larger call than this issue.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYbS3kS8xzsHNXFTzp4e2z
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Jul 30, 2026 6:57am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling size/m labels Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

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

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

  • content/docs/api/client-sdk.mdx (via packages/runtime)
  • content/docs/api/index.mdx (via @objectstack/runtime)
  • content/docs/api/wire-format.mdx (via @objectstack/runtime)
  • content/docs/automation/hook-bodies.mdx (via @objectstack/runtime)
  • content/docs/concepts/north-star.mdx (via packages/runtime)
  • content/docs/data-modeling/drivers.mdx (via @objectstack/runtime)
  • content/docs/deployment/index.mdx (via @objectstack/runtime)
  • content/docs/deployment/production-readiness.mdx (via @objectstack/runtime)
  • content/docs/deployment/single-project-mode.mdx (via @objectstack/runtime)
  • content/docs/deployment/vercel.mdx (via @objectstack/runtime)
  • content/docs/getting-started/your-first-project.mdx (via @objectstack/runtime)
  • content/docs/permissions/authentication.mdx (via @objectstack/runtime)
  • content/docs/permissions/authorization.mdx (via packages/runtime)
  • content/docs/plugins/packages.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/http-protocol.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/index.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/lifecycle.mdx (via @objectstack/runtime)
  • content/docs/releases/implementation-status.mdx (via @objectstack/runtime)

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.

Copy link
Copy Markdown
Contributor Author

Two notes from CI on this PR.

The Check Changeset failure is infrastructure, not the changeset. The job died before it ran anything: corepack couldn't fetch pnpm from registry.npmjs.orgread ECONNRESET inside Engine.ensurePackageManager, exit 1 during setup. Re-queued the failed job; no change pushed, because there is nothing here to fix.

The docs-drift advisory (18 files) needs no doc change, but one of them corroborates the premise. I checked the ones that could plausibly document these bodies — api/wire-format.mdx, protocol/kernel/http-protocol.mdx, api/index.mdx all have no share-link content. api/client-sdk.mdx does:

const link = await client.shareLinks.create('crm_account', recordId, {});
await client.shareLinks.revoke(link.token);

That documented link.token is exactly what #3983 fixed. Before it, create() against the plugin surface returned { link: … }, so unwrapResponse handed back the wrapper and link.token was undefined — the published example only worked if the dispatcher happened to serve the route. It is accurate on both surfaces as of #3983, and this PR keeps it that way by removing the dispatcher's duplicate key rather than by teaching anything to read two shapes.

So the doc needed no edit — but it was independent evidence that data is meant to unwrap to the link row itself, which is what both PRs converged on.


Generated by Claude Code

@os-zhuang
os-zhuang marked this pull request as ready for review July 30, 2026 07:09
@os-zhuang
os-zhuang merged commit de6daa5 into main Jul 30, 2026
19 of 20 checks passed
@os-zhuang
os-zhuang deleted the claude/envelope-drift-route-modules-v2zoky branch July 30, 2026 07:09
os-zhuang added a commit that referenced this pull request Jul 30, 2026
…ns (#4038 follow-up) (#4056)

The platform answers REST from two kinds of file. Route modules (*-routes.ts)
call `res.json(...)`, which this scan counted. Dispatcher domains
(runtime/src/domains/*.ts) RETURN `{ status, body }` for a central sender, so they
never call `res.json` and were invisible to it by construction.

That gap cost something real: /share-links emitted its payload under both `data`
and a legacy `link`/`links` for as long as nothing looked, and it surfaced only
because #3983's consumer sweep happened to walk past it (#4038, fixed in #4049).
I noted the blind spot there; this closes it.

The new table counts hand-built `response: { … }` literals per domain. A domain
answering only through the deps.* helpers hand-builds zero and cannot drift; any
hand-built one now needs a declared count plus a `note` saying why. Hand-building
is not automatically wrong — four kinds show up and only the last is drift:

  1. enveloped, but the helper cannot express it — deps.success hardcodes 200 so a
     201 is assembled by hand, and deps.error carries no headers so a 405 with
     `Allow:` is too (keys.ts, share-links.ts, one in mcp.ts)
  2. passthrough of a body this dispatcher does not own (mcp.ts, ai.ts)
  3. a foreign wire format a client library requires — /auth answers better-auth's
     shapes because better-auth's client parses them (auth.ts x4)
  4. drift

16 domains audited: 11 helper-only, 5 declaring hand-built responses, 1 ratcheted.
The ratchet is ai.ts -> #4053, where GET /ai/agents is SDK-addressable but
unenveloped and the SDK compensates by reading `.agents` off the raw body —
converting it without changing cloud and the SDK together makes
`client.ai.agents.list()` return an empty list silently, which is indistinguishable
from the legitimate "no AI service configured" state. That warning now fails CI for
whoever tries it, instead of sitting in an issue nobody reads.

Five self-test assertions cover the new scan. One caught a real false positive
while it was being written: matching the `response` key alone counted a PAYLOAD
field named response (`deps.success({ response: … })`) as a hand-built response.
It now requires `response` to be a sibling of `handled`, which is what makes the
pair an HttpDispatcherResult rather than just an object with that key.

Verified the guard actually bites: adding a hand-built response to a helper-only
domain fails with the site and the four-kind classification prompt.


Claude-Session: https://claude.ai/code/session_01CYbS3kS8xzsHNXFTzp4e2z

Co-authored-by: Claude <noreply@anthropic.com>
os-zhuang added a commit that referenced this pull request Jul 30, 2026
…hema cannot express (#4090)

* test(spec): envelopeViolations — the conformance check BaseResponseSchema cannot express

Every conformance suite from the #3843 line leads with
`BaseResponseSchema.safeParse(body)` under a comment calling it "the contract
itself, imported — not a restatement of it". That overclaimed, and the gap is
demonstrable:

  BaseResponseSchema.safeParse({ success: true })                    // passes
  BaseResponseSchema.safeParse({ success: true, data: link, link })  // passes

The schema declares no `data` (each response type adds its own via
`.extend({ data })`) and a plain z.object strips unknown keys rather than
rejecting them. So it catches the one drift it was added for — a missing or
non-boolean `success`, the flag `unwrapResponse` keys on — and nothing else. The
second body is exactly the duplicate-payload drift /share-links shipped until
#4038/#4049 removed it, and safeParse passed it the whole time. What was actually
catching that drift was the assertions each suite hand-wrote beside it, which
works only for as long as whoever writes the next suite remembers to.

`envelopeViolations(body)` returns every departure as readable reasons, empty when
conformant: `success` must be a boolean; a success body must carry `data`
(`undefined` only — null/[]/{}/0/'' are payloads, not absences); a failure body
must carry `error` with a string code and message; and no top-level key outside
success/data/error/meta, which is the general form of the duplicate-payload drift.
It deliberately does NOT check the shape of `data` — that is each route's own
payload schema, and conflating the two is what let SettingsNamespacePayload
describe a whole body before #3843 and only `data` after it.

Ten suites now assert it beside safeParse, and their comments say what each of the
two actually proves. Verified the pairing is load-bearing: reintroducing the
/share-links duplicate key fails the new assertion and still passes the old one.
Verified the rules are not too strict by running every existing suite unchanged —
spec 6951, rest 505, runtime 914, storage 220, settings 189, datasource 154,
i18n 62, sharing 225, client 200, all green, nothing flagged.

Placed in contract.zod.ts beside the schema it completes, alongside the other
plain predicates spec/api already exports (standardErrorCodeForHttpStatus,
readServiceSelfInfo). No new package.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYbS3kS8xzsHNXFTzp4e2z

* chore(spec): regenerate the API-surface snapshot for envelopeViolations

`check:api-surface` is a ratchet on `@objectstack/spec`'s public exports, and the
new predicate is an addition to it:

    ./api
      + envelopeViolations (function)
    0 breaking (removed/narrowed), 1 added.

One line, alphabetically beside the other predicates that module already exports.

Two things this caught that are worth writing down.

The gate lives in the TypeScript Type Check job, which runs TEN steps — I had
found four of them by grepping a window of lint.yml that cut off before the rest,
and ran only those. The full list is: spec tsc, check:docs, check:skill-refs,
check:react-blocks, a workspace build, examples typecheck, downstream-contract
typecheck, check:api-surface, check:skill-examples, and the two i18n checks. All
ten pass locally now.

And `gen:api-surface` reads `dist/index.d.ts`, so it fails outright under
`OS_SKIP_DTS=1` — the flag I had been using to keep local builds fast. Rebuilding
spec with declarations is a prerequisite for regenerating the snapshot, not an
optional speed-up.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYbS3kS8xzsHNXFTzp4e2z

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

The /share-links dispatcher domain emits data AND a legacy link/links beside it — a producer-side shim that outlived its readers

2 participants