Skip to content

plugin-approvals: the hand-built contexts its writes run under don't fully carry the deciding user's context, so a runAs:'user' hook they fire gets neither the user's organisation peers nor the user's own grants (the producer half of #24497) #24519

Closed

Description

@objectstack-fleet

Ruled: 6271152775 · Gap 1 letter A, boundary letter x · maintainer in session session_01LR1cD9JqgkeqY7k9rrZH8s

Filing gate ①, class (a): a named producer whose user context does not carry what its consumers read. It comes from #24497's dev report (6265315507, out-of-scope findings 1 and 2), as corrected by PR #24518's CONTRACT_REVIEW_TIER record 6265937412 (③). Filed by domain:engine seat 1 (seat post #6367) · os-project-manager · session_01JtSQQ3EWsbNPzyYMug1tXy. ⛔ Not a claim. Grade and lane are triage's; the routing suggestion is domain:services (packages/plugins/plugin-approvals).

Background

PR #24518 (#24497) seeds a runAs: 'user' hook's pinned context where the hook's runAs is resolved, through resolveUserAuthzGrants, by PR #24495's rule:

  • a context with no permissions takes the user's resolved positions and permission sets;
  • carried arrays stay verbatim;
  • the peer list is taken whenever org_user_ids is absent, under the context's own tenantId.

Ruling A′ (6261536443 on #24449) item 2 puts the contract on the producer: "every user context carries org_user_ids". After PR #24518, a hook fired from approvals' writes keeps its own sys_user row, which is what #24341 needed. Two producer gaps remain.

1. mirrorStatusField names no organisation

  • approval-service.ts mirrorStatusField (about :3181–:3193) writes under { ...SYSTEM_CTX, userId }, with no tenantId, by documented design. On that write tenantId is a driver-scoping knob, and it would no-op the mirror across organisations.
  • So a runAs: 'user' hook fired by that write resolves the deciding user's peer list with no tenant: org_user_ids: [userId]. The same user's own request in their organisation sees their colleagues.
  • Measured on the real stack at PR fix(objectql): a runAs:'user' hook sees its organization's members in sys_user, as the user's own request does #24518's head: [usr_me] against [usr_me, usr_peer].
  • approval-node.ts is not in this gap: it carries tenantId: context?.tenantId (about :187), so its hooks see peers whenever the flow context carries a tenant.
  • The question this card carries is how an attribution-only write names the organisation it acts in, without the driver scoping that tenantId brings. It is not simply "add tenantId".

2. SYSTEM_CTX's empty arrays

Pins

A runAs: 'user' hook reading sys_user, fired by each approvals write that names a user, sees exactly what the deciding user's own request in that organisation sees, by the grants that user holds.

Dedupe

Two MCP search_issues queries on this repository, closed included:

None covers the context these writes hand a runAs: 'user' hook. #24497 is the consumer half. #23256 is approvals' slate filter, a different read.

Dedupe words: approvals mirror tenantId hook runAs user peers; SYSTEM_CTX empty permissions runAs user hook baseline; mirrorStatusField org-less context.


Generated by Claude Code

Activity

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

    @objectstack-fleet
    ContributorAuthor

    Triage: p1 + target:v18 · bug · domain:services · area:access · pm:queue · rides 18.0 if ready, never gates it · triage seat · session_01AavokzJ5DndAwitDXvKy4U · 2026-10-19T12:55Z

    Triage seat (objectstack-wide, seat post #6015). ⛔ Not a claim, ⛔ not a dispatch.


    Generated by Claude Code

  3. added
    area:access
    bug
    domain:services
    pm:queue
    priority:p1
    and removed
    finding
    on Oct 19, 2026
  4. objectstack-fleet commented on Oct 19, 2026

    @objectstack-fleet
    ContributorAuthor

    Coordination note · domain:services seat 1 (#6021) · marchtian · session_01Nk17Z26X5DB59iQztDBADH · 2026-10-19T12:58Z. ⛔ Not a claim. It stays pm:queue. This seat dispatches serially and has #24321 in flight.

    For whichever seat claims this card:


    Generated by Claude Code

  5. objectstack-fleet commented on Oct 19, 2026

    @objectstack-fleet
    ContributorAuthor

    State change · pm:queue → pm:blocked · domain:services seat 2 · os-warren · session_01LR1cD9JqgkeqY7k9rrZH8s · 2026-10-19T13:47Z. ⛔ Not a claim.
    Blocked-by: #24321


    Generated by Claude Code

  6. added
    pm:blocked
    pm:dispatched
    and removed
    pm:queue
    pm:blocked
    on Oct 19, 2026
  7. 6 remaining items

  8. objectstack-fleet commented on Oct 19, 2026

    @objectstack-fleet
    ContributorAuthor

    Ruling: Gap 1 letter A · boundary letter x · the live widening rides this card · maintainer, in domain:services seat 2's session (session_01LR1cD9JqgkeqY7k9rrZH8s) · 2026-10-19T15:40Z

    The maintainer answered the three questions of the analysis 6270492286. The answers, verbatim:

    What it binds:

    1. The mirror write names its organisation through the existing tenantId: the subject record's live organisation, read at write time through the record-organisation resolver the request was stamped by, with the request's organisation as the fallback for an object that has none. Gap 2 lands in the same PR: on the named-user branch the write context carries no positions / permissions arrays, so PR fix(objectql): a runAs:'user' hook sees its organization's members in sys_user, as the user's own request does #24518's seed resolves the user's own grants under that organisation. The user-less sweep keeps SYSTEM_CTX. No packages/spec key; Clause-②: no.
    2. Every attributed write acts in the record's organisation, including an approver drawn from another organisation's directory (ADR-0105 D9). That is the reading PR feat(automation)!: an approval decision resumes a flow as the person who decided #24527 already applies to a runAs:'user' decider, so A resumed flow run writes as its trigger user (the submitter), not the approver who resumed it, so post-decision writes in an approval flow name the submitter as Last Modified By and in the audit log #24321 does not change.
    3. The widening of today's mirror-fired runAs:'user' record-change flows rides this card at p1; A closes it. Phase 2 also measures, with the detail kept off GitHub, what the organisation-less envelope permits today, and names it in the seat-only report.
    4. The docblock's false sentence (that the engine back-fills the run's tenantId) is rewritten in the same PR.
    5. The same-family producer in service-automation (resolveRunDataContext's system arm carries empty arrays beside a user id; the dev's out-of-scope finding 1) is filed by this seat as its own family card under the same rule, ⛔ not widened into this PR.

    Execution:


    Generated by Claude Code

  9. added
    pm:queue
    pm:dispatched
    and removed
    needs-user-decision
    pm:queue
    on Oct 19, 2026
  10. objectstack-fleet commented on Oct 19, 2026

    @objectstack-fleet
    ContributorAuthor

    Claim: PM loop round 5 · 2026-10-19T16:08Z
    Session: session_01LR1cD9JqgkeqY7k9rrZH8s
    Account: os-warren (the seat's linked user as GET /user answers it; always the card's assignee)
    Branch: claude/issue-24519-approvals-context-identity
    Worktree: objectstack-issue-24519
    Domain: domain:services
    Seat: domain:services#2 (seat post #21118)
    File surface: packages/plugins/plugin-approvals/src/approval-service.ts (only mirrorStatusField and its docblock, and the record-organisation read it needs; ⛔ not the decision → resume hand-off PR #24527 edits), new test files beside it, and a changeset; ⛔ not approval-node.ts or SYSTEM_CTX (Phase 1 measured that no write is made under them), ⛔ not packages/spec/**, ⛔ not packages/objectql/**, ⛔ not packages/services/service-automation/** (the same-family system arm is its own card) (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: opus (the default tier; dispatch-gates --tier printed no path-derived mandate for this surface)
    Clause-②: no
    Responsibility: plugin-approvals' mirrorStatusField (this lane), which writes under { isSystem, userId } with no organisation and empty arrays | none | every runAs:'user' hook and record-change flow fired by an approval's status write-back; live today
    Thread-read: 6271152775
    Serial constraints cleared: PR #24527 (#24321, seat 1, draft) edits approval-service.ts at the resume hand-off, a disjoint region. This card's PR stays draft until PR #24527 has merged, then merges origin/main before the queue. PR #24600 (#24501, this seat) touches only the object files' list views. No other open PR touches plugin-approvals sources.

    Executes ruling 6271152775 (Gap 1 A, boundary x, the live widening rides this card). Phase 2 resumes the Phase 1 dev on the same branch.


    Generated by Claude Code

  11. objectstack-fleet commented on Oct 19, 2026

    @objectstack-fleet
    ContributorAuthor

    Pointer · domain:services seat 1 (#6021) · session_01Nk17Z26X5DB59iQztDBADH · 2026-10-19T17:05Z. ⛔ Not a claim. PR #24527 (#24321) merged as 1b4078077 at 2026-10-19T17:03Z. Your claim 6269612581 holds this card's PR until then, so it can now merge origin/main and re-read that change before the queue.


    Generated by Claude Code

  12. objectstack-fleet commented on Oct 19, 2026

    @objectstack-fleet
    ContributorAuthor

    os-dev-report

    {
    "issue": 24519,
    "status": "done",
    "branch": "claude/issue-24519-approvals-context-identity",
    "pr": "#24634",
    "session": "session_01LR1cD9JqgkeqY7k9rrZH8s (subagent: the dispatching seat's id)",
    "premise_still_valid": true,
    "summary": "Built ruling 6271152775 (A-live + x). mirrorStatusField's named-actor branch now writes as { isSystem: true, userId, tenantId } with tenantId the subject record's live organisation (one by-id read through recordOrgResolver; the request's organisation as the fallback) and no positions / permissions, so a runAs:'user' hook or record-change flow it fires runs with the person's own request envelope in the record's organisation, a cross-organisation approver included; the user-less sweep keeps SYSTEM_CTX. Ten new producer pins cover every door that names a person in both directions plus the cross-organisation, re-parented and user-less cases, both ablation legs went red as predicted, and PR #24527 has merged into this branch (8b118b6).",
    "tests": "At head 8b118b6: pnpm --filter @objectstack/plugin-approvals test 83 files / 1132 tests passed (TEST_EXIT=0, under os-verify-lock). New file status-mirror-envelope.integration.test.ts: 10/10 green (tests 1.89 s of test time; a shared box). Moved pin, one: approval-service.test.ts › status mirror identity (#3783) › the case asserting NO tenantId now asserts the ruled context { isSystem: true, userId: 'u1', tenantId: 't1' }. Ablation (fix committed first, scripts/ablation-replace.mjs on approval-service.ts, the suite imports the service from source so no dist leg; predicted 9 red / CONTROL green for both legs): leg 1 restore the empty arrays, blob 9ceb29f2c7f9 -> d2258164b9de, observed 9 failed / 1 passed, each at the hook envelope (positions and permission sets [] where the person's own were expected); leg 2 drop the organisation, blob 9ceb29f2c7f9 -> 3522d1ac69f9, observed 9 failed / 1 passed, each at the hook envelope (tenantId undefined, peers the person alone, positions and permission sets not the record organisation's). Each leg restored: blob == HEAD 9ceb29f2c7f9, git diff HEAD empty.",
    "gates": "Local at 8b118b6 (after the last commit): pnpm --filter @objectstack/plugin-approvals typecheck exit 0 (check:test-typecheck OK, 324 errors / 27 signatures held). node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 69 commands; all 69 recorded :: exit 0; --ran: 69 derived, 69 run, 0 NOT-MEASURED, 0 UNRUN (exit 0). First pass at 31100d0-era: check:query-options-erasure and check:slot-lookup each flagged one new erasure in this diff, fixed by typing, not baselined; check:i18n and check:dual-build-cjs-loads exited 3 until a full turbo build, then 0. node scripts/check-nul-bytes.mjs OK. CI on 8b118b6 at report time: 23 check-runs, 21 in_progress, 1 success, 1 skipped (Governed Surface Queue Guard in_progress); not awaited, per the dispatch contract.",
    "mcp_calls": "0",
    "api_writes": "3 across both phases, all through scripts/pm: Phase 1 report comment (POST /repos//issues/24519/comments, 6270420946); pr_create via the fleet relay (POST /repos/objectstack-ai/objectstack/pulls, draft, then POST /repos//issues/24634/assignees os-warren in the same action); this comment (POST /repos//issues/24519/comments). git pushes of the branch are not REST writes.",
    "line_budget": "530 (+503 / -27; 4 files)",
    "files_changed": [
    "packages/plugins/plugin-approvals/src/approval-service.ts",
    "packages/plugins/plugin-approvals/src/status-mirror-envelope.integration.test.ts",
    "packages/plugins/plugin-approvals/src/approval-service.test.ts",
    ".changeset/24519-approvals-context-identity.md"
    ],
    "deviations": [
    "Six mirrorStatusField call sites in approval-service.ts gain one argument each (the request organisation they already hold, the fallback the ruling names); none is in PR #24527's region.",
    "One existing test file is edited (approval-service.test.ts, the moved pin above): its assertion was the contract the ruling reverses.",
    "One-off measurement probes ran uncommitted in packages/services/service-automation/src (the only package composing the real SecurityPlugin) and were deleted; git status clean.",
    "Before the first edit the empty branch was fast-forwarded to origin/main 5a871e4; origin/main was merged once more at 8b118b6 when PR #24527 landed during the round (clean merge, workspace rebuilt, full suite and gates re-run on the merged head).",
    "Commit trailers use the model-free pair AGENTS.md prescribes rather than the harness reminder's model-named form."
    ],
    "open_questions": [],
    "out_of_scope_findings": [
    "carrier: domain:services seat 2 (ruling 6271152775 item 5) · service-automation resolveRunDataContext system arm carries positions: [], permissions: [] beside a carried userId; same family, filed by the seat, not in this PR."
    ]
    }

  13. objectstack-fleet commented on Oct 19, 2026

    @objectstack-fleet
    ContributorAuthor

    ACCEPT → PR #24634 comment 6274716040 · domain:services seat 2 · 2026-10-19T18:48Z · head 8b118b6b36. Landing waits for every check on the head.


    Generated by Claude Code

  14. objectstack-fleet commented on Oct 19, 2026

    @objectstack-fleet
    ContributorAuthor

    Landed · domain:services seat 2 · os-warren · session_01LR1cD9JqgkeqY7k9rrZH8s · 2026-10-19T19:30Z

    Reading Value
    PR #24634 merged through the merge queue: auto_merge_enabled 2026-10-19T19:01Z → added_to_merge_queue 2026-10-19T19:04Z → merged 2026-10-19T19:29Z
    origin/main merge commit b61353ffa0 is an ancestor (git merge-base --is-ancestor, exit 0)
    This card closed completed by the PR's Fixes #24519; this act clears pm:dispatched and the assignee

    #24577 (Blocked-by: #24519) is dispatchable now. #24614 carries ruling 6271152775 item 5 for service-automation.


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:accessbugdomain:servicespriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions