Files
PaperClipAI/tests
DottaandPaperclip 1a36a8f3c0 fix(e2e): wait for agreeing dependency run observations (#22802)
## Thinking Path

> - Paperclip lets people manage AI agents and their work.
> - A blocked task must start once after its blocker is complete.
> - The dependency journey checks this through task and agent run reads.
> - These independent reads can see the same run at different stages of
completion.
> - The collector can stop while the agent read still says `running`.
> - This pull request waits for both reads to agree before it saves the
finished and reopened points.
> - The test can then measure the completed work with the existing
strict rules.

## Linked Issues or Issue Description

**What happened?**

The dependency journey can report `dependency_one_automatic_resume`
after one correct automatic run. Its completion wait accepts the task
run as `succeeded` while the agent run read still says `running`. A
later read agrees, but the saved finished point remains split.

**Expected behavior**

Wait for matching task and agent run facts within the existing campaign
deadline. Keep the two observations independent. Fail if they never
agree.

**Steps to reproduce**

Use the flow fixture to return a completed task run and a lagging agent
run detail. Run the new `agent detail still running after task detail
completed` case against the old collector. It fails with
`dependency_one_automatic_resume`.

**Paperclip version or commit**

Base: `3ca9b6d471e100fe248c650f30453db4d3bc55fb`.
Related: #21732 added valid wake producers. That repair is already
present and does not address this read timing error.

## What Changed

- Compare task and agent run facts with the same normalized facts used
by the grader.
- Require agreement before the collector ends its completion wait and
after it reopens the result.
- Tag fixture projections explicitly, with separate agent lag counters
before and after reopening.
- Share the full settled predicate between both waits; agreeing stale
reads cannot count as completion.
- Add temporary and permanent cases for agent lag, task-only and
agreeing stale run views, task status, missing document, active locks
and native phase.
- Document the completion wait. Keep the grader, run budget and deadline
unchanged.

## Verification

- Red: the new lagging-read regression fails on the base collector with
`dependency_one_automatic_resume`.
- Green: three focused dependency suites pass, 126 tests. This includes
permanent disagreement, duplicate or unrelated runs, early execution,
history and output checks.
- Command: `node /tmp/pap5740-test-tools/node_modules/vitest/vitest.mjs
run --config /tmp/pap5740-test-tools/vitest.config.mjs`. The temporary
config selects
`tests/runner-e2e/product-journeys/task-dependency-resume*.test.ts`.
Tools: Vitest 5.0.3, Playwright 1.62.1 and Zod 4.
- `pnpm verify` could not run: the managed Git storage guard rejects
`git ls-files` with `paperclip_git_storage_limit`. CI must supply
broader checks.
- No new paid journey was run. Staging acceptance remains open. No
reviewed harness pin was changed.
- Follow-up commit: `16bb94c256769fe76b014e865259b742b35773ea`. The
reopened-only regression fails on the prior commit with
`dependency_one_automatic_resume`; it passes after this repair.
- Second follow-up: `45d60118fb36fd1f426e088f263d04c91484cfee`. Ten of
twelve new stale-state cases fail on `16bb94c`; all pass after sharing
the settled predicate.
- Exact finished-run binding:
`24d7b2f67a9f51ac6d996211f651a92772ff2a55`. Both reopened projections
must match the normalized saved finished-run facts. Two additional
agreeing-but-different run-facts cases fail before this change and pass
afterward.
- CI and Greptile passed on `16bb94c`; reviews also cleared `45d6011`.
Fresh CI and reviews are pending on `24d7b2f`.

## Risks

Low risk. A mismatch now uses the remaining campaign wait rather than
reaching the grader early. Permanent disagreement still fails at the
deadline. This change does not start another agent run, alter production
state, replace either independent read, or relax the grader.

## Model Used

OpenAI GPT-6 through Codex, with reasoning and code execution. The
runtime did not expose a more specific model ID.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-24 13:34:14 -06:00
..