Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .scratch/agent-collaboration-tools/acceptance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Independent collaboration acceptance

PASS+NOTES for `ece0b569a7765a6f559f8fdf8d0604abc9491772`. A fresh verifier checked the real model and Feishu workflow, durable SQLite inputs, provider readback, and process shutdown.

The run used a clean detached checkout at `/Users/developer/IdeaProjects/agent-loop-collab-verify`. It started at `2026-11-20T22:09:16.574+08:00` and ended at `2026-11-20T22:13:28.110+08:00`.

```sh
npx --no-install tsx scripts/verify-collaboration.ts --config /Users/developer/IdeaProjects/agent-loop/config.json --env-file /Users/developer/IdeaProjects/agent-loop/.env --real-feishu --timeout-ms 600000 --evidence-dir /tmp/agent-loop-collaboration-live-ece0b56
```

The real lane used CodexAppServer, AgentLoop, SQLite, WorkspaceProvider, FeishuAdapter, and actual Feishu messages. Credentials came from the named configuration and environment file. Their contents are omitted. No production service, production database, existing group content, or Feishu WebSocket was used.

The observed sequence was:

1. One no-group Worker read the unique proof file and called `send_agent_message` once. The coordinator received durable input `agent-message:01997c7f3c7d6f4cb42c9e62d3f8cfc853ba31d82e73f1036e177fa07932e2b8` through `steer` at `2026-11-20T22:10:48.429+08:00` while the Worker original turn was active.
2. The coordinator recorded the marker at `2026-11-20T22:11:02.806+08:00`, before the Worker final. Its explicit ACK appeared in the coordinator group.
3. The Worker opened its own group. Ordinary commentary, question, and final text appeared once each without Worker `send_group_message` calls.
4. The coordinator scheduled one reminder for `2026-11-20T22:11:44.560+08:00`. It fired at `2026-11-20T22:11:44.771+08:00`, reached the original coordinator Thread, and triggered a record plus visible reminder reply.
5. A direct question injected through `AgentLoop.receive` triggered an explicit group reply. This input was synthetic. No real human webhook receipt is claimed.
6. Actual coordinator final answers contained the hidden marker, which was absent from both groups. The Worker did not copy that marker. Three repeated ticks created no extra calls or reminder inputs.

The new groups remain available for review:

| Role | Group name | Group ID |
| --- | --- | --- |
| Coordinator | Agent Loop 协作验收 1795183756574-2ec18db3 协调者 | `oc_fe058a81dfd7f4547ea2de1d05e58be6` |
| Worker | Agent Loop 协作验收 1795183756574-2ec18db3 Worker | `oc_6ea974c0c9f0efbb5622f68e9c3b8cf0` |

The independent Feishu readback found 15 messages and matched all 13 acknowledged provider receipts. Each marker below appeared exactly once:

| Marker | Provider message ID |
| --- | --- |
| `ACK_1795183756574-2ec18db3` | `om_x100b7f31010280a4b0795e239c78b8c` |
| `REMINDER_1795183756574-2ec18db3` | `om_x100b7f311995a8acb09f84a9e3da27d` |
| `DIRECT_REPLY_1795183756574-2ec18db3` | `om_x100b7f3116ec74a0cd03441667ac13c` |
| `WORKER_COMMENTARY_1795183756574-2ec18db3` | `om_x100b7f311e9650a4b3734484517a997` |
| `WORKER_QUESTION_1795183756574-2ec18db3` | `om_x100b7f311e797ca4ce77a578fc0ef1a` |
| `WORKER_FINAL_1795183756574-2ec18db3` | `om_x100b7f311e0f60accebcf96c0317589` |

The actual database contains two tasks, five delivered inputs, and one fired reminder. `PRAGMA integrity_check` returned `ok`. Source and fixture fingerprints match the run start. The checkout remains clean.

The separate dashboard check used the same source SHA, actual HTTP serving, Chromium, SQLite, and WorkspaceProvider with fake model and chat transports. It displayed `已记录完成,仍可继续` with `未请求清理`, then preserved the completion history while displaying `已清理` after removal of its temporary marker artifact. `dashboard-before.png` and `dashboard-after.png` record both rendered states.

The probe closed its Runtime and native process PIDs `52624`, `60795`. Direct PID checks found them absent. Chromium PID `52750` is absent, and `http://127.0.0.1:64122` has no listening socket. Test groups, Codex Threads, and the fixture remain retained.

The previous failed run remains separately recorded under `/tmp/agent-loop-collaboration-live-680e3da`. Its two test groups also remain retained.

Limits remain: the direct-question input was synthetic, and the live marker flow did not test old-data migration, pause or restart races, completed-task continuation, or resource cleanup. Dashboard acceptance used fake model and chat transports. This record does not claim deployment acceptance.

Raw evidence remains in `/tmp/agent-loop-collaboration-live-ece0b56`. `independent-verdict.json` indexes the proof, provider receipts, process checks, and raw files. `summary.json`, `calls.json`, `execution.json`, `runtime.json`, `database-independent.json`, `feishu-reconciled.json`, and `dashboard.json` contain the detailed evidence.
32 changes: 32 additions & 0 deletions .scratch/agent-collaboration-tools/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Collaboration implementation contract

Use design A as the base, with B’s explicit migration dispositions, live group receipt identity and paginated reminders. Both candidates selected the direct inbox/outbox shape and rejected a second replay journal. The lead initially scored both 10/10. Independent read-only GPT-6.2 Astra scored A 10/10 and B 9/10 because B’s schematic reminder union omitted immutable identity fields. The implementation includes those fields. The reviewer’s crash-window finding becomes an explicit acceptance test: restart after transaction commit but before scheduling must deliver the persisted input once. The pending inbox is the durable wake record; no second wake marker is required if recovery proves that behavior.

## Agreed public contract

- Three native tool names: project_action, send_agent_message, send_group_message. Strict schemas derive types and JSON schemas. The latter two have independent validated capability fallback ingress for retained Threads. No callable send/report/deliver_result/announce management aliases.
- Agent message arguments: requestId, taskId, text, optional references. taskId is the recipient, matching existing naming. Caller identity comes from the authenticated transport. Coordinator↔own Worker only.
- Group message arguments: requestId and text. The caller's verified current group is pinned at acceptance. Native questions, approvals, permissions and request_decision remain distinct.
- Reminder management: schedule_reminder(requestId,dueAt,text), list_reminders(offset?,limit?), cancel_reminder(requestId,reminderId). Owner comes from caller. dueAt is a finite, safe epoch millisecond in the supported date range. Overdue accepted values fire on the next due scan.
- Cleanup: cleanup_artifacts gains taskId and explicit scopeIds. Only coordinator can clean self or own Worker resources, including completed ones. complete_task persists conclusion/history without cleanup.

## Ownership

ProjectRuntime owns identity and durable operation acceptance. Store inbox/outbox own transport state. A small indexed reminder table owns schedule/cancel/fire; one transaction inserts its input and marks fired. AgentLoop owns nonblocking scheduling, pause/recovery, and original Thread input. TaskCloseout owns completion history and physical cleanup admission.

## Chosen grafts and constraints

- From A: keep taskId and require own ID for Worker open_group; avoid a new optional-target interpretation. Schedule recipient sweep without awaiting another Agent lane.
- From B: no post-upgrade publication from an unpublished old declaration. Archive it with an explicit disposition; accepted existing inbox/outbox rows keep original IDs and recovery. Retain uncertain outcomes visibly. Do not inspect historical final text to invent messages.
- From both: settle old implicit completion cleanup before recovery; retain completed history and partial deletion evidence, stop untouched implicit targets. A new explicit cleanup may use the exact preserved target identity.
- From both: fresh worktree acquisition after cleanup needs a persisted generation so old resource tombstones and frozen cleanup cannot target the replacement.
- Keep the current two-argument project-client management invocation usable; add a named-tool argument for message calls. The old business actions themselves are rejected.
- Migrate exact known Runtime-generated prompt fragments only. Preserve user goals, decisions and explicit restrictions. New developer/input context supersedes obsolete tool directions in retained conversations.

## Parallel implementation

1. Messaging branch owns tickets 01–04, protocol/fallback changes, both production role prompts, project runtime legacy result migration, affected existing tests and executable sample callers.
2. Reminder branch owns ticket 05, reminder persistence/provenance, narrow project action additions, tick/recover due scan, focused tests.
3. Lifecycle branch owns tickets 06–07, TaskCloseout migration/history, original Thread continuation, resource generation, dashboard projection and focused tests. It uses existing send tests on its base; integration migrates those calls to the new message API.

Each branch works from b053f4d in a different worktree. Integrate messaging first, reminders second, lifecycle third. Resolve shared schema/loop/runtime changes deliberately. Each branch records tests and remaining integration concerns. Final acceptance checks the combined native tools, retained Threads, actual Codex behavior, and isolated resource transitions.
10 changes: 10 additions & 0 deletions .scratch/agent-collaboration-tools/baseline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Baseline

Base commit: b053f4d0268e02213e07ea61d7a1cfa7db0049a3.

- npm run check passed.
- npm test ran 765 tests: 764 passed, 1 failed.
- The failure also reproduces when running only test/worker-execution-identity.test.ts. The case named “an adopted historical Worker blocks before unavailable saved resources can change its state” expects running but sees failed. The recovery path touches saved resources before the historical identity boundary. This predates the collaboration implementation.
- PR 66 changes the old report/final suppression path, which this specification replaces with distinct Agent and group tools. PR 68 changes closeout projection and dashboard presentation. Both were open at baseline inspection; neither branch was imported or modified.

Raw local logs: /tmp/agent-loop-collaboration-baseline.log and /tmp/agent-loop-collaboration-baseline-identity.log.
20 changes: 20 additions & 0 deletions .scratch/agent-collaboration-tools/decisions.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ts phase decision why evidence result
2026-11-20T13:23:13Z frame Use an isolated worktree and one integration PR for the approved eight tickets Existing checkout contains unrelated work; message and lifecycle APIs must migrate together .scratch/agent-collaboration-tools/implementation-plan.md open
2026-11-20T13:23:13Z grounding Reuse durable inbox delivery and preserve independent cleanup resource checks The approved spec changes workflow ownership, not runtime identity or resource ownership .scratch/agent-collaboration-tools/spec.md open
2026-11-20T13:23:13Z forge Use gh for PR and merge operations Origin CLI is not installed; GitHub repository is resolved https://github.com/mingtaojin/agent-loop verified
2026-11-20T13:24:19Z baseline Capture the reproducible historical identity recovery failure before implementation Separate existing behavior from regressions introduced by the migration .scratch/agent-collaboration-tools/baseline.md 764/765 tests pass; typecheck passes
2026-11-20T13:32:29Z acceptance Create a dedicated test project and Feishu groups for marker-only acceptance User explicitly selected new isolated test project and groups; production groups are excluded .scratch/agent-collaboration-tools/implementation-plan.md authorized; not yet executed
2026-11-20T13:32:59Z architecture Select A with B migration and receipt details after independent design comparison Both favor one transport owner; reviewer requires commit-before-schedule restart proof .scratch/agent-collaboration-tools/design-review.md design accepted; implementation verification pending
2026-11-20T13:38:05Z reminders Finish durable self reminder slice on isolated branch Atomic due transition reuses existing inbox and pause recovery 81b6eb3 typecheck and 127 focused tests pass; integration pending
2026-11-20T13:56:30Z integration Integrate named tools, reminders and lifecycle with shared fresh-input semantics New agent_message and reminder inputs must reopen original completed Workers without reviving old runtime event routes 680e3dabb9292ada2480a6d81a77385593e023c4 typecheck and 174 combined tests pass
2026-11-20T14:03:00Z verification Complete the serial suite after adjusting only the fake daemon startup budget The one-second fixture timed out under the full suite; the same case passed alone on baseline and head /tmp/agent-loop-collaboration-full.log 769/769 pass
2026-11-20T14:03:00Z review Fix three continuation edge cases identified by independent source review before shipping New Agent and reminder input must survive failed turns, completion while paused, and delayed provider timestamps /tmp/agent-loop-correctness-review.out regression reproduction and fixes in progress
2026-11-20T14:03:00Z acceptance Make the marker-only fixture explicitly keep both tasks open The first real run proved active delivery but stopped when the coordinator attempted completion outside the fixture allowlist /tmp/agent-loop-collaboration-live-680e3da/summary.json first run failed; runtime result not claimed as full pass
2026-11-20T14:09:20Z review Integrate the three reproduced continuation corrections Six regression scenarios failed before the change and passed after it; legacy suppression and delivered-message history remain intact 1f2c67c 202 related tests pass; final full suite pending
2026-11-20T14:09:20Z acceptance Correct fixture role boundaries, shell parsing and failure readback before a fresh real run The first run exposed fixture omissions; neither its exit nor partial provider evidence establishes full acceptance ece0b569a7765a6f559f8fdf8d0604abc9491772 typecheck and build pass; independent live rerun started
2026-11-20T14:11:25Z verification Pass the final full serial suite and built CLI on corrected runtime All continuation regression cases must pass with the full existing suite /tmp/agent-loop-collaboration-final-full.log 775/775 tests pass; typecheck build and CLI help pass
2026-11-20T14:18:14Z review Accept independent source re-review of corrected runtime The reviewer confirmed all three continuation fixes and preserved legacy and attachment semantics /tmp/agent-loop-final-review.out PASS+NOTES; source-only review
2026-11-20T14:18:14Z acceptance Accept the fresh real Codex and Feishu run on ece0b56 Independent provider readback matched 13 receipts and marker cardinality; actual SQLite and process state were checked .scratch/agent-collaboration-tools/acceptance.md PASS+NOTES; synthetic direct input and separate fake-transport dashboard lane disclosed
2026-11-20T14:18:14Z publication Open ready PR 70 targeting main User explicitly authorized PR and main merge; merge waits for independent passing verdicts https://github.com/mingtaojin/agent-loop/pull/70 OPEN; ece0b56; no merge conflict
2026-11-20T14:19:50Z audit Replace the unbounded trail audit with a fixed transcript excerpt and named evidence The first reviewer repeatedly reread a growing transcript without producing a verdict; a frozen scope allows a finite audit /tmp/agent-loop-audit-transcript-excerpt.txt fresh read-only GPT-6.2 Astra audit running
2026-11-20T14:20:56Z audit Resolve the independent trail audit documentation flag The first-run summary must state the omitted coordinator marker, Worker marker leakage and unexecuted synthetic question .scratch/agent-collaboration-tools/trail-review.md PASS+NOTES; documentation flag resolved
Loading