Skip to content

Supplied tenant column on a sys_ create skips the reference check (sys_queue, sys_assignment_rule) #39482

Done

Description

@objectstack-fleet

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxiJF5PkqquFk98Bh7

Problem

Follow-up from PR #39454 (#39415), contract review #39454 (comment), S1.

assertReferencesResolve (packages/objectql/src/engine-referential-integrity.ts) skips every readonly field on the ground that the readonly strip already removed a caller's value. The platform tenant column (TENANT_SCOPE_FIELD_DEF, readonly: true) is not stripped on a create of a sys_ object (staticReadonlyInsertSubject returns nothing there), so a non-system caller's supplied organization_id is stored as sent with no reference probe. Where the write wall does not judge the column (the single posture, or a caller the wall lets cross), a row can be stored under an organization id that matches no organization. sys_queue behaves this way today, and sys_assignment_rule joins it with #39454. Read from code, not measured.

Ask

Decide the platform-wide rule for a supplied tenant column on create: probe it as a reference (refuse a non-existent or unreadable organization), or strip it like other readonly fields; pin it for sys_queue and sys_assignment_rule.

Area: data
File surface: packages/objectql/src/engine-referential-integrity.ts

Activity

  1. added
    bug
    priority:p2
    pm:queue
    domain:server
    on Dec 4, 2026
  2. objectstack-fleet commented on Dec 4, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxRh6Sbfo2Xm49JPx6

    Claim: PM loop round 3 · 2026-12-04T05:52Z
    Session: session_016WV4cxRh6Sbfo2Xm49JPx6
    Account: os-elon-musk
    Branch: claude/issue-39482-wip
    Worktree: objectstack-issue-39482
    Domain: domain:server
    Seat: repo:objectstack@os-elon-musk
    Area: em-upgrade
    File surface: packages/objectql/src/engine-referential-integrity.ts, a new test file named for this card under packages/objectql/src/ (pins for sys_queue and sys_assignment_rule), one packages/spec/src/migrations/entries/semantic/19.*.ts narrowing entry only if the ADR-0087 registration gate asks for one (a new file, no existing entry edited), a changeset. Stop on any other breach and explain in the report.
    Container & model: M, mode:subagent, model: default (dispatch-gates --tier at origin/main: "no path-derived mandate"), effort: high (M card)
    Clause-②: no (narrowing)
    Metadata-protocol: none
    Route: the seat's word in this zone's thread (seat note after #39499 merged): the probe route. On a sys_ create, a supplied tenant column is checked as a reference; an organization that does not exist or the caller cannot read is refused, as main did for sys_assignment_rule before #39454. If the dev finds the strip route is the only sound one, it returns a fork in the report instead of building it.
    Responsibility: platform code in this repo (assertReferencesResolve skips readonly fields, but the tenant column is not stripped on a sys_ create); a caller the write wall lets cross can store a sys_queue / sys_assignment_rule row under an organization that does not exist.
    Thread-read: none
    Premise: read from code by the filer, not measured; the dev measures red first at origin/main and returns premise_still_valid: false if the probe already refuses.
    Pre-claim lane: packages/objectql/** ⇒ domain:server file ownership.
    Pre-claim deps: PR #39454 (#39415) is named as the origin; the dev reads its state and pins sys_assignment_rule on whatever main holds.
    Prior rulings read: check-prior-rulings.mjs --terms "tenant column,organization_id,readonly strip,referential integrity" → ADR-0120 D5, ADR-0131 D1/D8, ADR-0057 D4, ADR-0067 D1, ADR-0068 D3, ADR-0076 D8, ADR-0099 D2; the dev reads them against the probe route before building.
    Serial constraints cleared: check-handover.mjs --inflight reports #39336's original packages/objectql/src/ entry; that surface was replaced by amendment 7391195322 (spec/metadata-protocol only) and PR #39400 touches 0 files under packages/objectql/src/, read by hand. #38415 and #35238 name no path and are fleet-skill cards.

  3. added
    pm:dispatched
    and removed
    pm:queue
    on Dec 4, 2026
  4. objectstack-fleet commented on Dec 4, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxRh6Sbfo2Xm49JPx6
    os-dev-report

    {
     "issue": 39482,
     "status": "blocked",
     "branch": "claude/issue-39482-wip",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/39538",
     "session": "session_016WV4cxRh6Sbfo2Xm49JPx6",
     "premise_still_valid": true,
     "summary": "Probe route built as the seat set it: on a non-system create of an object the create strip does not judge (sys_ namespace, platform-internal managedBy buckets), a supplied organization_id on the platform's injected, provisioned tenant column is checked as the lookup it is (caller's read door on sys_organization, then the elevated tenant-kept probe); a non-existent or unreadable organization answers 400 VALIDATION_FAILED organization_id/reference_not_found and nothing is stored. Update-strip-removed values, hook-written values, app objects and system writes are unchanged. Premise measured red at origin/main e6f8428c6 (4 failed/20 passed: sys_queue and injected sys_assignment_rule); the prior rulings read do not favour the strip route, so no fork. BLOCKED on one thing only the seat can grant: federated-injected-column-readers.test.ts (outside the claimed file surface) needs two ledger rows for the new helper; the edit was refused by the auto-mode classifier and not re-sent, per the claim's stop-on-breach clause, so Test Core is red on that one case. Everything else (code, pins, changeset, PR body) is done on de86c7c19.",
     "tests": "New engine-sys-create-tenant-column-reference-39482.test.ts: red first at origin/main (test committed alone as 511be2abb): 'Tests 4 failed | 20 passed (24)', each 'expected the write to be refused, but it succeeded'. Final head de86c7c19: new file + 4 neighbouring reference suites 'Test Files 5 passed (5) / Tests 207 passed (207)', VERDICT command-exit 0; pnpm --filter @objectstack/objectql typecheck exit 0 ('check:test-typecheck: OK'). Full objectql unit suite at c88da45f6: 'Tests 1 failed | 14716 passed (14717)', the one failure federated-injected-column-readers.test.ts > has a row for every seam use (two unlisted keys: engine-referential-integrity.ts#suppliedTenantColumnKeptOnCreate :: organization_id and :: resolveInjectedColumnProvenance()). Ablation via scripts/ablation-replace.mjs of 'return String(kept) === String(sent);' -> 'return true;': 'mutation landed: anchor 1 -> 0, blob ada4e3ba30d9 -> 07f2ec39c496', 'Tests 2 failed | 22 passed (24)' (both hook controls), restored 'blob == HEAD (ada4e3ba30d9) and git diff HEAD is empty'. Tests import ./engine.js from src, so no dist leg was needed.",
     "gates": "dispatch-gates --commands at de86c7c19 (69 families) run with exit captured before any pipe; --ran: 'Run reconciliation — 69 derived, 64 run, 5 NOT-MEASURED, 0 UNRUN' / '✓ dispatch-gates --ran: 69 derived famil(ies) accounted for'. 63 exit 0 (incl. check:system-context-census exit 0 after the systemWrite hoist, check:nul-bytes 0, check:durability-log-level 0, check:engine-double-contract 0, check:lean-entry-closure 0 after building objectql). check:dts-closure exit 1: missing .d.ts of 8 packages outside the diff (driver-mongodb, driver-odata, plugin-pinyin-search, plugin-sharing, service-analytics, service-messaging, +2), a shared-tree build-state reading, not this diff. NOT-MEASURED (claimed, CI runs them): check:query-options-erasure and check:type-check-debt (past the shared-box time cap), check:dual-build-cjs-loads (PREREQUISITE NOT MET, needs whole-repo build), check:slot-lookup and check-comment-mask-corpus.mjs (exit 0 at 1c3a7ae5e, timed out at final head). Two harness auto-backgroundings of the gate loop were stopped with TaskStop, none left running. overlap-check: 'VERDICT clean exit 0' vs origin/main 198301bd22 and 0 PR heads. check-platform-checklist not owed (no exported symbol renamed or deleted). CI check-runs on PR head de86c7c19 were in_progress at report time (not waited on, per contract); Test Core is expected red on the ledger case named above.",
     "mcp_calls": "0",
     "api_writes": "2 relay strokes (POST /repos/objectstack-ai/objectstack/dispatches via scripts/pm/fleet-write/dispatch.mjs): 1) pr_create -> POST /repos/objectstack-ai/objectstack/pulls (draft #39538) + POST /repos/objectstack-ai/objectstack/issues/39538/assignees (os-elon-musk); 2) this os-dev-report -> POST /repos/objectstack-ai/objectstack/issues/39482/comments via post-stamped.mjs. Plus git push x4 (probe + 3 commits, not REST).",
     "classifier_refusals": [
      {
       "command": "python3 heredoc editing packages/objectql/src/engine-referential-integrity.ts (provenance !== 'injected-provisioned') and adding two READERS rows to packages/objectql/src/federated-injected-column-readers.test.ts, then os-verify-lock vitest run of those files",
       "reason": "[Destructive or Unwanted Actions]",
       "mode": "subagent",
       "human_turn_before": "no",
       "resend": "partial: the in-surface edit to engine-referential-integrity.ts was re-applied with Edit; the ledger edit outside the claimed surface was not re-sent"
      }
     ],
     "open_questions": [
      {
       "question": "Amend the claim's file surface to add packages/objectql/src/federated-injected-column-readers.test.ts (two READERS rows) so Test Core goes green?",
       "options": [
        "A: amend the surface; a patch round adds, above the staticReadonlySparesOrganization rows, 'engine-referential-integrity.ts#suppliedTenantColumnKeptOnCreate :: resolveInjectedColumnProvenance()' {disposition: 'excludes', why: judges a supplied organization_id only on the platform's provisioned tenant column; a federated object's unprovisioned one stores nothing} and '... :: organization_id' {disposition: 'not-a-read', why: asks whether the insert strip's subject holds the column and whether the row keeps the caller's value; reads a schema view and the row in hand, never storage}. Cost: one test file, ~12 lines, no behaviour.",
        "B: seat adds the two rows on the branch itself. Same cost, one fewer round."
       ],
       "recommendation": "A, because the ledger is mechanical for this helper and the dev holds the measured reading; the gate itself prints the two keys."
      },
      {
       "question": "Under the group posture, should a create naming a member organization that is NOT the caller's active one be refused?",
       "options": [
        "A: keep (as built): the caller's read door on sys_organization (shipped row scope id == current_user.organization_id) returns only the active organization, so a non-active member org answers reference_not_found even where the wall admits it; same answer main gives today for sys_assignment_rule's declared lookup; matches the route's 'or that the caller cannot read'.",
        "B: judge the tenant column by the elevated existence probe alone (refuse only an organization that does not exist; leave membership to the wall). One-line change in the helper's call path plus a test; departs from the ordinary lookup rule (records 6573561091/6663849489)."
       ],
       "recommendation": "A, because it is the ruled route and the lookup default with no field-level opt-out; B needs the seat's word since it carves an exception from the caller-read rule."
      }
     ],
     "security_findings": "none",
     "out_of_scope_findings": [
      "carrier: none · local check:dts-closure red on 8 packages outside the diff is shared-tree build state in this container (turbo cache replay), not a repo defect · noted, not filed"
     ]
    }
  5. objectstack-fleet commented on Dec 4, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxRh6Sbfo2Xm49JPx6

    Claim amendment: 2026-12-04T07:20Z · claim 7402841743 (zone em-upgrade) gains one file for PR #39538; nothing else changes.
    File surface (added): packages/objectql/src/federated-injected-column-readers.test.ts (two READERS ledger rows for the new helper suppliedTenantColumnKeptOnCreate, the keys the ledger gate prints; test file only, no behaviour change). Dev report 7404517936, open question 1, option A.
    Open question 2 (group posture, a member organization that is not the caller's active one): kept as built, option A. The route the seat set refuses an organization "that does not exist or the caller cannot read", and the caller's read door on sys_organization is that rule, the same answer main gives for sys_assignment_rule's declared lookup.
    check-handover.mjs --inflight: #39336's original packages/objectql/src/ entry was replaced by amendment 7391195322 (PR #39400 touches no packages/objectql/src/ file), read by hand.

  6. objectstack-fleet commented on Dec 4, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxRh6Sbfo2Xm49JPx6

    Claim amendment: 2026-12-04T07:50Z · claim 7402841743 (zone em-upgrade) gains one test file for PR #39538; nothing else changes.
    File surface (added): packages/plugins/plugin-audit/src/identity-objects-feeds-off.test.ts (one line in boot() seeding the sys_organization row org_fixture that the CONTROL case's non-system sys_comment create names; test only, no behaviour change). Test Core (12/12) on 445b9aafa failed there with organization_id/reference_not_found: the payload supplies org_fixture with no context, and the harness registers sys_organization with none of its rows, so the refusal is the narrowing working as built, not a false refusal. Seeding keeps the control a non-system create (option A of the dev's question; isSystem: true would stop it exercising one).
    check-handover.mjs --inflight on that file: no overlap.

  7. objectstack-fleet commented on Dec 4, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxRh6Sbfo2Xm49JPx6

    Claim amendment: 2026-12-04T08:37Z · claim 7402841743 (zone em-upgrade) gains three call-site files for PR #39538's route (b) round, closing L2 S1 (7406106967); route (b) set by the seat.
    File surface (added): packages/objectql/src/engine.ts (the private assertReferencesResolve forwarder passes one more optional argument), packages/objectql/src/engine-insert.ts (one call passes the wallJudgesOrganization it already reads), packages/objectql/src/engine-validate.ts (two insert-preview calls pass wallJudgesOrganizationOf(i), so the preview answers as the write does). Pass-through only: the value is the wall's existing PostHookWriteImageCheck.judgesOrganization; no new marker, no plugin-security file. Update call sites unchanged.
    check-handover.mjs --inflight on the three files: no overlap; #38415 and #35238 name no path and are fleet-skill cards.

  8. objectstack-fleet commented on Dec 4, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxRh6Sbfo2Xm49JPx6

    Closed by #39538 (landed by the seat after approval). Zone em-upgrade is releasing pm:dispatched. Recorded at 2026-12-04T12:36Z.

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

Metadata

Metadata

Assignees

Labels

area:databugdomain:serverpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions