You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
a system-door delete faults with sys_recycle_bin.organization_id NOT NULL when the record carries no organization_id #35667
Filing gate: ① product defect · Source: fleet · out-of-scope finding of the #35640 measurement (readings 7023666050, kind K7), filed on the seat's order after its fable review. ⛔ Not a claim.
Grade: left to triage. The seat's review suggests p2: a platform fault, not specific to one driver. Reach: measured through os verify --delete-behaviors (system door) on bootStack.
Business reason
A delete through the system door (runAs: 'system', which flows, hooks and admin tooling use) of a record that has no organization_id fails instead of moving the record to the recycle bin. Such records include those of an object with tenancy: { enabled: false }, and any row the mongodb driver wrote, since it does not stamp one. The delete is lost, and the caller gets a database constraint error.
What happens
os verify --delete-behaviors on a fixture whose objects carry no organization_id (tenancy disabled) reported 6 system-door faults with NOT NULL constraint failed: sys_recycle_bin.organization_id. This happened identically on a memory datasource and on a real mongod. The REST-door deletes of the same records held. The fault is the recycle-bin write, which copies the record's organization_id into a column that refuses null.
Expected
A system-door delete of a record with no organization_id either lands in the recycle bin with the org the context supplies, or is recorded under a rule the recycle bin states for global records. It never fails on the constraint.
Done when
A test deletes a tenancy: { enabled: false } record through the system door, and the delete succeeds with the record recoverable from the recycle bin (or the stated rule holds), on memory and on a SQL store.
Who acts: the owner of the recycle bin (sys_recycle_bin) and the system delete path (triage routes).
Dedupe: repo:objectstack-ai/objectstack is:issue is:open recycle bin organization_id (2026-11-19 22:2xZ): no match (#35640, #35488 and #33631 are unrelated).
Triage: lands in domain:server · pm:queue; rationale: area:data · Bug · Broken (a system-door delete of a record with no organization_id faults on sys_recycle_bin.organization_id NOT NULL instead of moving the record to the recycle bin) · flows, hooks and admin tooling deleting org-less records, on more than one driver · measured with os verify --delete-behaviors → p2 as the seat's review suggests. area:build → area:data: the fault is in the delete path.
packages/objectql/src/recycle-bin/**: the entry's organization, capture.tsorganizationOf and write().
If the measurement shows a tenant-column row left unstamped by a driver, that driver's insert stamp, named in the report before it is edited.
One pin (memory and a SQL store), one patch changeset.
⛔ packages/objectql/src/engine.ts must not grow: it is at its facade ceiling, 6857 of 6857.
Stop on any breach and explain it in the report.
Container & model: M, mode:subagent, model: default, effort: high
Clause-②: no
Metadata-protocol: none
Responsibility: objectstack platform: objectql's recycle-bin capture writes the entry's organization_id from the record or the context, and sys_recycle_bin's tenant column is NOT NULL (ADR-0131 D1) | none | flows, hooks and admin tooling deleting through the system door a record that has no organization_id, measured by os verify --delete-behaviors on memory and mongod
Thread-read: 7023873162
Premise: holds on main8145424. capture.ts sets row.organization_id only when the record's tenant field or context.tenantId is a non-empty string, so an org-less record with an org-less system context writes the entry with no organization into a NOT NULL column (ADR-0131 D1). The dev re-measures first.
Serial constraints cleared: no open PR touches packages/objectql/src/recycle-bin/** (open-PR file read at 2026-11-21T11:16Z). fix(audit): a search the server widens never names a column the caller may not query #34817 touches engine.ts, which this card must not grow. overlap-check runs before each push.
Pre-claim lane: seat 7 order (2026-11-21T11:13Z), Tesla's word to work the data cards (2026-11-21 11:10Z). area:data, domain:server; no governed path. L2 tier is decided on the diff.
Pre-claim deps: none.
Prior rulings read: ADR-0148 D1: an entry is a row of a system object, so it is organization-owned (ADR-0131). ADR-0131 D1: NULL is not a state for organization_id; §1.6: a legitimately org-less row belongs to an object with no organization column. No ruling comment on the card thread (check-prior-rulings, 0 of 1). ⛔ If neither the context's organization nor an existing stated rule settles which organization an org-less record's entry carries, the dev reports needs_decision with the options and does not choose.
{
"issue": 35667,
"status": "blocked",
"branch": "claude/issue-35667-recycle-bin-orgless-delete",
"pr": null,
"session": "session_01L9qibwJEh7hMPPvagWM1g7",
"premise_still_valid": true,
"summary": "Premise reproduced on main 8145424b53 (scratch test, not committed): a system-door delete (context { isSystem: true }, no tenantId; a beforeDelete hook saw session { isSystem: true } and no tenantId) of a tenancy: { enabled: false } record throws SQLITE_CONSTRAINT_NOTNULL 'NOT NULL constraint failed: sys_recycle_bin.organization_id' on SqlDriver/better-sqlite3, and the row stays; on InMemoryDriver the delete answers true and the bin entry is written with organization_id null (the memory driver enforces no NOT NULL, ADR-0131 D1 note), a silent NULL-org row. The governing text settles the organization: ADR-0131 D9 (resolveSystemInsertOrganization 'generalizes ADR-0123 D3 to every writer: a write on a tenant-column object with no organization is derived under single and refused otherwise'); the bin entry is a raw write on a tenant-column object (ADR-0148 D1: organization-owned) that bypasses that resolver, so the fix is: record's organization, else context's, else the engine's own resolveSystemInsertOrganization(sys_recycle_bin, context, [row]) (derived Default Organization under single, ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED under a wall, unstamped only in the no-organization-object lean embedding per the D9 note). BLOCKED: the capture's host (RecycleBinCaptureHost) is an object literal built in engine.ts openRecycleBinCapture (engine.ts:4971-4979), and every route to the engine's resolver (that literal, or the deleteAndAggregateHost factory at engine.ts:5858) needs one more line in engine.ts, which is at its ceiling (wc -l 6857 = maxLines 6857, scripts/facade-delegation-registry.json, ruling 7051956587) and off this claim's file surface. Nothing committed; the branch carries no commit beyond main.",
"tests": "Measurement only, scratch file packages/runtime/src/zz-measure-35667.test.ts (deleted after, tree clean: git status --porcelain empty) on HEAD 8145424b53, after `pnpm --workspace-concurrency=2 --filter '@objectstack/objectql...' --filter '@objectstack/driver-sql...' --filter '@objectstack/driver-memory...' build` (lock VERDICT command-exit 0). Run: `pnpm --filter @objectstack/runtime exec vitest run --project local --maxWorkers=2 src/zz-measure-35667.test.ts` (lock VERDICT command-exit 1, Tests 1 failed | 3 passed; the failure is the memory tenant-column control, see below). Readings: [sqlite GLOBAL] storedOrg (absent), hookSaw [{isSystem:true}], outcome threw SQLITE_CONSTRAINT_NOTNULL 'NOT NULL constraint failed: sys_recycle_bin.organization_id', bin []. [memory GLOBAL] storedOrg (absent), outcome true, bin [{object_name: mz_global, organization_id: null}]. [sqlite SCOPED control] system insert stamped org_default (D9 derived), delete true, bin entry organization_id org_default. [memory SCOPED] the system insert itself is refused by the memory driver's tenancy guard (MemoryMultiTenantUnsupportedError, engine handed tenantId org_default), so a memory store cannot hold an engine-written tenant-column row in this composition. No fix built, so no pin, no ablation.",
"gates": "NOT MEASURED: every gate family, reason: no diff (no commit beyond main 8145424b53), so dispatch-gates --commands has an empty change set and there is no PR whose check-runs could be cited. overlap-check not run: nothing pushed beyond the empty branch-creation probe.",
"dogfood_battery": "n/a — no PR, no `!` in a title and no (narrowing) arm",
"mcp_calls": "0",
"api_writes": "1 — POST /repos/objectstack-ai/objectstack/issues/35667/comments (os-dev-report, via scripts/pm/post-stamped.mjs); plus git push of the empty branch claude/issue-35667-recycle-bin-orgless-delete (routing probe, not a REST write)",
"open_questions": [
{
"question": "How does the D9 resolution reach the bin writer, given engine.ts is at 6857 of 6857 and off this claim's surface? The fix itself is three parts: (1) capture.ts RecycleBinCaptureHost gains `resolveSystemInsertOrganization(object, execCtx, rows)` returning a Promise of the organization id or undefined; (2) RecycleBinCapture.write(), when organizationOf() answers undefined, calls `this.host.resolveSystemInsertOrganization(RECYCLE_BIN_OBJECT, this.context, [row])` and stamps row.organization_id with the answer (a refusal throws before the root row is removed, so the delete is refused loudly with the D9 code instead of the constraint); (3) engine.ts openRecycleBinCapture's host literal gains ONE line after line 4978: `resolveSystemInsertOrganization: (...a) => this.resolveSystemInsertOrganization(...a),`. Pins: memory + sqlite in packages/runtime (it already depends on objectql, driver-memory, driver-sql and has installDefaultOrganization), system-door delete of a tenancy-disabled record, assert delete true, entry organization_id = org_default, restore brings the row back.",
"options": [
"A: raise engine.ts maxLines 6857 -> 6858 by ruling for this one host member and widen the claim surface to that line; cost: one line, ~40-line capture diff + two pins + patch changeset, about half a day including gates.",
"B: have the facet-split card that owns engine.ts free one line first (or move the openRecycleBinCapture host literal into a FacetHost like the other facets, which shrinks engine.ts), then this card lands as in A without a raise; cost: depends on that card, this card waits.",
"C: resolve the organization in capture.ts without the engine (call @objectstack/core resolveSystemWriteOrganization with a posture read from the deployment env and a raw sys_organization probe through the bin's driver); cost: small, but it is a second spelling of the D9 decision that misses the engine's injected tenancy-posture accessor and its memoised probe, so it can disagree with the engine's own system insert. Not recommended."
],
"recommendation": "A, because the member is a pure delegation line of the kind the facade registry exists to count, the decision it delegates to is the one ADR-0131 D9 names for every writer, and C would fork that decision (AGENTS.md Prime Directive 12 / ADR-0138 D4 'never a second spelling')."
},
{
"question": "Confirm the walled-posture consequence of the D9 reading: under isolated or group, a system-door delete (no tenantId on the context) of a tenancy: { enabled: false } record would be refused with ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED (500) rather than land in the bin, since D9 says nothing defaults to an owner other than the derivable one. The REST door carries the session's organization and is unaffected; under single (the posture os verify measured) the entry lands under the Default Organization.",
"options": [
"A: accept it as D9 states (loud refusal under a wall; the caller threads tenantId).",
"B: rule a deployment-level sibling of sys_recycle_bin with no organization column for entries about tenant-less objects (the shape ADR-0131 D7 gives identity mail and sys_setting's global rung); needs a ruling and an ADR-0148 note."
],
"recommendation": "A for this card, because it is what the governing text already says and it never writes NULL nor drops an entry; B only if a walled-posture caller shows real pull."
}
],
"security_findings": "none",
"out_of_scope_findings": [
"class: b · reach: named producer MongoDBDriver.create, whose own docblock (packages/drivers/driver-mongodb/src/mongodb-driver.ts:178-184, mongodb-tenancy-guard.ts:6-8) says it never reads DriverOptions.tenantId and writes are not stamped with a tenant column, so a tenant-column row it writes carries no organization_id against ADR-0131 D1; NOT MEASURED live (no mongod in this container) · evidence: code read on 8145424b53; the D9 capture fix above also covers such a row's system-door delete under single (derived organization) · dedupe words: mongodb organization_id stamp, injectTenantOnInsert mongodb, tenant column unstamped",
"carrier: #35667 · the memory-store half (bin entry written with organization_id null, measured above) is the same defect and the same fix; noted, not filed"
]
}
L1 on the os-dev report 7062012198 · 2026-11-21T11:38Z · waiting on an engine.ts ceiling ruling
Reading: ACCEPT of the measurement. blocked stands. The premise holds on main8145424:
On sqlite, a system-door delete of a tenancy: { enabled: false } record throws NOT NULL constraint failed: sys_recycle_bin.organization_id, and the record stays.
On memory, the same delete writes a bin entry with organization_id null.
The door's context is { isSystem: true }, with no tenantId.
Which organization the entry carries is already decided. It is not a product question: ADR-0131 D9's system-write resolver (resolveSystemInsertOrganization, engine.ts:2040) applies to every writer on a tenant-column object. The bin entry is such a write (ADR-0148 D1), and it skips the resolver. Under single the entry takes the derived Default Organization; under a wall it is refused loudly with ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED. NULL is never written, and an entry is never dropped.
Blocker. The capture's host is the literal in engine.tsopenRecycleBinCapture (engine.ts:4971-4979, re-read on main), so the resolver reaches the capture only through one more delegation line there. engine.ts is at its facade ceiling, 6857 of 6857. The dev stopped, as the claim requires. It committed nothing, and the branch claude/issue-35667-recycle-bin-orgless-delete sits at main.
Routed to the seat for a ruled raise of 6857 → 6858, the report's option A: one pure delegation line, plus about 40 lines in capture.ts and pins on memory and sqlite. The second open question, the walled-posture refusal, goes with it. Until then the claim 7061800429 stands, and the card is waiting on seat 7.
Out of scope, from the report: MongoDBDriver.create does not stamp the tenant column (code read only; no mongod here). The seat decides whether to file it.
One-sentence problem. A delete that a flow, a hook or an admin tool makes of a record belonging to no organization fails with a database error and the record stays; the fix is settled, and the open point is whether its one line of wiring may be added to the engine's size-capped core file.
Background
The card comes from an os verify --delete-behaviors run that reported 6 system-door faults on a fixture whose objects carry no organization. The dev reproduced it on main8145424 (report 7062012198) and L1 accepted the measurement (7062039355):
On sqlite, a system-door delete of a tenancy: { enabled: false } record throws NOT NULL constraint failed: sys_recycle_bin.organization_id, and the row stays.
On the memory store the delete answers true and the bin entry is written with a null organization.
Which organization the entry carries is not in question. ADR-0131 D9 decides it for every writer: derived under single, refused otherwise. The recycle-bin capture writes its entry raw through the bin's driver, so it never reaches the resolver that the engine's insert calls. The seat has already accepted the walled-posture consequence as D9 states it (a loud refusal with ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED); it is context here, not part of the question.
The blocker is where the wiring goes. The capture reads the engine through a host object that engine.ts builds (openRecycleBinCapture, packages/objectql/src/engine.ts:4959-4981). The dev's fix adds one delegation line to that literal, and engine.ts is at its ceiling: 6857 lines against maxLines 6857.
Governing text
Ruling 6897467376 on [Decision] next codemod splits for the large hot files, in order, and whether to name a shrink-only line ceiling (hot-file card F) #33949, item 2 (read with gh api repos/objectstack-ai/objectstack/issues/comments/6897467376 --jq .body): 「Line ceiling: yes, narrow form only. It applies only to files already split, at their post-split line count plus a small margin. Going over is an error that tells the author to put new code in a new module. Raising a ceiling needs the maintainer's ruling. Files not yet split get no ceiling, at most a warning.」
The gate that carries it, scripts/check-facade-delegation-only.mjs:266-270 (found with grep -n "MAINTAINER-ONLY\|new module" scripts/check-facade-delegation-only.mjs): 「a file in facade form does not grow: put the new code in a new module (a facet file beside the facade, or a module of its own) and import it from there, instead of adding lines here. Raising a ceiling is ⛔ MAINTAINER-ONLY」. Its header (:146-169) says why the ceiling exists, 「Delegation-only keeps logic out of the facade class, but it does not stop the FILE growing: each new member is a stub plus its docblock」, and that 「a raise re-measures baseLines under a new ruling」.
ADR-0131 D9, docs/adr/0131-total-organization-ownership-no-null-organization-id.md:742-749 (found with grep -n "D9 — A missing stamp" docs/adr/0131-*.md): 「resolveSystemInsertOrganization generalizes ADR-0123 D3 to every writer: a write on a tenant-column object with no organization is derived under single (the Default Organization is the only one) and refused otherwise, with a message naming what is missing (ADR-0123 D4). ⛔ Nothing defaults to any owner other than the derivable one.」
ADR-0148 D1, docs/adr/0148-recycle-bin-separate-store-restore-under-original-ids-retention-in-days.md:169: 「The entry is a row of a system object, so it is organization-owned like every other row (ADR-0131)」.
ADR-0138 D4 item 2, docs/adr/0138-guest-model-anonymous-principal-doors-grants-and-organization.md:510-513 (found with grep -rn "second spelling" docs/adr packages/objectql/src/engine.ts): 「This is the predicate ADR-0131 D9 already uses for a write's organization … and the guest entry asks the same one, never a second spelling of it.」 The engine says the same of its own answer at packages/objectql/src/engine.ts:3095-3096.
AGENTS.md has no line on the facade ceiling or on a second spelling (grep -n -i "facade\|second spelling" AGENTS.md returns nothing). The ceiling is governed by the ruling and its gate, and the one-spelling rule by ADR-0138 D4 and the engine docblock.
Protocol statement
No option changes the protocol. The sys_recycle_bin schema, the delete contract and the engine's public contract stay as they are, and the capture's host is an internal interface. The fix ships as a patch. Option A changes one governance row (scripts/facade-delegation-registry.json), which by the ruling only the maintainer may raise.
Premises, each with a re-check
Run from the objectstack checkout.
P1. engine.ts is at its ceiling. Re-check: git show 8145424b53:packages/objectql/src/engine.ts | wc -l; node -e "const r=require('./scripts/facade-delegation-registry.json');console.log(JSON.stringify(r.ceilings.find(c=>c.file.endsWith('objectql/src/engine.ts'))))". Reading: 6857 lines; row {baseLines 6853, baseCommit 170ca481f0, maxLines 6857, ruling 7051956587}.
P2. The capture sets the entry's organization only from the record or the context. Re-check: sed -n 332,338p packages/objectql/src/recycle-bin/capture.ts; sed -n 268,272p packages/objectql/src/recycle-bin/capture.ts. Reading: holds; with neither, the row is written with no organization through driver.create.
P3. The capture's host is a per-call literal in engine.ts with seven members. Re-check: sed -n 4959,4981p packages/objectql/src/engine.ts. Reading: holds; the literal and its five read closures take lines 4966 to 4979, which is 14 lines.
P4. The D9 resolver is one body, reached by the engine through the middleware facet's host. Re-check: sed -n 2040,2047p packages/objectql/src/engine.ts; grep -n "static async resolveSystemInsertOrganization" packages/objectql/src/engine-middleware-and-context.ts. Reading: holds; the body needs _registry, probeInstallOrganizations and resolveEnginePosture, and that host carries all three (sed -n 6022,6040p packages/objectql/src/engine.ts).
P5. The delete module already holds the engine and already reads a sibling facet's host through it. Re-check: grep -n "Host.of(this.facade)" packages/objectql/src/engine-delete-and-aggregate.ts packages/objectql/src/engine-update.ts; grep -n "securityResolversHost.of(engine)" packages/objectql/src/fixed-read-leaf-seam.ts. Reading: holds at engine-delete-and-aggregate.ts:258, engine-update.ts:532 and fixed-read-leaf-seam.ts:157, all landed by PR feat(objectql, core, spec): the engine seam for the fixed-read leaf and its driver declaration (ADR-0155, step 2 of 6) #35839.
P6. The delete module is where the entry is written. Re-check: sed -n 686,689p packages/objectql/src/engine-delete-and-aggregate.ts. Reading: holds; bin?.write() is awaited before the root row is removed, so a refusal thrown there refuses the delete.
P7. Neither the delete module nor the capture module carries a ceiling. Re-check: node -e "console.log(require('./scripts/facade-delegation-registry.json').ceilings.map(c=>c.file).join('\n'))". Reading: four files carry one (protocol.ts, engine.ts, sql-driver.ts, registry.ts).
P9. The fault itself (sqlite throws, memory stores null). Source: the dev's scratch test, deleted after the run (report 7062012198). Reading: not re-run here. This checkout has no installed dependencies or build, so no test and not even the facade gate can run.
Does the fix land with a ruled raise of the engine.ts ceiling from 6857 to 6858, or by a route that adds no line to engine.ts, and if the latter, which route?
Options
Option
What it does
What the customer sees
Effort
A Raise the ceiling by one line
By ruling, maxLines goes 6857 → 6858. The registry row becomes baseLines 6857, baseCommit 8145424b53, maxLines 6858, ruling = this ruling's record id (measured on 8145424; the dev re-measures on the PR's base). The fix is one delegation line in the capture's host literal, about 40 lines in the capture module, pins on memory and sqlite, and a patch changeset
The delete works: under single the record lands in the bin under the Default Organization and can be restored; under a wall it is refused with a named reason and no longer with a constraint error. It lands about half a day after the ruling
B No raise: hand the capture the engine's own resolver from the delete module
The delete module, which already holds the engine, passes the capture a call to the one D9 resolver body through the middleware facet's host, the route PR #35839 landed for another seam. engine.ts gains no line and the registry is not touched. The capture's change is the same 40 lines, taking the resolver as an argument of its write step where A takes it as a host member
The same as A, in the same half day. No ruling record is added to the registry
domain:server · 1 PR · route precedent PR #35839 (the delete module +10 −4 inside a +1411 −44, 32-file PR, so its total is not a size precedent); size precedent PR #31702 as above
C No raise: shrink first
Turn the capture's per-call host literal into a per-engine facet host like the 17 the codemod wrote. Measured by counting: the stub loses 14 lines, the class's static block gains 9, the new member adds 1, so engine.ts goes 6857 → 6853. Or wait for a split card, of which none is open for engine.ts
The same as A, later: one more refactor PR on a hot file that an open PR (#34817) also touches
domain:server · 2 PRs (refactor, then fix) · PR #30083 did this for the codemod facets in one pass (+873 −1160, 19 files; engine.ts 14,140 → 13,548); no precedent for converting one literal by hand
Rejected, each a second spelling or a way round the ruling:
Resolving the organization inside the capture without the engine (the dev's option C: posture from the environment and a raw probe of the organization table). It forks D9: it misses the engine's injected posture accessor and its memoised probe, so it can disagree with the engine's own system insert.
Calling the engine's public decision answer and rebuilding the refusal in the capture. That answer 「refuses nothing itself」 by its own docblock, so the capture would become a second place that turns a decision into the D9 refusal.
Joining two existing lines of engine.ts to make room. It meets the count and defeats what the ceiling is for.
Effort spread: A and B are the same size; C is about twice. The effort rule (a 3× gap with close ① readings) does not apply.
What each option means in business terms
A: ask the owner for one more seat in a room the owner capped, for a guest who could sit next door.
B: put the new wiring in the next room, where the cap says new things go, and use the corridor that was built for this.
C: clear some space in the capped room first, then bring the guest in.
Four axes, from the business standpoint
① Long-term soundness. The ceiling is the maintainer's own rule, and its text gives the remedy: new code goes in a new module. B follows it with no exception and uses the single D9 decision. A is an exception. The earlier raise had no alternative, because a member of a public interface has to sit on the class. This fix has one, already landed in the same module. A also repeats: the file is exactly full, so every later wiring need returns to the maintainer one line at a time, and an open PR is already 23 lines over. C goes in the right direction, but it is a refactor of a hot file with no card behind it and should not hold up a p2 defect. The counting also shows a larger shrink is there for a card of its own: 83 per-call host literals in engine.ts carry 107 read-closure lines. No option slows SQL for memory or Mongo parity.
② Real pull. The defect is real and measured: 6 system-door faults in the verify run, reproduced on sqlite. It reaches flows, hooks and admin tooling that delete a record of an object with tenancy turned off. In the example apps two objects declare that (both in the showcase), none in HotCRM. The card also names rows the mongodb driver wrote, which was read in code and not measured live. All three options fix it; A and B at the same speed, C later.
③ Keeping AI from getting it wrong. For an AI-authored app the outcome is the same under A, B and C: a flow that deletes such a record gets a success under single or a loud, named refusal under a wall, where today it gets a raw constraint error on SQL and a silent ownerless entry on memory. The rejected routes are the ones that could leak silently, by answering differently from the engine. For the AI developers who work in this repository the options differ: the gate tells them to put new code in a new module, and B does what the gate says, while A teaches them to ask for a line. No new gate is proposed.
④ Startup focus. B adds nothing to maintain: no registry change and no ruling record. A adds a ruling to carry in the registry and sets a pattern of raises. C adds a refactor with no pull beyond the ceiling itself.
Recommendation and confidence gaps
Recommend B.
Not A: the ceiling's stated remedy is a new module and this fix can follow it, so a raise would spend the maintainer's exception on something that needs none.
Not C: it is the right direction with no card and no urgency, and it delays a p2 defect behind a refactor of a hot file.
Confidence gaps, stated and not used to change the recommendation:
B is read from the code and not built. This checkout has no installed dependencies, so I could not type-check the cross-facet call, run the facade gate or run the pins.
B makes the capture take one engine decision as an argument where its other seven arrive on its host. The host interface is documented as 「the engine members the capture reads」, so the capture's docblock has to say why this one is handed in.
The fault's reproduction is the dev's; I did not re-run it.
End state. In two years a record deleted through any door, with or without an organization, either sits in the recycle bin under an owner the platform can derive or is refused with a named reason, as deleted rows stay scoped to their organization in Salesforce's Recycle Bin and Dataverse's recycle bin; and the engine's core file stays a thin, capped facade, with new wiring living in the modules beside it.
Self-check. 「只看①选 B;②③④ 是否翻转:否」
After the ruling
If B:
Lane and size: domain:server, seat 7 area d7-B, one PR, the same claim. The seat amends the claim's file surface to add packages/objectql/src/engine-delete-and-aggregate.ts (the write call) and, if the dev exposes the resolver as a small function beside its body, packages/objectql/src/engine-middleware-and-context.ts. ⛔ engine.ts and the registry stay untouched.
The ruling should carry these premises, which the dev verifies before building:
The delete module can call the D9 resolver body through the middleware facet's host of this.facade, and it type-checks.
pnpm check:facade-delegation-only stays green, and wc -l packages/objectql/src/engine.ts still reads 6857.
With the resolver handed in, the dev's four readings move as expected: sqlite and memory store the Default Organization on the entry under single, and a restore brings the row back.
⛔ If 1 or 2 does not hold, the dev reports a fork and builds nothing. It does not add the line to engine.ts.
To settle it in one ruling, the maintainer may add the fallback in the same words: if premise 1 or 2 fails, raise to 6858 with the row given under A. Without that sentence a failed premise brings the card back.
Pins: memory and sqlite, in packages/runtime as the dev proposed. A system-door delete of a tenancy-disabled record answers true, the entry's organization is the Default Organization, and restore brings the row back. A walled posture answers ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED and the row stays. A record that carries its own organization and a context that carries one are stamped as before (controls).
Changeset: patch, Clause-②: no, Metadata-protocol: none.
If A instead: the same pins and changeset, plus the registry row { "file": "packages/objectql/src/engine.ts", "baseLines": 6857, "baseCommit": "8145424b53", "maxLines": 6858, "ruling": "<this ruling's record id>" }, re-measured on the PR's base, and the claim's surface widened to that one line.
Out of scope, from the dev's report: the mongodb driver does not stamp the tenant column (code read only). The seat decides whether to file it.
os-decision-facets
① 项目长远合理性: B follows the ceiling ruling's own remedy (new code in a new module) with no exception and keeps the one D9 decision; A is an exception that repeats one line at a time on a file that is exactly full; C is right in direction but has no card. No option slows SQL for memory or Mongo parity.
② 实际业务拉动: 6 system-door delete faults in the verify run, reproduced on sqlite; flows, hooks and admin tooling deleting records of tenancy-disabled objects (2 such objects in the example apps, none in HotCRM). All options fix it; A and B at the same speed.
③ 防 AI 犯错: after the fix an app gets success or a loud named refusal where today it gets a raw constraint error or a silent ownerless entry; the rejected routes are the ones that could disagree silently with the engine. B does what the gate's own message tells authors to do. No new gate proposed.
④ 创业阶段不扩散: B adds no registry change and no ruling record to carry; A adds one and sets a pattern of raises; C adds a refactor with no pull beyond the ceiling.
Prior rulings read: recycle-bin,sys_recycle_bin,resolveSystemInsertOrganization,ceiling,facade → 22 hits; ADR-0131 D9, ADR-0148 D1; thread: none
packages/objectql/src/recycle-bin/capture.ts. When neither the record nor the context names an organization, the entry takes the resolver's answer. A refusal throws before the root row is removed, so the delete is refused loudly.
Pins on memory and sqlite (packages/runtime composes both), and one patch changeset.
⛔ packages/objectql/src/engine.ts gains no line, and scripts/facade-delegation-registry.json is not touched. The dev builds only when both of these hold:
the delete module reaches the resolver through the middleware facet's host and type-checks;
check:facade-delegation-only stays green, with wc -l packages/objectql/src/engine.ts still 6857.
If either fails, the dev reports a fork with the evidence and builds nothing, and only then does the 6857 → 6858 raise go to the maintainer. Under a walled posture, ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED is D9 as written, which the seat accepted. Effort stays high; the same dev resumes with its own measurements.
Ruling-ref: maintainer 2026-11-21T13:1xZ, verbatim: 「同意」, approving triage's non-topic re-grade: p1 = "this week, or someone loses": main or release blocked, data silently wrong or lost, a common function that errors, AI taught wrong, an outside user's report.
2026-11-21T13:14Z · p2 → p1 on the maintainer's word: a common function that errors: a system-door delete faults on the recycle-bin NOT NULL. Lane and state unchanged.
{
"issue": 35667,
"status": "done",
"branch": "claude/issue-35667-recycle-bin-orgless-delete",
"pr": "https://github.com/objectstack-ai/objectstack/pull/36097",
"session": "session_01L9qibwJEh7hMPPvagWM1g7",
"premise_still_valid": true,
"summary": "I built route B as the seat ruled (claim amendment 7062354282). The delete module (engine-delete-and-aggregate.ts) hands the capture's write() a call to MiddlewareAndContextFacet.resolveSystemInsertOrganization through middlewareAndContextHost.of(this.facade). That is the same ADR-0131 D9 body the engine's insert uses. In capture.ts, write() stamps the entry with the record's organization, else the context's, else the resolver's answer. Under single that is the Default Organization; under a wall the delete is refused with ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED before the root row is removed. engine.ts still has 6857 lines and the facade registry is untouched. Deviation: the memory-store pin is not on @objectstack/driver-memory. A new test consumer of that driver turned check:driver-memory-census red ('Rule it, migrate it, or file it'), so that leg is a describe in objectql's capture harness, which keeps rows the way driver-memory does with no NOT NULL. The sqlite leg is in packages/runtime. Fixture triage: the capture harness registered sys_organization but held no organization, the broken boot invariant that D9 refuses. That turned 10 existing capture tests red, so the harness now seeds the Default Organization; the organization-delete cascade test opts out, because every delete in it names its organization.",
"tests": "All on head 4bd70f0a1c. Gate before building: `pnpm check:facade-delegation-only` exit 0, printing 'packages/objectql/src/engine.ts: 6857 lines, ceiling 6857'; `wc -l` reads 6857; `pnpm --filter @objectstack/objectql typecheck` exit 0 (lock VERDICT command-exit 0). Pins: runtime/src/recycle-bin-orgless-system-delete.test.ts on sqlite, Tests 3 passed (3). The new describe in objectql capture.test.ts: capture harness Tests 30 passed (30); src/recycle-bin/ Test Files 5 passed, Tests 178 passed. Ablation: scripts/ablation-replace.mjs replaced the resolver call with `const derived: string | undefined = undefined;` (anchor 1 to 0, blob d124655c5f01 to 79309b11f005). After an objectql rebuild, `ablation-dist-preflight --absent` reported the marker absent from 14 built files. With the mutation, the runtime pin had 2 failed and 1 passed (the context control), and the capture harness had 2 failed and 28 passed. Restore: `git checkout HEAD --`, `git diff HEAD` 0 bytes, hash matched d124655c5f01, rebuild, preflight found the marker present in 2 files, tree clean. After the restore: 3 passed and 30 passed. `pnpm --filter @objectstack/objectql test`: Test Files 624 passed (624), Tests 14217 passed (14217). `pnpm --filter @objectstack/objectql typecheck`: exit 0 (lock VERDICT command-exit 0). Consumer suites that compose the bin and delete without a booted auth, all lock VERDICT command-exit 0: mcp stdio-data-bridge.recycle-bin 5 passed, cloud-connection connection-credential-ledger 11 passed, metadata-protocol seed-tenancy-backfill 58 passed, runtime sandbox/body-runner 42 passed. Left to CI: `pnpm --filter @objectstack/runtime typecheck` (it needs the runtime dependency closure built) and `test:repo`.",
"gates": "Local: `node scripts/pm/dispatch-gates.mjs --commands` derived 66 families on 4bd70f0a1c, and all 66 exited 0 (exit codes captured per command, before any pipe). `--ran` reconciliation exited 0: 66 derived, 66 run, 0 NOT-MEASURED, 0 UNRUN. On the earlier head e95ae7d746, check:driver-memory-census was red (exit 1) and check:dual-build-cjs-loads exited 3 (PREREQUISITE NOT MET); both are green on 4bd70f0a1c, and dual-build measured 124 entry points across 72 packages. overlap-check returned VERDICT clean exit 0 before each of the three pushes (origin/main and #36060 merge cleanly). CI on PR #36097 at head 4bd70f0a1c was in_progress when this report was written: Check Changeset, Governed Surface Queue Guard, Lint (CI release & engine gates, ESLint, docs & code guards, the scoped lanes, PM dispatch-gates and repo & tooling gates queued), Type Check (workspace, consumer gates, source gates, debt ledger) and PR-body guards; there are no conclusions yet.",
"dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
"mcp_calls": "0",
"api_writes": "3 — POST /repos/objectstack-ai/objectstack/issues/35667/comments (first os-dev-report, comment 7062012198, via post-stamped); pr_create through scripts/pm/fleet-write/dispatch.mjs (relay run 44908574326: POST /repos/objectstack-ai/objectstack/pulls, then POST /repos/objectstack-ai/objectstack/issues/36097/assignees with os-tesla; read back 8914 of 8914 bytes identical); POST /repos/objectstack-ai/objectstack/issues/35667/comments (this os-dev-report, via post-stamped). Also git pushes of the branch, which are not REST writes.",
"open_questions": [],
"security_findings": "none",
"out_of_scope_findings": [
"carrier: none · MongoDBDriver does not stamp the tenant column on insert, by its own docblock (packages/drivers/driver-mongodb/src/mongodb-driver.ts, the single-tenant note). This is a code read only and no test reproduced it, so on the seat's word it is noted in the PR's Acceptance notes and not filed. The capture change covers the system-door delete of such a row under single."
]
}
Close-out · 2026-11-21T14:20Z · #35667 done by PR #36097
PR #36097 merged through the queue at 2026-11-21T14:18Z as 7dd1a2f613c476aae4ef78755d21c0c546a02b6f. The merge group's Dogfood Regression Gate passed.
What landed. A recycle-bin entry now takes its organization from the record, else from the context, else from the ADR-0131 D9 system-write resolver: MiddlewareAndContextFacet.resolveSystemInsertOrganization, the same body the engine's insert uses, which the delete module reaches through the middleware facet's host. The effect on a delete whose record and context name no organization (the system door, typically):
Under single, it lands in the bin under the Default Organization and restores.
Under a wall, it is refused with ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED (500) before the root row is removed.
NULL is never written, and no entry is dropped. engine.ts stays at 6857 lines (route B, no ceiling raise).
Review trail
Claim 7061800429. First report 7062012198 (blocked on the ceiling). Wait record 7062039355.
The seat took route B from dc-7a's analysis 7062338699; claim amendment 7062354282.
os-dev report 7063245386.
L1 ACCEPT 7063276615. No L2 was owed.
O1 was answered by a Clause-② basis: line in the PR body: a bug fix, not a narrowing.
Landing 7063635220.
Carries
Nits N1 and N2 on the changeset wording: the branch applies to any context with no organization, and permanent: true is the other route under a wall.
The memory-store pin lives in objectql's capture harness, because check:driver-memory-census refuses a new driver-memory test consumer.
Not filed, per the seat: MongoDBDriver.create does not stamp the tenant column. That is a code read only, and no test reproduced it.
pm:dispatched removed. The card was closed by the merge.
Activity
objectstack-fleet commentedon Nov 19, 2026
triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH
Triage: lands in
domain:server·pm:queue; rationale: area:data · Bug · Broken (a system-door delete of a record with noorganization_idfaults onsys_recycle_bin.organization_id NOT NULLinstead of moving the record to the recycle bin) · flows, hooks and admin tooling deleting org-less records, on more than one driver · measured withos verify --delete-behaviors→ p2 as the seat's review suggests.area:build→area:data: the fault is in the delete path.objectstack-fleet commentedon Nov 21, 2026
repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7
Claim: PM loop · 2026-11-21T11:17Z
Session:
session_01L9qibwJEh7hMPPvagWM1g7Account:
os-teslaBranch:
claude/issue-35667-recycle-bin-orgless-deleteWorktree:
objectstack-issue-35667Domain:
domain:serverSeat:
repo:objectstack#7Area: d7-B (objectql write path)
File surface:
packages/objectql/src/recycle-bin/**: the entry's organization,capture.tsorganizationOfandwrite().patchchangeset.packages/objectql/src/engine.tsmust not grow: it is at its facade ceiling, 6857 of 6857.Stop on any breach and explain it in the report.
Container & model:
M,mode:subagent,model: default,effort: highClause-②: no
Metadata-protocol: none
Responsibility:
objectstack platform: objectql's recycle-bin capture writes the entry's organization_id from the record or the context, and sys_recycle_bin's tenant column is NOT NULL (ADR-0131 D1) | none | flows, hooks and admin tooling deleting through the system door a record that has no organization_id, measured by os verify --delete-behaviors on memory and mongodThread-read: 7023873162
Premise: holds on
main8145424.capture.tssetsrow.organization_idonly when the record's tenant field orcontext.tenantIdis a non-empty string, so an org-less record with an org-less system context writes the entry with no organization into a NOT NULL column (ADR-0131 D1). The dev re-measures first.Serial constraints cleared: no open PR touches
packages/objectql/src/recycle-bin/**(open-PR file read at 2026-11-21T11:16Z). fix(audit): a search the server widens never names a column the caller may not query #34817 touchesengine.ts, which this card must not grow. overlap-check runs before each push.Pre-claim lane: seat 7 order (2026-11-21T11:13Z), Tesla's word to work the data cards (2026-11-21 11:10Z).
area:data,domain:server; no governed path. L2 tier is decided on the diff.Pre-claim deps: none.
Prior rulings read: ADR-0148 D1: an entry is a row of a system object, so it is organization-owned (ADR-0131). ADR-0131 D1: NULL is not a state for
organization_id; §1.6: a legitimately org-less row belongs to an object with no organization column. No ruling comment on the card thread (check-prior-rulings, 0 of 1). ⛔ If neither the context's organization nor an existing stated rule settles which organization an org-less record's entry carries, the dev reportsneeds_decisionwith the options and does not choose.objectstack-fleet commentedon Nov 21, 2026
repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7
os-dev-report
{ "issue": 35667, "status": "blocked", "branch": "claude/issue-35667-recycle-bin-orgless-delete", "pr": null, "session": "session_01L9qibwJEh7hMPPvagWM1g7", "premise_still_valid": true, "summary": "Premise reproduced on main 8145424b53 (scratch test, not committed): a system-door delete (context { isSystem: true }, no tenantId; a beforeDelete hook saw session { isSystem: true } and no tenantId) of a tenancy: { enabled: false } record throws SQLITE_CONSTRAINT_NOTNULL 'NOT NULL constraint failed: sys_recycle_bin.organization_id' on SqlDriver/better-sqlite3, and the row stays; on InMemoryDriver the delete answers true and the bin entry is written with organization_id null (the memory driver enforces no NOT NULL, ADR-0131 D1 note), a silent NULL-org row. The governing text settles the organization: ADR-0131 D9 (resolveSystemInsertOrganization 'generalizes ADR-0123 D3 to every writer: a write on a tenant-column object with no organization is derived under single and refused otherwise'); the bin entry is a raw write on a tenant-column object (ADR-0148 D1: organization-owned) that bypasses that resolver, so the fix is: record's organization, else context's, else the engine's own resolveSystemInsertOrganization(sys_recycle_bin, context, [row]) (derived Default Organization under single, ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED under a wall, unstamped only in the no-organization-object lean embedding per the D9 note). BLOCKED: the capture's host (RecycleBinCaptureHost) is an object literal built in engine.ts openRecycleBinCapture (engine.ts:4971-4979), and every route to the engine's resolver (that literal, or the deleteAndAggregateHost factory at engine.ts:5858) needs one more line in engine.ts, which is at its ceiling (wc -l 6857 = maxLines 6857, scripts/facade-delegation-registry.json, ruling 7051956587) and off this claim's file surface. Nothing committed; the branch carries no commit beyond main.", "tests": "Measurement only, scratch file packages/runtime/src/zz-measure-35667.test.ts (deleted after, tree clean: git status --porcelain empty) on HEAD 8145424b53, after `pnpm --workspace-concurrency=2 --filter '@objectstack/objectql...' --filter '@objectstack/driver-sql...' --filter '@objectstack/driver-memory...' build` (lock VERDICT command-exit 0). Run: `pnpm --filter @objectstack/runtime exec vitest run --project local --maxWorkers=2 src/zz-measure-35667.test.ts` (lock VERDICT command-exit 1, Tests 1 failed | 3 passed; the failure is the memory tenant-column control, see below). Readings: [sqlite GLOBAL] storedOrg (absent), hookSaw [{isSystem:true}], outcome threw SQLITE_CONSTRAINT_NOTNULL 'NOT NULL constraint failed: sys_recycle_bin.organization_id', bin []. [memory GLOBAL] storedOrg (absent), outcome true, bin [{object_name: mz_global, organization_id: null}]. [sqlite SCOPED control] system insert stamped org_default (D9 derived), delete true, bin entry organization_id org_default. [memory SCOPED] the system insert itself is refused by the memory driver's tenancy guard (MemoryMultiTenantUnsupportedError, engine handed tenantId org_default), so a memory store cannot hold an engine-written tenant-column row in this composition. No fix built, so no pin, no ablation.", "gates": "NOT MEASURED: every gate family, reason: no diff (no commit beyond main 8145424b53), so dispatch-gates --commands has an empty change set and there is no PR whose check-runs could be cited. overlap-check not run: nothing pushed beyond the empty branch-creation probe.", "dogfood_battery": "n/a — no PR, no `!` in a title and no (narrowing) arm", "mcp_calls": "0", "api_writes": "1 — POST /repos/objectstack-ai/objectstack/issues/35667/comments (os-dev-report, via scripts/pm/post-stamped.mjs); plus git push of the empty branch claude/issue-35667-recycle-bin-orgless-delete (routing probe, not a REST write)", "open_questions": [ { "question": "How does the D9 resolution reach the bin writer, given engine.ts is at 6857 of 6857 and off this claim's surface? The fix itself is three parts: (1) capture.ts RecycleBinCaptureHost gains `resolveSystemInsertOrganization(object, execCtx, rows)` returning a Promise of the organization id or undefined; (2) RecycleBinCapture.write(), when organizationOf() answers undefined, calls `this.host.resolveSystemInsertOrganization(RECYCLE_BIN_OBJECT, this.context, [row])` and stamps row.organization_id with the answer (a refusal throws before the root row is removed, so the delete is refused loudly with the D9 code instead of the constraint); (3) engine.ts openRecycleBinCapture's host literal gains ONE line after line 4978: `resolveSystemInsertOrganization: (...a) => this.resolveSystemInsertOrganization(...a),`. Pins: memory + sqlite in packages/runtime (it already depends on objectql, driver-memory, driver-sql and has installDefaultOrganization), system-door delete of a tenancy-disabled record, assert delete true, entry organization_id = org_default, restore brings the row back.", "options": [ "A: raise engine.ts maxLines 6857 -> 6858 by ruling for this one host member and widen the claim surface to that line; cost: one line, ~40-line capture diff + two pins + patch changeset, about half a day including gates.", "B: have the facet-split card that owns engine.ts free one line first (or move the openRecycleBinCapture host literal into a FacetHost like the other facets, which shrinks engine.ts), then this card lands as in A without a raise; cost: depends on that card, this card waits.", "C: resolve the organization in capture.ts without the engine (call @objectstack/core resolveSystemWriteOrganization with a posture read from the deployment env and a raw sys_organization probe through the bin's driver); cost: small, but it is a second spelling of the D9 decision that misses the engine's injected tenancy-posture accessor and its memoised probe, so it can disagree with the engine's own system insert. Not recommended." ], "recommendation": "A, because the member is a pure delegation line of the kind the facade registry exists to count, the decision it delegates to is the one ADR-0131 D9 names for every writer, and C would fork that decision (AGENTS.md Prime Directive 12 / ADR-0138 D4 'never a second spelling')." }, { "question": "Confirm the walled-posture consequence of the D9 reading: under isolated or group, a system-door delete (no tenantId on the context) of a tenancy: { enabled: false } record would be refused with ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED (500) rather than land in the bin, since D9 says nothing defaults to an owner other than the derivable one. The REST door carries the session's organization and is unaffected; under single (the posture os verify measured) the entry lands under the Default Organization.", "options": [ "A: accept it as D9 states (loud refusal under a wall; the caller threads tenantId).", "B: rule a deployment-level sibling of sys_recycle_bin with no organization column for entries about tenant-less objects (the shape ADR-0131 D7 gives identity mail and sys_setting's global rung); needs a ruling and an ADR-0148 note." ], "recommendation": "A for this card, because it is what the governing text already says and it never writes NULL nor drops an entry; B only if a walled-posture caller shows real pull." } ], "security_findings": "none", "out_of_scope_findings": [ "class: b · reach: named producer MongoDBDriver.create, whose own docblock (packages/drivers/driver-mongodb/src/mongodb-driver.ts:178-184, mongodb-tenancy-guard.ts:6-8) says it never reads DriverOptions.tenantId and writes are not stamped with a tenant column, so a tenant-column row it writes carries no organization_id against ADR-0131 D1; NOT MEASURED live (no mongod in this container) · evidence: code read on 8145424b53; the D9 capture fix above also covers such a row's system-door delete under single (derived organization) · dedupe words: mongodb organization_id stamp, injectTenantOnInsert mongodb, tenant column unstamped", "carrier: #35667 · the memory-store half (bin entry written with organization_id null, measured above) is the same defect and the same fix; noted, not filed" ] }objectstack-fleet commentedon Nov 21, 2026
repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7
L1 on the os-dev report 7062012198 · 2026-11-21T11:38Z · waiting on an engine.ts ceiling ruling
Reading: ACCEPT of the measurement.
blockedstands. The premise holds onmain8145424:tenancy: { enabled: false }record throwsNOT NULL constraint failed: sys_recycle_bin.organization_id, and the record stays.organization_idnull.{ isSystem: true }, with notenantId.Which organization the entry carries is already decided. It is not a product question: ADR-0131 D9's system-write resolver (
resolveSystemInsertOrganization,engine.ts:2040) applies to every writer on a tenant-column object. The bin entry is such a write (ADR-0148 D1), and it skips the resolver. Undersinglethe entry takes the derived Default Organization; under a wall it is refused loudly withERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED. NULL is never written, and an entry is never dropped.Blocker. The capture's host is the literal in
engine.tsopenRecycleBinCapture(engine.ts:4971-4979, re-read onmain), so the resolver reaches the capture only through one more delegation line there.engine.tsis at its facade ceiling, 6857 of 6857. The dev stopped, as the claim requires. It committed nothing, and the branchclaude/issue-35667-recycle-bin-orgless-deletesits atmain.Routed to the seat for a ruled raise of 6857 → 6858, the report's option A: one pure delegation line, plus about 40 lines in
capture.tsand pins on memory and sqlite. The second open question, the walled-posture refusal, goes with it. Until then the claim 7061800429 stands, and the card is waiting on seat 7.Out of scope, from the report:
MongoDBDriver.createdoes not stamp the tenant column (code read only; no mongod here). The seat decides whether to file it.objectstack-fleet commentedon Nov 21, 2026
repo:objectstack#7 · os-tesla · session_01L9qibzo28WC7HsvkY8hvV3
Decision analysis · 2026-11-21T12:06Z
维护者速读
Analysis (English)
One-sentence problem. A delete that a flow, a hook or an admin tool makes of a record belonging to no organization fails with a database error and the record stays; the fix is settled, and the open point is whether its one line of wiring may be added to the engine's size-capped core file.
Background
The card comes from an
os verify --delete-behaviorsrun that reported 6 system-door faults on a fixture whose objects carry no organization. The dev reproduced it onmain8145424 (report 7062012198) and L1 accepted the measurement (7062039355):tenancy: { enabled: false }record throwsNOT NULL constraint failed: sys_recycle_bin.organization_id, and the row stays.Which organization the entry carries is not in question. ADR-0131 D9 decides it for every writer: derived under
single, refused otherwise. The recycle-bin capture writes its entry raw through the bin's driver, so it never reaches the resolver that the engine's insert calls. The seat has already accepted the walled-posture consequence as D9 states it (a loud refusal withERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED); it is context here, not part of the question.The blocker is where the wiring goes. The capture reads the engine through a host object that
engine.tsbuilds (openRecycleBinCapture,packages/objectql/src/engine.ts:4959-4981). The dev's fix adds one delegation line to that literal, andengine.tsis at its ceiling: 6857 lines againstmaxLines6857.Governing text
gh api repos/objectstack-ai/objectstack/issues/comments/6897467376 --jq .body): 「Line ceiling: yes, narrow form only. It applies only to files already split, at their post-split line count plus a small margin. Going over is an error that tells the author to put new code in a new module. Raising a ceiling needs the maintainer's ruling. Files not yet split get no ceiling, at most a warning.」scripts/check-facade-delegation-only.mjs:266-270(found withgrep -n "MAINTAINER-ONLY\|new module" scripts/check-facade-delegation-only.mjs): 「a file in facade form does not grow: put the new code in a new module (a facet file beside the facade, or a module of its own) and import it from there, instead of adding lines here. Raising a ceiling is ⛔ MAINTAINER-ONLY」. Its header (:146-169) says why the ceiling exists, 「Delegation-only keeps logic out of the facade class, but it does not stop the FILE growing: each new member is a stub plus its docblock」, and that 「a raise re-measuresbaseLinesunder a new ruling」.engine.tsceiling raise, of about 3 to 5 lines.」 It was for a new optional member of the engine's public contract.docs/adr/0131-total-organization-ownership-no-null-organization-id.md:742-749(found withgrep -n "D9 — A missing stamp" docs/adr/0131-*.md): 「resolveSystemInsertOrganizationgeneralizes ADR-0123 D3 to every writer: a write on a tenant-column object with no organization is derived undersingle(the Default Organization is the only one) and refused otherwise, with a message naming what is missing (ADR-0123 D4). ⛔ Nothing defaults to any owner other than the derivable one.」docs/adr/0148-recycle-bin-separate-store-restore-under-original-ids-retention-in-days.md:169: 「The entry is a row of a system object, so it is organization-owned like every other row (ADR-0131)」.docs/adr/0138-guest-model-anonymous-principal-doors-grants-and-organization.md:510-513(found withgrep -rn "second spelling" docs/adr packages/objectql/src/engine.ts): 「This is the predicate ADR-0131 D9 already uses for a write's organization … and the guest entry asks the same one, never a second spelling of it.」 The engine says the same of its own answer atpackages/objectql/src/engine.ts:3095-3096.AGENTS.md has no line on the facade ceiling or on a second spelling (
grep -n -i "facade\|second spelling" AGENTS.mdreturns nothing). The ceiling is governed by the ruling and its gate, and the one-spelling rule by ADR-0138 D4 and the engine docblock.Protocol statement
No option changes the protocol. The
sys_recycle_binschema, the delete contract and the engine's public contract stay as they are, and the capture's host is an internal interface. The fix ships as apatch. Option A changes one governance row (scripts/facade-delegation-registry.json), which by the ruling only the maintainer may raise.Premises, each with a re-check
Run from the objectstack checkout.
engine.tsis at its ceiling. Re-check:git show 8145424b53:packages/objectql/src/engine.ts | wc -l; node -e "const r=require('./scripts/facade-delegation-registry.json');console.log(JSON.stringify(r.ceilings.find(c=>c.file.endsWith('objectql/src/engine.ts'))))". Reading: 6857 lines; row{baseLines 6853, baseCommit 170ca481f0, maxLines 6857, ruling 7051956587}.sed -n 332,338p packages/objectql/src/recycle-bin/capture.ts; sed -n 268,272p packages/objectql/src/recycle-bin/capture.ts. Reading: holds; with neither, the row is written with no organization throughdriver.create.engine.tswith seven members. Re-check:sed -n 4959,4981p packages/objectql/src/engine.ts. Reading: holds; the literal and its five read closures take lines 4966 to 4979, which is 14 lines.sed -n 2040,2047p packages/objectql/src/engine.ts; grep -n "static async resolveSystemInsertOrganization" packages/objectql/src/engine-middleware-and-context.ts. Reading: holds; the body needs_registry,probeInstallOrganizationsandresolveEnginePosture, and that host carries all three (sed -n 6022,6040p packages/objectql/src/engine.ts).grep -n "Host.of(this.facade)" packages/objectql/src/engine-delete-and-aggregate.ts packages/objectql/src/engine-update.ts; grep -n "securityResolversHost.of(engine)" packages/objectql/src/fixed-read-leaf-seam.ts. Reading: holds atengine-delete-and-aggregate.ts:258,engine-update.ts:532andfixed-read-leaf-seam.ts:157, all landed by PR feat(objectql, core, spec): the engine seam for the fixed-read leaf and its driver declaration (ADR-0155, step 2 of 6) #35839.sed -n 686,689p packages/objectql/src/engine-delete-and-aggregate.ts. Reading: holds;bin?.write()is awaited before the root row is removed, so a refusal thrown there refuses the delete.node -e "console.log(require('./scripts/facade-delegation-registry.json').ceilings.map(c=>c.file).join('\n'))". Reading: four files carry one (protocol.ts,engine.ts,sql-driver.ts,registry.ts).engine.ts. Re-check:gh api -X GET search/issues -f q='repo:objectstack-ai/objectstack is:issue is:open engine.ts facade' --jq '.items[]|"\(.number) \(.title)"'. Reading: 5 hits, namely [Decision] next codemod splits for the large hot files, in order, and whether to name a shrink-only line ceiling (hot-file card F) #33949 (the split order, which namesregistry.tsand seven other files next, notengine.ts), this card, seed: a seed row that supplies a summary (roll-up) field value is stored as written, and nothing recomputes it until a child write #35655 and two seat cards. The engine's own split cards Codemod split: generate the objectql engine.ts split with a deterministic script, verified byte-identical #29986, refactor: compress the codemod facade stubs in engine.ts and protocol.ts — one shared host per facet instead of a per-call host literal (body-identical; about 1,000 lines off engine.ts) #30051 and refactor: facade ObjectRepository and ScopedContext in engine.ts with the same codemod (about 700 lines), as the ObjectQL class already is #30052 are closed.engine.ts. Re-check:gh api repos/objectstack-ai/objectstack/pulls/34817/files --paginate --jq '.[]|select(.filename|endswith("objectql/src/engine.ts"))|"+\(.additions) -\(.deletions)"'. Reading: PR fix(audit): a search the server widens never names a column the caller may not query #34817 is open withengine.ts+25 −2.The concrete question
Does the fix land with a ruled raise of the
engine.tsceiling from 6857 to 6858, or by a route that adds no line toengine.ts, and if the latter, which route?Options
maxLinesgoes 6857 → 6858. The registry row becomesbaseLines 6857,baseCommit 8145424b53,maxLines 6858,ruling= this ruling's record id (measured on 8145424; the dev re-measures on the PR's base). The fix is one delegation line in the capture's host literal, about 40 lines in the capture module, pins on memory and sqlite, and a patch changesetsinglethe record lands in the bin under the Default Organization and can be restored; under a wall it is refused with a named reason and no longer with a constraint error. It lands about half a day after the rulingdomain:server· 1 PR · raise precedent PR #35954 (+252 −14, 9 files;engine.ts+6 −3, registry +4 −4, under ruling 7051956587); capture-side size precedent PR #31702 (+128 −23, 4 files; capture +44 −17, capture test +64 −2)engine.tsgains no line and the registry is not touched. The capture's change is the same 40 lines, taking the resolver as an argument of its write step where A takes it as a host memberdomain:server· 1 PR · route precedent PR #35839 (the delete module +10 −4 inside a +1411 −44, 32-file PR, so its total is not a size precedent); size precedent PR #31702 as aboveengine.tsgoes 6857 → 6853. Or wait for a split card, of which none is open forengine.tsdomain:server· 2 PRs (refactor, then fix) · PR #30083 did this for the codemod facets in one pass (+873 −1160, 19 files;engine.ts14,140 → 13,548); no precedent for converting one literal by handRejected, each a second spelling or a way round the ruling:
engine.tsto make room. It meets the count and defeats what the ceiling is for.Effort spread: A and B are the same size; C is about twice. The effort rule (a 3× gap with close ① readings) does not apply.
What each option means in business terms
Four axes, from the business standpoint
① Long-term soundness. The ceiling is the maintainer's own rule, and its text gives the remedy: new code goes in a new module. B follows it with no exception and uses the single D9 decision. A is an exception. The earlier raise had no alternative, because a member of a public interface has to sit on the class. This fix has one, already landed in the same module. A also repeats: the file is exactly full, so every later wiring need returns to the maintainer one line at a time, and an open PR is already 23 lines over. C goes in the right direction, but it is a refactor of a hot file with no card behind it and should not hold up a p2 defect. The counting also shows a larger shrink is there for a card of its own: 83 per-call host literals in
engine.tscarry 107 read-closure lines. No option slows SQL for memory or Mongo parity.② Real pull. The defect is real and measured: 6 system-door faults in the verify run, reproduced on sqlite. It reaches flows, hooks and admin tooling that delete a record of an object with tenancy turned off. In the example apps two objects declare that (both in the showcase), none in HotCRM. The card also names rows the mongodb driver wrote, which was read in code and not measured live. All three options fix it; A and B at the same speed, C later.
③ Keeping AI from getting it wrong. For an AI-authored app the outcome is the same under A, B and C: a flow that deletes such a record gets a success under
singleor a loud, named refusal under a wall, where today it gets a raw constraint error on SQL and a silent ownerless entry on memory. The rejected routes are the ones that could leak silently, by answering differently from the engine. For the AI developers who work in this repository the options differ: the gate tells them to put new code in a new module, and B does what the gate says, while A teaches them to ask for a line. No new gate is proposed.④ Startup focus. B adds nothing to maintain: no registry change and no ruling record. A adds a ruling to carry in the registry and sets a pattern of raises. C adds a refactor with no pull beyond the ceiling itself.
Recommendation and confidence gaps
Recommend B.
Confidence gaps, stated and not used to change the recommendation:
End state. In two years a record deleted through any door, with or without an organization, either sits in the recycle bin under an owner the platform can derive or is refused with a named reason, as deleted rows stay scoped to their organization in Salesforce's Recycle Bin and Dataverse's recycle bin; and the engine's core file stays a thin, capped facade, with new wiring living in the modules beside it.
Self-check. 「只看①选 B;②③④ 是否翻转:否」
After the ruling
If B:
domain:server, seat 7 area d7-B, one PR, the same claim. The seat amends the claim's file surface to addpackages/objectql/src/engine-delete-and-aggregate.ts(the write call) and, if the dev exposes the resolver as a small function beside its body,packages/objectql/src/engine-middleware-and-context.ts. ⛔engine.tsand the registry stay untouched.this.facade, and it type-checks.pnpm check:facade-delegation-onlystays green, andwc -l packages/objectql/src/engine.tsstill reads 6857.single, and a restore brings the row back.engine.ts.packages/runtimeas the dev proposed. A system-door delete of a tenancy-disabled record answers true, the entry's organization is the Default Organization, and restore brings the row back. A walled posture answersERR_SYSTEM_WRITE_ORGANIZATION_REQUIREDand the row stays. A record that carries its own organization and a context that carries one are stamped as before (controls).patch,Clause-②: no,Metadata-protocol: none.If A instead: the same pins and changeset, plus the registry row
{ "file": "packages/objectql/src/engine.ts", "baseLines": 6857, "baseCommit": "8145424b53", "maxLines": 6858, "ruling": "<this ruling's record id>" }, re-measured on the PR's base, and the claim's surface widened to that one line.Related cards and PRs
engine.ts+25 −2.os-decision-facets
① 项目长远合理性: B follows the ceiling ruling's own remedy (new code in a new module) with no exception and keeps the one D9 decision; A is an exception that repeats one line at a time on a file that is exactly full; C is right in direction but has no card. No option slows SQL for memory or Mongo parity.
② 实际业务拉动: 6 system-door delete faults in the verify run, reproduced on sqlite; flows, hooks and admin tooling deleting records of tenancy-disabled objects (2 such objects in the example apps, none in HotCRM). All options fix it; A and B at the same speed.
③ 防 AI 犯错: after the fix an app gets success or a loud named refusal where today it gets a raw constraint error or a silent ownerless entry; the rejected routes are the ones that could disagree silently with the engine. B does what the gate's own message tells authors to do. No new gate proposed.
④ 创业阶段不扩散: B adds no registry change and no ruling record to carry; A adds one and sets a pattern of raises; C adds a refactor with no pull beyond the ceiling.
Prior rulings read: recycle-bin,sys_recycle_bin,resolveSystemInsertOrganization,ceiling,facade → 22 hits; ADR-0131 D9, ADR-0148 D1; thread: none
objectstack-fleet commentedon Nov 21, 2026
repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7
Claim amendment · 2026-11-21T12:07Z · route B, on the seat's routing call (seat 7, 2026-11-21T12:07Z), from the dc-7a analysis 7062338699
The claim 7061800429 stands, with its file surface widened to:
packages/objectql/src/engine-delete-and-aggregate.ts. The delete module, which already holds the engine and reads a sibling facet's host (engine-delete-and-aggregate.ts:258, the route PR feat(objectql, core, spec): the engine seam for the fixed-read leaf and its driver declaration (ADR-0155, step 2 of 6) #35839 landed), hands the capture's write step the one ADR-0131 D9 resolver body through the middleware facet's host.packages/objectql/src/recycle-bin/capture.ts. When neither the record nor the context names an organization, the entry takes the resolver's answer. A refusal throws before the root row is removed, so the delete is refused loudly.packages/runtimecomposes both), and onepatchchangeset.⛔
packages/objectql/src/engine.tsgains no line, andscripts/facade-delegation-registry.jsonis not touched. The dev builds only when both of these hold:check:facade-delegation-onlystays green, withwc -l packages/objectql/src/engine.tsstill 6857.If either fails, the dev reports a fork with the evidence and builds nothing, and only then does the 6857 → 6858 raise go to the maintainer. Under a walled posture,
ERR_SYSTEM_WRITE_ORGANIZATION_REQUIREDis D9 as written, which the seat accepted. Effort stayshigh; the same dev resumes with its own measurements.objectstack-fleet commentedon Nov 21, 2026
triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH
Ruling-ref: maintainer 2026-11-21T13:1xZ, verbatim: 「同意」, approving triage's non-topic re-grade: p1 = "this week, or someone loses": main or release blocked, data silently wrong or lost, a common function that errors, AI taught wrong, an outside user's report.
2026-11-21T13:14Z · p2 → p1 on the maintainer's word: a common function that errors: a system-door delete faults on the recycle-bin NOT NULL. Lane and state unchanged.
objectstack-fleet commentedon Nov 21, 2026
repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7
os-dev-report
{ "issue": 35667, "status": "done", "branch": "claude/issue-35667-recycle-bin-orgless-delete", "pr": "https://github.com/objectstack-ai/objectstack/pull/36097", "session": "session_01L9qibwJEh7hMPPvagWM1g7", "premise_still_valid": true, "summary": "I built route B as the seat ruled (claim amendment 7062354282). The delete module (engine-delete-and-aggregate.ts) hands the capture's write() a call to MiddlewareAndContextFacet.resolveSystemInsertOrganization through middlewareAndContextHost.of(this.facade). That is the same ADR-0131 D9 body the engine's insert uses. In capture.ts, write() stamps the entry with the record's organization, else the context's, else the resolver's answer. Under single that is the Default Organization; under a wall the delete is refused with ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED before the root row is removed. engine.ts still has 6857 lines and the facade registry is untouched. Deviation: the memory-store pin is not on @objectstack/driver-memory. A new test consumer of that driver turned check:driver-memory-census red ('Rule it, migrate it, or file it'), so that leg is a describe in objectql's capture harness, which keeps rows the way driver-memory does with no NOT NULL. The sqlite leg is in packages/runtime. Fixture triage: the capture harness registered sys_organization but held no organization, the broken boot invariant that D9 refuses. That turned 10 existing capture tests red, so the harness now seeds the Default Organization; the organization-delete cascade test opts out, because every delete in it names its organization.", "tests": "All on head 4bd70f0a1c. Gate before building: `pnpm check:facade-delegation-only` exit 0, printing 'packages/objectql/src/engine.ts: 6857 lines, ceiling 6857'; `wc -l` reads 6857; `pnpm --filter @objectstack/objectql typecheck` exit 0 (lock VERDICT command-exit 0). Pins: runtime/src/recycle-bin-orgless-system-delete.test.ts on sqlite, Tests 3 passed (3). The new describe in objectql capture.test.ts: capture harness Tests 30 passed (30); src/recycle-bin/ Test Files 5 passed, Tests 178 passed. Ablation: scripts/ablation-replace.mjs replaced the resolver call with `const derived: string | undefined = undefined;` (anchor 1 to 0, blob d124655c5f01 to 79309b11f005). After an objectql rebuild, `ablation-dist-preflight --absent` reported the marker absent from 14 built files. With the mutation, the runtime pin had 2 failed and 1 passed (the context control), and the capture harness had 2 failed and 28 passed. Restore: `git checkout HEAD --`, `git diff HEAD` 0 bytes, hash matched d124655c5f01, rebuild, preflight found the marker present in 2 files, tree clean. After the restore: 3 passed and 30 passed. `pnpm --filter @objectstack/objectql test`: Test Files 624 passed (624), Tests 14217 passed (14217). `pnpm --filter @objectstack/objectql typecheck`: exit 0 (lock VERDICT command-exit 0). Consumer suites that compose the bin and delete without a booted auth, all lock VERDICT command-exit 0: mcp stdio-data-bridge.recycle-bin 5 passed, cloud-connection connection-credential-ledger 11 passed, metadata-protocol seed-tenancy-backfill 58 passed, runtime sandbox/body-runner 42 passed. Left to CI: `pnpm --filter @objectstack/runtime typecheck` (it needs the runtime dependency closure built) and `test:repo`.", "gates": "Local: `node scripts/pm/dispatch-gates.mjs --commands` derived 66 families on 4bd70f0a1c, and all 66 exited 0 (exit codes captured per command, before any pipe). `--ran` reconciliation exited 0: 66 derived, 66 run, 0 NOT-MEASURED, 0 UNRUN. On the earlier head e95ae7d746, check:driver-memory-census was red (exit 1) and check:dual-build-cjs-loads exited 3 (PREREQUISITE NOT MET); both are green on 4bd70f0a1c, and dual-build measured 124 entry points across 72 packages. overlap-check returned VERDICT clean exit 0 before each of the three pushes (origin/main and #36060 merge cleanly). CI on PR #36097 at head 4bd70f0a1c was in_progress when this report was written: Check Changeset, Governed Surface Queue Guard, Lint (CI release & engine gates, ESLint, docs & code guards, the scoped lanes, PM dispatch-gates and repo & tooling gates queued), Type Check (workspace, consumer gates, source gates, debt ledger) and PR-body guards; there are no conclusions yet.", "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm", "mcp_calls": "0", "api_writes": "3 — POST /repos/objectstack-ai/objectstack/issues/35667/comments (first os-dev-report, comment 7062012198, via post-stamped); pr_create through scripts/pm/fleet-write/dispatch.mjs (relay run 44908574326: POST /repos/objectstack-ai/objectstack/pulls, then POST /repos/objectstack-ai/objectstack/issues/36097/assignees with os-tesla; read back 8914 of 8914 bytes identical); POST /repos/objectstack-ai/objectstack/issues/35667/comments (this os-dev-report, via post-stamped). Also git pushes of the branch, which are not REST writes.", "open_questions": [], "security_findings": "none", "out_of_scope_findings": [ "carrier: none · MongoDBDriver does not stamp the tenant column on insert, by its own docblock (packages/drivers/driver-mongodb/src/mongodb-driver.ts, the single-tenant note). This is a code read only and no test reproduced it, so on the seat's word it is noted in the PR's Acceptance notes and not filed. The capture change covers the system-door delete of such a row under single." ] }objectstack-fleet commentedon Nov 21, 2026
repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7
Close-out · 2026-11-21T14:20Z · #35667 done by PR #36097
PR #36097 merged through the queue at 2026-11-21T14:18Z as
7dd1a2f613c476aae4ef78755d21c0c546a02b6f. The merge group's Dogfood Regression Gate passed.What landed. A recycle-bin entry now takes its organization from the record, else from the context, else from the ADR-0131 D9 system-write resolver:
MiddlewareAndContextFacet.resolveSystemInsertOrganization, the same body the engine's insert uses, which the delete module reaches through the middleware facet's host. The effect on a delete whose record and context name no organization (the system door, typically):single, it lands in the bin under the Default Organization and restores.ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED(500) before the root row is removed.NULL is never written, and no entry is dropped.
engine.tsstays at 6857 lines (route B, no ceiling raise).Review trail
Clause-② basis:line in the PR body: a bug fix, not a narrowing.Carries
permanent: trueis the other route under a wall.check:driver-memory-censusrefuses a new driver-memory test consumer.MongoDBDriver.createdoes not stamp the tenant column. That is a code read only, and no test reproduced it.pm:dispatchedremoved. The card was closed by the merge.fix(objectql): a system-door delete of a record with no organization …