Skip to content

objectql delete: a by-id delete whose driver answers false still runs afterDelete, summary recompute and data.record.deleted, and answers false or RECORD_NOT_FOUND depending on a hook binding #35329

Closed

Description

@objectstack-fleet

repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb

Filing gate: ② out-of-scope finding (class b, named producer): the decision analysis for #35167 (area data-1 of seat repo:objectstack#5, file objectstack-seat5/area-ux/data-1/decision-35167-35174-34292.md), read from code on origin/main de8d5497. Filed on the seat's word (2026-11-19 05:02Z): one card for the delete-loser answer and the after-effects on the same false path.
Reader: domain:server (packages/objectql/src/engine-delete-and-aggregate.ts). Suggested-grade: p2 · data wrong × rare (a concurrent delete loser fires delete after-effects for a row it did not remove).
Dedupe: afterDelete false delete loser, delete false RECORD_NOT_FOUND afterDelete, concurrent delete afterDelete in open issues: none.

维护者速读

  • 现象:两个调用同时按主键删同一条记录,输家的驱动返回 false(什么也没删)。引擎仍然照跑 afterDelete 钩子、重算汇总字段、发 data.record.deleted 实时事件,等于为别人删掉的记录再触发一遍「删除后」的全部动作。输家拿到的答复也不一致:没绑 beforeDelete 钩子时是 false,绑了时是 RECORD_NOT_FOUND。
  • 影响:REST 和批量接口已经把 false 翻成 404,页面用户看不出差别;受影响的是直接调引擎的自动化代码(钩子 ctx.api、动作处理器、流程节点)和那些重复触发的删除后动作。
  • 修法:前镜像已读到、驱动明确回 false 时,在派发 afterDelete 之前抛 RECORD_NOT_FOUND,与 REST 一致,后续动作都不跑。
  • 需要你做的:无(分诊定级)。

Facts (origin/main de8d549, read, not run)

Ask

When a by-id delete has a proven pre-image and the driver answers false, throw RECORD_NOT_FOUND before afterDelete, summary recompute and the realtime event. Measure first: the four cells (metadata beforeDelete hook or not × SQLite or PostgreSQL) for the loser's answer and for whether afterDelete / the event fire today. Pins: a forced driver false after a pre-image throws RECORD_NOT_FOUND and fires no afterDelete, no summary recompute and no event; CONTROL: a normal delete fires all three once. Ablate red. Predicate (many-row) delete is out of scope unless the same lines carry it.

Clause-②: no expected (an engine caller already gets RECORD_NOT_FOUND for a missing row; this makes the loser always get it). Measure on the diff.

Order

After #35167 (same file, engine-delete-and-aggregate.ts; #35167 awaits the maintainer's ruling). If #35167 is ruled with no code change, this card is free to go.

Related: #35167, #35142 / PR #35165, #31630 (recycle-bin false handling at the same call).

⛔ Not a claim.

Activity

  1. added
    priority:p2
    pm:queue
    finding
    domain:server
    on Nov 19, 2026
  2. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb

    Claim: PM loop round 14 · area data-1 (the maintainer, verbatim, 2026-11-19T04:35Z project chat: 「再开 area:data」; standing 「暂时都只派 p1 p2 的卡」) · 2026-11-19T12:11Z
    Area: data-1
    Session: session_01Utp6Ca1jJvsA1dHsPwMiQb
    Account: os-bill
    Branch: claude/issue-35329-delete-loser-not-found
    Worktree: objectstack-issue-35329 (os-dev worktree in the data-1 container)
    Domain: domain:server
    Seat: repo:objectstack#5
    File surface: packages/objectql/src/engine-delete-and-aggregate.ts (the by-id delete's driver-false path before afterDelete, summary recompute and the realtime event), a new test named for this card (objectql, or plugin-security if a real SQLite middleware chain is needed, as #35386 did), root .changeset/. Predicate (many-row) delete is out of scope unless the same lines carry it. Stop on breach and report.
    Container & model: M, mode:subagent, model: default — no path-derived mandate, effort: high
    Clause-②: no (an engine caller already gets RECORD_NOT_FOUND for a missing row; measure on the diff)
    Metadata-protocol: none
    Responsibility: platform — a concurrent by-id delete loser runs afterDelete, summary recompute and data.record.deleted for a row it did not remove, and answers false or RECORD_NOT_FOUND depending on a hook binding; engine callers (hook ctx.api, action handlers, flow nodes).
    Thread-read: none
    Premise: read from code at de8d5497; #35167 (same file) merged via PR #35386 and moved the unit inside the middleware, which the card says does not remove this. The dev measures the four cells first.
    Serial constraints cleared: #35167 / PR #35386 merged; no open PR holds engine-delete-and-aggregate.ts in this area (#34886 / PR #35479 does not touch it).
    Pre-claim lane: domain:server (packages/objectql/**)
    Pre-claim deps: #35167 merged.
    Prior rulings read: #35167 ruling A (seat relay, 05:04Z); decision file decision-35167-35174-34292.md; #31630 (recycle-bin false handling); thread: none

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

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb
    os-dev-report

    {
    "issue": 35329,
    "status": "done",
    "branch": "claude/issue-35329-delete-loser-not-found",
    "pr": "#35537",
    "head": "0719692cb35b31b5978c64d74d69c6a613791aef",
    "session": "session_01Utp6Ca1jJvsA1dHsPwMiQb",
    "premise_still_valid": true,
    "summary": "By-id delete: once the pre-image proved the row present, a driver answer of false now throws recordNotFoundError (same error as the pre-image miss) inside runByIdDelete, after the recycle-bin withdraw and outside its compensating try, so afterDelete, the roll-up recompute and data.record.deleted never run for the loser; an off-contract 0 and the predicate path are untouched. Pinned on real SQLite (two writers racing for one row, parked deterministically in a code-registered beforeDelete) with a CONTROL; four stale objectql pins that asserted the old false answer were updated. Clause-2 measured as no (narrowing): an engine caller that got false now gets a refusal, so the changeset carries BREAKING + ADR-0087 marker and the dogfood battery ran green on the head.",
    "A0": {
    "method": "two writers delete one row; the first parks in a beforeDelete dispatch after its pre-image read; the second deletes meanwhile; readings with the new throw ablated (= origin/main behaviour) and with it in place",
    "sqlite_no_metadata_hook": "before: loser answers false; afterDelete x2, recompute x2, data.record.deleted x2 | after: loser RECORD_NOT_FOUND/404; each x1",
    "sqlite_metadata_beforeDelete": "before and after: second writer waits (unit holds the only connection), answers RECORD_NOT_FOUND/404 at its pre-image; each x1",
    "postgres16_no_metadata_hook": "before: loser false; each x2 | after: RECORD_NOT_FOUND/404; each x1",
    "postgres16_metadata_beforeDelete": "before: second writer does NOT wait; loser false; each x2 | after: RECORD_NOT_FOUND/404; each x1 (the hook-binding split is SQLite-only)",
    "postgres_setup": "private temporary cluster, PostgreSQL 16, 127.0.0.1:55329, initdb in /tmp/pg-35329, stopped and removed after; one-off measurement files, not committed"
    },
    "A1": "re-anchored at 0719692 in packages/objectql/src/engine-delete-and-aggregate.ts: pre-image throw :478; driver.delete :668; recycle-bin false handling :677-678; new throw :695; afterDelete dispatch :833-848; isDeleteResultShape :858; recomputeSummaries :882; by-id data.record.deleted :909",
    "A2": "withdraw() runs first (unchanged), then the throw, outside the try whose catch calls compensate(), so the entry is written, withdrawn and never compensated twice; the #31630 pins in recycle-bin/capture.test.ts still assert bin ops ['create','delete'] and zero entries, only the answer moves from false to RECORD_NOT_FOUND; on the atomic plan the throw is inside this.transaction, so the walked cascade rolls back (now asserted: contacts 2, note 1 after the false cell)",
    "A3": "no separate soft-delete branch exists in the engine; a recycle-bin delete is the same driver.delete call plus the entry, so it reaches the same false branch and the throw applies after the withdrawal; not widened",
    "files_changed": [
    ".changeset/35329-delete-loser-not-found.md",
    "packages/objectql/src/engine-delete-and-aggregate.ts",
    "packages/objectql/src/engine-cascade-delete.test.ts",
    "packages/objectql/src/recycle-bin/capture.test.ts",
    "packages/plugins/plugin-security/src/delete-driver-false-not-found-sqlite.test.ts"
    ],
    "line_budget": "248 added / 7 deleted across 5 files vs merge base 895dd43 (human-merge threshold 3000: under); engine change +16/-2; no skills/** or governed surface touched",
    "tests": "plugin-security new file at 8d299a3 (lock VERDICT command-exit 0): Test Files 3 passed, Tests 7 passed incl. one-off SQLite/PG measurement files; ablation leg (scripts/ablation-replace.mjs, anchor 1 -> 0, blob 6b3eaa8d0989 -> f945759657a5): 'answers RECORD_NOT_FOUND ...' red, expected { value: false } to deeply equal { code: 'RECORD_NOT_FOUND', ...}; restored: blob == HEAD, git diff HEAD empty. objectql full suite at 42aec00: Test Files 2 failed | 613 passed, Tests 4 failed | 13891 passed -- the 4 were stale pins asserting the old false answer (capture.test.ts x3, engine-cascade-delete.test.ts x1), updated in 938fc5c: 2 files / 53 tests passed; ablation of the same line turns exactly those 4 red (Tests 4 failed | 49 passed), restored blob == HEAD. objectql typecheck exit 0 (938fc5c); plugin-security full suite Test Files 282 passed, Tests 7039 passed | 45 skipped; plugin-security typecheck exit 0 (42aec00). test:repo not run locally (declared to CI, Test Core).",
    "gates": "dispatch-gates --commands at 0719692: 69 families, each run with exit captured before any pipe; 68 exit 0; NOT MEASURED: pnpm check:type-check-debt (exit 3 PREREQUISITE NOT MET -- its closure build queued behind this PR's own dogfood run on the shared lock; CI Lint & Repo Gates runs it). --ran reconciliation: '69 derived famil(ies) accounted for -- 68 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)'. overlap-check --branch=HEAD VERDICT clean exit 0 before every push. PR #35537 check-runs at report time: in_progress (Check Changeset, Lint ·, Type Check ·, Governed Surface Queue Guard, PR-body guards) -- not awaited per contract.",
    "dogfood_battery": "0719692cb3 · os-verify-lock VERDICT command-exit 0 (held 2554s, shared box) · pnpm --filter '@objectstack/dogfood^...' build exit 0 · pnpm --filter @objectstack/dogfood test: Test Files 482 passed | 3 skipped (485) · Tests 4092 passed | 68 skipped (4160) · no failures",
    "deviations": [
    "Clause-2 arm: the claim line reads 'Clause-②: no'; measured on the diff an engine caller that got false now gets RECORD_NOT_FOUND, so per the dispatch order's rule the PR and changeset declare 'Clause-②: no (narrowing)' with BREAKING + '(adr-0087: not-required (no-migration-prescription))' marker, title carries '!', dogfood battery run on the head",
    "File surface widened beyond the claim (engine file, new test, changeset): packages/objectql/src/recycle-bin/capture.test.ts and packages/objectql/src/engine-cascade-delete.test.ts were edited because they pinned the exact false answer the card's ruling changes (4 reds at 42aec00); assertion changes only, plus one added rollback assertion; named in the PR body. Not stopped on it because the PR cannot be green otherwise.",
    "PR body footer: the relay stored the body byte-identical (9759/9759) with no platform-appended footer; attribution is the signature line; body not re-sent",
    "Merged origin/main once (b1d2d2d) before the suites; no conflicts"
    ],
    "mcp_calls": "0",
    "api_writes": "2 -- fleet-write relay: POST /repos/objectstack-ai/objectstack/dispatches executing pr_create (POST /repos/objectstack-ai/objectstack/pulls draft + POST /repos//issues/35537/assignees os-bill); post-stamped.mjs: POST /repos//issues/35329/comments (this os-dev-report)",
    "open_questions": [],
    "security_findings": "none",
    "out_of_scope_findings": [
    "carrier: none · noted in the PR's Acceptance notes, not filed: a parent cascade stops with the child's RECORD_NOT_FOUND when a dependent row is gone before the child delete removes it (already true at the child's pre-image read on origin/main; this PR extends it to the window after the read, e.g. a child beforeDelete hook deleting its own row) -- whether a cascade should tolerate an already-gone dependent is a separate behaviour question, not a reproduced defect against a declared contract"
    ]
    }

  5. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb

    Claim amendment · area data-1 · 2026-11-19T15:17Z (amends claim 7008712719, as L1-a R1 7013287121 requires)

    File surface, added: packages/objectql/src/recycle-bin/capture.test.ts and packages/objectql/src/engine-cascade-delete.test.ts. Their four existing pins asserted the old driver-false answer that this card's ruling changes. Only those assertions move, to the RECORD_NOT_FOUND / 404 envelope, and one rollback assertion is added (the cascade's rows come back on the atomic plan). PR #35537 names both files.

  6. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb
    os-dev-report

    {
      "issue": 35329,
      "status": "done",
      "branch": "claude/issue-35329-delete-loser-not-found",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/35537",
      "session": "session_01Utp6Ca1jJvsA1dHsPwMiQb",
      "head": "a6ec895d8c56fb038a3ca4ecd6c2c0901e3b9e8d",
      "premise_still_valid": true,
      "summary": "Round 2 on head a6ec895d8c. S1 is taken by route (a). A child delete that a parent's cascade issued (the referentialCascadeDelete claim) and whose driver answers false no longer throws. It sets cascadeChildVanished (engine-delete-and-aggregate.ts:710), returns false, and skips every after-effect (afterDelete, the secret release, the roll-up recompute, data.record.deleted) at :743. The walk goes on and the parent's delete completes, which is main's outcome. A delete the caller addressed by id keeps the RECORD_NOT_FOUND/404 refusal (:713). The decision is made at the changed line, by the cascade claim only, and RECORD_NOT_FOUND is not tolerated in the walk. N1: the prose is fixed at engine-delete-and-aggregate.ts:468-478 and :875-883, at recycle-bin/capture.ts:172-180, and in the capture.test.ts cell title. N2 plus S1 in the changeset: the stores are now examples, the own-row door (own-row-delete-routes.ts:233) is named along with its locale-less userMessage, the cascade child's outcome is stated, and the caller's fix says the new error names the addressed row. Deviation from the order's wording: the changeset does not say that every by-id RECORD_NOT_FOUND 'always' names the addressed row. That would be false for a dependent that the child delete's own read does not return, which still stops the cascade with RECORD_NOT_FOUND naming that dependent, as on main. The changeset states that case.",
      "dispositions": {
        "S1": "fixed, route (a), in this PR (code :664/:704-715/:743; pins engine-cascade-delete.test.ts:1000 and the new CONTROL at :1033)",
        "N1": "fixed (prose only: engine-delete-and-aggregate.ts:468-478 and :875-883, recycle-bin/capture.ts:172-180, capture.test.ts cell title now 'logs at error, and still refuses with RECORD_NOT_FOUND, when the entry cannot be withdrawn')",
        "N2": "fixed (changeset: stores as examples; own-row door named; userMessage built by the engine from a context with no locale)"
      },
      "pins": "engine-cascade-delete.test.ts:1000 'a delete of the very same row from inside the cascaded dispatch finds the token claimed': the parent delete resolves true and acct and qline are both gone. The vanished cascade child ran no after-effect: afterDelete markers [false] (only the hook's own winning delete), and releaseSecretHandles / recomputeSummaries / publishDataEvent were each called once for qline ([1,1,1], the winner's, not twice). CONTROL at :1033: the same self-deleting hook on a by-id delete of qline answers {code:'RECORD_NOT_FOUND',status:404}, with the same once-only after-effects.",
      "tests": "All runs used os-verify-lock, VERDICT command-exit 0. 382d79aa98: objectql full vitest, Test Files 615 passed (615), Tests 13896 passed (13896). a6ec895d8c: objectql typecheck (tsc + check:test-typecheck) exit 0, 'check:test-typecheck: OK — 39 file(s) / 233 error(s) / 64 pinned signature(s) held'. a6ec895d8c: engine-cascade-delete.test.ts Tests 26 passed. a6ec895d8c: plugin-security delete-driver-false-not-found-sqlite.test.ts Tests 3 passed. a6ec895d8c: turbo run typecheck --filter=./packages/*, Tasks 87 successful, 87 total. Ablation at ff325dcb26 via scripts/ablation-replace.mjs, anchor 'if (referentialCascadeDelete) {' replaced by 'if (false as boolean) {': 'ok mutation landed: anchor 1 -> 0, blob 6df5f2aca62e -> 68b1c3daca02'. The cascade pin went red ('promise rejected \"Error: Record r_2 not found in qline\" instead of resolving') and the CONTROL stayed green ('Tests 1 failed | 1 passed | 24 skipped'). 'ok restored: blob == HEAD (6df5f2aca62e) and git diff HEAD is empty'. No dist leg was needed because the test imports ./engine.js from source. Only one test file's types changed between 382d79aa98 and a6ec895d8c.",
      "gates": "Local: dispatch-gates --commands (derived at 382d79aa98; a6ec895d8c is a type-only test edit) gave 70 families. Each was run with its exit code captured before any pipe. 68 exited 0 on the first pass. check:dual-build-cjs-loads and check:i18n exited 3 (PREREQUISITE NOT MET) and then exited 0 after the workspace build. --ran: '70 derived famil(ies) accounted for — 70 run, 0 NOT-MEASURED (a DERIVED zero — all 70 recorded an exit code and none of them is 3)'. overlap-check --branch=HEAD: 'VERDICT clean exit 0'. CI on a6ec895d8c at report time: 37 success, 18 skipped, 2 in_progress. Lint & Repo Gates, TypeScript Type Check, Type Check · workspace, Test Core, Build Core, Governed Surface Queue Guard, Test UI, Live E2E UI and Dogfood Regression Gate are all success. Check Changeset has one success and one run in_progress (re-triggered by the body edit). Earlier reds: on 2d1c794629 the Lint & Repo Gates / TypeScript Type Check failures were cancellations, every lane 'cancelled' because the next push superseded the run. On ff325dcb26 Type Check · workspace was a real red: TS7006 \"Parameter 'args' implicitly has an 'any' type\" at engine-cascade-delete.test.ts:996 (the new spy filter), reported by check:test-typecheck as an ARRIVED signature. a6ec895d8c fixes it by typing the filter ((args: unknown[]) over { mock: { calls: unknown[][] } }), with no change to the ledger.",
      "dogfood_battery": "a6ec895d8c · os-verify-lock: VERDICT command-exit 0 · Test Files 482 passed | 3 skipped (485) · Tests 4092 passed | 68 skipped (4160) · no failures",
      "mcp_calls": "0",
      "api_writes": "2 — REST writes through the relay: post-stamped --body=35537 (PR body rewrite, relay run 44575203545) and post-stamped --comment=35329 (this os-dev-report). Plus 3 git pushes (2d1c794629, ff325dcb26, a6ec895d8c), which are not REST.",
      "deviations": "(1) Three heads were pushed instead of one. The coordinator asked for fewer intermediate heads, and the last push carries everything. (2) ff325dcb26 carried the TS7006 described under gates; it is fixed at a6ec895d8c. (3) The changeset's caller-fix sentence is narrowed from the order's 'a by-id RECORD_NOT_FOUND now always names the row the caller addressed' to 'the error this change adds always names the row the caller addressed', and it names the pre-existing dependent-read case, because the literal sentence would be untrue for that case. (4) The PR body gained the session-URL footer, which the round-1 body did not carry. (5) test:repo was not run locally (declared to CI: Test Core).",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": []
    }
  7. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb
    os-dev-report

    mode:subagent · battery-only order on PR #35537, no code changed · read 2026-11-19T18:49Z

    {
      "issue": 35329,
      "status": "done",
      "branch": "claude/issue-35329-delete-loser-not-found",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/35537",
      "session": "session_01Utp6Ca1jJvsA1dHsPwMiQb",
      "premise_still_valid": true,
      "summary": "Battery-only rerun on the new head 503f464a68. The diff since a6ec895d8c, where the last battery ran (os-dev-report 7016489277), is the changeset alone: git diff --stat a6ec895d8c 503f464a68 lists only .changeset/35329-delete-loser-not-found.md, 1 insertion and 1 deletion. No code was changed and nothing was pushed in this run. The full dogfood battery passed on 503f464a68.",
      "tests": "Detached worktree from origin/claude/issue-35329-delete-loser-not-found, HEAD 503f464a68fdc459e5fea15570ab0626e22bc00b. Ran pnpm install --frozen-lockfile (exit 0). Under the verify lock: pnpm --filter '@objectstack/dogfood^...' build && pnpm --filter @objectstack/dogfood test, with no OS_TEST_SHARD and no path. Output: Test Files 482 passed | 3 skipped (485); Tests 4092 passed | 68 skipped (4160).",
      "gates": "No local check families ran: the diff is one changeset line and this was a battery-only order. On 503f464a68 the CI check-runs read through REST commits/503f464a68/check-runs were 37 success, 16 skipped and 0 failure, out of 53.",
      "dogfood_battery": "503f464a68 · os-verify-lock: VERDICT command-exit 0 · held the lock 2299s, waited 404s · Test Files 482 passed | 3 skipped (485) · Tests 4092 passed | 68 skipped (4160) · no failures",
      "mcp_calls": "0",
      "api_writes": "1 — POST repos/objectstack-ai/objectstack/issues/35329/comments (this report, via post-stamped.mjs)",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": []
    }

    Generated by Claude Code

  8. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb

    Close-out 2026-11-19T19:21Z: PR #35537 merged, and Fixes closed this card.

    A by-id delete whose pre-image proved the row present, and whose driver then removes nothing because a concurrent writer won, now answers RECORD_NOT_FOUND / 404. The pre-image miss already answered that way. Before, the losing delete still ran afterDelete, the roll-up recompute and data.record.deleted a second time. The recycle-bin entry is withdrawn as before. On the atomic plan, the cascade the loser walked rolls back.

    A child delete that a parent's cascade issued answers false and runs no after-effects, and the walk goes on, which is main's outcome for the parent. A0 was measured on SQLite and PostgreSQL 16. The PR is a narrowing (!, BREAKING with an ADR-0087 marker), and the dogfood battery is green on the merged head.

    L1-a ACCEPT 7013287121. Seat contract review 7014131594, delta 7016703648 PASS. pm:dispatched off.

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

Metadata

Metadata

Assignees

Labels

area:datadomain:serverfindingpriority:p2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions