Skip to content

assignment rules: creating one from Setup fails with "组织不能为空" because organization_id is required and never stamped #39415

In progress

Description

@objectstack-fleet

repo:objectstack@hotlong · hotlong · session_2d709547c1624199b93584a53fbaaca2

What happens

Setup → 分派与审批 → 分配规则 → 新建分配规则. I filled every visible field: name, label, object 报修单, assign to queue 维修组, round-robin. Clicking 创建 shows 「组织不能为空」 at the top of the form. The form has no organization field, so a new admin has nothing to fix and cannot create a rule at all.

POST /api/v1/data/sys_assignment_rule answers:

400 {"error":"组织不能为空","code":"VALIDATION_FAILED","fields":[{"field":"organization_id","code":"required",...}]}

The same body plus "organization_id": "<current org>" is created (201), and the rule then lists normally.

Why

packages/plugins/plugin-sharing/src/objects/sys-assignment-rule.object.ts:78 declares organization_id: Field.lookup('sys_organization', { required: true, … }). The organization is not stamped from the session before the required check runs.

Sibling objects that leave the tenancy column implicit get it stamped. sys_queue, created from the same Setup group a minute earlier, stored organization_id = <current org> without the form sending it.

Expected

An organization-authored rule created from Setup (or from the API by a signed-in admin) is stamped with the caller's organization, as the queue is. A test should create a rule through the data API without organization_id and assert the stored row's organization.

(origin/main f32b7d6, showcase objectstack dev --ui --seed-admin.)

Activity

  1. added
    bug
    priority:p1
    pm:queue
    area:access
    domain:server
    on Dec 3, 2026
  2. objectstack-fleet commented on Dec 3, 2026

    @objectstack-fleet
    ContributorAuthor

    triage@hotlong · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in area:workflow · domain:server · Bug · p1 · pm:queue · size S, touched 2026-12-03T23:20Z. Rationale: area:access is not on the North Star list. Assignment rules route records step by step, which is workflow, so I moved it there. Creating any assignment rule from Setup fails, because organization_id is required and never filled in. The capability is dead on arrival, so the filer's p1 stands. Issue type set to Bug.
    Grade: area:workflow · Bug · p1 · every admin creating an assignment rule · read (new-company walkthrough).

  3. added
    area:workflow
    and removed
    area:access
    on Dec 3, 2026
  4. objectstack-fleet commented on Dec 3, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Claim: PM loop round 2 · 2026-12-03T23:44Z · zone em-p1 (whole-repo p1 first)
    Area: em-p1
    Session: session_016WV4czHUJLmdQAqm4fdDs9
    Account: os-elon-musk
    Branch: claude/issue-39415-wip
    Worktree: objectstack-issue-39415
    Domain: domain:server
    Seat: repo:objectstack@os-elon-musk
    File surface: packages/plugins/plugin-sharing/src/objects/sys-assignment-rule.object.ts, the organization-stamp path the engine already applies to sibling Setup objects such as sys_queue (reason: the fix reuses it; the dev names the exact file in the report before widening to it), a new test named for 39415 beside the changed file (create through the data API with no organization_id, assert the stored row's organization), a patch changeset. ⛔ Not sys-sharing-rule.object.ts (open PR #39386 edits it). Stop on any other breach; explain in the report.
    Container & model: S, mode:subagent, model: default (dispatch-gates --tier at f32b7d6d: "no path-derived mandate"), effort: high (reason: tenancy stamping on a permission-adjacent Setup object; the route between an implicit tenancy column and a stamp is a reading)
    Clause-②: no
    Metadata-protocol: none
    Responsibility: plugin-sharing sys_assignment_rule (objectstack) declares organization_id required with no stamp from the session, so every create from Setup answers 400 「组织不能为空」 | the platform's implicit tenancy stamp covers sys_queue, not this object | every admin creating an assignment rule today
    Thread-read: 7395427472
    Premise: holds — at origin/main f32b7d6 sys-assignment-rule.object.ts declares organization_id: Field.lookup('sys_organization', { required: true, … }) while sys-queue.object.ts declares no organization_id field; the 400 is the filer's measurement on showcase.
    Pre-claim lane: domain:server (plugin-sharing); this seat keeps it.
    Pre-claim deps: none named.
    Prior rulings read: card thread 0 rulings; the object's own comment "a stored rule always belongs to one organization. A rule that reaches every organization is a DECLARED rule, never a row here" stays true after the fix (the stamp fills it, nothing makes it optional).
    Serial constraints cleared: check-handover.mjs --inflight --paths=packages/plugins/plugin-sharing/src/objects/sys-assignment-rule.object.ts --card=39415 → NO OVERLAP READ (exit 5; #38415 and #35238 name no path).

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

    @objectstack-fleet
    ContributorAuthor

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

    {
      "issue": 39415,
      "status": "done",
      "branch": "claude/issue-39415-wip",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/39454",
      "session": "session_016WV4czHUJLmdQAqm4fdDs9",
      "premise_still_valid": true,
      "summary": "Resumed from claude/issue-39415-wip@9bc749aace. The prior run had pushed 4 commits, not 1: the fix, a changeset follow-up, i18n regen, and the index removal. All were verified and kept, nothing was force-pushed, and origin/main was merged in at ecd0700b. sys_assignment_rule no longer declares its own required organization_id, so it carries the platform tenant column sys_queue rides. That column is injected by applySystemFields (packages/objectql/src/registry.ts, called from registry-object-registration.ts) and stamped by SqlDriver#injectTenantOnInsert; a system write's organization comes from objectql/src/tenancy/system-write-organization.ts. No second mechanism and no edits there. Non-null holds: the column is created NOT NULL (ADR-0131 D1), the save guard still refuses a no-organization row naming organization_id, and the object's 'a stored rule always belongs to one organization' comment stays. This run added two pins: (a) the rule lists and routes, (b) an update cannot move it to another organization. It also corrected one changeset sentence and opened draft PR #39454. CLAIM-LINE READING for the seat: organization_id stays in the served field list, with the same name, type and reference. Its attributes change from required:true, group System and its own label/help/translations to the platform's TENANT_SCOPE_FIELD_DEF (required:false, hidden, readonly, system). A data-API create is wider (the key is no longer needed). A data-API update is narrower: organization_id is dropped with the engine read-only WARN, where on the merge base it moved the rule. Measured at engine level, as is the effect under the group posture. What a metadata author can write is unchanged (this is a platform table), so Metadata-protocol: none holds. Whether the update narrowing earns Clause-② (narrowing) is the seat's call; I copied the claim's 'no' unchanged.",
      "tests": "At head 78c464c3: `pnpm --filter @objectstack/plugin-sharing exec vitest run --maxWorkers=2` gave VERDICT command-exit 0, Test Files 82 passed (82), Tests 1787 passed | 11 skipped (1798). The 39415 file alone gave Tests 7 passed (7). RED FIRST: sys-assignment-rule.object.ts was restored from merge base 4eca9da0 with the rest at head, giving VERDICT command-exit 1, 5 failed | 2 passed. The 5 that failed: create with no org stored in admin's org; each admin's rule in own org; column equals sys_queue's; lists and routes; update cannot move. Log: WARN Insert operation failed fields organization_id/required reason 'Organization is required'. The two green before are preservation pins: a named org kept on a system write, and the no-org refusal. Engine-level MEASURE, with the object file swapped and no plugin-security composed: an org-A admin creating with organization_id:B stored org_b on main and stored org_b at head (unchanged). The same admin updating organization_id to B stored org_b on main and org_a at head, with a WARN that the read-only field was DROPPED. No ablation beyond the red-first swap, because the changed behaviour is the object declaration that the red-first run removes.",
      "gates": "① `pnpm exec turbo run build --filter=@objectstack/plugin-sharing --concurrency=2` gave VERDICT command-exit 0, Tasks 16 successful, 15 cached. ② the plugin-sharing test above gave exit 0, and `pnpm --filter @objectstack/plugin-sharing run typecheck` gave VERDICT command-exit 0 (check:test-typecheck OK: 2 files / 3 errors / 3 pinned signatures held). ③ `dispatch-gates --commands --repo objectstack-ai/objectstack` at 78c464c3 derived 66 commands. 64 exited 0, including check:i18n 'all bundles in sync', check:keyed-text-bounds, check:platform-object-tenancy-census, check:tenant-audit-census, check:nul-bytes, check:issue-citations, check:adr-0087-registration 'adds no migration entry', check:empty-changeset, check:type-check-coverage/debt and check:engine-double-contract. Two were NOT MEASURED. check:dual-build-cjs-loads exited 3 with PREREQUISITE NOT MET (packages with no dist: studio, client-react, organizations, scenarios). check:query-options-erasure exited 124: its self-test passed, then its repo-wide lint walk exceeded my 240 s per-command timeout. Both are CI's. `dispatch-gates --ran` gave exit 0: 66 derived, 64 run, 2 NOT-MEASURED, 0 UNRUN. Exit codes were captured per command before any pipe (`timeout 240 bash -c CMD > log; e=$?`). PR check-runs: not read yet. The report is delivered at the end of local verification, and CI convergence is the PM's.",
      "mcp_calls": "0",
      "api_writes": "2 relay strokes. (1) fleet-write pr_create, request fw-20261204T005233Z-b014fb, run 47239278514 success: POST /repos/objectstack-ai/objectstack/pulls (draft, forced) and POST /repos/objectstack-ai/objectstack/issues/39454/assignees [os-elon-musk]; read back 7130 bytes sent, 7130 stored, identical. (2) post-stamped comment on #39415: POST /repos/objectstack-ai/objectstack/issues/39415/comments (this report). Also `git push origin claude/issue-39415-wip` (twice: 9bc749aa..78c464c3, not REST). Reads used `gh api` GET on issue 39415 and its comments.",
      "classifier_refusals": [],
      "open_questions": [],
      "security_findings": "withheld",
      "out_of_scope_findings": [
        "carrier: none · noted in PR Acceptance notes, not filed. Not measured: an upgraded single-tenant database still holds the physical index from the removed `{ fields: ['organization_id'] }` entry, and whether `os migrate plan` lists it as an index drop was not measured."
      ],
      "line_budget": "283 changed lines (+228 / -55, 14 files) vs the 3000 human-merge threshold: under. Of these, 44 lines are the 11 regenerated translation bundles.",
      "files_changed": [
        ".changeset/39415-assignment-rule-organization-stamp.md",
        "packages/plugins/plugin-sharing/src/objects/sys-assignment-rule.object.ts",
        "packages/plugins/plugin-sharing/src/objects/sys-assignment-rule.organization-stamp-39415.test.ts",
        "packages/plugins/plugin-sharing/src/translations/{ar,de,en,es-ES,fr,ja-JP,ko,pt-BR,ru,zh-CN,zh-Hant}.objects.generated.ts (generated by check-i18n-bundles.mjs --write; generated files are unlisted in the claim's surface by the template)"
      ],
      "deviations": [
        "The third gate batch (commands 49 to 66) was moved to the background by the harness when it passed the 600 s foreground cap. I stopped it with TaskStop as soon as I saw it; it had finished 13 commands, and I re-ran the remaining 5 in the foreground.",
        "Resume premise: the dispatch said one commit had been pushed, but the remote branch held four (23213d84, 0476c4ff, ae5e1d24, 9bc749aa). All were read and kept.",
        "Not composed in a test: the plugin-security write wall (refusing a foreign organization_id on a walled insert). Its verdict reads column presence and posture only (security-plugin-write-tenant-wall.ts composeWriteTenantWall), so it is unchanged by this diff. That is stated rather than pinned, because plugin-security is not a plugin-sharing dependency.",
        "The PR body carries the HTML attribution comment on line 1 because the dispatch order prescribed it verbatim."
      ]
    }
  7. objectstack-fleet commented on Dec 4, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Claim: PM loop round 2 (re-posted 2026-12-04T01:33Z; supersedes the Clause-②: line of claim 7395960225 on L1-b REWORK 7397958207 on PR #39454: the diff widens create and narrows update) · zone em-p1 (whole-repo p1 first)
    Area: em-p1
    Session: session_016WV4czHUJLmdQAqm4fdDs9
    Account: os-elon-musk
    Branch: claude/issue-39415-wip
    Worktree: objectstack-issue-39415
    Domain: domain:server
    Seat: repo:objectstack@os-elon-musk
    File surface: (unchanged, plus the 11 regenerated packages/plugins/plugin-sharing/src/translations/*.objects.generated.ts bundles) packages/plugins/plugin-sharing/src/objects/sys-assignment-rule.object.ts, the organization-stamp path the engine already applies to sibling Setup objects such as sys_queue (reason: the fix reuses it; the dev names the exact file in the report before widening to it), a new test named for 39415 beside the changed file (create through the data API with no organization_id, assert the stored row's organization), a patch changeset. ⛔ Not sys-sharing-rule.object.ts (open PR #39386 edits it). Stop on any other breach; explain in the report.
    Container & model: S, mode:subagent, model: default (dispatch-gates --tier at f32b7d6d: "no path-derived mandate"), effort: high (reason: tenancy stamping on a permission-adjacent Setup object; the route between an implicit tenancy column and a stamp is a reading)
    Clause-②: yes (narrowing)
    Metadata-protocol: none
    Responsibility: plugin-sharing sys_assignment_rule (objectstack) declares organization_id required with no stamp from the session, so every create from Setup answers 400 「组织不能为空」 | the platform's implicit tenancy stamp covers sys_queue, not this object | every admin creating an assignment rule today
    Thread-read: 7397350644
    Premise: holds — at origin/main f32b7d6 sys-assignment-rule.object.ts declares organization_id: Field.lookup('sys_organization', { required: true, … }) while sys-queue.object.ts declares no organization_id field; the 400 is the filer's measurement on showcase.
    Pre-claim lane: domain:server (plugin-sharing); this seat keeps it.
    Pre-claim deps: none named.
    Prior rulings read: card thread 0 rulings; the object's own comment "a stored rule always belongs to one organization. A rule that reaches every organization is a DECLARED rule, never a row here" stays true after the fix (the stamp fills it, nothing makes it optional).
    Serial constraints cleared: check-handover.mjs --inflight --paths=packages/plugins/plugin-sharing/src/objects/sys-assignment-rule.object.ts --card=39415 → NO OVERLAP READ (exit 5; #38415 and #35238 name no path).

  8. objectstack-fleet commented on Dec 4, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Claim amendment: 2026-12-04T02:16Z · to claim 7397968121 · on L2 contract review 7398747505 (PASS, should-fix S1) on PR #39454
    File surface (added): packages/plugins/plugin-sharing/src/assignment-rule-hooks.ts (the save guard: refuse a create that names an organization_id matching no organization, the reference check the readonly tenant column no longer gets), its pin in the existing 39415 test file. Prose faces of N4 (changeset BREAKING sentence) and N1 (object comment) ride along. Everything else in the claim stands. check-handover.mjs --inflight --paths=packages/plugins/plugin-sharing/src/assignment-rule-hooks.ts --card=39415: NO OVERLAP READ.

  9. objectstack-fleet commented on Dec 4, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Claim amendment: 2026-12-04T02:16Z · to claim 7397968121 · withdraws the surface added by amendment 7398767715
    S1 closes by its second route (L1-b's recommendation): the changeset and the object comment state the widening (a create that names an organization is no longer reference-checked, as for sys_queue), with N4 folded in; the platform-wide reference check on the tenant column is a separate card. assignment-rule-hooks.ts is NOT touched. Surface back to the claim's own files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:workflowbugdomain:serverpm:dispatchedpriority:p1

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions