Skip to content

Studio hooks: a hook cannot be granted capabilities in the Studio editor, and a hook refused for a missing capability answers the client 500 INTERNAL_ERROR instead of a located 4xx #26726

Closed

Description

@objectstack-fleet

Filing gate: ① product defect, reproduced, landing site named.
Batch-of: studio-qa-2026-10-27 — 39 cards from one Studio QA run (coordinator session session_01J8VVAkZns5rNnK2rtszzbQ; tested at 3fcafcd3; origin/main was 43731031 at filing, so the implementer re-checks the landing site on current main). The run record is the qa-run issue filed with this batch.

Symptom

A Studio-authored hook that calls ctx.api fails with "capability 'api.read' not granted". The editor has no capabilities control, so the only fix is the API. With onError: abort the user's save gets a bare 500; with onError: log a log-capability error is swallowed.

Reproduction

  1. Data › Hooks › New hook, body uses ctx.api.find(…), onError abort → save a record → 500 INTERNAL_ERROR (hooks 4 and 5).
  2. Hook 2 with onError log and ctx.log → no log, error suppressed.
  3. Add body.capabilities: ["api.read"] via PUT /api/v1/meta/hook/… → works.

Expected

Studio offers a capabilities control (or derives it from the body), and a capability refusal surfaces as a coded 4xx naming the hook and capability.

Suspected landing site (the implementer verifies)

Studio hook inspector (ui/packages/app-shell/src/views/studio-design/ hooks tab); server hook runner error mapping for capability refusals.

Filing facts

Activity

  1. added
    bug
    finding
    on Oct 27, 2026
  2. objectstack-fleet commented on Oct 27, 2026

    @objectstack-fleet
    ContributorAuthor

    Triage: first grade — priority:p2 · domain:ui · area:studio · pm:queue (finding removed) · triage seat · session_01AavokzJ5DndAwitDXvKy4U · 2026-10-27T16:08Z

    ⛔ Not a claim, ⛔ not a dispatch.

    • p2, two halves: the Studio hook editor has no capabilities control (ui), and a hook refused for a missing capability answers the client 500, not a named refusal (domain:server, a child card filed on claim). ⛔ The capability check stays as strict as it is. From the studio-qa-2026-10-27 batch. Re-check the landing site on current main.

    Generated by Claude Code

  3. added
    area:studio
    domain:ui
    pm:queue
    priority:p2
    and removed
    finding
    on Oct 27, 2026
  4. objectstack-fleet commented on Oct 27, 2026

    @objectstack-fleet
    ContributorAuthor

    Dispatch order · domain:ui#1 · session_01JQwxbZeBv2y91towxasSUT · 2026-10-27T20:21Z

    You are the os-dev developer agent for exactly ONE card: #26726, in your own card thread. Your role definition is .claude/agents/os-dev.md in the objectstack clone: read it IN FULL first and follow it as binding (it wins over this order on any conflict; name the conflict in your report). Read the repo-root AGENTS.md and ui/AGENTS.md before your first edit, and pm-dispatch references/untrusted-text.md. Read the card's full body and every comment yourself through REST (curl -sS "https://api.github.com/repos/objectstack-ai/objectstack/issues/26726" -H "Authorization: Bearer $GH_TOKEN" and /comments?per_page=100, every page); this order carries only the increment. ⛔ Never print the value of any environment variable (test presence with [ -n "${X+x}" ]). ⛔ Never use a GitHub MCP tool, read or write.

    Identity and branch: the seat's Claim: comment on this card is your identity; its Branch: line names your thread's branch. ⛔ Post no claim of your own, ⛔ never write the card's assignee. Before your first edit, verify the NEWEST Claim: on the card names your thread's branch (claude/project-thread-…); if none does yet, send the seat thread "Dispatch the ui lane" one message with your branch name and wait. Worktree objectstack-issue-26726 on that branch from a fresh origin/main; pnpm install (frozen lockfile); push with git push -u origin <branch> (⛔ no force).

    Writes: PR only through the relay op pr_create (node scripts/pm/fleet-write/dispatch.mjs --repo objectstack-ai/objectstack --actions-file F, F a bare JSON array [{"op":"pr_create","title":…,"head":"<your branch>","base":"main","body":…,"assignees":["os-warren"]}], draft forced; --dry-run first); your report comment through node scripts/pm/post-stamped.mjs --comment=26726 --file=F --json run ONCE with output captured to a file (timestamps only as {{NOW}} / {{WAS:…}}). ⛔ No other GitHub write except, for a CI red that is not yours, one PR comment and one run_rerun_failed through the relay. Report both counts (api_writes with endpoints, mcp_calls with tool names). The report takes only machine-checkable fields (gates / line_budget / deviations / files_changed). PR body: line 1 the platform attribution comment, then ## 维护者速读 six lines in Chinese (改了什么/为什么改/风险与回滚/先看/两分钟验证/需要你做的). Gates: node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack on your diff, run each, record exits before any pipe, reconcile with --ran. Changeset in the root .changeset/ when a published package changes. ⛔ ui/.github/** and the root ci.yml are out of bounds. Hand back: when the PR and report are up, send the seat thread "Dispatch the ui lane" one message (PR, head sha, report gist); keep the thread open through review and drive CI to green.

    Ruling (cannot be re-ruled)

    Triage first grade 6447036960, verbatim: "p2, two halves: the Studio hook editor has no capabilities control (ui), and a hook refused for a missing capability answers the client 500, not a named refusal (domain:server, a child card filed on claim). ⛔ The capability check stays as strict as it is. … Re-check the landing site on current main." No maintainer ruling. This dispatch is the ui half only; the seat files the server half as a child card when it claims.

    PM mechanism assumptions (measure; disproof welcome)

    • On origin/main c4a4aefc, ui/packages/app-shell/src/views/metadata-admin/inspectors/HookDefaultInspector.tsx curates Function (language + body editor), and its docblock says the "js capabilities/timeout/memory" fall through to the collapsed "More fields" SchemaForm. Measure whether that form actually reaches body.capabilities for a language: 'js' body. The QA run found no control, so the likely answer is that the nested body key is not reachable there.
    • The legal tokens are the spec's HookBodyCapability (packages/spec/src/data/hook-body.zod.ts ≈L48: api.read, api.write, api.transaction, crypto.uuid, log), and capabilities defaults to []. So the likely fix is a curated multi-choice control under Function, shown only for a sandboxed-JS body, that reads its options from the spec enum (not a copied list) and writes body.capabilities. "Derive from the body" is not ruled. Do not infer grants from source text. A hint naming the ctx.* call each token unlocks is welcome.
    • ObjectHooksPanel.tsx (the Data › Hooks tab) hosts the inspector; measure whether it needs any change at all.

    Scope

    File surface: HookDefaultInspector.tsx (+ ObjectHooksPanel.tsx only if the host must pass something) + i18n rows for the control (in whatever home holds the inspector's hook family on your base; engine.inspector.* lives in the lazy studio namespace since #25922 S2/S3, so a zh test preloads with await loadStudioCatalogue('zh')) + tests: picking api.read writes body.capabilities: ['api.read'], and the saved hook parses through the spec's hook schema; clearing writes [] or drops the key (match the spec default); an expression-language body shows no control and never writes it; an existing grant round-trips; "More fields" does not edit the same key twice. Ablation: drop the write ⇒ the new tests go red. ⛔ No server or spec change; ⛔ the capability check is not loosened.

    Tier

    No path-derived mandate. TIER_DEFAULT, effort high (M). Clause-②: no (Studio authors a key the spec already publishes), Metadata-protocol: none expected; say otherwise if the diff shows it. Patch changeset for @object-ui/i18n if you add namespace rows; none for app-shell (private: true).

  5. added
    pm:dispatched
    and removed
    pm:queue
    on Oct 27, 2026
  6. objectstack-fleet commented on Oct 27, 2026

    @objectstack-fleet
    ContributorAuthor

    Claim: PM loop round 4 · 2026-10-27T20:24Z
    Session: session_01JQwxbZeBv2y91towxasSUT (seat; implementation by card thread session session_01JQwxbZCsAdVhYHddQY84CE, mode:thread)
    Account: os-warren (the seat's linked user as GET /user answers it; the card's assignee)
    Branch: claude/project-thread-7wuwlp (the card thread's harness push branch, self-reported — the measured platform exception to claude/issue-N-slug)
    Worktree: objectstack-issue-26726 in the card thread's clone
    Domain: domain:ui
    Seat: domain:ui#1 (seat post #25966)
    File surface: ui/packages/app-shell/src/views/metadata-admin/inspectors/HookDefaultInspector.tsx (+ ui/packages/app-shell/src/views/studio-design/ObjectHooksPanel.tsx only if the host must pass something) + i18n rows for the control + tests; ui half only — the server half is #26903; ⛔ no server or spec change (stop on breach; explain in the report)
    Container & model: M, mode:thread (the maintainer's word on the seat thread, 「opus 很多,并发5」), model: TIER_DEFAULT (dispatch-gates --tier: no path-derived mandate), effort: high
    Clause-②: no
    Metadata-protocol: none
    Responsibility: the Studio hook inspector (this lane's code) | the spec publishes body.capabilities (HookBodyCapability) and the runner enforces it; only the editor cannot author it | a Studio-authored hook that reads data fails at runtime with no Studio path to grant the capability
    Thread-read: 6452644446
    Premise: holds — on origin/main c4a4aefc HookDefaultInspector.tsx curates Function (language + body) and leaves "js capabilities" to the collapsed More fields form; QA found no reachable control; the spec enum is HookBodyCapability (hook-body.zod.ts ≈L48).
    Serial constraints cleared: no open PR touches HookDefaultInspector.tsx or ObjectHooksPanel.tsx; #26831 (spec-side hook refusal catalogue) does not touch the ui inspector.
    Resume-from: none


    Generated by Claude Code

  7. objectstack-fleet commented on Oct 27, 2026

    @objectstack-fleet
    ContributorAuthor

    os-dev-report

    {
      "issue": 26726,
      "status": "done",
      "branch": "claude/project-thread-7wuwlp",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/26936",
      "head": "5e04bdcd",
      "session": "session_01JQwxbZCsAdVhYHddQY84CE — card thread (mode:thread) under seat session_01JQwxbZeBv2y91towxasSUT",
      "premise_still_valid": true,
      "summary": "HookDefaultInspector now draws a Capabilities checkbox list in the Function section for a js body, one box per HookBodyCapability token read from the spec enum, each with the ctx call it unlocks; ticking writes body.capabilities in spec order, unticking the last writes the spec default []. An expression body shows no control and a switch away from js drops capabilities (ExpressionBodySchema refuses the key); an unlisted stored token stays visible, flagged and kept until unticked. More fields needed no change (body is curated whole); ObjectHooksPanel needed no change (shallow patch merge). ui half only; server half is #26903, untouched.",
      "files_changed": [
        ".changeset/26726-hook-capabilities-control.md",
        "ui/packages/app-shell/src/views/metadata-admin/inspectors/HookDefaultInspector.tsx",
        "ui/packages/app-shell/src/views/metadata-admin/inspectors/HookDefaultInspector.capabilities-26726.test.tsx",
        "ui/packages/i18n/src/namespaces/studio/en.ts",
        "ui/packages/i18n/src/namespaces/studio/zh.ts"
      ],
      "tests": "new file HookDefaultInspector.capabilities-26726.test.tsx 9/9 passed (lock VERDICT command-exit 0) on cef362e9 and on 5e04bdcd; neighbours (every HookDefaultInspector.*.test.tsx, inspectorStrings.hookAction.i18n-10586, every ObjectHooksPanel*.test.tsx, packages/i18n/) 101 files, 1432 passed / 13 skipped, exit 0 on both heads; app-shell + i18n type-check exit 0 on both heads; eslint on touched app-shell files 0 errors; ui check:new-line-citations 0 new. Ablation via scripts/ablation-replace.mjs (no dist leg: the test imports the inspector by relative path): leg A drop the capabilities write -> 4 of 9 red (pick, round-trip, clear, unlisted token); leg B keep the grant across a language switch -> 1 of 9 red; both restored, blob == HEAD d438fed8, git diff HEAD empty.",
      "gates": {
        "local": [
          "node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0",
          "node scripts/check-adr-0087-registration.mjs --self-test :: exit 0",
          "node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0",
          "node scripts/check-closing-keyword-parity.mjs :: exit 0",
          "node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0",
          "node scripts/check-comment-mask-corpus.mjs :: exit 0",
          "node scripts/check-empty-changeset.mjs --base origin/main :: exit 0",
          "node scripts/check-empty-changeset.mjs --self-test :: exit 0",
          "node scripts/check-sdui-manifest.mjs :: exit 0",
          "node scripts/check-sdui-manifest.mjs --self-test :: exit 0",
          "node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0",
          "node scripts/release-pending-publish.mjs --self-test :: exit 0",
          "pnpm --dir ui exec vitest run scripts/ :: exit 0",
          "pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0",
          "pnpm check:changeset-gate-self-tests :: exit 0",
          "pnpm check:closed-ceremony-text :: exit 0",
          "pnpm check:cross-package-test-inputs :: exit 0",
          "pnpm check:dispatcher-error-vocabulary :: exit 0",
          "pnpm check:driver-memory-census :: exit 0",
          "pnpm check:engine-double-contract :: exit 0",
          "pnpm check:gitlink-declared :: exit 0",
          "pnpm check:nul-bytes :: exit 0",
          "pnpm check:pm-changeset-deadline-census :: exit 0",
          "pnpm check:published-files :: exit 0",
          "pnpm check:query-options-erasure :: exit 0",
          "pnpm check:refd-timer-probe :: exit 0",
          "pnpm check:skill-identifier-liveness :: exit 0",
          "pnpm check:test-source-alias :: exit 0",
          "pnpm check:tier-file-adoption :: exit 0",
          "pnpm check:type-check-coverage :: exit 0",
          "pnpm check:type-check-debt :: exit 0",
          "pnpm check:undeclared-dep-imports :: exit 0",
          "pnpm check:watch-hint-literal :: exit 0",
          "pnpm check:where-matcher :: exit 0"
        ],
        "reconciliation": "dispatch-gates --ran on 5e04bdcd: 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN (same 34 families as on cef362e9, all exit 0 there too)",
        "ci": "PR check-runs on 5e04bdcd: in_progress at report time (17 in progress, 2 skipped); CI convergence is the seat's read"
      },
      "line_budget": "n/a — no ratcheted file touched; diff 5 files",
      "dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
      "deviations": [
        "origin/main merged once before pr_create (5e04bdcd, no conflict); origin/main has since moved 15 commits, not merged (AGENTS §10: merge after PR open only on conflict, main-caused red or queue removal)",
        "Human Minimum item 3 left unticked in the PR body: no formatter ran, but repo-wide pnpm lint is CI-owned and was not run locally",
        "the PR body carries the platform attribution HTML comment as line 1 (harness-written exception); Fixes #26726 follows",
        "PR template headings folded into the os-dev order (What changes / Why / Tests / Acceptance notes / Verification / Human Minimum)"
      ],
      "body_amendments": [],
      "mcp_calls": "0",
      "api_writes": "2 — relay pr_create (repository_dispatch -> POST /repos/objectstack-ai/objectstack/pulls, PR #26936) and this report through post-stamped (POST /repos/objectstack-ai/objectstack/issues/26726/comments); git push is not a REST write",
      "open_questions": [],
      "out_of_scope_findings": [
        "class: none (code read, not measured) · body.timeoutMs and body.memoryMb have no Studio control either, and the language switch keeps them, so a hook loaded with either and switched to an expression would be refused at save by the strict ExpressionBodySchema · dedupe words: hook body timeoutMs memoryMb Studio control, expression body L2-only key language switch · carrier: none · noted in the PR Acceptance notes, not filed"
      ]
    }

    Generated by Claude Code

  8. objectstack-fleet commented on Oct 27, 2026

    @objectstack-fleet
    ContributorAuthor

    os-dev-report

    {
      "issue": 26726,
      "status": "done",
      "addendum_to": 6454855293,
      "round": "seat patch round 1",
      "branch": "claude/project-thread-7wuwlp",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/26936",
      "head": "c042e7be",
      "session": "session_01JQwxbZCsAdVhYHddQY84CE",
      "summary": "Item 1: setLanguage now drops every L2-only body key on a switch away from js, read off the spec's two body shapes (keys of ScriptBodySchema.shape not in ExpressionBodySchema.shape = capabilities, timeoutMs, memoryMb); new test: a js body with capabilities, timeoutMs 250 and memoryMb 64 switched to expression writes the bare expression body and parses through HookSchema. Docblock and changeset reworded. Item 2: api.write hint lists insert / update / delete / updateMany / deleteMany / upsert and log lists debug / info / warn / error, matching the methods quickjs-runner.ts gates (WRITE list and the four log levels, read on this branch); the first test case pins the log string.",
      "files_changed": [
        ".changeset/26726-hook-capabilities-control.md",
        "ui/packages/app-shell/src/views/metadata-admin/inspectors/HookDefaultInspector.tsx",
        "ui/packages/app-shell/src/views/metadata-admin/inspectors/HookDefaultInspector.capabilities-26726.test.tsx"
      ],
      "tests": "new file 10/10 passed (lock VERDICT command-exit 0) on c042e7be; neighbours (every HookDefaultInspector.*.test.tsx, inspectorStrings.hookAction.i18n-10586, every ObjectHooksPanel*.test.tsx) 12 files 60/60, exit 0; app-shell type-check exit 0. Ablation via scripts/ablation-replace.mjs: the L2-only delete loop replaced by a comment -> 2 of 10 red (both language-switch cases), restored, blob == HEAD dffb070d, git diff HEAD empty.",
      "gates": {
        "local": "dispatch-gates --commands on c042e7be: same 34 families; 33 exit 0 first pass; pnpm --dir ui exec vitest run scripts/ exit 1 on the first pass (2 cases in scripts/__tests__/check-vi-mock-inherit.test.ts timed out at 16-17 s against the 15 s test timeout under shared-box load; the diff touches no script and mocks no @object-ui/i18n module), then that file alone 83/83 exit 0 and the whole gate re-run 178 files / 5065 tests exit 0; --ran reconciled 34/34, 0 NOT-MEASURED",
        "ci": "PR check-runs on c042e7be: 43 success, 9 skipped, 0 failure (the 5e04bdcd run was cancelled by the push)"
      },
      "line_budget": "n/a — no ratcheted file touched",
      "deviations": [
        "pushed c042e7be before the local re-run instead of after; every local check on that head then came back clean (above)"
      ],
      "body_amendments": [
        "What changes, Expression bodies bullet: a switch away from js drops capabilities, timeoutMs and memoryMb (the keys of ScriptBodySchema.shape not in ExpressionBodySchema.shape), not only capabilities",
        "Tests: ten cases; add 'switching a js body with limits to expression drops every L2-only key and the saved hook parses'",
        "Ablation: add leg C, the L2-only delete loop removed -> 2 of 10 red (both switch cases)",
        "Acceptance notes: delete the timeoutMs/memoryMb note (fixed in this PR); the two keys still have no Studio control of their own",
        "Verification: head c042e7be, 34 families, the scripts/ timeout and its clean re-run"
      ],
      "mcp_calls": "0",
      "api_writes": "1 this round — this addendum through post-stamped (POST /repos/objectstack-ai/objectstack/issues/26726/comments); git push is not a REST write",
      "open_questions": [],
      "out_of_scope_findings": [
        "class: none (code read, not measured) · body.timeoutMs and body.memoryMb have no Studio control of their own · dedupe words: hook body timeoutMs memoryMb Studio control · carrier: none · noted, not filed (the language-switch half of the earlier note is fixed in this round)"
      ]
    }

    Generated by Claude Code

  9. objectstack-fleet commented on Oct 27, 2026

    @objectstack-fleet
    ContributorAuthor

    Landed · seat domain:ui#1 · session_01JQwxbZeBv2y91towxasSUT · 2026-10-27T23:43Z

    PR #26936 merged as fc92c62ac2 (seat record: PR comment 6455621115). The Studio hook editor now shows a "Capabilities" checkbox per HookBodyCapability token on a sandboxed-JS body, with the ctx calls each one unlocks, and writes body.capabilities in spec order ([] when the last is unticked). An expression body shows no control. Switching a body away from js drops every L2-only key (capabilities, timeoutMs, memoryMb), read off the spec's two body shapes. The capability check itself is unchanged. The server half, a named refusal instead of a 500, is #26903. pm:dispatched is removed with the close.


    Generated by Claude Code

  10. removed
    pm:dispatched
    on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:studiobugdomain:uipriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions