From 7bd654c978c95bc19280906bf850ff94c06497c7 Mon Sep 17 00:00:00 2001 From: Goon Date: Wed, 27 May 2026 14:16:17 +0700 Subject: [PATCH 1/2] plan(p6): add domain coverage P6 backend-unblocked CLI plan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirrors issue #16 scope (7 command surfaces) as 4 grouped implementation phases with TDD per the user's request. Backend evidence: digitopvn/goclaw PR #37 + PR #44. Verified beta tag containing PR #44 is v3.12.0-beta.20. Phases: 1. Scope Lock — contract re-verification, drift sweep 2. Traces Follow + Providers Reconnect (PR #37) 3. Sessions Branch + Follow (PR #44 chat) 4. Channels Writers Test (PR #44 channels) 5. Activity + Logs Runtime Aggregate (PR #44 aggregation) 6. Tests + Docs sweep with out-of-scope red-team 7. Ship Readiness — single PR to dev Out-of-scope list retained verbatim from issue #16: traces replay, generic logs aggregate, WS/SSE chat history, watch loops. --- .../phase-01-scope-lock.md | 60 ++++++++ ...2-traces-follow-and-providers-reconnect.md | 111 ++++++++++++++ .../phase-03-sessions-branch-and-follow.md | 115 ++++++++++++++ .../phase-04-channels-writers-test.md | 76 +++++++++ .../phase-05-activity-and-logs-aggregate.md | 114 ++++++++++++++ .../phase-06-tests-and-docs.md | 65 ++++++++ .../phase-07-ship-readiness.md | 70 +++++++++ .../plan.md | 144 ++++++++++++++++++ 8 files changed, 755 insertions(+) create mode 100644 plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-01-scope-lock.md create mode 100644 plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-02-traces-follow-and-providers-reconnect.md create mode 100644 plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-03-sessions-branch-and-follow.md create mode 100644 plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-04-channels-writers-test.md create mode 100644 plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-05-activity-and-logs-aggregate.md create mode 100644 plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-06-tests-and-docs.md create mode 100644 plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-07-ship-readiness.md create mode 100644 plans/260527-1412-domain-coverage-p6-backend-unblocked/plan.md diff --git a/plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-01-scope-lock.md b/plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-01-scope-lock.md new file mode 100644 index 0000000..dcec545 --- /dev/null +++ b/plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-01-scope-lock.md @@ -0,0 +1,60 @@ +--- +phase: 1 +title: "Scope Lock" +status: pending +priority: P2 +effort: "1h" +dependencies: [] +--- + +# Phase 1: Scope Lock + +## Overview + +Lock the 7-surface scope, re-verify backend contracts against `digitopvn/goclaw` `dev` tip, and produce the contract evidence file that subsequent phases reference. No CLI code changes. + +## Requirements + +- Re-fetch and read each backend handler to confirm path, method, query params, body shape, status enum, and error semantics. +- Confirm beta tag `v3.12.0-beta.20` is the minimum that contains PR #44 commit `43049d3b` (already verified during plan creation; phase re-asserts). +- Confirm no command-name collisions in current `cmd/` tree. +- Produce `reports/scope-lock-260527-p6.md` summarizing contracts and any drift discovered. + +## Implementation Steps + +1. From the `digitopvn/goclaw` checkout (or via `gh api`), read: + - `internal/http/traces.go` — locate the `traces/follow` handler. + - `internal/http/providers.go` — locate the `providers/{id}/reconnect` handler. + - `internal/http/sessions.go` — locate the branch and history/follow handlers. + - `internal/http/channel_instances.go` — locate the writers/test handler. + - `internal/http/activity.go` — locate the aggregate handler. + - `internal/http/logs.go` — locate the runtime/aggregate handler. + - `internal/http/openapi_spec.json` for any documented schema differences. +2. For each handler record: route, method, required vs optional inputs, response shape, status enum, error codes, admin-only flag. +3. Compare against `plans/reports/codex-prompt-260522-p6-pr44-backend-unblocked-cli.md` (lives on `feat/claude-skill-v0.1` worktree) and the plan overview. Flag any drift. +4. Re-verify beta tag: `gh api repos/digitopvn/goclaw/compare/v3.12.0-beta.20...43049d3b --jq '.status'` must return `identical`. +5. Re-verify no naming collisions: `grep -in 'Use:.*"follow\|reconnect\|branch\|aggregate\|test"' cmd/*.go`. +6. Write `reports/scope-lock-260527-p6.md` with the table of confirmed contracts. + +## Todo List + +- [ ] Backend contract re-read for all 7 endpoints. +- [ ] Drift table populated (or zero-drift confirmed). +- [ ] Beta tag re-confirmed. +- [ ] Naming collision sweep run with output captured. +- [ ] `reports/scope-lock-260527-p6.md` written. +- [ ] Phase status flipped to Complete. + +## Success Criteria + +- Zero unresolved contract questions before phase 2 starts. +- Scope file under `reports/` exists and is referenced from each implementation phase's "Evidence" section. + +## Out of Scope + +- Any CLI code change. +- Any test scaffolding (phase 2+). + +## Next Steps + +Proceed to Phase 2 (Traces Follow + Providers Reconnect). diff --git a/plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-02-traces-follow-and-providers-reconnect.md b/plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-02-traces-follow-and-providers-reconnect.md new file mode 100644 index 0000000..ffc5d3d --- /dev/null +++ b/plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-02-traces-follow-and-providers-reconnect.md @@ -0,0 +1,111 @@ +--- +phase: 2 +title: "Traces Follow + Providers Reconnect (PR #37 surfaces)" +status: pending +priority: P2 +effort: "3h" +dependencies: [1] +--- + +# Phase 2: Traces Follow + Providers Reconnect + +## Overview + +Implement two CLI surfaces from backend PR #37 (already in beta `v3.12.0-beta.16`+): polling-friendly trace follow and provider reconnect. Strict TDD — failing tests land before any Cobra command code. + +## Surfaces + +### 2.1 `goclaw traces follow` + +```bash +goclaw traces follow --session-key [--since ] [--limit N] [--include-spans] [--status ] [--channel ] [-o json|yaml|table] +goclaw traces follow --agent [same flags] +``` + +- Endpoint: `GET /v1/traces/follow` +- Require exactly one of `--session-key` or `--agent` (validate before HTTP call). +- Optional: `status`, `channel`, `since`, `limit`, `include_spans`. `since` must be RFC3339. +- Server default `limit=50`, max `200`. Don't enforce max client-side; let server respond. +- Response shape: + ```json + {"traces":[],"spans_by_trace_id":{},"server_time":"...","next_since":"...","limit":50} + ``` +- JSON/YAML: print full envelope. +- Table: rows like `traces list` — `TRACE_ID`, `AGENT`, `STATUS`, `DURATION_MS`, `INPUT_TOKENS`, `OUTPUT_TOKENS`, `COST`. +- **One request only. No watch loop.** + +### 2.2 `goclaw providers reconnect` + +```bash +goclaw providers reconnect [-o json|yaml|table] +``` + +- Endpoint: `POST /v1/providers/{id}/reconnect` +- Admin-only on backend; client sends no body. Do NOT send `{"verify":true}`. +- Do NOT add `--verify` flag; users call `goclaw providers verify ` separately if needed. +- Path-escape `` via existing helper. +- Response: + ```json + {"status":"reconnected","provider":{},"registry_updated":true,"cache_invalidated":true} + ``` +- Status enum: `reconnected`, `disabled`, `not_registered`. +- Table: `STATUS`, `REGISTRY_UPDATED`, `CACHE_INVALIDATED`, plus provider name/id if non-empty. + +## Files + +- Modify: `cmd/traces.go` — append `tracesFollowCmd` + register on `tracesCmd`. +- Modify: `cmd/providers.go` or new `cmd/providers_reconnect.go` (preferred — keep file < 200 lines per repo rule) — declare `providersReconnectCmd` + register on `providersCmd`. +- New: `cmd/traces_follow_test.go` +- New: `cmd/providers_reconnect_test.go` + +## TDD Sequence + +1. Write `cmd/traces_follow_test.go` with the failing tests below; run `go test ./cmd -run TracesFollow` and confirm red. +2. Implement `tracesFollowCmd` minimally until tests pass. +3. Write `cmd/providers_reconnect_test.go`; confirm red. +4. Implement `providersReconnectCmd`; confirm green. +5. `go vet ./... && go build ./...` clean. + +## Tests + +### `cmd/traces_follow_test.go` + +- Session-key target builds path `/v1/traces/follow?session_key=...&...`. +- Agent target builds path `/v1/traces/follow?agent_id=...&...`. +- Missing both target flags returns validation error before HTTP call. +- Setting both target flags returns validation error before HTTP call. +- Non-RFC3339 `--since` returns validation error before HTTP call. +- JSON output preserves `next_since` and `spans_by_trace_id`. +- Table output includes the seven required columns. + +### `cmd/providers_reconnect_test.go` + +- POST path is `/v1/providers/{escaped-id}/reconnect`. +- Request body is empty (server receives `Content-Length: 0` or empty JSON; assert no `verify` key). +- JSON output preserves `registry_updated` and `cache_invalidated`. +- Table output renders status + boolean columns. +- Provider ID with `/` or `:` is path-escaped (regression test for RT-02). + +## Todo List + +- [ ] Red tests for traces follow. +- [ ] `tracesFollowCmd` implemented + green. +- [ ] Red tests for providers reconnect. +- [ ] `providersReconnectCmd` implemented + green. +- [ ] `go vet` + `go build` clean. +- [ ] Phase status flipped to Complete. + +## Success Criteria + +- Both commands callable via `goclaw --help`. +- All new tests pass without skipping or relying on live server. +- No regression in existing `traces list`, `traces get`, `traces export`, or any `providers` subcommand. + +## Risks + +- Forgetting path-escape on provider ID (RT-02 lesson). Mitigated by explicit escape test. +- Accidentally adding `--verify` based on familiarity with `providers verify`. Mitigated by codex prompt's explicit prohibition + test asserting empty body. + +## Next Steps + +Phase 3 (Sessions Branch + Follow). diff --git a/plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-03-sessions-branch-and-follow.md b/plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-03-sessions-branch-and-follow.md new file mode 100644 index 0000000..63ab03f --- /dev/null +++ b/plans/260527-1412-domain-coverage-p6-backend-unblocked/phase-03-sessions-branch-and-follow.md @@ -0,0 +1,115 @@ +--- +phase: 3 +title: "Sessions Branch + Follow (PR #44 chat surfaces)" +status: pending +priority: P2 +effort: "3h" +dependencies: [2] +--- + +# Phase 3: Sessions Branch + Follow + +## Overview + +Implement the two chat-session surfaces from backend PR #44 (beta `v3.12.0-beta.20`+): branch a session at a message index, and cursor-based history follow. TDD. + +## Surfaces + +### 3.1 `goclaw sessions branch` + +```bash +goclaw sessions branch --up-to-index [--new-session-key ] [--label