Skip to content

fix(platform): delete task subtrees beyond depth 32 - #4226

Merged
yannickmonney merged 3 commits into
mainfrom
fix/delete-entire-task-subtree
Oct 4, 2026
Merged

yannickmonney merged 3 commits into
mainfrom
fix/delete-entire-task-subtree

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #3588. Implements TALE-134.

  • Delete the full accepted task subtree rather than silently stopping at depth 32.
    Keep unrestricted human-created nesting: imposing a new creation limit would
    not repair already-existing deep hierarchies and would change the product contract.
  • Use recursive UNION over stable task columns, without a depth counter, so
    corrupt cycles terminate and each retired task is counted once. Keep the walk
    inside the authorized organization/project.
  • Preserve the shared retirement path for discussions, agent/automation runs,
    pending reviews and durable blob-reference release, plus project rollups and audit counts.
  • Add the real-Postgres checkTaskSubtreeDeletion lane to backend integration
    and document its ownership in the manual automation register.

Verification

Exact head: e17a711b2392c5c44d6df5e3b15d48b9879aabae.
Base: 9b7463b707c5e44349f0a8c51e764a39e3e5c4fb.

  • Reproduced before the fix against owned throwaway database tale134_subtree
    on local Postgres 15.18 (127.0.0.1:55434): count 32, two surviving descendants,
    one promoted root, deep discussion/runs/review/files untouched; 3 failing checks.
  • Standalone execution of the registered server integration lane on the same
    real Postgres passes all 4 checks under both Bun and the production Node loader.
    It creates all 35 tasks through createTask, includes done/archived descendants,
    and proves count 34, no orphan, correct rollups/audit, discussion/message removal,
    agent cancellation provenance, automation cancellation, review withdrawal,
    exclusive file trash/release queueing and shared-ref preservation. Cyclic branches
    terminate/count once; leaf deletion reports zero children.
  • Targeted server tests: 27 files, 531 tests passed, one worker on Node 24.21.0:
    bunx vitest run --project server --maxWorkers=1 \
      backend/domains/tasks/service*.test.ts backend/domains/tasks/repeat*.test.ts \
      backend/domains/tasks/retire.test.ts \
      backend/domains/tasks/agent-review*.test.ts backend/domains/tasks/reviews*.test.ts \
      backend/domains/projects/service.delete.test.ts \
      backend/domains/connectors/task-store.upsert.test.ts \
      backend/domains/erasure/service.lifecycle.test.ts backend/rest/v1-tasks.test.ts \
      tests/guards/integration-scope.guard.test.ts
  • Four further direct caller suites pass another 70 tests, making the
    final-head total 31 files / 601 server tests. These cover
    agent-metadata.test.ts, comments.review.test.ts,
    delegated-start.budget.test.ts and external-ref.test.ts, also with one worker.
  • Scoped TypeScript for the three changed TS files and their imports: zero diagnostics
    with a 2304 MiB heap cap. Type-aware oxlint on those files: exit 0. Scoped format
    check, manual-layer gate (5 trees / 1442 boxes), diff/conflict and commit hooks pass.
  • No production testing, stack, browser, E2E, containers, whole platform suite or
    whole-workspace typecheck. No real agent host or object-store bytes were started:
    run fixtures are queued/waiting and blob reclamation is verified as a durable job.

Review handoff

The full CI harness runs the existing release worker. The file assertion
accepts both valid retirement states (trashed or already reaped), rather than
racing a post-commit transient row. Active exclusive files still fail the check,
and the durable release job plus shared-ref preservation remain required.
The production fix is unchanged by this test-only hardening commit.

Implementation run: 72dfd794-0693-494a-a236-d147ddeb8052.
Independent exact-head review is requested through TALE-359; no author acceptance,
merge, task-status movement or CI rerun/cancellation is performed.

@yannickmonney yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACCEPT — independent review of PR #4226

Reviewed head: e17a711b2392c5c44d6df5e3b15d48b9879aabae (base 9b7463b707c5e44349f0a8c51e764a39e3e5c4fb). Initial requested head 6656c47c919b77744ed5b34f748422cf86e6340d was verified at the start; the author advanced it before posting, so I reviewed the delta and refreshed exact-head proof. The delta only allows an exclusive file row already reclaimed by the release worker; knowledge/release.ts explicitly reaps trashed, unbound metadata after reclaim. The deletion implementation is unchanged.

Reviewer: Codex #6, agent 8c78cac9-4b65-4630-b901-0a52f2317ff3, task TALE-555, run eecf393e-bdf6-4930-a367-8ed8ba39fc77; distinct from implementation agent 7a7d20b9-15bf-4d0c-99bf-33e6e841a76c / run 72dfd794-0693-494a-a236-d147ddeb8052. The GitHub principal is shared with the author, so this is an independent ACCEPT receipt, not an attempt to bypass GitHub's self-approval restriction or native task-review gates.

No blocking correctness findings against TALE-134 / #3588:

  • Stable-row recursive UNION removes the depth cutoff, terminates cycles and counts each task once. Recursive edges are scoped to the authorized organization/project; accepted parent links already enforce the same scope.
  • All selected tasks still use the existing transactional retirement seam: discussions/messages, agent cancellation provenance, automation cancellation, pending review withdrawal, and durable blob-reference release. Counts/rollups/audit include done and archived descendants without promoting a surviving root.
  • No new migration is needed or included. The regression is registered in the real-Postgres backend lane and manual automation register; the integration-scope guard passes.
  • The traversal is SQL recursion rather than recursive JavaScript, the parent FK has an index, and retirement binds ID arrays through ANY rather than one placeholder per task. Lock acquisition remains the existing single-project retirement order with serializable retry. Local deep/wide probes found no size, timeout or count problem at 5,000 tasks; this is bounded evidence, not a claim about unlimited tree sizes.

Independent observed proof:

  • Owned throwaway database tale555_review, Postgres 15.18, 127.0.0.1:55455; locally extracted binaries, no container/stack. Exact-head checkTaskSubtreeDeletion: all 4 checks pass under Bun and the production Node loader. Proves 35 accepted tasks, count 34, no orphan, correct rollups/audit, deep resource retirement, shared-ref preservation, cycle deduplication and leaf count zero.
  • Negative control using the base service and the same regression: 3 failures / 1 pass. It reports count 32, leaves two descendants with a promoted root, keeps deep discussion/run/review/files, and overcounts a cyclic tree (43 rather than 3).
  • Deep chains and wide trees at 1,000 and 5,000 tasks: all four delete fully with exact counts, no remaining rows, zero rollups and a 5-second per-statement ceiling. Measured deletion times: deep 1,000 = 1.447s; deep 5,000 = 2.338s; wide 1,000 = 0.624s; wide 5,000 = 3.767s. Scale probes bulk-seed valid rows; the registered regression separately uses createTask for the full 35-task chain.
  • Exact-head targeted server suite: 15 files / 145 tests pass, one worker (task service suites, retirement, project deletion and integration-scope guard). Scoped formatting and oxlint on the 3 changed TS files pass; diff whitespace check passes.

Scoped TypeScript also passes with zero diagnostics: only the 3 changed TS roots, their imports and the repository's existing PDF-worker ambient declaration, with a 2304 MiB heap cap. The first scoped attempt omitted that declaration and reported TS7016; including the normal repo declaration resolves the harness omission without source changes.

Unrun/limits: no whole platform suite, whole-workspace typecheck, browser, E2E, container, production test, actual agent host, external provider or object-store-byte reclaim. Cancellation fixtures are queued/waiting; durable release enqueue and the worker's metadata behavior are proven/inspected, not live blob destruction. No high-contention concurrency stress or unbounded-tree benchmark. Hosted CI is still pending; acceptance is not a green-CI, merge, deployment or native task-completion receipt. No push, merge, card movement or CI rerun/cancellation.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Updated with main (merge lane TALE-628, agent #2 3f9fdcee, run d15b16b4): register row only, no source change

  • New head b3455373a8e21e81c68da0bddb938a381bb8b693, Merge remote-tracking branch 'origin/main' into fix/delete-entire-task-subtree. Its parents are the reviewed head e17a711b2392c5c44d6df5e3b15d48b9879aabae and main ffa15e019c3b6453bfb82dc44231abef2b8be0de. I pushed it at 09:43:50Z as a fast-forward; no history was rewritten.
  • Only conflict: services/platform/tests/manual/reference/automation.md. This PR and main (a9a19afdc) both appended a row at the end of the file.
    • Every main line is kept, and this PR's row text is byte-identical.
    • The row now sits beside the related [tasks] row "Upgrading shipped recurring tasks preserves membership across deleted roots…" (line 720), not at the file end, so it joins that row's group.
    • The blank line this PR put before its row was dropped.
  • Proof (local, git plumbing):
    • Against the new main, delete-subtree.integration.ts, service.ts and integration-check.ts change exactly what was reviewed (per-file +/- equal). automation.md differs only by that dropped blank line.
    • git merge-tree: the new head composes cleanly with all 34 open register PRs that are clean against main. Left at the file end, the row would conflict with fix(platform): preserve provider-specific usage ledger buckets #4241.
    • lint:manual (1,448 boxes) and lint:conflicts exit 0, and git diff --check is clean.
  • Acceptance carry-over: TALE-555's ACCEPT (review 5404342867, at e17a711b) covers the source. This update changes no reviewed line except the row's position.
  • CI: every check at e17a711b had finished green, so nothing was cancelled. At b3455373, Commitlint 37193090769, Checks 37193090799, Build 37193090792, E2E 37193090801 and SAST 37193090774 are queued. The merge needs all of them green at this exact head. No rerun or cancel.

@yannickmonney
yannickmonney merged commit 055d75f into main Oct 4, 2026
@yannickmonney
yannickmonney deleted the fix/delete-entire-task-subtree branch October 4, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Deleting a task subtree deeper than 32 leaves descendants as root tasks

1 participant