Repository navigation
fix(metadata-protocol): a widget probe refused by read admission names the caller's read access, not a dataset edit - #25560
Conversation
…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>
…ss-refusal fix 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>
…ADR-0112 D6c Claude-Session: https://claude.ai/code/session_01CxBKycaiUpA1yGx1XyoGqX Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift Check2 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
Coarse fallback — 11 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # 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 |
席位核对ACCEPT ·
Generated by Claude Code |
Requested by Sales · project thread
Fixes #25544
Clause-②: no
Metadata-protocol: none
What was wrong
POST /api/v1/packages/:id/publish-draftsprobes each dashboard widget by runningqueryDatasetas the publishing caller. A publisher who may not read the dataset's object gets an error-tierwidget_query_failedissue. Its message is right ([Analytics] Access denied: reading "task_item" is not permitted for this user.). Itsfixwas not: the widget plane'scatchgave 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'scatchonly:code, not its message. The analytics service's read admission throwscode: 'PERMISSION_DENIED',status: 403,object: OBJECT_NAME(read-admission.ts), and the field-level gate throws the same code withfields(field-read-admission.ts).readAdmissionRefusal(e)matches oncode === PERMISSION_DENIED(typed asStandardErrorCode) and readsobjectandfieldsfrom the error.DATASET_NAMEis 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'sobjectis the fallback.PERMISSION_DENIEDstays on the dataset fix.fieldReadUnjudgeableError(a member that is not a column reference) carriesmember, and its remedy is a dataset change. Amemberon the error therefore keeps the old fix.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) runsrunBuildProbeswith 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_DENIEDwithmember→ dataset fix; bareError→ dataset fix. Each case also checks thatcode,severity,refandmessagedid not change.packages/runtime/src/domains/packages-publish-drafts-probe-caller-context.test.tsexercises the real path: the door,publishPackageDrafts,runBuildProbesand a realAnalyticsService. The non-reader case now checks that the fix namesread 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 frominclude. The real compiler refuses it (DATASET_INVALID), and the dataset fix is kept.Ablation, run once (runtime imports
@objectstack/metadata-protocolthroughdist/, so it was rebuilt):node scripts/ablation-replace.mjschangederr.code !== PERMISSION_DENIEDtoerr.code !== 'ABLATION_25544'. Its output:ok mutation landed: anchor 1 -> 0, blob b4e89c9068d6 -> 2de0ef3cb9ab. Afterpnpm --filter @objectstack/metadata-protocol build,ablation-dist-preflight.mjsprinted✓ dist/: marker present in 2 built files. The tsup JS emitted; the dts step exited 1 because the now-unused constant trippednoUnusedLocals, and the JS is what the suites import.3 failed | 3 passed (6). The three access arms went red; the three dataset-fix arms stayed green.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--absentprinted✓ dist/: marker absent from all 24 built files. Both suites were green again:6 passed (6)and3 passed (3).Local verification
All readings on the final head
967be5c033.pnpm --filter '@objectstack/runtime^...' --filter '@objectstack/metadata-protocol' buildunderscripts/pm/os-verify-lock.sh—VERDICT command-exit 0.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 typecheckandpnpm --filter @objectstack/runtime typecheck— both exit 0, in the same lockedVERDICT command-exit 0.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 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).pnpm check:error-code-casing(exit 1 — the new test's'widget_query_failed'literal needed the ADR-0112 D6cadr0112-ok:reason the sibling pin already carries; added, now✓ no unlisted lowercase error codes in 9427 scanned file(s)) andpnpm check:dual-build-cjs-loads(exit 3 —PREREQUISITE NOT MET, 38 packages had nodist/in this worktree; green once the closure was built).pnpm lint— exit 0.Test Core,Build Core, and the threemain-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-prereqsandpnpm check:skill-frame-freshness: not derived and not owed (nopackages/specbuild and no four-axis frame file in the diff).!in the title andClause-②: nocarries no(narrowing)arm.Acceptance notes
PERMISSION_DENIEDrefusals the same structured shape:code,statusandobjectand 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 areasonfield belongs topackages/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