Skip to content

fix(platform): refuse comment and dependency writes on archived tasks - #4219

Merged
yannickmonney merged 2 commits into
mainfrom
fix/archived-task-comment-dependency-gate
Oct 4, 2026
Merged

yannickmonney merged 2 commits into
mainfrom
fix/archived-task-comment-dependency-gate

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

What changed

The REST comment door refused an archived task with 403 TASK_ARCHIVED. The app's comment create, edit and delete, and its dependency add and remove, only checked the project's archive, so a stale client still changed an archived task's discussion and dependency graph (#3589). The app task read also answered canComment: true for every readable task, so the app still showed the composer and the Edit/Delete actions on an archived task.

All of these now go through the same archived-task gate, assertTaskNotArchived, in the domain. It runs after the access checks and before any write.

  • Comments (comments.ts)
    • A person's comment (appendTaskComment, so the app door, the REST door's backstop and the REST ask-answer mirror) refuses TASK_ARCHIVED when the task is archived.
    • Every edit and delete (assertCommentModifiable) refuses it too, for the author and for an admin moderating.
  • Dependencies (service.ts)
    • addTaskDependency refuses when either end is archived. The board offers neither, and an archived blocker's status no longer moves, so a new edge from it would block for good.
    • removeTaskDependency refuses when the blocked task is archived, since the edge is that task's record.
    • Dropping an archived blocker from an active task stays allowed. That is the board's own Blocks removal, and the only way to free the active task, because openTaskBlockerIds still counts an archived, open blocker.
  • Task read (getTask): canComment is now false for an archived task or an archived project, the two states every comment door refuses. The composer and the comment actions already follow this flag, so the app no longer offers verbs the server refuses. No frontend change was needed.

Decisions a reviewer may want to challenge

  1. Machine lanes are unchanged. A run's completion report, the agent task_comment tool, the workflow task.comment step, ask mirrors and retractions, and the overdue nudge still write to a task that was archived under them. Archiving cancels no run, and the sibling trusted writers (agentUpdateTaskStatusTrusted, outputs, priority) ignore the archive too. Refusing the completion report would roll back the whole settle, and the run would hang until the watchdog. Whether archiving should stop live work, or machine lanes should refuse too, is a separate product decision. A unit test pins today's behaviour ("still takes the report of a run working the task").
  2. Status codes per door stay as they were. The app door answers TASK_ARCHIVED with 400, as it already does for title, status, move, assign, reviewer, repeat and start. The REST door answers 403. Both refuse with the same code, and error-codes.md records the split as before.
  3. canComment now also reflects an archived project. The server already refused those comments with PROJECT_ARCHIVED, so the composer it showed there was a dead end of the same kind.

Sweep

  • Docs: one paragraph in docs/{en,de,fr}/platform/projects/tasks.md says what an archived task allows. The REST reference already documents 403 TASK_ARCHIVED for comments, and REST behaviour is unchanged.
  • Manual layer:
    • new boundary box TASK-B40 (the hidden composer and a stale tab's toast);
    • an automation.md row for the server half;
    • an error-codes.md row for the app door's 400.
  • No new user-visible strings: the stale-tab toast reads the refusal's own words through failureDetail, as the other archived-task refusals do.

How I verified it

Exact head 61a03dfea, base main 9b7463b70.

Unit, red on main, then green. I copied the final test files onto a main tree.

main 9b7463b this branch
comments.archived.test.ts + service.archived.test.ts 7 failed / 6 passed: every refusal case and the canComment read fail, every control passes 13/13 passed

Related suites: backend/domains/tasks/, rest/v1-tasks*, rest/v1-automations.asks, connectors/task-store, automations/store.terminal-asks, core/tasks/mentions and domains/sandbox, 92 files.

  • First pass: 5 failures in 3 files, all mocked task rows without archivedAt (real rows always carry it, null or a number) or a ./service.ts mock without the gate.
  • I fixed those fixtures.
  • The 5 affected comment suites then passed 20/20.

Real Postgres, both HTTP doors. I ran the new harness lane checkArchivedTaskWrites on a throwaway local Postgres 16 + pgvector with ITEST_LANES=checkArchivedTaskWrites. It drives:

  • the app door with a session;
  • the REST door with an API key;
  • the database read-back: messages, meta, comment count, updated_at, activity, audit rows and edges.
check main + lane only this branch
comment create / edit / delete on the archived task FAIL: app 200/none ×3; REST 403/TASK_ARCHIVED; title control 400/TASK_ARCHIVED; the task changed (activity 3→6, audit 3→8, message replaced); canComment=true PASS: app 400/TASK_ARCHIVED ×4; REST 403/TASK_ARCHIVED; nothing changed; canComment archived/active = false/true
dependency add (into / from) and remove FAIL: 200, 400/TASK_DEPENDENCY_CYCLE (the first add had landed), 200; edges changed PASS: 400/TASK_ARCHIVED ×3; edges unchanged
controls: drop an archived blocker from an active task, active-task verbs on both doors, restore → comment PASS PASS

The only other FAIL in both local runs is the boot check knowledge BM25 indexes verified at boot, which needs pg_search. The local cluster doesn't have it; CI's tale-db image does.

Gates on the changed files.

  • oxlint --type-aware: 0 diagnostics.
  • oxfmt --check: clean.
  • Scoped tsc --noEmit: exit 0. It covered the changed files plus routes.ts, v1-tasks.ts and integration-check.ts.
  • bun run lint:manual: ok.
  • check-guide.ts suites/tasks.md: OK.
  • Pre-commit: conflict markers, oxfmt and opengrep passed.

Not run here: the full platform suite, a whole-workspace tsc, browser/E2E, and the full backend:integration run. CI runs those. I didn't drive the hidden composer in a browser (TASK-B40 is manual).

Closes #3589

The REST comment door refused an archived task with TASK_ARCHIVED, but the
app's comment create, edit and delete and its dependency add and remove only
checked the project's archive, so a stale client still changed an archived
task's discussion and dependency graph (#3589).

- comments: a person's comment, and every edit or delete, now passes
  assertTaskNotArchived after the access checks and before any write. A
  run's own report still lands, like its status park.
- dependencies: adding refuses an archived task at either end; removing
  refuses when the blocked task is archived, and still drops an archived
  blocker from an active task.
- getTask answers canComment false for an archived task or project, so the
  composer and the comment actions follow the doors.

Proof: unit tests and the checkArchivedTaskWrites lane (app and REST doors
on real Postgres), red on main and green here. Docs (en/de/fr), TASK-B40
and the manual registers say what an archived task allows.

Closes #3589
@yannickmonney

Copy link
Copy Markdown
Contributor Author

ACCEPT — independent review, TALE-542 / TALE-135 / #3589

Exact reviewed head: 61a03dfead11535df1c300a1c7c5e5c7847e2158.
Reviewer: independent Codex review run; implementation is agent #6 53fe2a33 / run 138ad67b-ad4d-4187-b65e-04599978d636.

No blocking finding against TALE-135's acceptance criteria:

  • assertTaskNotArchived is applied in the domain before person-authored comment create, comment edit/delete, dependency add at either endpoint, and dependency removal when the blocked task is archived.
  • The app and REST comment doors use the same TASK_ARCHIVED domain code; the app's 400 versus REST's 403 status split is preserved and documented.
  • Refusal paths precede thread/message/meta, dependency, activity and audit writes. getTask.canComment is false for archived tasks and archived projects, while active and restored controls remain enabled.
  • The deliberate exception is coherent: dropping an archived blocker from an active blocked task remains allowed so the active task can be freed; trusted machine/run lanes remain unchanged as explicitly called out by the PR.
  • The new checkArchivedTaskWrites lane seeds state before archive, exercises both HTTP doors and database read-back, checks comments/dependencies/activity/audit invariants, and then checks active/restored controls.

Evidence reviewed: PR diff and author checkpoint/evidence on TALE-135, including the reported throwaway Postgres run of checkArchivedTaskWrites and the stated 21/21 unit results. I independently attempted the targeted server suites (comments.archived.test.ts, service.archived.test.ts, and directly affected comment/service suites), but the staged checkout's existing workspace dependencies fail during Vitest startup (z.object/z.enum/z.number undefined); no install or broad suite was run.

Unrun proof: no fresh local Postgres integration run, browser/manual TASK-B40, full suite, whole-workspace typecheck, build, or CI rerun/watch. This is an independent source/behavior ACCEPT record, not a merge, push, card move, or protected-human approval. Exact head was rechecked immediately before posting.

@yannickmonney

yannickmonney commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor Author

TALE-565 register-only merge repair: merged origin/main 67c724a54d851803b7c6204bc13241f527e9a6a1 without rebasing or force-pushing.

New head: 20ed22e95fd27ef0d5166d553a294037dfe1b7d9. Conflicted file: services/platform/tests/manual/suites/tasks.md. All boxes are preserved; the conflicted Cost header is reconciled to 123 boxes.

Interdiff: only the register merge (verified with git show --remerge-diff); no implementation edits beyond Git’s automatic merge. bun run lint:manual and bun services/platform/tests/manual/scripts/check-guide.ts services/platform/tests/manual/suites/tasks.md pass. Conflict-marker and whitespace checks pass; commit hooks pass (Markdown is excluded by the repository formatter).

Hosted CI is queued; no rerun or cancellation requested. No PR merge, review verdict or card move. Agent #2 owns exact-head verification and merge once CI is green.

@yannickmonney
yannickmonney merged commit b92fb05 into main Oct 4, 2026
@yannickmonney
yannickmonney deleted the fix/archived-task-comment-dependency-gate branch October 4, 2026 08:49
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: App comment and dependency writes bypass archived-task protection

1 participant