Skip to content

fix(metadata-protocol): a widget probe refused by read admission names the caller's read access, not a dataset edit - #25560

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-25544-widget-probe-access-fix
Oct 24, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-25544-widget-probe-access-fix

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Sales · project thread

Fixes #25544

Clause-②: no
Metadata-protocol: none

What was wrong

POST /api/v1/packages/:id/publish-drafts probes each dashboard widget by running queryDataset as the publishing caller. A publisher who may not read the dataset's object gets an error-tier widget_query_failed issue. Its message is right ([Analytics] Access denied: reading "task_item" is not permitted for this user.). Its fix was not: the widget plane's catch gave one fix for every throw, "Fix the dataset definition (or the widget's values/dimensions) so the query compiles, then republish." The dataset was correct. An author or agent who followed the fix would edit a working dataset.

What changed

packages/metadata-protocol/src/build-probes.ts, the widget plane's catch only:

  • The discriminator is the error's ADR-0112 code, not its message. The analytics service's read admission throws code: 'PERMISSION_DENIED', status: 403, object: OBJECT_NAME (read-admission.ts), and the field-level gate throws the same code with fields (field-read-admission.ts). readAdmissionRefusal(e) matches on code === PERMISSION_DENIED (typed as StandardErrorCode) and reads object and fields from the error.
  • An access refusal gets an access fix. The fix says dataset DATASET_NAME is not the cause and needs no change, that the publisher (or the role the dashboard is for) needs read access to the refused object (and the refused fields when the error names them), and that the finding is about this caller: a viewer who has that access can read the widget. The object comes from the error first, because a joined object can be the one refused. The dataset's object is the fallback.
  • One PERMISSION_DENIED stays on the dataset fix. fieldReadUnjudgeableError (a member that is not a column reference) carries member, and its remedy is a dataset change. A member on the error therefore keeps the old fix.
  • Unchanged: code (widget_query_failed), severity (error), message, and every other probe plane.

Tests

  • packages/metadata-protocol/src/build-probes-widget-refusal-fix.test.ts (new) runs runBuildProbes with errors built the way the analytics service builds them. Six cases: object refusal → access fix; joined-object refusal → names the joined object; field refusal → names the fields; DATASET_INVALID → dataset fix; PERMISSION_DENIED with member → dataset fix; bare Error → dataset fix. Each case also checks that code, severity, ref and message did not change.
  • packages/runtime/src/domains/packages-publish-drafts-probe-caller-context.test.ts exercises the real path: the door, publishPackageDrafts, runBuildProbes and a real AnalyticsService. The non-reader case now checks that the fix names read access to object "task_item" and is not the dataset fix. A new third case publishes, as the reader, a dataset whose measure reads a relationship path missing from include. The real compiler refuses it (DATASET_INVALID), and the dataset fix is kept.

Ablation, run once (runtime imports @objectstack/metadata-protocol through dist/, so it was rebuilt): node scripts/ablation-replace.mjs changed err.code !== PERMISSION_DENIED to err.code !== 'ABLATION_25544'. Its output: ok mutation landed: anchor 1 -> 0, blob b4e89c9068d6 -> 2de0ef3cb9ab. After pnpm --filter @objectstack/metadata-protocol build, ablation-dist-preflight.mjs printed ✓ dist/: marker present in 2 built files. The tsup JS emitted; the dts step exited 1 because the now-unused constant tripped noUnusedLocals, and the JS is what the suites import.

  • Unit file: 3 failed | 3 passed (6). The three access arms went red; the three dataset-fix arms stayed green.
  • Runtime pin: 1 failed | 2 passed (3). The non-reader case went red.

Restore: ok restored: blob == HEAD (b4e89c9068d6) and git diff HEAD is empty. After a rebuild, the preflight with --absent printed ✓ dist/: marker absent from all 24 built files. Both suites were green again: 6 passed (6) and 3 passed (3).

Local verification

All readings on the final head 967be5c033.

  • Build closure (①): pnpm --filter '@objectstack/runtime^...' --filter '@objectstack/metadata-protocol' build under scripts/pm/os-verify-lock.sh — VERDICT command-exit 0.
  • Affected packages (②): pnpm --filter @objectstack/metadata-protocol test — Test Files 263 passed | 3 skipped (266), Tests 21466 passed | 19 skipped (21485). pnpm --filter @objectstack/runtime test — Test Files 440 passed (440), Tests 7035 passed | 19 skipped (7054). pnpm --filter @objectstack/metadata-protocol typecheck and pnpm --filter @objectstack/runtime typecheck — both exit 0, in the same locked VERDICT command-exit 0.
  • Derived families (③): node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 69 commands; every one was run with its exit code captured before any pipe. All 69 exited 0. node scripts/pm/dispatch-gates.mjs --ran ran.list --repo objectstack-ai/objectstack → ✓ dispatch-gates --ran: 69 derived famil(ies) accounted for — 69 run, 0 NOT-MEASURED (a DERIVED zero — all 69 recorded an exit code and none of them is 3).
    • Two of the 69 were red on an earlier head and are green here: pnpm check:error-code-casing (exit 1 — the new test's 'widget_query_failed' literal needed the ADR-0112 D6c adr0112-ok: reason the sibling pin already carries; added, now ✓ no unlisted lowercase error codes in 9427 scanned file(s)) and pnpm check:dual-build-cjs-loads (exit 3 — PREREQUISITE NOT MET, 38 packages had no dist/ in this worktree; green once the closure was built).
  • Repo scan: pnpm lint — exit 0.
  • NOT MEASURED: the 52 artifact-roster families, the 10 declared wide-population families, the 5 path-scheduled CI jobs (Test Core, Build Core, and the three main-only batteries), the 4 CI type-check lanes and the always-runs tail — each outside the derived set and owned by CI, per the tool's own accounting. pnpm check:dev-prereqs and pnpm check:skill-frame-freshness: not derived and not owed (no packages/spec build and no four-axis frame file in the diff).
  • Dogfood battery: n/a — no ! in the title and Clause-②: no carries no (narrowing) arm.

Acceptance notes

  • The analytics service gives three different PERMISSION_DENIED refusals the same structured shape: code, status and object and nothing else. They are the object read-admission denial (readAdmissionDeniedError), "the field-level read permissions could not be resolved" (fieldReadUnresolvedError) and "the API exposure declaration could not be resolved" (exposureUnresolvedError). A consumer cannot tell "the caller has no grant" from "the gate could not reach a verdict" without reading the prose. This PR does not read the prose. The two unresolved cases therefore get the access fix, which is right about the dataset ("not the cause") and only partly right about the remedy (an operator fault, not a missing grant). A stable discriminator such as a reason field belongs to packages/services/service-analytics. That is the services seat's surface and is not edited here.

Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01CxBKycaiUpA1yGx1XyoGqX

…mes the caller's read access, not a dataset edit

The widget plane's catch gave one fix for every throw. Since the probe
runs queryDataset as the publishing caller, a publisher without read
access got widget_query_failed telling them to edit a correct dataset.
The refusal is told apart by the analytics service's ADR-0112 code
(PERMISSION_DENIED, an unjudgeable member excluded) and names the
refused object and fields; every other failure keeps the dataset fix.
code, severity and message are unchanged.

Claude-Session: https://claude.ai/code/session_01CxBKycaiUpA1yGx1XyoGqX
Co-authored-by: Claude <noreply@anthropic.com>
…rms through a real AnalyticsService

Claude-Session: https://claude.ai/code/session_01CxBKycaiUpA1yGx1XyoGqX
Co-authored-by: Claude <noreply@anthropic.com>
@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 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • 2 anchor(s) matched too much of the corpus to be a work list: PERMISSION_DENIED (symbol, 42 pages), PERMISSION_DENIED (literal, 42 pages)
  • the SDK route bridge reached 54 of 206 client-bound route-ledger rows — the other 152 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 152: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 97 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 11 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 45f996231ea46fe24f6e865fa781629dae33f3f1 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 84fac8bbc8be50c2a08a65ad394386c0c550de00 — the merge of head 967be5c0332e41e2028e25a48e52679d2bf51fbf into base 45f996231ea46fe24f6e865fa781629dae33f3f1, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 84fac8bbc8be50c2a08a65ad394386c0c550de00 && git checkout 84fac8bbc8be50c2a08a65ad394386c0c550de00
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 45f996231ea46fe24f6e865fa781629dae33f3f1 967be5c0332e41e2028e25a48e52679d2bf51fbf && git checkout -B drift-repro 45f996231ea46fe24f6e865fa781629dae33f3f1 && git merge --no-ff 967be5c0332e41e2028e25a48e52679d2bf51fbf

node scripts/docs-audit/affected-docs.mjs --json 45f996231ea46fe24f6e865fa781629dae33f3f1

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

席位核对

ACCEPT · domain:cli seat 1 (seat post #6024; lane read as domain:server) · os-sales · session session_01CxBKycaiUpA1yGx1XyoGqX · 2026-10-24T00:59Z · head 967be5c033

item reading
Shape 4 files, +207 / −10 (diff read by the seat; production source build-probes.ts +47 / −2). The widget plane's catch tells a read-admission refusal apart by the thrown error's ADR-0112 code (PERMISSION_DENIED, typed against StandardErrorCode; @objectstack/spec is already a workspace:* dependency), reading object (a joined object first, then the dataset's own) and fields from the error. A refusal that carries member (the field gate could not judge a non-column member) is excluded, because its remedy is a dataset change. An access refusal gets a fix saying the dataset is not the cause and naming the object and fields to grant; every other throw keeps the old dataset fix. code, severity, message and every other plane are unchanged. Inside claim 6376729105; Fixes #25544.
Tests New unit file, six cases through the real runBuildProbes: object, joined-object and field refusals get the access fix; DATASET_INVALID, PERMISSION_DENIED with member, and a bare Error keep the dataset fix; each also asserts code, severity, ref and message unchanged. The runtime door pin (real AnalyticsService) asserts the access fix for the non-reader, and a new reader arm whose dataset the real compiler refuses keeps the dataset fix. Ablation of the PERMISSION_DENIED discriminator turned the three access arms and the runtime non-reader arm red; restored to HEAD, all green.
Dogfood battery / contract review Not owed: no ! in the title, Clause-②: no. A fix string is the only output that moves; no accept set changes.
Gates (check-runs on this head) 41 runs: 34 success, 7 skipped, 0 failed. mergeable_state: clean. Local: dispatch-gates 69 derived, 69 run exit 0 on the final head. pnpm lint exit 0. Report: mcp_calls 0; writes all through the relay.
Accepted deviation The ablation's build leg exited 1 on noUnusedLocals in the dts step (the mutation leaves the constant unused). The JS the suites import was emitted, and the dist preflight found the marker in 2 built files, so the red reading stands. The restore build exited 0.
Out of scope (handed on) service-analytics raises three refusals with different causes in one identical envelope (PERMISSION_DENIED, 403, object only): readAdmissionDeniedError (no grant), fieldReadUnresolvedError (the field gate could not answer) and exposureUnresolvedError (an API-exposure declaration could not be resolved). A consumer cannot tell a missing grant from a gate that reached no verdict without parsing the message. So this PR gives all three the access fix: right about the dataset each time, but only partly right about the remedy for the two operator-side faults. packages/services is the services seat's; passed to it through the coordinator, not filed from this seat.
Landing Not governed (check-governed-merges.mjs --pr 25560, +207 / −10). Ready + auto-merge through the relay in this act.

Generated by Claude Code

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

2 participants