Skip to content

Commit 7a63980

Browse files
committed
feat(agent): harden agentic flow planning
1 parent 80e320e commit 7a63980

48 files changed

Lines changed: 1683 additions & 200 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/context/app.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ The `@coop/app` package serves two purposes: (1) the public landing page for Coo
99
```
1010
packages/app/src/
1111
main.tsx # Vite entry point, mounts <App />
12-
app.tsx # Root router (~800 lines): landing, pair, receiver, inbox, board
13-
pairing-handoff.ts # URL payload extraction for /pair route
12+
app.tsx # Root router: landing, app receiver routes, legacy receiver routes, board
13+
receiver-routes.ts # Canonical /app/* receiver routes and legacy aliases
14+
pairing-handoff.ts # URL payload extraction for receiver pairing routes
1415
board-handoff.ts # URL payload extraction for /board/:coopId route
1516
views/
1617
Landing/index.tsx # Static landing page with ritual guide
@@ -23,10 +24,13 @@ Routes are path-based, resolved from `window.location`:
2324

2425
| Path | Component | Purpose |
2526
|------|-----------|---------|
26-
| `/` | Landing | Product story, setup ritual guide |
27-
| `/pair` | Receiver pairing | Accept pairing via URL payload |
28-
| `/pair` (after pairing) | Receiver capture | Audio/photo/file capture UI |
29-
| `/inbox` | Receiver inbox | Local capture list |
27+
| `/` | Landing or standalone receiver redirect | Browser landing page; installed PWA redirects to `/app/pair` or `/app/receiver` based on pairing |
28+
| `/landing` | Landing | Explicit product story route |
29+
| `/app` | Receiver app root | Installed PWA root; redirects into the active receiver state |
30+
| `/app/pair` | Receiver pairing | Accept pairing via URL payload |
31+
| `/app/receiver` | Receiver capture | Audio/photo/file capture UI |
32+
| `/app/inbox` | Receiver inbox | Local capture list |
33+
| `/pair`, `/receiver`, `/inbox` | Legacy receiver aliases | Legacy paths resolved by `receiverKindFromLegacyPath()` |
3034
| `/board/:coopId` | Board | React Flow visualization of coop state |
3135

3236
### Landing Page
@@ -104,9 +108,11 @@ export function bootstrapCoopBoardHandoff(targetWindow: Window): CoopBoardSnapsh
104108

105109
## Key Patterns
106110

107-
### All Logic in @coop/shared
111+
### All Domain Logic in Shared Public Surfaces
108112

109-
The app imports all domain logic from shared:
113+
The app imports domain and app-shell logic from shared public surfaces. App-specific receiver and
114+
landing helpers usually come from `@coop/shared/app`; package root imports are reserved for values
115+
that are deliberately exported from `@coop/shared`.
110116

111117
```typescript
112118
import {
@@ -115,7 +121,7 @@ import {
115121
buildCoopBoardGraph,
116122
connectReceiverSyncRelay,
117123
createReceiverSyncEnvelope,
118-
} from '@coop/shared';
124+
} from '@coop/shared/app';
119125
```
120126

121127
The app contains no business logic of its own. It only has view components, routing, and handoff utilities.
@@ -151,13 +157,13 @@ The app uses plain CSS with class-based styling. Key class naming:
151157
- **Never add routing libraries**. Routes are path-based with manual resolution. Keep it simple.
152158
- **Never add state management libraries**. The app uses React `useState`/`useEffect` directly.
153159
- **Never define domain logic in the app**. Import from `@coop/shared`.
154-
- **Never import from `@coop/shared` deep paths**. Use the barrel export.
160+
- **Never import from `@coop/shared` deep paths**. Use `@coop/shared`, `@coop/shared/app`, or another exported package subpath.
155161

156162
## Key Files
157163

158164
- `app.tsx` — Root component with routing, receiver flows, sync management
159165
- `views/Landing/index.tsx` — Static landing page
160166
- `views/Board/index.tsx` — React Flow board visualization
161-
- `pairing-handoff.ts` — URL payload extraction for /pair
167+
- `pairing-handoff.ts` — URL payload extraction for `/app/pair` and legacy `/pair`
162168
- `board-handoff.ts` — URL payload extraction for /board/:coopId
163169
- `main.tsx` — Vite entry point
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Context For Agentic Flow Hardening
2+
3+
## Existing References
4+
5+
- Transcript review from the Syntax agentic-coding-flow video.
6+
- `.plans/features/ai-native-dev-workflow/` for ledger, scorecard, adversarial-review, and closeout precedent.
7+
- `.plans/adr/ADR-009-agentic-development-friction.md` for scarce-review-attention and human-judgment-callout rationale.
8+
- `.plans/README.md` for canonical feature pack shape, lane statuses, and plan validation.
9+
- `DESIGN.md`, `AGENTS.md`, and `CLAUDE.md` for design and agent guidance.
10+
11+
## Relevant Codepaths
12+
13+
- `.plans/templates/feature/` and `.plans/templates/status.json`
14+
- `.plans/how-can-we-improve-cuddly-kahan.md`
15+
- `packages/shared/src/contracts/schema-sync.ts`
16+
- `packages/shared/src/sync-config.ts`
17+
- `packages/api/src/routes/sync.ts`
18+
- `packages/api/src/ws/handler.ts`
19+
- `packages/api/src/ws/types.ts`
20+
- `scripts/plans.ts`
21+
- `scripts/check-agentic-flow.ts`
22+
- `.claude/context/app.md`
23+
- `DESIGN.md`
24+
25+
## Constraints
26+
27+
- Advisory first: the import-boundary check must exit `0` by default and fail only with `--strict`.
28+
- Preserve current API/WS wire shapes and fallback/drop behavior.
29+
- No Dexie/Yjs persisted-state changes.
30+
- No new UI framework, package-local tokens, package-specific `.env`, or CI-blocking gate.
31+
- Keep `.plans` and `status.json` as execution truth; do not add a parallel workflow ledger.
32+
33+
## Notes For Agents
34+
35+
- Claude should focus on the readability and usefulness of extension design guidance and app route context.
36+
- Codex should focus on templates, schemas, advisory checks, API/shared parsing, and plan validation.
37+
- Shared assumption: this pass hardens the workflow without changing end-user product behavior.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Implementation Notes For Agentic Flow Hardening
2+
3+
## What Changed
4+
5+
- Added the canonical `agentic-flow-hardening` feature pack and migrated the last flat landing polish note into `landing-closing-polish`.
6+
- Added `Agent Readiness` to feature specs, a docs lane template, and schema/migration preflight prompts in implementation lanes.
7+
- Added shared Zod contracts for ICE config responses, ICE rate-limit errors, and signaling messages.
8+
- Updated API, WebSocket signaling, and shared ICE config fetch parsing to consume those contracts while preserving existing wire shapes.
9+
- Added advisory `check:agentic-flow`, wired it into `agentic:check`, and hardened it after review to scan package source and tests with AST-based import extraction.
10+
- Updated extension design guidance and app route context to reduce stale routing/CSS guidance.
11+
12+
## Why It Changed
13+
14+
- The first import-boundary pass needed to stay advisory, but review showed that advisory visibility is only useful if it catches common import forms and package-level tests.
15+
- Existing QA templates had pass ownership drift. The hardening pass now keeps Codex QA pass 1 and Claude QA pass 2 aligned across templates and migrated packs.
16+
- The app route table was corrected first, then adjacent app-context import and pairing-route wording was tightened so agents do not follow stale examples.
17+
18+
## Follow-Ups
19+
20+
- Consider wiring `check:agentic-flow --strict` into CI only after advisory output has been watched on several real feature packs.
21+
- Run the normal sequential QA handoff branches before treating the pack as fully closed.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# QA Report For Agentic Flow Hardening
2+
3+
## Pre-Handoff Review
4+
5+
- Status: findings addressed in the hardening pass
6+
- Commands:
7+
- `bun run plans:validate`
8+
- `bun run plans:legacy`
9+
- `bun run check:agentic-flow`
10+
- `git diff --check`
11+
- Findings:
12+
- Hardened `check:agentic-flow` to scan package source and tests, including package-level test directories outside `src`.
13+
- Replaced regex-only import detection with TypeScript AST-based import extraction so multiline imports, exports, dynamic imports, and `require()` calls are visible.
14+
- Corrected QA ownership drift in templates and migrated feature specs so pass 1 is Codex and pass 2 is Claude.
15+
- Tightened `.claude/context/app.md` guidance around `@coop/shared/app` and receiver pairing routes.
16+
17+
## QA Pass 1: Codex
18+
19+
- Status: blocked until `handoff/qa-codex/agentic-flow-hardening` exists
20+
- Commands:
21+
- Findings:
22+
23+
## QA Pass 2: Claude
24+
25+
- Status: blocked until Codex QA creates `handoff/qa-claude/agentic-flow-hardening`
26+
- Commands:
27+
- Findings:
28+
29+
## Residual Risk
30+
31+
- The import-boundary check is advisory by default. `--strict` exists for a future opt-in gate after the team has watched advisory output on real work.
32+
- Browser proof remains intentionally out of scope because this pass changed guidance, contracts, checks, and API parsing rather than rendered UI behavior.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
feature: agentic-flow-hardening
3+
title: Agentic Flow Hardening API lane
4+
lane: api
5+
agent: codex
6+
status: done
7+
source_branch: feature/agentic-flow-hardening
8+
work_branch: codex/api/agentic-flow-hardening
9+
depends_on:
10+
- ../spec.md
11+
- contracts.codex.todo.md
12+
owned_paths:
13+
- packages/api/src/routes/sync.ts
14+
- packages/api/src/routes/__tests__/sync.test.ts
15+
- packages/api/src/ws/handler.ts
16+
- packages/api/src/ws/types.ts
17+
- packages/api/src/ws/__tests__/handler.test.ts
18+
- packages/shared/src/sync-config.ts
19+
done_when:
20+
- iceConfigResponseSchema.parse
21+
- signalingMessageSchema.safeParse
22+
- fetchServerMintedIceConfig
23+
skills:
24+
- api
25+
- hono
26+
- contracts
27+
updated: 2026-05-26
28+
---
29+
30+
# API Lane
31+
32+
## Objective
33+
34+
Consume the shared sync/message schemas in API and shared client boundaries while preserving current behavior.
35+
36+
`done_when` should use concrete, searchable evidence strings that will exist under `owned_paths`
37+
when the lane is truly complete.
38+
Keep changes inside `owned_paths` where possible. If work spills beyond them, explain why in
39+
`Handoff Notes`.
40+
41+
## Files
42+
43+
- `packages/api/...`
44+
- Shared request/response contracts
45+
- Runtime message handlers if affected
46+
47+
## Tasks
48+
49+
- [x] Parse `/sync/ice` success and rate-limit payloads through shared schemas.
50+
- [x] Parse fetched ICE configs with shared schema and keep `null` fallback for invalid/unreachable responses.
51+
- [x] Parse WebSocket signaling messages through shared schema.
52+
- [x] Preserve tolerant drop behavior and publish passthrough fields.
53+
- [x] Add or update API tests.
54+
- [x] Keep work inside `owned_paths` or document justified spillover.
55+
- [x] Capture any migration or rollout notes.
56+
57+
## Verification
58+
59+
- [x] `vitest run packages/shared/src/contracts/__tests__/schema-sync.test.ts packages/api/src/routes/__tests__/sync.test.ts packages/api/src/ws/__tests__/handler.test.ts`
60+
- [x] `bun run validate:smoke`
61+
62+
## Handoff Notes
63+
64+
QA should verify that malformed JSON, missing type, invalid publish topic, non-string subscribe topics, publish passthrough, and ICE fallback behavior remain intact. No route or WebSocket message names changed.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
feature: agentic-flow-hardening
3+
title: Agentic Flow Hardening contracts lane
4+
lane: contracts
5+
agent: codex
6+
status: done
7+
source_branch: feature/agentic-flow-hardening
8+
work_branch: codex/contracts/agentic-flow-hardening
9+
depends_on:
10+
- ../spec.md
11+
owned_paths:
12+
- packages/shared/src/contracts/schema-sync.ts
13+
- packages/shared/src/contracts/__tests__/schema-sync.test.ts
14+
done_when:
15+
- iceConfigResponseSchema
16+
- signalingMessageSchema
17+
skills:
18+
- contracts
19+
- onchain
20+
- permissions
21+
updated: 2026-05-26
22+
---
23+
24+
# Contracts Lane
25+
26+
## Objective
27+
28+
Add shared sync/message Zod schemas and inferred types without changing public wire shapes.
29+
30+
`done_when` should use concrete, searchable evidence strings that will exist under `owned_paths`
31+
when the lane is truly complete.
32+
Keep changes inside `owned_paths` where possible. If work spills beyond them, explain why in
33+
`Handoff Notes`.
34+
35+
## Files
36+
37+
- `packages/shared/src/modules/onchain/...`
38+
- `packages/shared/src/modules/policy/...`
39+
- `packages/shared/src/modules/session/...`
40+
41+
## Tasks
42+
43+
- [x] Add ICE config response and rate-limit error schemas.
44+
- [x] Add subscribe, unsubscribe, publish, ping, and union signaling schemas.
45+
- [x] Export inferred TypeScript types from shared contracts.
46+
- [x] Add targeted schema tests.
47+
- [x] Keep work inside `owned_paths` or document justified spillover.
48+
- [x] Document any live-probe follow-up.
49+
50+
## Verification
51+
52+
- [x] `vitest run packages/shared/src/contracts/__tests__/schema-sync.test.ts packages/api/src/routes/__tests__/sync.test.ts packages/api/src/ws/__tests__/handler.test.ts`
53+
- [x] `bun run validate:smoke`
54+
55+
## Handoff Notes
56+
57+
Public contract callout: schemas document existing ICE/signaling shapes. No route, WebSocket message name, chain-mode, permission, or persisted-state changes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
feature: agentic-flow-hardening
3+
title: Agentic Flow Hardening docs lane
4+
lane: docs
5+
agent: codex
6+
status: done
7+
source_branch: feature/agentic-flow-hardening
8+
work_branch: codex/docs/agentic-flow-hardening
9+
depends_on:
10+
- state.codex.todo.md
11+
- contracts.codex.todo.md
12+
- api.codex.todo.md
13+
- ui.claude.todo.md
14+
skills:
15+
- docs
16+
- review
17+
updated: 2026-05-26
18+
---
19+
20+
# Docs Lane
21+
22+
## Objective
23+
24+
Consolidate durable guidance after the implementation lanes without duplicating the full feature spec.
25+
26+
## Files
27+
28+
- `AGENTS.md`
29+
- `CLAUDE.md`
30+
- `DESIGN.md`
31+
- `.claude/context/app.md`
32+
- `.plans/templates/feature/...`
33+
34+
## Tasks
35+
36+
- [x] Keep `.plans` and `status.json` as execution truth.
37+
- [x] Point UI/CSS agents at the extension appendix.
38+
- [x] Keep route context aligned with current app route constants.
39+
- [x] Keep `check:agentic-flow` documented as advisory by default.
40+
41+
## Verification
42+
43+
- [x] `bun run plans:validate`
44+
- [x] `bun run check:design-md`
45+
- [x] `bun run check:agentic-flow`
46+
47+
## Handoff Notes
48+
49+
Guidance is intentionally advisory except for existing DesignMD/token checks. No new blocking CI gate was introduced.

0 commit comments

Comments
 (0)