diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 902f8e89..03bb5415 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -1588,7 +1588,7 @@ Plans: **Requirements**: TBD **Success Criteria** (what must be TRUE): - 1. A `tide` corpus of the whole community surface (31 D-09: every route under `/_wave/api/v1/community`, the guest, push, bot and token routes and the webhook, 196 routes) is recorded from the PHP backend through `vue-wavepath-app` and `hubot-wavepath`, with hand-written cases for the routes no client calls, and replays green against PHP itself. + 1. A `tide` corpus of the whole community surface (31 D-09: every route under `/_wave/api/v1/community`, the guest, push, bot and token routes and the webhook, as parsed from `routes.php` at the recording commit, with the route count written into the manifest) is recorded from the PHP backend through `vue-wavepath-app` and `hubot-wavepath`, with hand-written cases for the routes no client calls, and replays green against PHP itself. 2. Every writing case of the corpus has a broadcast golden with all publications PHP sent for it, on any namespace (31 D-10), and outbound vendor calls are recorded as upstream sidecars. 3. The foundation slice (groups, members, invites, join, friends, realtime authorization) is `ported` in `sm-wavepath-app` and replays green, broadcasts included. A gate script reports the pending count of the remaining routes and fails closed. 4. Behaviour stays neutral to the other consumers of these plugins: `sm-bm-app` and `sm-demo-app` build and pass their tests with the released plugin versions (31 D-14). Framework READMEs and docs still name no application. @@ -1599,8 +1599,8 @@ Plans: Plans: **Wave 1** -- [ ] 31-01-PLAN.md — Tide core data contracts: relative masks, cookies, headers, labels, repeat and manifest reference -- [ ] 31-03-PLAN.md — `sm-wavepath-app` skeleton and fail-closed isolated PHP parity stack +- [ ] 31-01-PLAN.md — Tide core data contracts: relative-time and numeric-clock masks, cookies, headers, labels, bounded repeat and manifest reference +- [ ] 31-03-PLAN.md — `sm-wavepath-app` skeleton and fail-closed isolated PHP parity stack (pins resolved over every gitlink, Typesense) - [ ] 31-09-PLAN.md — Folded `vue-chat-layer` slash-command parity fix - [ ] 31-10-PLAN.md — Folded additive moderation seams for users, friend groups and attachment filenames @@ -1609,16 +1609,16 @@ Plans: - [ ] 31-08-PLAN.md — Folded OIDC PHP parity recording in `sm-oauthserver-plugin` **Wave 3** -- [ ] 31-04-PLAN.md — Scenario on both sides, 196 pending-route manifest, corpus checker, harness and fail-closed gate +- [ ] 31-04-PLAN.md — Scenario on both sides, derived pending-route manifest, corpus checker with consistency checks, harness and fail-closed gate **Wave 4** -- [ ] 31-05-PLAN.md — Full 196-route PHP recording with client provenance, publications, upstreams and green self-replay +- [ ] 31-05-PLAN.md — Full PHP recording of the derived inventory at pins resolved at recording start, with client provenance, publications, upstreams and green self-replay **Wave 5** - [ ] 31-06-PLAN.md — Foundation infrastructure: envelope, actor, buckets, contexts, resolvers, authorizers and realtime **Wave 6** -- [ ] 31-07-PLAN.md — Foundation handlers and lifecycle green: groups, members, invites, join, friends and phase gate +- [ ] 31-07-PLAN.md — Foundation handlers and lifecycle green: groups, members, invites, join, friends, CRT group summary with roots-only counts, and phase gate **Wave 7** - [ ] 31-11-PLAN.md — Unit tests last: tide, app foundation, parity/gate and folded-todo regression matrices diff --git a/.planning/phases/31-chat-polish-against-wavepath-clients/31-01-PLAN.md b/.planning/phases/31-chat-polish-against-wavepath-clients/31-01-PLAN.md index 9cf7a1f4..af00ce4c 100644 --- a/.planning/phases/31-chat-polish-against-wavepath-clients/31-01-PLAN.md +++ b/.planning/phases/31-chat-polish-against-wavepath-clients/31-01-PLAN.md @@ -16,38 +16,56 @@ files_modified: - modules/tide/manifest.go - modules/tide/rules_test.go - modules/tide/relative_smoke_test.go + - modules/tide/clock_smoke_test.go - modules/tide/additions_smoke_test.go - modules/tide/README.md - docs/services/parity-testing.md + - docs/console/utilities.md autonomous: true requirements: [SC-4, D-06, D-11, D-12] estimate: - tokens: 150000 - raw_tokens: 150000 - tasks: 2 + tokens: 185000 + raw_tokens: 185000 + tasks: 3 confidence: low must_haves: truths: - - "Tide core data contracts: relative masks, cookies, headers, labels, repeat and manifest reference is delivered against the frozen PHP corpus and locked decisions." + - "Tide core data contracts are delivered against the frozen PHP corpus and locked decisions: relative-time and numeric-clock masks, cookies, extra headers, client labels, bounded repeat with parallel warm-up, and the manifest reference." + - "A response whose `*_at` key carries an epoch integer, or whose clock key a step masks as `epoch-ms`, self-replays green against the same backend; a wrong clock shape (string against integer, seconds against milliseconds, a fraction) is still a diff (tide gap T-11)." + - "A manifest case can repeat its request up to `tide.MaxRepeat` times with up to `tide.MaxRepeatParallel` warm-ups in flight, so a 429 case reaches any rate bucket the corpus parser derives, including the largest one; only the final response is kept." - "Verification fails closed: missing, skipped, pending or mismatching evidence is not counted as a pass." - "D-16 remains intact: messaging, satellites, Range support, guest/bot/webhook host services, zero total pending and final security review stay in Phases 31.1/31.2." artifacts: - path: "modules/tide/normalize.go" - provides: "Tide core data contracts: relative masks, cookies, headers, labels, repeat and manifest reference" + provides: "relative-time mask (T-1) and numeric epoch-clock masks (T-11)" + - path: "modules/tide/flow.go" + provides: "Step.Repeat, Step.RepeatParallel, NormalizeRule.Mask, MaxRepeat, MaxRepeatParallel" + - path: "modules/tide/manifest.go" + provides: "RouteCase.Repeat, RouteCase.RepeatParallel, Manifest.Reference" key_links: - from: "modules/tide/normalize.go" - to: "the plan's automated verification" - via: "the named tracer and fail-closed checks" + to: "modules/tide/replay.go" + via: "maskLeaf applied to both sides of every replayed response body" + - from: "modules/tide/manifest.go" + to: "modules/tide/record.go" + via: "recordRoute copies Repeat and RepeatParallel into the step that RecordFlow sends" --- ## Phase Goal -WavePath's complete 196-route PHP community corpus is recorded and self-replays green; Phase 31 ports and proves only the 36-route foundation slice, leaving exactly 160 routes pending for Phases 31.1 and 31.2 per D-16. +WavePath's complete PHP community corpus is recorded and self-replays green: every route the corpus parser derives from `routes.php` at the commits resolved when the recording starts, plus the two realtime routes. Phase 31 ports and proves only the foundation slice listed in `parity/foundation-routes.txt`; every other corpus route stays pending for Phases 31.1 and 31.2 per D-16. Counts are derived at recording time and checked for consistency, never pinned (reference snapshot 2026-11-22, not a target: 218 tracked, 36 foundation, 182 pending). + +## Artifacts this phase produces (this plan) + +- `modules/tide/relative_smoke_test.go` with `TestRelativeTimeMaskSmoke`; `modules/tide/clock_smoke_test.go` with `TestNumericClockMaskSmoke`; `modules/tide/additions_smoke_test.go` with `TestCookieCaptureSmoke`, `TestExtraHeadersSmoke`, `TestClientLabelSmoke`, `TestRepeatSmoke`, `TestManifestReferenceSmoke`. +- Unexported in `modules/tide/normalize.go`: a `_human` key predicate and its mask (token `{{relative}}`), the epoch-integer branch of `maskDate`, the `epoch-ms` rule mask, constants `maskEpochMs` (``) and `maskEpochS` (``). +- Exported in `modules/tide`: `NormalizeRule.Mask` (yaml `mask,omitempty`, mode `epoch-ms`), `Step.Repeat` and `RouteCase.Repeat` (yaml `repeat,omitempty`), `Step.RepeatParallel` and `RouteCase.RepeatParallel` (yaml `repeat_parallel,omitempty`), constants `tide.MaxRepeat` (5000) and `tide.MaxRepeatParallel` (32), `Manifest.Reference` (yaml `reference,omitempty`). +- Capture source `response.cookie` in `extractCapture`; header modes `exact` and `present` for `Step.Headers` and `RouteCase.Headers`; the widened client-label rule in `rules.go`. -Tide core data contracts: relative masks, cookies, headers, labels, repeat and manifest reference. +Tide core data contracts: relative-time and numeric-clock masks, cookies, headers, labels, bounded repeat with parallel warm-up, and the manifest reference. -Purpose: preserve the frozen client/PHP contract while keeping this executor slice cohesive and within the authorized hybrid re-slice. +Purpose: preserve the frozen client/PHP contract while keeping this executor slice cohesive and within the authorized hybrid re-slice. Every addition is generic and names no application. Output: the artifacts and machine evidence named below. @@ -91,24 +109,58 @@ Output: the artifacts and machine evidence named below. - Task 4: Cookie captures, extra response headers, any client label, repeated requests and the manifest's reference revisions (tide gaps T-6, T-7, T-8, T-10; D-12) + Task 2: Numeric epoch clocks compare by shape (tide gap T-11) + Task 1 is committed: `go test -count=1 -run '^TestRelativeTimeMaskSmoke$' -v ./modules/tide/` prints `--- PASS: TestRelativeTimeMaskSmoke`. + modules/tide/normalize.go, modules/tide/flow.go, modules/tide/fixture.go, modules/tide/clock_smoke_test.go, modules/tide/README.md, docs/services/parity-testing.md + modules/tide/normalize.go (as Task 1 left it: maskLeaf, maskDate, isDateKey, disabledPath, carbonOffsetRe, the mask constants), modules/tide/normalize_upload_test.go (the case "date of the wrong type" with `{"updated_at":5}` that must keep producing one diff), modules/tide/normalize_test.go (the `client_id_issued_at` cases, masked before the date branch), modules/tide/flow.go (NormalizeRule), modules/tide/fixture.go (writeNormalize at line 241 and the strict loader), modules/tide/relative_smoke_test.go (Task 1's record/replay style), 31-RESEARCH.md "Drift D10" (T-11: epoch-millisecond `updated_at`, `server_time_ms`, epoch `last_read_at`) and assumption A16 + + - `TestNumericClockMaskSmoke`: a reference server answers `{"id": 1, "updated_at": 1763800000000, "seen_at": 1763800000, "server_time_ms": 1763800000123, "ring_ms": 30000}`; the step carries the rule `{path: server_time_ms, mask: epoch-ms}`. A port answering other 13-digit and 10-digit values at `updated_at`, `seen_at` and `server_time_ms` and the same `ring_ms` replays with no diff. + - A port answering `updated_at` as a Carbon `+00:00` string, or as a 10-digit integer, or as `1.5`, produces exactly one `Diff` at that path; a port answering `ring_ms` 25000 produces one `Diff` (a duration is compared exactly; no rule names it). + - Without the `epoch-ms` rule, two different `server_time_ms` values produce one `Diff` (the `_ms` suffix alone masks nothing); with the rule, a non-integer or a 10-digit value at that path is a `Diff`. + - A rule with an unknown `mask` value is a validation error when the flow or manifest is loaded; a flow saved with the rule loads again with the rule intact. + - A Carbon `+00:00` string (the `toIso8601String()` form, assumption A16) still masks as a date, and `{"updated_at":5}` still produces one diff. + + Per D-11 and D-12 (the corpus recorded at the resolved pins carries epoch-millisecond clocks in its responses, RESEARCH "Drift D10"). Generic; no application name in code, comments or docs. +1. Red first: `modules/tide/clock_smoke_test.go` with `TestNumericClockMaskSmoke` from the behavior block, in Task 1's record/replay style with neutral keys. Run it and see it fail. +2. `normalize.go`, `maskDate`: besides `nil` and the Carbon `+00:00` string, accept a `json.Number` that is a non-negative integer of exactly 13 digits (mask to a new constant `maskEpochMs`, value ``) or exactly 10 digits (mask to `maskEpochS`, value ``). Every other number (fraction, sign, other digit count) and every other type appends a `Diff` whose expected shape reads "Carbon +00:00 string, epoch integer or null" and returns the value unchanged. Masking different tokens for seconds and milliseconds keeps a unit change visible. +3. `flow.go`: add `Mask string` (yaml `mask,omitempty`) to `NormalizeRule`, documented with its one mode `epoch-ms`. `normalize.go`: in `maskLeaf`, after the `disabledPath` check, a rule whose path matches (same matching as `disabledPath`) and whose `Mask` is `epoch-ms` masks a 13-digit non-negative integer to `` and appends a `Diff` for anything else. A key ending in `_ms` without such a rule is compared as today. Refuse an unknown `Mask` value with a validation error where normalize rules of steps and manifest routes are loaded. +4. `fixture.go`: `writeNormalize` writes `mask` when set (F-9: a saved flow must load again). +5. `modules/tide/README.md` (Features "Replay and diff", API reference row of `tide.NormalizeRule`) and `docs/services/parity-testing.md` (the masking paragraph): epoch integers under `*_at` keys are compared by shape, seconds and milliseconds stay distinct, and a server clock key is masked only by an explicit `mask: epoch-ms` rule, with a neutral example. +6. Commit: `feat(tide): compare epoch clocks by shape`. + + go vet ./modules/tide/ && go test -count=1 -short ./modules/tide/ && go test -count=1 -run '^TestNumericClockMaskSmoke$' -v ./modules/tide/ 2>&1 | grep -q -- '^--- PASS: TestNumericClockMaskSmoke' + Non-zero exit: vet fails, an existing tide test fails (the "date of the wrong type" case or a round-trip test broke), or the `--- PASS: TestNumericClockMaskSmoke` line is absent. + go run ./cmd/summer docs:build --check 2>&1 | grep -q 'no problems found' + Non-zero exit: the docs checker reports an identifier or link that does not exist instead of `docs:build: no problems found`. + + + - `grep -c 'yaml:"mask,omitempty"' modules/tide/flow.go` prints 1 and `grep -c '' modules/tide/normalize.go` prints at least 1. + - `grep -c 'epoch-ms' modules/tide/README.md docs/services/parity-testing.md | awk -F: '{s+=$2} END {print s}'` prints at least 2. + - `go test -count=1 -run 'TestNormalize|TestRoundTrip' -v ./modules/tide/ 2>&1 | grep -c '^--- FAIL'` prints 0. + - `D="$(git diff 2acf8e4 -- modules/tide docs cmd/summer/parity.go)" && printf '%s\n' "$D" | grep '^+' | grep -ciE 'wavepath|_wave/|wave_guest|hubot|fonoteka'` prints 0. + + A response with epoch-millisecond clocks self-replays green against the backend that produced it, a unit or type change is still a diff, and a server clock is masked only where a step says so. + + + + Task 4: Cookie captures, extra response headers, any client label, bounded repeated requests and the manifest's reference revisions (tide gaps T-6, T-7, T-8, T-10; D-12) modules/tide/variables.go, modules/tide/record.go, modules/tide/replay.go, modules/tide/diff.go, modules/tide/rules.go, modules/tide/rules_test.go, modules/tide/flow.go, modules/tide/fixture.go, modules/tide/manifest.go, modules/tide/additions_smoke_test.go, modules/tide/README.md, docs/services/parity-testing.md, docs/console/utilities.md - modules/tide/variables.go (lines 20-40 the scrub patterns, 265-350 extractCapture, 685-750 the two uses of cookieRe), modules/tide/rules.go (lines 14-16, 50-65, 137-141 filterHeaders joining Set-Cookie with a newline), modules/tide/rules_test.go (lines 54-56), modules/tide/record.go (lines 17-60 the RecordFlow loop, 118-140), modules/tide/replay.go (the step loop and line 109), modules/tide/diff.go (lines 35-80), modules/tide/flow.go (Step, Request, CaptureRule), modules/tide/fixture.go (lines 48, 135-166: the strict loader and writeStep, writeRequest), modules/tide/manifest.go (Manifest, RouteCase, recordRoute's Step literal, mergeHeaders, caseRequest), modules/tide/headers_test.go, modules/tide/capture_test.go (the capture test style), modules/tide/proxy.go (where the client label becomes a directory name), modules/tide/README.md (Features "Capture rules", the Manifest rows), docs/services/parity-testing.md (the capture-source sentence in "The parity commands"), 31-PATTERNS.md "tide T-6" to "tide T-10" and finding F-9 + modules/tide/variables.go (lines 20-40 the scrub patterns, 265-350 extractCapture, 685-750 the two uses of cookieRe), modules/tide/rules.go (lines 14-16, 50-65, 137-141 filterHeaders joining Set-Cookie with a newline), modules/tide/rules_test.go (lines 54-56), modules/tide/record.go (lines 17-60 the RecordFlow loop, 118-140), modules/tide/replay.go (the step loop and line 109), modules/tide/diff.go (lines 35-80), modules/tide/flow.go (Step, Request, CaptureRule, NormalizeRule as Task 2 left it), modules/tide/fixture.go (lines 48, 135-166: the strict loader and writeStep, writeRequest), modules/tide/manifest.go (Manifest, RouteCase, recordRoute's Step literal, mergeHeaders, caseRequest), modules/tide/headers_test.go, modules/tide/capture_test.go (the capture test style), modules/tide/proxy.go (where the client label becomes a directory name), modules/tide/README.md (Features "Capture rules", the Manifest rows), docs/services/parity-testing.md (the capture-source sentence in "The parity commands"), 31-PATTERNS.md "tide T-6" to "tide T-10" and finding F-9, 31-RESEARCH.md "Drift D6" (the largest bucket at the reference snapshot needs 1201 requests inside one minute) - `TestCookieCaptureSmoke` (T-6): a response with two Set-Cookie headers; a rule `from: response.cookie`, `name: session_ref` captures that cookie's value into the store; a missing cookie is the error "missing response cookie session_ref"; the saved fixture holds the placeholder and not the value, in the Set-Cookie header and in a later request's Cookie header; a JWT-shaped value in a cookie of any name that no rule captured refuses the write. - `TestExtraHeadersSmoke` (T-7): a case with `headers: {Retry-After: present, X-RateLimit-Limit: exact}` records both headers; replay passes when Retry-After differs but is non-empty and X-RateLimit-Limit is equal; it reports `header.X-Ratelimit-Limit` when that value differs and `header.Retry-After` when it is missing; a header that is in no list is not recorded. - `TestClientLabelSmoke` (T-8): rules with client `bot` and `web-app` load; `nuxt` and `mcp` still load; an empty label, a label with a slash, a dot or an upper-case letter is refused. - - `TestRepeatSmoke` (T-10): a case with `repeat: 3` against a server that answers 200 twice and then 429 records one response with status 429 and the server saw three requests; replay sends three and compares the last; `repeat: 0` and an absent field mean one request; `repeat: 1001` is a validation error; a flow with `repeat` saved and loaded keeps the value. - - `TestManifestReferenceSmoke` (D-12): a manifest with a `reference` map of two entries parses and `Manifest.Reference` holds them; a manifest without it parses; an unknown top-level key is still refused. + - `TestRepeatSmoke` (T-10): a case with `repeat: 3` against a server that answers 200 twice and then 429 records one response with status 429 and the server saw three requests; replay sends three and compares the last; `repeat: 0` and an absent field mean one request; `repeat` one above `tide.MaxRepeat` is a validation error and `repeat` equal to `tide.MaxRepeat` validates; `repeat: 40` with `repeat_parallel: 8` against a counting server: the server saw 40 requests, never more than 8 in flight, and the final request arrived only after every warm-up had finished, and only its response is kept; `repeat_parallel` above `tide.MaxRepeatParallel`, negative, or set while `repeat` is 0 or 1 is a validation error; a flow with `repeat` and `repeat_parallel` saved and loaded keeps both values. + - `TestManifestReferenceSmoke` (D-12): a manifest with a `reference` map of two entries parses and `Manifest.Reference` holds them; a manifest without it parses; an empty name or an empty revision is refused; an unknown top-level key is still refused. - Per D-11 (the guest cookie credential, the ten rate-bucket cases, Range and rate-limit headers), D-07 and D-17 (a recording client that is neither of the two existing labels) and D-12. + Per D-11 (the guest cookie credential, one 429 case per rate bucket the corpus parser derives, Range and rate-limit headers), D-07 and D-17 (a recording client that is neither of the two existing labels) and D-12 (the reference revisions are written into the manifest at recording time). 1. T-6, `variables.go`: add the capture source `response.cookie` to `extractCapture`: parse the recorded `Set-Cookie` value (several cookies are joined with a newline by `filterHeaders`) and return the value of the cookie named `rule.Name`; error text in the style of the other sources. Replace the single-name cookie pattern in the scrubber: detect `name=value` pairs in `Cookie` and `Set-Cookie` headers for any cookie name, mask a value that equals a vars entry with that variable's placeholder, redact in logs as before, and refuse a token-shaped value that is not masked, whatever the cookie is called. 2. T-7, `record.go`, `diff.go`, `replay.go`: `keepResponseHeaders` takes the step and also keeps every header named in `Step.Headers`. `compareHeaders` reads the map values as a mode: empty or `exact` compares the value, `present` requires a non-empty value on both sides; any other mode is a validation error when the flow or manifest is loaded. 3. T-8, `rules.go`: accept any client label matching lower-case letters, digits, hyphen and underscore, 1 to 32 characters, starting with a letter or digit. Keep `ClientNuxt` and `ClientMCP`. Update `rules_test.go:54-56` in the same commit (F-8): the label that used to fail now loads, and the refused shapes are tested instead. -4. T-10, `flow.go`, `fixture.go`, `manifest.go`, `record.go`, `replay.go`: add `Repeat int` (yaml `repeat,omitempty`) to `Step` and to `RouteCase`; `recordRoute` copies it into the step. `RecordFlow` and the replay loop send the request that many times in a row (0 and 1 mean once; above 1000 is refused at validation) and keep, capture from and compare only the last response. Add the field to `writeStep` so a saved flow loads again (F-9). -5. D-12, `manifest.go`: add `Reference map[string]string` (yaml `reference,omitempty`) to `Manifest`, documented as the source revisions of the reference backend the corpus was recorded from (repository name to commit). `ValidateManifest` refuses an empty name or an empty revision. +4. T-10, `flow.go`, `fixture.go`, `manifest.go`, `record.go`, `replay.go`: add `Repeat int` (yaml `repeat,omitempty`) and `RepeatParallel int` (yaml `repeat_parallel,omitempty`) to `Step` and to `RouteCase`; `recordRoute` copies both into the step. Export `MaxRepeat = 5000` and `MaxRepeatParallel = 32` in `flow.go`, documented as generic safety bounds (a rate bucket of a few thousand requests per window fits; the bound is not tied to any backend). `RecordFlow` and the replay loop send the request `Repeat` times (0 and 1 mean once): the first `Repeat - 1` are warm-ups sent with at most `max(1, RepeatParallel)` in flight, their bodies drained and discarded (a transport error on a warm-up aborts the case and names it); after every warm-up has finished, the final request is sent alone, and only it is kept, captured from and compared. Validation on load: `Repeat` in 0 to `MaxRepeat`, `RepeatParallel` in 0 to `MaxRepeatParallel`, and `RepeatParallel` above 1 only with `Repeat` above 1. Add both fields to `writeStep` so a saved flow loads again (F-9). +5. D-12, `manifest.go`: add `Reference map[string]string` (yaml `reference,omitempty`) to `Manifest`, documented as the source revisions of the reference backend the corpus was recorded from (repository or path name to full commit id, resolved when recording starts). `ValidateManifest` refuses an empty name or an empty revision. 6. `additions_smoke_test.go`: the behavior block. -7. `modules/tide/README.md`: Features "Capture rules" (the cookie source), "Replay and diff" (header modes), "Manifests" (repeat, reference), the client label rule; API reference rows where a described type gained a field. `docs/services/parity-testing.md`: the capture-source list gains `response.cookie`; one paragraph each for extra headers and for repeat. `docs/console/utilities.md` only if a described flag or behaviour changed. +7. `modules/tide/README.md`: Features "Capture rules" (the cookie source), "Replay and diff" (header modes), "Manifests" (repeat, repeat_parallel with the two bounds, reference), the client label rule; API reference rows where a described type gained a field, and rows for `tide.MaxRepeat` and `tide.MaxRepeatParallel`. `docs/services/parity-testing.md`: the capture-source list gains `response.cookie`; one paragraph each for extra headers and for repeat with parallel warm-ups. `docs/console/utilities.md` only if a described flag or behaviour changed. 8. Before the commit run `go vet ./... && go test -count=1 -short ./...` once for the whole repo and record the result (a failure outside tide, cmd/summer and docs is reported, not fixed). Commit: `feat(tide): cookie captures, extra headers, client labels, repeat and manifest reference`. Then post the g15office comment on task `hgol7otp`. go vet ./modules/tide/ ./cmd/summer/ && go test -count=1 -short ./modules/tide/ ./cmd/summer/ && go test -count=1 -run '^(TestCookieCaptureSmoke|TestExtraHeadersSmoke|TestClientLabelSmoke|TestRepeatSmoke|TestManifestReferenceSmoke)$' -v ./modules/tide/ 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 5 @@ -118,13 +170,14 @@ Output: the artifacts and machine evidence named below. - `grep -c '"response.cookie"' modules/tide/variables.go` prints at least 1, and `TestCookieCaptureSmoke` passes with a cookie name that tide's source does not mention. - - `grep -c 'yaml:"repeat,omitempty"' modules/tide/flow.go modules/tide/manifest.go | awk -F: '{s+=$2} END {print s}'` prints 2 and `grep -c 'yaml:"reference,omitempty"' modules/tide/manifest.go` prints 1. + - `grep -c 'yaml:"repeat,omitempty"' modules/tide/flow.go modules/tide/manifest.go | awk -F: '{s+=$2} END {print s}'` prints 2, `grep -c 'yaml:"repeat_parallel,omitempty"' modules/tide/flow.go modules/tide/manifest.go | awk -F: '{s+=$2} END {print s}'` prints 2 and `grep -c 'yaml:"reference,omitempty"' modules/tide/manifest.go` prints 1. + - `grep -cE 'MaxRepeat[[:space:]]+=[[:space:]]+5000' modules/tide/flow.go` prints 1 and `grep -cE 'MaxRepeatParallel[[:space:]]+=[[:space:]]+32' modules/tide/flow.go` prints 1. - `go test -count=1 -run '^TestRoundTrip' -v ./modules/tide/ 2>&1 | grep -c '^--- FAIL'` prints 0. - `D="$(git diff 2acf8e4 -- modules/tide docs cmd/summer/parity.go)" && printf '%s\n' "$D" | grep '^+' | grep -ciE 'wavepath|_wave/|wave_guest|hubot|fonoteka'` prints 0 (the diff is captured first, so a failing git is not read as a clean result). - `git diff --stat 2acf8e4 -- go.mod go.sum` prints nothing. - `git status --porcelain -- modules/tide cmd/summer/parity.go cmd/summer/parity_test.go docs/services/parity-testing.md docs/console/utilities.md` prints nothing (everything committed). - A corpus can log in with a cookie that exists only in Set-Cookie, assert rate-limit and range headers, be recorded by a client with any label, hit a rate bucket in one case, and name the commits it was recorded from. + A corpus can log in with a cookie that exists only in Set-Cookie, assert rate-limit and range headers, be recorded by a client with any label, drive any derived rate bucket to its 429 in one case (with parallel warm-ups when a sequential burst would outlast the bucket window), and name the commits it was recorded from. @@ -144,7 +197,8 @@ Output: the artifacts and machine evidence named below. |-----------|----------|-----------|----------|-------------|-----------------| | T-31-01 | Information disclosure | upstream sidecars with minted credentials (T-4) | high | mitigate | a credential is rewritten only for a declared host, header and scheme; the token itself is never written, only the listed claims; `WriteUpstream` keeps refusing every other unmasked credential; `TestMintedCredentialSmoke` asserts the sidecar holds no JWT-shaped string and that an undeclared host is still refused | | T-31-02 | Information disclosure | cookie values in fixtures (T-6) | high | mitigate | captured cookie values go to the mode-0600 vars store; the scrubber masks any cookie value equal to a vars entry and refuses a token-shaped cookie value under any name; `TestCookieCaptureSmoke` | -| T-31-06 | Denial of service | `repeat` and `--wait` | low | mitigate | `repeat` is bounded at 1000 and validated on load; `--wait` is a bounded duration and listeners are loopback only | +| T-31-06 | Denial of service | `repeat`, `repeat_parallel` and `--wait` | low | mitigate | `repeat` is bounded by `tide.MaxRepeat` and `repeat_parallel` by `tide.MaxRepeatParallel`, both validated on load; warm-ups go only to the step's own target; `--wait` is a bounded duration and listeners are loopback only | +| T-31-38 | Spoofing | numeric clock masks hiding a real difference (T-11) | medium | mitigate | an epoch integer masks only at a `*_at` key or under an explicit `mask: epoch-ms` rule; digit count decides the token, so seconds and milliseconds never compare equal; durations and every other number are compared exactly; a wrong type is a `Diff`; `TestNumericClockMaskSmoke` pins each branch | | T-31-SC | Tampering | npm/pip/cargo installs | high | mitigate | no package install; use existing dependencies and explicit lockfiles | @@ -153,7 +207,7 @@ Run every task's automated command and preserve its fails_when semantics. Do not -Tide core data contracts: relative masks, cookies, headers, labels, repeat and manifest reference is complete, its named tests ran, and no locked decision or D-16 phase boundary drifted. +Tide core data contracts (relative-time and numeric-clock masks, cookies, headers, labels, bounded repeat with parallel warm-up and manifest reference) are complete, their named tests ran, and no locked decision or D-16 phase boundary drifted. diff --git a/.planning/phases/31-chat-polish-against-wavepath-clients/31-02-PLAN.md b/.planning/phases/31-chat-polish-against-wavepath-clients/31-02-PLAN.md index 40938a9a..d103c1a0 100644 --- a/.planning/phases/31-chat-polish-against-wavepath-clients/31-02-PLAN.md +++ b/.planning/phases/31-chat-polish-against-wavepath-clients/31-02-PLAN.md @@ -21,32 +21,50 @@ files_modified: autonomous: true requirements: [SC-2, SC-4, D-06, D-10, D-11] estimate: - tokens: 180000 - raw_tokens: 180000 + tokens: 190000 + raw_tokens: 190000 tasks: 2 confidence: low must_haves: truths: - - "Tide per-case broadcast/upstream sidecars, minted credentials, body comparers and CLI wiring is delivered against the frozen PHP corpus and locked decisions." + - "Tide per-case broadcast/upstream sidecars, minted credentials, body comparers and CLI wiring are delivered against the frozen PHP corpus and locked decisions." + - "A route that writes (any method other than GET, HEAD and OPTIONS, or a route marked `writes: true` such as a GET that heals rows) always gets a broadcast golden, an explicit empty one when PHP published nothing; replaying such a route without its golden fails (D-10)." + - "Publication payloads compare epoch clocks by shape at any depth, the same way responses do (T-3 with T-11)." - "Verification fails closed: missing, skipped, pending or mismatching evidence is not counted as a pass." - "D-16 remains intact: messaging, satellites, Range support, guest/bot/webhook host services, zero total pending and final security review stay in Phases 31.1/31.2." artifacts: - - path: "modules/tide/centrifugo.go" - provides: "Tide per-case broadcast/upstream sidecars, minted credentials, body comparers and CLI wiring" + - path: "modules/tide/centrifugo_golden.go" + provides: "BroadcastPath, DiffPublicationsUnordered, DiffCaseBroadcasts, CaseBroadcastOptions, payload-wide masks" + - path: "modules/tide/manifest.go" + provides: "CaseHook, ManifestConfig sidecar fields, Route.Writes, RouteWrites" + - path: "modules/tide/upstream.go" + provides: "MintedCredential, UpstreamBodyComparer, UpstreamBodyMatch, OpaqueBody" key_links: - - from: "modules/tide/centrifugo.go" - to: "the plan's automated verification" - via: "the named tracer and fail-closed checks" + - from: "modules/tide/manifest.go" + to: "modules/tide/centrifugo_golden.go" + via: "recordRoute and ReplayManifest write and compare a per-case broadcast golden, required for every writing route" + - from: "cmd/summer/parity.go" + to: "modules/tide/manifest.go" + via: "the manifest-mode flags fill ManifestConfig.Recorder, Upstream and BeforeCase" --- ## Phase Goal -WavePath's complete 196-route PHP community corpus is recorded and self-replays green; Phase 31 ports and proves only the 36-route foundation slice, leaving exactly 160 routes pending for Phases 31.1 and 31.2 per D-16. +WavePath's complete PHP community corpus is recorded and self-replays green: every route the corpus parser derives from `routes.php` at the commits resolved when the recording starts, plus the two realtime routes. Phase 31 ports and proves only the foundation slice listed in `parity/foundation-routes.txt`; every other corpus route stays pending for Phases 31.1 and 31.2 per D-16. Counts are derived at recording time and checked for consistency, never pinned (reference snapshot 2026-11-22, not a target: 218 tracked, 36 foundation, 182 pending). + +## Artifacts this phase produces (this plan) + +- `modules/tide/sidecar_smoke_test.go` with `TestManifestCaseSidecarsSmoke`, `TestBroadcastPayloadMaskSmoke`, `TestRecorderPresenceAndUnsubscribeSmoke`; `modules/tide/upstream_smoke_test.go` with `TestMintedCredentialSmoke`, `TestUpstreamBodyComparerSmoke`. +- `tide.BroadcastPath`, `tide.DiffPublicationsUnordered`, `tide.DiffCaseBroadcasts`, `tide.CaseBroadcastOptions` (fields `Unordered`, `RequireGolden`, `Normalize`). +- `tide.CaseHook`; `ManifestConfig` fields `BeforeCase`, `Recorder`, `BroadcastSettle`, `Upstream`; `Route.Writes` (yaml `writes,omitempty`); `tide.RouteWrites`. +- `CentrifugoRecorderOptions` fields `RecordUnsubscribe`, `Presence`; `(*UpstreamProxy).Begin`, `(*UpstreamProxy).Recorded`. +- `tide.MintedCredential`, `UpstreamScript` key `minted`, `UpstreamProxyConfig.Minted`, placeholder `{{minted}}`; `tide.UpstreamBodyComparer`, `tide.UpstreamBodyMatch`, `(*UpstreamFake).SetBodyComparer`, `tide.OpaqueBody`. +- `summer parity:record` and `parity:replay` flags `--broadcasts`, `--centrifugo-listen`, `--api-key`, `--settle`, `--presence`, `--record-unsubscribe`, `--upstream-script`, `--upstream-listen`, `--ca-dir`, `--case-hook`, `--wait`. -Tide per-case broadcast/upstream sidecars, minted credentials, body comparers and CLI wiring. +Tide per-case broadcast/upstream sidecars with writing-route classification, payload-wide clock masks, minted credentials, body comparers and CLI wiring. -Purpose: preserve the frozen client/PHP contract while keeping this executor slice cohesive and within the authorized hybrid re-slice. +Purpose: preserve the frozen client/PHP contract while keeping this executor slice cohesive and within the authorized hybrid re-slice. Every addition is generic and names no application. Output: the artifacts and machine evidence named below. @@ -65,23 +83,24 @@ Output: the artifacts and machine evidence named below. - Task 2: One manifest run records a broadcast sidecar and an upstream sidecar for every case, with a reset hook before each (tide gaps T-2, T-3, T-9) + Task 2: One manifest run records a broadcast sidecar and an upstream sidecar for every case, with a reset hook before each and an explicit golden for every writing route (tide gaps T-2, T-3, T-9, T-11 in payloads) modules/tide/manifest.go, modules/tide/centrifugo.go, modules/tide/centrifugo_golden.go, modules/tide/upstream_proxy.go, modules/tide/centrifugo_test.go, modules/tide/sidecar_smoke_test.go, cmd/summer/parity.go, cmd/summer/parity_test.go, modules/tide/README.md, docs/services/parity-testing.md, docs/console/utilities.md - modules/tide/manifest.go (ManifestConfig, RecordManifest, recordRoute, caseFixturePath, ReplayManifest and its per-case loop), modules/tide/centrifugo.go (whole file), modules/tide/centrifugo_golden.go (whole file, and the doc comment of NormalizePublications that lists every rule), modules/tide/upstream_proxy.go (UpstreamProxy, NewUpstreamProxy, scripted, Flush, ListenAndServe), modules/tide/upstream.go (UpstreamPath, WriteUpstream), modules/tide/centrifugo_test.go (lines 17-68: postJSON, the assertions F-8 names), modules/tide/normalize_phase13_test.go (lines 53-60), cmd/summer/parity.go (parityRecordCommand, parityReplayCommand, runParityUpstream, the flag lists), cmd/summer/parity_test.go, modules/tide/README.md (API reference rows for the recorder, goldens and the proxy; "CLI commands"), docs/services/parity-testing.md ("Broadcast goldens", "Upstream exchanges"), docs/console/utilities.md (the parity flag table), 31-PATTERNS.md "tide T-2", "tide T-3", "tide T-9", ../fonoteka.go/parity/broadcast_goldens_test.go (lines 210-241, the unordered comparison this plan generalises; read only) + modules/tide/manifest.go (Route, ManifestConfig, RecordManifest, recordRoute, caseFixturePath, ReplayManifest and its per-case loop, the strict loader), modules/tide/centrifugo.go (whole file), modules/tide/centrifugo_golden.go (whole file, and the doc comment of NormalizePublications that lists every rule), modules/tide/normalize.go (the T-1 and T-11 masks 31-01 added: `_human`, the epoch-integer branch of maskDate, the `epoch-ms` rule), modules/tide/upstream_proxy.go (UpstreamProxy, NewUpstreamProxy, scripted, Flush, ListenAndServe), modules/tide/upstream.go (UpstreamPath, WriteUpstream), modules/tide/centrifugo_test.go (lines 17-68: postJSON, the assertions F-8 names), modules/tide/normalize_phase13_test.go (lines 53-60), cmd/summer/parity.go (parityRecordCommand, parityReplayCommand, runParityUpstream, the flag lists), cmd/summer/parity_test.go, modules/tide/README.md (API reference rows for the recorder, goldens and the proxy; "CLI commands"), docs/services/parity-testing.md ("Broadcast goldens", "Upstream exchanges"), docs/console/utilities.md (the parity flag table), 31-01-SUMMARY.md (final mask identifiers), 31-PATTERNS.md "tide T-2", "tide T-3", "tide T-9", 31-RESEARCH.md "Drift D7" item 1 and "Drift D10" (a GET that writes; epoch clocks in publications), ../fonoteka.go/parity/broadcast_goldens_test.go (lines 210-241, the unordered comparison this plan generalises; read only) - - `TestManifestCaseSidecarsSmoke`: a reference `httptest` server whose POST route publishes one message to the in-process recorder and calls one HTTPS vendor URL through the in-process upstream proxy, and whose GET route does neither. `RecordManifest` over a two-route manifest with `Recorder`, `Upstream` and `BeforeCase` set writes: both fixtures; `BroadcastPath(postFixture)` holding one publication; `UpstreamPath(postFixture)` holding one exchange; no sidecar of either kind for the GET case. The hook was called once per case, in order, with that route and case. `ReplayManifest` in self-check mode with the recorder attached passes, and fails with a publication diff after the sidecar on disk is edited. - - `TestBroadcastPayloadMaskSmoke` (T-3): two publications whose payload holds `edited_at` and `read_at` at depth 2 and 3 with different Carbon dates, and a `created_at_human` with different strings, normalise equal; a date written with a `Z` suffix where the golden has a Carbon offset stays visible as a diff. + - `TestManifestCaseSidecarsSmoke`: a reference `httptest` server whose POST route publishes one message to the in-process recorder and calls one HTTPS vendor URL through the in-process upstream proxy, whose plain GET route does neither, and whose second GET route is marked `writes: true` in the manifest and publishes nothing. `RecordManifest` over the three-route manifest with `Recorder`, `Upstream` and `BeforeCase` set writes: every fixture; `BroadcastPath(postFixture)` holding one publication; `BroadcastPath(writingGetFixture)` holding a golden with zero publications; `UpstreamPath(postFixture)` holding one exchange; no sidecar of either kind for the plain GET case. The hook was called once per case, in order, with that route and case. `ReplayManifest` in self-check mode with the recorder attached passes; it fails with a publication diff after the POST sidecar on disk is edited, and fails naming the case and "missing broadcast golden" after the writing GET's golden is deleted. + - `RouteWrites`: a route without `writes` writes exactly when its method is not GET, HEAD or OPTIONS; `writes: true` on a GET and `writes: false` on a POST override the method; a manifest with `writes` marshalled with goccy/go-yaml and parsed again with `ParseManifest` keeps it. + - `TestBroadcastPayloadMaskSmoke` (T-3, T-11): two publications whose payload holds `edited_at` and `read_at` at depth 2 and 3 with different Carbon dates, a `created_at_human` with different strings, and a `last_read_at` epoch integer of 10 digits at depth 3 with different values, normalise equal; a date written with a `Z` suffix where the golden has a Carbon offset, and a `last_read_at` of 13 digits where the golden has 10, stay visible as diffs; a payload key `server_time_ms` differs unless `CaseBroadcastOptions.Normalize` carries `{path: server_time_ms, mask: epoch-ms}`. - `TestRecorderPresenceAndUnsubscribeSmoke` (T-9): with `RecordUnsubscribe` set, an unsubscribe call is recorded as a `Publication`; with a presence table for one channel, a presence call for that channel answers one client entry per listed user id and another channel answers the empty result; with neither option the behaviour of the existing tests is unchanged. - `DiffPublicationsUnordered` returns no diff for the same publications in another order and a diff when one body differs. - Per D-10 (a golden for every writing case), D-11 (vendor calls as sidecars) and D-06 (unattended). -1. `centrifugo_golden.go`: add `BroadcastPath(fixturePath string) string` (maps `x.yaml` or `x.yml` to `x.broadcasts.yaml`, mirroring `UpstreamPath`). Add `DiffPublicationsUnordered(expected, actual []Publication) []Diff` (both sides sorted by normalised body, then `DiffPublications`). Add `DiffCaseBroadcasts(fixturePath string, pubs []Publication, store *Store, unordered bool) ([]Diff, error)`: loads the golden at `BroadcastPath(fixturePath)` (a missing file means a golden with zero publications), normalises `pubs` with `NormalizePublications` and diffs. T-3: in `normalizer.walk`, mask every string value under `$.data.payload.` whose key ends in `_at` and that matches the Carbon offset form or an ISO-8601 form, at any depth, and mask keys ending in `_human` under the payload with the Task 1 rule. Keep the id rule as it is (an id becomes a placeholder only when it equals a captured `id:*` variable). Update the doc comment of `NormalizePublications`. + Per D-10 (a golden for every writing case, including a GET that writes), D-11 (vendor calls as sidecars) and D-06 (unattended). +1. `centrifugo_golden.go`: add `BroadcastPath(fixturePath string) string` (maps `x.yaml` or `x.yml` to `x.broadcasts.yaml`, mirroring `UpstreamPath`). Add `DiffPublicationsUnordered(expected, actual []Publication) []Diff` (both sides sorted by normalised body, then `DiffPublications`). Add `type CaseBroadcastOptions struct` with `Unordered bool`, `RequireGolden bool` and `Normalize []NormalizeRule`, and `DiffCaseBroadcasts(fixturePath string, pubs []Publication, store *Store, opts CaseBroadcastOptions) ([]Diff, error)`: loads the golden at `BroadcastPath(fixturePath)`; a missing file is a golden with zero publications unless `RequireGolden` is set, when it is a `Diff` reading "missing broadcast golden"; normalises `pubs` with `NormalizePublications` and diffs. T-3: in `normalizer.walk`, mask every string value under `$.data.payload.` whose key ends in `_at` and that matches the Carbon offset form or an ISO-8601 form, at any depth, and mask keys ending in `_human` under the payload with 31-01's rule. T-11: an epoch integer under a payload `_at` key masks with the digit-count tokens of 31-01 (10 and 13 digits distinct, every other number a diff), and a payload key named by an `epoch-ms` rule in `opts.Normalize` masks as in 31-01. Keep the id rule as it is (an id becomes a placeholder only when it equals a captured `id:*` variable). Update the doc comment of `NormalizePublications`. 2. `centrifugo.go` (T-9): add two fields to `CentrifugoRecorderOptions`: `RecordUnsubscribe bool` (an `/unsubscribe` call is stored as a `Publication` like a publish) and `Presence map[string][]string` (channel name to user ids; a `/presence` call for a listed channel answers a `result.presence` object with one synthetic client entry per user id, each carrying `client` and `user`; other channels answer the empty result as today). Defaults keep today's behaviour. 3. `upstream_proxy.go`: add `(*UpstreamProxy).Begin(out string) error` (sets the sidecar path of the next `Flush`, clears the recorded exchanges and errors, and makes every script entry available again; for a non-empty `out` the CA directory and the vars file must be outside its directory, as `NewUpstreamProxy` checks for `Out`; an empty `out` resets the proxy and sets no path) and `(*UpstreamProxy).Recorded() int`. `NewUpstreamProxy` accepts an empty `Out` when the proxy is driven through `Begin`; `Flush` with no path set is an error. -4. `manifest.go`: add `type CaseHook func(ctx context.Context, route Route, c RouteCase) error` and four `ManifestConfig` fields: `BeforeCase CaseHook`, `Recorder *CentrifugoRecorder`, `BroadcastSettle time.Duration`, `Upstream *UpstreamProxy`. In `recordRoute`, per case: call `BeforeCase` (an error aborts the run and names the case); `Recorder.Reset()`; `Upstream.Begin(UpstreamPath(dest))`; `RecordFlow`; wait `BroadcastSettle` (default `DefaultBroadcastSettle`); when the recorder holds publications, normalise them, refuse a body containing the API key (as `RecordBroadcasts` does) and write a `BroadcastGolden` named after the case to `BroadcastPath(dest)`; when it holds none, write no sidecar and, under `Update`, remove a stale one; `Upstream.Flush()` only when `Recorded()` is above zero, else remove a stale sidecar under `Update`. In `ReplayManifest`, per case: `BeforeCase`, `Recorder.Reset()`, `Upstream.Begin("")` (on replay the proxy answers from its script and nothing is flushed), replay, settle, and when `Recorder` is set compare with `DiffCaseBroadcasts` (unordered); a publication diff makes the case failing. +4. `manifest.go`: add `Writes *bool` (yaml `writes,omitempty`) to `Route`, documented as "the route changes state; set it on a GET whose handler writes, or to false on a POST that does not", and `RouteWrites(r Route) bool` (the explicit value, else true for every method other than GET, HEAD and OPTIONS); the strict loader (`ParseManifest`) accepts the field and a YAML marshal of `Manifest` writes it. Add `type CaseHook func(ctx context.Context, route Route, c RouteCase) error` and four `ManifestConfig` fields: `BeforeCase CaseHook`, `Recorder *CentrifugoRecorder`, `BroadcastSettle time.Duration`, `Upstream *UpstreamProxy`. In `recordRoute`, per case: call `BeforeCase` (an error aborts the run and names the case); `Recorder.Reset()`; `Upstream.Begin(UpstreamPath(dest))`; `RecordFlow`; wait `BroadcastSettle` (default `DefaultBroadcastSettle`); normalise the recorder's publications, refuse a body containing the API key (as `RecordBroadcasts` does), and write a `BroadcastGolden` named after the case to `BroadcastPath(dest)` when `RouteWrites(route)` is true (zero publications allowed: an explicit empty golden) or when the recorder holds publications; otherwise write no sidecar and, under `Update`, remove a stale one; `Upstream.Flush()` only when `Recorded()` is above zero, else remove a stale sidecar under `Update`. In `ReplayManifest`, per case: `BeforeCase`, `Recorder.Reset()`, `Upstream.Begin("")` (on replay the proxy answers from its script and nothing is flushed), replay, settle, and when `Recorder` is set compare with `DiffCaseBroadcasts` using `Unordered: true`, `RequireGolden: RouteWrites(route)` and the route's `Normalize` rules; a publication diff or a missing golden makes the case failing. 5. `cmd/summer/parity.go`: on `parity:record` and `parity:replay`, manifest mode only (each is an error without `--manifest`): `--broadcasts` (true/false: attach a recorder), `--centrifugo-listen` (default `tide.DefaultCentrifugoListen`), `--api-key` (default `$PARITY_CENTRIFUGO_API_KEY`), `--settle` (default `tide.DefaultBroadcastSettle`), `--presence` (a YAML file with one key `channels`, mapping a channel name to a list of user ids; names and ids are expanded with the vars store when the file is loaded), `--record-unsubscribe` (true/false), `--upstream-script` (attach an upstream proxy in script mode), `--upstream-listen` (default `tide.DefaultUpstreamProxyListen`), `--ca-dir`, `--case-hook` (path to an executable file, run directly with no shell before each case, with the environment variables `PARITY_ROUTE_ID`, `PARITY_CASE_ID` and `PARITY_SEED_HOOK`; a missing or non-executable file is refused at start, a non-zero exit aborts the run), `--wait` (a Go duration: after the listeners are bound, wait up to this long for `--target` to accept TCP connections before the first request; default 0). Every listen address must be loopback. The command prints the CA certificate path when a proxy is attached. Update the help text and the examples of both commands. 6. `centrifugo_test.go`: keep the existing assertions for the default options and add the option cases (F-8). `sidecar_smoke_test.go`: the behavior block. `cmd/summer/parity_test.go`: a help-output check that `parity:record` lists `--case-hook`, `--broadcasts` and `--upstream-script`, and that `--broadcasts true` without `--manifest` is an error. -7. `modules/tide/README.md`: Features (per-case sidecars; presence and unsubscribe options; payload-wide masks), API reference rows for `tide.BroadcastPath`, `tide.DiffCaseBroadcasts`, `tide.DiffPublicationsUnordered`, `tide.CaseHook`, `tide.ManifestConfig` and the two new proxy methods, and the changed description of `tide.NormalizePublications`; "CLI commands": a manifest-mode example with the new flags (neutral paths). `docs/services/parity-testing.md`: "Broadcast goldens" gains the per-case sidecar workflow and "Upstream exchanges" the per-case recording. `docs/console/utilities.md`: the flag lists of `parity:record` and `parity:replay`. +7. `modules/tide/README.md`: Features (per-case sidecars; the writing-route rule and `writes`; presence and unsubscribe options; payload-wide masks including epoch clocks), API reference rows for `tide.BroadcastPath`, `tide.DiffCaseBroadcasts`, `tide.CaseBroadcastOptions`, `tide.DiffPublicationsUnordered`, `tide.CaseHook`, `tide.RouteWrites`, `tide.ManifestConfig` and the two new proxy methods, and the changed description of `tide.NormalizePublications`; "CLI commands": a manifest-mode example with the new flags (neutral paths). `docs/services/parity-testing.md`: "Broadcast goldens" gains the per-case sidecar workflow and the writing-route rule, "Upstream exchanges" the per-case recording. `docs/console/utilities.md`: the flag lists of `parity:record` and `parity:replay`. 8. Commit: `feat(tide): per-case broadcast and upstream sidecars in manifest recording`. go vet ./modules/tide/ ./cmd/summer/ && go test -count=1 -short ./modules/tide/ ./cmd/summer/ && go test -count=1 -run '^(TestManifestCaseSidecarsSmoke|TestBroadcastPayloadMaskSmoke|TestRecorderPresenceAndUnsubscribeSmoke)$' -v ./modules/tide/ 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 3 @@ -91,24 +110,25 @@ Output: the artifacts and machine evidence named below. - `grep -c 'func BroadcastPath' modules/tide/centrifugo_golden.go` prints 1 and `grep -c 'BeforeCase' modules/tide/manifest.go` prints at least 2. + - `grep -c 'yaml:"writes,omitempty"' modules/tide/manifest.go` prints 1, `grep -c 'func RouteWrites' modules/tide/manifest.go` prints 1 and `grep -c 'type CaseBroadcastOptions struct' modules/tide/centrifugo_golden.go` prints 1. - `go run ./cmd/summer help parity:record 2>&1 | grep -c -- 'case-hook'` prints at least 1. - - `grep -c 'case-hook' docs/console/utilities.md` prints at least 1 and `grep -c 'tide.BroadcastPath' modules/tide/README.md` prints at least 1. + - `grep -c 'case-hook' docs/console/utilities.md` prints at least 1 and `grep -c 'tide.BroadcastPath' modules/tide/README.md` prints at least 1 and `grep -c 'tide.RouteWrites' modules/tide/README.md` prints at least 1. - `go test -count=1 -run '^TestCentrifugoRecorder' -v ./modules/tide/ 2>&1 | grep -c '^--- FAIL'` prints 0. - `D="$(git diff 2acf8e4 -- modules/tide docs cmd/summer/parity.go)" && printf '%s\n' "$D" | grep '^+' | grep -ciE 'wavepath|_wave/|wave_guest|hubot|fonoteka'` prints 0 (the diff is captured first, so a failing git is not read as a clean result). - A porter can record a whole manifest with one command and get, next to every fixture, the publications and vendor calls that case caused, each case starting from a reset state; replaying against the reference backend proves the goldens are reproducible. + A porter can record a whole manifest with one command and get, next to every fixture, the publications and vendor calls that case caused, each case starting from a reset state; every writing route, a GET that writes included, has a golden; replaying against the reference backend proves the goldens are reproducible. Task 3: Upstream sidecars hold signed and encrypted vendor calls (tide gaps T-4, T-5) modules/tide/upstream.go, modules/tide/upstream_proxy.go, modules/tide/upstream_smoke_test.go, modules/tide/README.md, docs/services/parity-testing.md - modules/tide/upstream.go (whole file: UpstreamCompareHeaders at 118-128, binaryScalar at 84-116, NewUpstreamFake at 195, RoundTrip at 200-229, compare at 252, WriteUpstream at 573, the credential refusal at 635-638 and fullyMasked and credentialResidueRe at 655-666), modules/tide/upstream_proxy.go (loadUpstreamScript, UpstreamScript, how a recorded request is built around lines 420-450), modules/tide/upstream_test.go (lines 16-60: upstreamTestSidecar, upstreamCall and its send helper, the neutral host), modules/tide/testdata/upstream/post_json.upstream.yaml, modules/tide/README.md (the Upstream rows and the security rules under "CLI commands"), docs/services/parity-testing.md ("Upstream exchanges", "Recording through the proxy", "Replaying offline"), 31-PATTERNS.md "tide T-4, T-5", ../fonoteka.go/parity/upstream_replay_test.go (lines 50-55: the existing callers of NewUpstreamFake whose signature must not change; read only) + modules/tide/upstream.go (whole file: UpstreamCompareHeaders at 118-128, binaryScalar at 84-116, NewUpstreamFake at 195, RoundTrip at 200-229, compare at 252, WriteUpstream at 573, the credential refusal at 635-638 and fullyMasked and credentialResidueRe at 655-666), modules/tide/upstream_proxy.go (loadUpstreamScript, UpstreamScript, how a recorded request is built around lines 420-450, and the Begin method Task 2 added), modules/tide/upstream_test.go (lines 16-60: upstreamTestSidecar, upstreamCall and its send helper, the neutral host), modules/tide/testdata/upstream/post_json.upstream.yaml, modules/tide/README.md (the Upstream rows and the security rules under "CLI commands"), docs/services/parity-testing.md ("Upstream exchanges", "Recording through the proxy", "Replaying offline"), 31-PATTERNS.md "tide T-4, T-5", ../fonoteka.go/parity/upstream_replay_test.go (lines 50-55: the existing callers of NewUpstreamFake whose signature must not change; read only) - `TestMintedCredentialSmoke`: an upstream script declares a minted credential for host `api.example.test`, header `Authorization`, scheme `Bearer`, claims `iss` and `video`. The proxy records a request carrying a bearer JWT. The written sidecar holds no JWT-shaped string; the header value is the scheme followed by a placeholder; the two claims are recorded. The fake accepts a replayed request with a different token whose `iss` and `video` claims match, and reports a problem when `iss` differs or the scheme differs. A request with a bearer token to a host that is not declared still refuses the write with the existing error. - The same for a header value in the form scheme word, a `t=` parameter holding a JWT and a `k=` parameter holding a key that is in the vars store: the token becomes the placeholder and the key is masked by its variable. - `TestUpstreamBodyComparerSmoke`: a fake with a comparer registered for a content type receives the expected and the actual body bytes and its returned problems fail `Verify`; with `OpaqueBody` registered, two different non-empty bodies pass and an empty body fails; with no comparer the existing JSON and byte comparison is unchanged. - Per D-11 (LiveKit and web-push calls are recorded and asserted) and threat T-31-01. + Per D-11 (LiveKit and web-push calls, DM-call LiveKit calls included, are recorded and asserted) and threat T-31-01. 1. T-4 in `upstream.go` and `upstream_proxy.go`: add `type MintedCredential struct` with fields `Host` (exact, or with a leading `*.` wildcard), `Header`, `Scheme` (the auth scheme word) and `Claims []string` (JWT claim names compared by value on replay; `exp`, `iat`, `nbf` and `jti` are never compared and are refused in the list). `UpstreamScript` gains a top-level `minted` list, and `UpstreamProxyConfig` gains `Minted []MintedCredential` for callers that build the config in code. When the proxy records a request whose host and header match a declaration and whose value starts with the declared scheme, the first JWT-shaped token in the value is replaced by a fixed placeholder (`{{minted}}`), and the exchange's request records the declaration that matched and the values of the listed claims (decoded from the token's payload without verifying the signature). Add the fields to the sidecar structs, the YAML writer and the strict loader. `WriteUpstream` keeps refusing any credential header that is neither masked by a vars entry nor rewritten by a declaration; do not relax `fullyMasked` for anything else. The fake's `compare`: for a request recorded with a minted declaration, the actual header must have the same scheme and, when claims were recorded, the same claim values; the placeholder is never compared as text. 2. T-5 in `upstream.go`: add `type UpstreamBodyComparer func(expected, actual []byte, contentType string) []string`, `type UpstreamBodyMatch struct` with `Host` (exact or `*.` wildcard, optional) and `ContentType` (prefix, optional; at least one of the two is required), `(*UpstreamFake).SetBodyComparer(match UpstreamBodyMatch, cmp UpstreamBodyComparer)`, and `OpaqueBody` (an `UpstreamBodyComparer` that reports a problem only when exactly one side is empty). `compare` consults the first matching comparer for the body only; headers, method and URL are compared as before. Keep the signature of `NewUpstreamFake`. 3. `upstream_smoke_test.go`: the behavior block, with the builder style and neutral host of `upstream_test.go`. @@ -145,8 +165,9 @@ Output: the artifacts and machine evidence named below. | Threat ID | Category | Component | Severity | Disposition | Mitigation Plan | |-----------|----------|-----------|----------|-------------|-----------------| | T-31-03 | Elevation of privilege | `--case-hook` executes a program | medium | mitigate | the flag takes a path to an executable file and runs it directly with no shell; route and case ids are passed as environment variables, never interpolated into a command line; a missing or non-executable file is refused at start | -| T-31-04 | Spoofing | masks and opaque comparers hiding real differences | medium | mitigate | every mask is shape-checked and emits a `Diff` on a wrong shape; the opaque comparer and every body comparer are opt-in per host or content type; a step can disable the relative-time mask; defaults are unchanged and pinned by the existing tests | +| T-31-04 | Spoofing | masks and opaque comparers hiding real differences | medium | mitigate | every mask is shape-checked and emits a `Diff` on a wrong shape; payload epoch clocks keep seconds and milliseconds distinct; a `_ms` key masks only under an explicit rule; the opaque comparer and every body comparer are opt-in per host or content type; a step can disable the relative-time mask; defaults are unchanged and pinned by the existing tests | | T-31-05 | Information disclosure | broadcast sidecars | medium | mitigate | the per-case writer reuses the API-key body check of `RecordBroadcasts`; the authorization header is stored as a boolean only; `WriteBroadcastGolden` keeps refusing token-shaped bodies | +| T-31-39 | Repudiation | a writing GET (rows healed on read) recorded without a golden, so a missing publication or an extra one goes unseen | medium | mitigate | `Route.Writes` marks such a route; `RouteWrites` decides by the flag, else by method; every writing route gets an explicit golden (empty allowed) and `RequireGolden` turns a missing golden into a failing case; `TestManifestCaseSidecarsSmoke` deletes the golden and expects the failure | | T-31-SC | Tampering | npm/pip/cargo installs | high | mitigate | no package install; use existing dependencies and explicit lockfiles | @@ -155,7 +176,7 @@ Run every task's automated command and preserve its fails_when semantics. Do not -Tide per-case broadcast/upstream sidecars, minted credentials, body comparers and CLI wiring is complete, its named tests ran, and no locked decision or D-16 phase boundary drifted. +Tide per-case broadcast/upstream sidecars (writing-route classification and payload clock masks included), minted credentials, body comparers and CLI wiring are complete, their named tests ran, and no locked decision or D-16 phase boundary drifted. diff --git a/.planning/phases/31-chat-polish-against-wavepath-clients/31-03-PLAN.md b/.planning/phases/31-chat-polish-against-wavepath-clients/31-03-PLAN.md index 39a2096e..f553bc68 100644 --- a/.planning/phases/31-chat-polish-against-wavepath-clients/31-03-PLAN.md +++ b/.planning/phases/31-chat-polish-against-wavepath-clients/31-03-PLAN.md @@ -20,32 +20,49 @@ files_modified: - ../sm-wavepath-app/parity/README.md - ../sm-wavepath-app/README.md autonomous: false -requirements: [SC-1, D-01, D-02, D-05, D-08, D-20, D-21] +requirements: [SC-1, D-01, D-02, D-05, D-08, D-12, D-20, D-21] estimate: - tokens: 200000 - raw_tokens: 200000 + tokens: 225000 + raw_tokens: 225000 tasks: 4 confidence: low must_haves: truths: - - "sm-wavepath-app skeleton and fail-closed isolated PHP parity stack is delivered against the frozen PHP corpus and locked decisions." + - "sm-wavepath-app skeleton and fail-closed isolated PHP parity stack are delivered against the frozen PHP corpus and locked decisions." + - "The pins are resolved, not hardcoded: `php_parity.sh pin` reads wavepath.org HEAD (or `PARITY_PIN_REF`) and writes one pin per gitlink that `git ls-tree -r` lists at that commit, whatever their number; the export and `check` use exactly that list (D-12 freeze at recording time)." + - "The PHP stack runs Scout with the Typesense driver against a loopback-only Typesense container, so the recording covers the search routes once (31.2 D-03); per-case restore re-indexes before a search case." - "Verification fails closed: missing, skipped, pending or mismatching evidence is not counted as a pass." - "D-16 remains intact: messaging, satellites, Range support, guest/bot/webhook host services, zero total pending and final security review stay in Phases 31.1/31.2." artifacts: - - path: "../sm-wavepath-app/.gitmodules" - provides: "sm-wavepath-app skeleton and fail-closed isolated PHP parity stack" + - path: "../sm-wavepath-app/parity/php_parity.sh" + provides: "pin, export, db, typesense, reindex, reset, serve, snapshot, restore, script, rows" + - path: "../sm-wavepath-app/scripts/parity-stack.sh" + provides: "up (readonly, record), down, status, check, selftest, self-replay" + - path: "../sm-wavepath-app/parity/pins.env" + provides: "the resolved superproject commit and one pin per gitlink" key_links: - - from: "../sm-wavepath-app/.gitmodules" - to: "the plan's automated verification" - via: "the named tracer and fail-closed checks" + - from: "../sm-wavepath-app/parity/pins.env" + to: "../sm-wavepath-app/parity/php_parity.sh" + via: "export archives every gitlink at its pin and writes .parity-export, which check compares with pins.env" + - from: "../sm-wavepath-app/parity/case_hook.sh" + to: "../sm-wavepath-app/parity/php_parity.sh" + via: "restore before every case, reindex before a search case" --- ## Phase Goal -WavePath's complete 196-route PHP community corpus is recorded and self-replays green; Phase 31 ports and proves only the 36-route foundation slice, leaving exactly 160 routes pending for Phases 31.1 and 31.2 per D-16. +WavePath's complete PHP community corpus is recorded and self-replays green: every route the corpus parser derives from `routes.php` at the commits resolved when the recording starts, plus the two realtime routes. Phase 31 ports and proves only the foundation slice listed in `parity/foundation-routes.txt`; every other corpus route stays pending for Phases 31.1 and 31.2 per D-16. Counts are derived at recording time and checked for consistency, never pinned (reference snapshot 2026-11-22, not a target: 218 tracked, 36 foundation, 182 pending). + +## Artifacts this phase produces (this plan) + +- The repository `../sm-wavepath-app` (module `git.golem15.com/golem15/sm-wavepath-app` unless Task 5 renames it): `summer.yaml`, `go.mod`, `go.work`, `main.go`, `plugins.gen.go`, `boot_test.go` with `TestBootAllPlugins`, `app/app.go` with `PluginIDs` and `Handler`, `config/app.yaml`. +- App plugin `plugins/golem15/wavepath` (package `wavepath`, `const ID = "golem15.wavepath"`, type `Plugin`). +- `parity/pins.env` (keys `SUPERPROJECT` and one `PIN_` per gitlink), `parity/parity.env` (test-only values including `TYPESENSE_API_KEY`), `parity/php_parity.sh` (subcommands `pin`, `export`, `db`, `typesense`, `reindex`, `artisan`, `reset`, `serve`, `snapshot`, `restore`, `script`, `rows`; function `export_env`), `parity/wavepath_reset.php`, `parity/case_hook.sh`, `parity/fixtureplugin` (`ID()` `parity.fixtureplugin`, `Seed`), `parity/manifest.yaml`, `parity/fixtures/seed/bootstrap.yaml`, `parity/parity_test.go` with `TestParityCorpus`, `parity/testmain_test.go`, `parity/README.md`. +- `scripts/parity-stack.sh` (subcommands `up --mode readonly|record`, `down [--all]`, `status`, `check`, `selftest`, `self-replay`; variables `PARITY_LISTENER_WAIT`, `PARITY_PHP_WORKERS`, `PARITY_PIN_REF`, `PARITY_PINS_FILE`), `scripts/check-parity.sh` (first form). +- Files under the parity root: `$PARITY_ROOT/$PARITY_INSTANCE/php/.parity-export`, `vars.yaml` (mode 0600), `snapshot.sql`; containers `wavepath-parity-mariadb` (127.0.0.1:33306) and `wavepath-parity-typesense` (127.0.0.1:38108). -sm-wavepath-app skeleton and fail-closed isolated PHP parity stack. +sm-wavepath-app skeleton and fail-closed isolated PHP parity stack, with pins resolved at run time over every gitlink and Typesense-backed search. Purpose: preserve the frozen client/PHP contract while keeping this executor slice cohesive and within the authorized hybrid re-slice. Output: the artifacts and machine evidence named below. @@ -66,82 +83,88 @@ Output: the artifacts and machine evidence named below. - Task 1: Tracer: one route goes from PHP at the pinned commits to a recorded fixture, a green PHP self-replay, a pending manifest entry the Go harness loads and a gate that prints the pending count + Task 1: Tracer: one route goes from PHP at the resolved pins to a recorded fixture, a green PHP self-replay, a pending manifest entry the Go harness loads and a gate that prints the pending count D-02: the repository name, module path and parity/ layout are what WavePath's agent and every later WavePath phase build on; a rename later touches every import. Task 5 asks before the first push. - `../sm-wavepath-app` does not exist; `docker info` answers; `GIT_OPTIONAL_LOCKS=0 git -C /media/nvme/dev/jz/wavepath.org cat-file -t 7c517191879cada7bb50ac05f474f3ac02ad4b98` prints `commit` and `GIT_OPTIONAL_LOCKS=0 git -C /media/nvme/dev/jz/wavepath.org/plugins/golem15/chat cat-file -t fbfbcf98e3392269c6e98801270669dc5d845b3b` prints `commit`. + `../sm-wavepath-app` does not exist; `docker info` answers; `docker image ls --format '{{.Repository}}:{{.Tag}}'` lists `mariadb:11` and `typesense/typesense:30.2`; `GIT_OPTIONAL_LOCKS=0 git -C /media/nvme/dev/jz/wavepath.org rev-parse --verify 'HEAD^{commit}'` prints a 40-character id; `GIT_OPTIONAL_LOCKS=0 git -C /media/nvme/dev/jz/wavepath.org submodule status` prints no line starting with `-` (every gitlink is initialised, so each pinned commit can be read locally). ../sm-wavepath-app/.gitignore, ../sm-wavepath-app/.gitmodules, ../sm-wavepath-app/summer.yaml, ../sm-wavepath-app/go.mod, ../sm-wavepath-app/go.sum, ../sm-wavepath-app/go.work, ../sm-wavepath-app/main.go, ../sm-wavepath-app/plugins.gen.go, ../sm-wavepath-app/boot_test.go, ../sm-wavepath-app/config/app.yaml, ../sm-wavepath-app/app/app.go, ../sm-wavepath-app/plugins/golem15/wavepath/go.mod, ../sm-wavepath-app/plugins/golem15/wavepath/plugin.go, ../sm-wavepath-app/plugins/golem15/wavepath/README.md, ../sm-wavepath-app/parity/pins.env, ../sm-wavepath-app/parity/parity.env, ../sm-wavepath-app/parity/php_parity.sh, ../sm-wavepath-app/parity/wavepath_reset.php, ../sm-wavepath-app/parity/fixtureplugin/plugin.go, ../sm-wavepath-app/parity/fixtureplugin/seed.go, ../sm-wavepath-app/parity/manifest.yaml, ../sm-wavepath-app/parity/fixtures/seed/bootstrap.yaml, ../sm-wavepath-app/parity/fixtures/routes/GET___wave_api_v1_community_friends_jwt.yaml, ../sm-wavepath-app/parity/parity_test.go, ../sm-wavepath-app/parity/testmain_test.go, ../sm-wavepath-app/scripts/parity-stack.sh, ../sm-wavepath-app/scripts/check-parity.sh - ../sm-demo-app/summer.yaml, ../sm-demo-app/go.mod, ../sm-demo-app/go.work, ../sm-demo-app/.gitmodules, ../sm-demo-app/boot_test.go, ../sm-demo-app/testmain_test.go, ../sm-demo-app/plugins/demo/plugin.go (lines 35-126), ../fonoteka.go/go.mod, ../fonoteka.go/go.work, ../fonoteka.go/app/app.go, ../fonoteka.go/parity/php_parity.sh (whole file), ../fonoteka.go/parity/fonoteka_reset.php (lines 1-100 and 640-676), ../fonoteka.go/parity/fixtureplugin/plugin.go, ../fonoteka.go/parity/fonoteka_seed_test.go (lines 1-80 and 600-660), ../fonoteka.go/parity/manifest.yaml (lines 1-40), ../fonoteka.go/parity/parity_test.go (lines 40-210), ../fonoteka.go/parity/synthetic_test.go (lines 36-104), ../fonoteka.go/parity/fixtures/seed/bootstrap.yaml, modules/tide/README.md ("Usage", "CLI commands"), 31-RESEARCH.md ("Recording commit and pins", "PHP stack from outside the checkout", "The sm-wavepath-app skeleton"), 31-PATTERNS.md (the sections for summer.yaml, app/app.go, manifest.yaml, php_parity.sh, wavepath_reset.php, fixtureplugin and parity_test.go). From the PHP contract, read-only with `git show`: the route at `routes.php` line 616 (`GET community/friends`), `controllers/api/CommunityFriendsController.php` (index), `classes/responses/ApiResponse.php`, and the code that issues the session JWT at login - Per D-02, D-01, D-08, D-20, D-04, D-21 and D-15. + ../sm-demo-app/summer.yaml, ../sm-demo-app/go.mod, ../sm-demo-app/go.work, ../sm-demo-app/.gitmodules, ../sm-demo-app/boot_test.go, ../sm-demo-app/testmain_test.go, ../sm-demo-app/plugins/demo/plugin.go (lines 35-126), ../fonoteka.go/go.mod, ../fonoteka.go/go.work, ../fonoteka.go/app/app.go, ../fonoteka.go/parity/php_parity.sh (whole file), ../fonoteka.go/parity/fonoteka_reset.php (lines 1-100 and 640-676), ../fonoteka.go/parity/fixtureplugin/plugin.go, ../fonoteka.go/parity/fonoteka_seed_test.go (lines 1-80 and 600-660), ../fonoteka.go/parity/manifest.yaml (lines 1-40), ../fonoteka.go/parity/parity_test.go (lines 40-210), ../fonoteka.go/parity/synthetic_test.go (lines 36-104), ../fonoteka.go/parity/fixtures/seed/bootstrap.yaml, modules/tide/README.md ("Usage", "CLI commands"), 31-RESEARCH.md ("Drift D1" (35 gitlinks at the reference snapshot, three of them new), "Drift D12" (env names, Redis, search), "Recording commit and pins", "PHP stack from outside the checkout", "The sm-wavepath-app skeleton"), 31-PATTERNS.md (the sections for summer.yaml, app/app.go, manifest.yaml, php_parity.sh, wavepath_reset.php, fixtureplugin and parity_test.go). From the PHP contract, read-only with `git show` at the resolved wavepath pin: the `GET community/friends` route in `routes.php`, `controllers/api/CommunityFriendsController.php` (index), `classes/responses/ApiResponse.php`, the code that issues the session JWT at login; and at the superproject commit: `config/scout.php` (the env names of the Typesense driver and the keys of `typesense.model-settings`) + Per D-02, D-01, D-08, D-12 (freeze at recording time), D-20, D-04, D-21 and D-15, and the session decisions on resolved pins and Typesense (31.2 D-03). 1. Repository: `git init -b master ../sm-wavepath-app`. `.gitignore` covers the built binary `wavepath`, `tmp/`, `*.vars`, `*.vars.yaml` and editor files. `summer.yaml`: module `git.golem15.com/golem15/sm-wavepath-app`, binary `wavepath`, the eight shared plugin entries in the order of the interfaces block, then `golem15.wavepath` with module `git.golem15.com/golem15/sm-wavepath-app/plugins/golem15/wavepath`. Add the eight shared plugins as submodules at `plugins/golem15/NAME` with `ssu` (or `git submodule add -b BRANCH`), each checked out at the released tag listed in the interfaces block. `go.mod` requires the framework and the plugins at those tags and replaces the framework with `../summercms.go`; `go.work` uses `.`, the eight submodule directories and `./plugins/golem15/wavepath`, and carries the framework replace. Check each plugin's go.mod for other `replace` lines and override any in go.work. 2. App plugin shell `plugins/golem15/wavepath` (own go.mod, package `wavepath`): `const ID = "golem15.wavepath"`, a `Plugin` type holding `*backpack.App`, `Requires()` returning the eight shared plugin ids, `Register` and `Boot` that only store the app, `init()` calling `party.Register`, compile-time assertion for `party.Plugin`. README in the module README structure (H1, one sentence, import line, Overview, Usage, Testing), marked as the start of WavePath's Go app. 3. `app/app.go`: `PluginIDs` (the nine ids) and `Handler` in the shape of fonoteka's, with the nine plugins blank-imported. `config/app.yaml`: the application config the binary and tests load, with test-only values only. Generate `plugins.gen.go` and `main.go` with the `summer build` command (install the CLI with `go install ./cmd/summer` from `summercms.go`, then run `summer build` in the app directory); do not hand-write them. `boot_test.go`: `TestBootAllPlugins` in the shape of the demo's. -4. `parity/pins.env`: `KEY=value` lines for `SUPERPROJECT`, and one `PIN_NAME` per pinned repository (wavepath, chat, chatchannels, chatbots, chatvideo, forum, herald, userfriends, user, websockets, oauthserver, journal, and the three clients), with full 40-character ids read from `git ls-tree 7c517191879cada7bb50ac05f474f3ac02ad4b98` in the checkout. They must agree with the research table; a difference is reported, not resolved silently. `parity/parity.env`: the test-only overlay values as `KEY=value` data: `APP_KEY`, `JWT_SECRET`, `CENTRIFUGO_API_KEY`, `CENTRIFUGO_SECRET` (at least 32 bytes), `CENTRIFUGO_PROXY_SECRET`, a VAPID pair generated once for tests, `LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET`, `TURNSTILE_SECRET`, `TURNSTILE_SITE_KEY`, and a JWT lifetime long enough for a whole recording run. +4. `parity/php_parity.sh pin` writes `parity/pins.env`; it is never written by hand. With `GIT_OPTIONAL_LOCKS=0`: resolve `SUPERPROJECT` to the full id of `PARITY_PIN_REF` (default `HEAD`) in `WAVEPATH_SRC`; list every gitlink with `git ls-tree -r SUPERPROJECT` (mode 160000), recursing into a gitlink's own tree when it has nested gitlinks; write `SUPERPROJECT=` and one line `PIN_=@<40-character id>` per gitlink, where KEY is the path upper-cased with every character outside `A-Z0-9` replaced by `_`, sorted by path. The number of gitlinks is whatever `ls-tree` lists (a labelled reference snapshot of 2026-11-22 found 35, three of them new since the old freeze); no repository list is written into the script. Each pinned commit must exist in its own repository (`git -C cat-file -e ^{commit}`); a missing object is `refuse: pin not present locally` (never fetch). It prints `pin: superproject gitlinks N`. `pin` writes `${PARITY_PINS_FILE:-parity/pins.env}`, and every subcommand that reads the pins (`export`, `check`) reads the same variable, so a separate instance (plan 31-08's `oidc`) can pin without touching the committed corpus pins. `parity/parity.env`: the test-only overlay values as `KEY=value` data: `APP_KEY`, `JWT_SECRET`, `CENTRIFUGO_API_KEY`, `CENTRIFUGO_SECRET` (at least 32 bytes), `CENTRIFUGO_PROXY_SECRET`, a VAPID pair generated once for tests, `LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET`, `TURNSTILE_SECRET`, `TURNSTILE_SITE_KEY`, `TYPESENSE_API_KEY`, and a JWT lifetime long enough for a whole recording run. 5. `parity/php_parity.sh` (bash, `set -euo pipefail`, structure of fonoteka's): variables `WAVEPATH_SRC` (default `/media/nvme/dev/jz/wavepath.org`), `PARITY_ROOT` (default `${XDG_CACHE_HOME:-$HOME/.cache}/summercms/wavepath-parity`), `PARITY_INSTANCE` (default `corpus`), `PHP_ROOT="$PARITY_ROOT/$PARITY_INSTANCE/php"`, vars file `$PARITY_ROOT/$PARITY_INSTANCE/vars.yaml` (mode 0600). Subcommands for the tracer: - - `export`: with `GIT_OPTIONAL_LOCKS=0`, archive the superproject at `SUPERPROJECT` into `PHP_ROOT`, then every gitlink that `git ls-tree -r` lists at that commit (recursively) from its own repository directory at the recorded commit; a missing commit object is a refusal naming the repository (never fetch there). Copy `vendor/` with `rsync -a` (source read-only), and any other untracked directory Composer installed that the application needs to boot. Write `PHP_ROOT/.parity-export` listing each path and commit. Never copy `.env`. + - `export`: with `GIT_OPTIONAL_LOCKS=0`, archive the superproject at `SUPERPROJECT` of `parity/pins.env` into `PHP_ROOT`, then every gitlink of `pins.env` under `plugins/` from its own repository at its pin. A gitlink outside `plugins/` (client, desktop and SDK repositories) is not copied: its checkout must be at its pin (`git -C rev-parse HEAD` equals the pin, else `refuse: checkout is not at its pin`; plan 31-05 drives the clients from these checkouts), and a dirty client tree prints a `warn:` line. Copy `vendor/` with `rsync -a` (source read-only), and any other untracked directory Composer installed that the application needs to boot. Write `PHP_ROOT/.parity-export`: the line `superproject ` and one line per `pins.env` gitlink with path, commit and `exported` or `client`. Never copy `.env`. - `db`: start (or reuse) the container `wavepath-parity-mariadb` from the local image `mariadb:11`, published on `127.0.0.1:33306` only, and create the database `wavepath_parity_$PARITY_INSTANCE`. - - `export_env` (a function): refuse a database name without `parity` or a non-loopback host; export `DB_*`, `CACHE_DRIVER=file`, `SESSION_DRIVER=array`, `MAIL_MAILER=array`, `APP_URL`, `APP_DEBUG=false`, `SCOUT_DRIVER=null` and the values of `parity/parity.env` (parsed as data). - - `artisan ARGS`, `reset` (runs `artisan winter:up`, then `artisan tinker --execute` requiring the absolute path of `parity/wavepath_reset.php` with `PARITY_VARS_OUT` set), `serve` (PHP's built-in server on `127.0.0.1:8423` with `-d error_reporting=8191`, cwd `PHP_ROOT`), `rows SELECT` (one SELECT without a semicolon). + - `typesense`: start (or reuse) the container `wavepath-parity-typesense` from the local image `typesense/typesense:30.2`, published on `127.0.0.1:38108` only, data under `$PARITY_ROOT/typesense-data`, API key `TYPESENSE_API_KEY` of `parity/parity.env`; wait up to 30 seconds for its `/health` to answer `ok`. + - `export_env` (a function): refuse a database name without `parity`, a non-loopback `DB_HOST` or a non-loopback `TYPESENSE_HOST`; export `DB_*`, `CACHE_DRIVER=file`, `SESSION_DRIVER=array`, `MAIL_MAILER=array`, `APP_URL`, `APP_DEBUG=false`, `SCOUT_DRIVER=typesense`, `TYPESENSE_HOST=127.0.0.1`, `TYPESENSE_PORT=38108`, `TYPESENSE_PROTOCOL=http`, `SCOUT_PREFIX=parity_${PARITY_INSTANCE}_` (instances never share an index), `KLIPY_TOKEN=` and `X_CAPTURE_BEARER_TOKEN=` (empty, so no developer value is read; RESEARCH "Drift D12"), and the values of `parity/parity.env` (parsed as data). + - `reindex`: through `artisan tinker`, read the searchable classes as the keys of `config('scout.typesense.model-settings')` of the export, then run `artisan scout:flush` and `artisan scout:import` for each; print `reindex: N models`. + - `artisan ARGS`, `reset` (runs `artisan winter:up`, then `artisan tinker --execute` requiring the absolute path of `parity/wavepath_reset.php` with `PARITY_VARS_OUT` set, then `reindex`), `serve` (PHP's built-in server on `127.0.0.1:8423` with `-d error_reporting=8191`, cwd `PHP_ROOT`), `rows SELECT` (one SELECT without a semicolon). - After `export`, assert through `artisan tinker` that the file of `Golem15\Chat\Classes\AttachmentStreamer` lies under `PHP_ROOT`; otherwise print `refuse: PHP loaded chat from outside the parity root` and exit 1. -6. `scripts/parity-stack.sh` in its thinnest form: `up` (mode `readonly`: `BROADCAST_ENABLED=false`, `QUEUE_CONNECTION=database` with no worker, `HTTPS_PROXY` and `https_proxy` set to `http://127.0.0.1:9`, then export, db, reset and serve, recording the process group), `down` (stops this instance's PHP server; the container stays), `self-replay` (runs `summer parity:replay --manifest parity/manifest.yaml --fixtures parity/fixtures --target http://127.0.0.1:8423 --vars VARSFILE --self-check true` and prints its summary line). +6. `scripts/parity-stack.sh` in its thinnest form: `up` (mode `readonly`: `BROADCAST_ENABLED=false`, `QUEUE_CONNECTION=database` with no worker, `HTTPS_PROXY` and `https_proxy` set to `http://127.0.0.1:9`, then pin check (`pins.env` exists; `up` never re-pins, plan 31-05's wrapper does), export, db, typesense, reset and serve, recording the process group), `down` (stops this instance's PHP server; the containers stay), `self-replay` (runs `summer parity:replay --manifest parity/manifest.yaml --fixtures parity/fixtures --target http://127.0.0.1:8423 --vars VARSFILE --self-check true` and prints its summary line). 7. `parity/wavepath_reset.php`, tracer scope: users `alice@parity.test` and `dave@parity.test` with explicit ids, an accepted friendship between them, id floors with `ALTER TABLE … AUTO_INCREMENT`, the session JWT of alice minted with the application's own token code, and only the vars file as output (`jwt:alice`, `id:alice`, `id:dave`; never echo a value). 8. `parity/fixtureplugin`: the plugin shell (`ID()` `parity.fixtureplugin`, `Requires()` `golem15.wavepath`, constructed in process, never registered) and `Seed(ctx, db, store)` writing the same two users, the friendship and the same variable names, with alice's JWT minted through the user plugin's token service. 9. `parity/manifest.yaml`: version 1, auth groups `jwt`, `guest`, `bot`, `webhook`, `realtime`, the seed spec, and one route: id `GET /_wave/api/v1/community/friends jwt`, status `pending`, seed hook `community`, two cases: `alice` (request header `Cookie: token={{jwt:alice}}`, `Accept: application/json`) and `unauthenticated` (no cookie). Record both from PHP with `summer parity:record --manifest`, then run the self-replay. If the recorded body holds a relative-time string that only plan 31-01's mask can compare and that plan has not committed it yet, record `GET /_wave/api/v1/push/vapid-public-key jwt` as the tracer route instead and say so in the SUMMARY (the friends route is then recorded in plan 31-05). 10. `parity/testmain_test.go` and `parity/parity_test.go`: a testcontainers Postgres (`postgres:16-alpine`) started in `TestMain` after `flag.Parse()` unless `testing.Short()`; `seedHooks` with `community` calling `fixtureplugin.Seed`; `TestParityCorpus` loads and validates the manifest, serves `app.Handler` through `httptest`, loads every fixture of a pending route without sending it, replays every ported route strictly, and logs one line `parity: ported P pending N`. A pending route is never counted as passing. -11. `scripts/check-parity.sh` in its first form: the corpus stage (fixtures of the manifest load), the replay stage (`go test -count=1 -json ./parity`, failing on a failed test, on zero tests and on a missing `TestParityCorpus`), an optional `--self-replay` stage calling `scripts/parity-stack.sh up`, `self-replay` and `down`, and one summary line `check-parity: recorded R/T ported P pending N`. The flags `--allow-unrecorded` and `--allow-pending-foundation` are accepted. -12. Commit in `../sm-wavepath-app` in logical steps (skeleton; PHP stack; scenario seed; manifest and fixture; harness and gate), staging by path. +11. `scripts/check-parity.sh` in its first form: the corpus stage (fixtures of the manifest load), the replay stage (`go test -count=1 -json ./parity`, failing on a failed test, on zero tests and on a missing `TestParityCorpus`), an optional `--self-replay` stage calling `scripts/parity-stack.sh up`, `self-replay` and `down`, and one summary line `check-parity: recorded R/T ported P pending N` (T = manifest routes). The flags `--allow-unrecorded` and `--allow-pending-foundation` are accepted. +12. Commit in `../sm-wavepath-app` in logical steps (skeleton; PHP stack with pins; scenario seed; manifest and fixture; harness and gate), staging by path. go -C ../sm-wavepath-app vet . ./app/... ./parity/... ./plugins/golem15/wavepath/... && go -C ../sm-wavepath-app test -count=1 -short . ./app/... ./plugins/golem15/wavepath/... && go -C ../sm-wavepath-app test -count=1 -run '^TestBootAllPlugins$' -v . 2>&1 | grep -q -- '^--- PASS: TestBootAllPlugins' && go -C ../sm-wavepath-app test -count=1 -run '^TestParityCorpus$' -v ./parity 2>&1 | grep -q -- '^--- PASS: TestParityCorpus' Non-zero exit: vet or a short test fails, the nine plugins do not boot, or the `--- PASS: TestParityCorpus` line is absent (the manifest or the fixture did not load, Docker was not reachable, or the filter matched nothing). OUT="$(../sm-wavepath-app/scripts/check-parity.sh --self-replay --allow-unrecorded --allow-pending-foundation 2>&1)" && printf '%s\n' "$OUT" | grep -qE 'failing 0 unrecorded 0' && printf '%s\n' "$OUT" | grep -qE '^check-parity: recorded 1/1 ported 0 pending 1' - Non-zero exit from the gate (the PHP stack refused or did not boot, the self-replay found a difference), or the output lacks the self-replay line `failing 0 unrecorded 0`, or lacks the summary line `check-parity: recorded 1/1 ported 0 pending 1`. + Non-zero exit from the gate (the PHP stack refused or did not boot, Typesense did not answer, the self-replay found a difference), or the output lacks the self-replay line `failing 0 unrecorded 0`, or lacks the summary line `check-parity: recorded 1/1 ported 0 pending 1`. - `grep -c '^\[submodule ' ../sm-wavepath-app/.gitmodules` prints 8, and `git -C ../sm-wavepath-app submodule status` prints eight lines, none starting with `+` or `-`. - `grep -c 'golem15.wavepath' ../sm-wavepath-app/summer.yaml` prints 1; `grep -c 'parity.fixtureplugin' ../sm-wavepath-app/summer.yaml ../sm-wavepath-app/plugins.gen.go ../sm-wavepath-app/app/app.go | awk -F: '{s+=$2} END {print s}'` prints 0. + - The pins are the resolved gitlink set: `S="$(sed -n 's/^SUPERPROJECT=//p' ../sm-wavepath-app/parity/pins.env)" && test "${#S}" = 40 && test "$(grep -c '^PIN_' ../sm-wavepath-app/parity/pins.env)" = "$(GIT_OPTIONAL_LOCKS=0 git -C /media/nvme/dev/jz/wavepath.org ls-tree -r "$S" | awk '$2=="commit"' | wc -l)"` exits 0. + - `.parity-export` matches the pins: `P="${XDG_CACHE_HOME:-$HOME/.cache}/summercms/wavepath-parity/corpus/php/.parity-export" && test "$(grep -vc '^superproject ' "$P")" = "$(grep -c '^PIN_' ../sm-wavepath-app/parity/pins.env)"` exits 0. + - `grep -vE '^\s*#' ../sm-wavepath-app/parity/php_parity.sh | grep -cE 'plugins/golem15/(chat|user|wavepath)[^/]'` prints 0 (no fixed repository list in the script). - The recorded fixture has the `alice` case with status 200 and the `unauthenticated` case with the status PHP answered, and holds no JWT: `grep -cE 'eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.' ../sm-wavepath-app/parity/fixtures/routes/*.yaml | awk -F: '{s+=$2} END {print s}'` prints 0. - `stat -c %a "${XDG_CACHE_HOME:-$HOME/.cache}/summercms/wavepath-parity/corpus/vars.yaml"` prints 600. - `grep -vE '^\s*#' ../sm-wavepath-app/parity/php_parity.sh ../sm-wavepath-app/scripts/parity-stack.sh | grep -cE 'worktree add|git (-C [^ ]+ )?(checkout|stash|commit|fetch|pull)|composer (install|update)|(npm|pnpm) (install|ci|add)'` prints 0. - `git -C ../sm-wavepath-app remote` prints nothing. - The application repository exists and boots, the PHP reference backend runs from the pinned commits without touching the other agent's checkout, and one real route is recorded, self-replays green on PHP and is counted as pending by the Go harness and by the gate. + The application repository exists and boots, the PHP reference backend runs from pins resolved over every gitlink without touching the other agent's checkout, Scout talks to a loopback Typesense, and one real route is recorded, self-replays green on PHP and is counted as pending by the Go harness and by the gate. - Task 2: The stack fails closed: record mode, instances, snapshot and per-case restore, status and check, and a self-test of every refusal + Task 2: The stack fails closed: record mode, instances, snapshot and per-case restore with re-index, status and check, and a self-test of every refusal Task 1's verify passed: `../sm-wavepath-app/scripts/parity-stack.sh up` and `down` work in read-only mode. ../sm-wavepath-app/scripts/parity-stack.sh, ../sm-wavepath-app/parity/php_parity.sh, ../sm-wavepath-app/parity/case_hook.sh, ../sm-wavepath-app/parity/README.md - ../sm-wavepath-app/scripts/parity-stack.sh and ../sm-wavepath-app/parity/php_parity.sh (as Task 1 left them), ../fonoteka.go/scripts/dev-stack.sh (lines 1-130 the header contract and helpers; the functions is_loopback, parse_env_file, check_keys, check_services, port_busy, launch, stop_groups, cleanup, up, down, status, check and the dispatch at the end), ../fonoteka.go/parity/php_parity.sh (lines 10-73 and 120-220), 31-RESEARCH.md ("Recommended shape" items 1 to 6, pitfalls 3, 4, 5 and 8), 31-PATTERNS.md ("parity-stack.sh", "Fail-closed scripts", "No Analog Found"). From the PHP contract with `git show`: the config files that name the environment variables for Centrifugo, LiveKit, VAPID, Turnstile, the queue and the cache - Per D-08 and D-20, closing threats T-31-08 and T-31-10. + ../sm-wavepath-app/scripts/parity-stack.sh and ../sm-wavepath-app/parity/php_parity.sh (as Task 1 left them), ../fonoteka.go/scripts/dev-stack.sh (lines 1-130 the header contract and helpers; the functions is_loopback, parse_env_file, check_keys, check_services, port_busy, launch, stop_groups, cleanup, up, down, status, check and the dispatch at the end), ../fonoteka.go/parity/php_parity.sh (lines 10-73 and 120-220), 31-RESEARCH.md ("Recommended shape" items 1 to 6, pitfalls 3, 4, 5, 7 and 8, "Drift D6" (bucket sizes at the reference snapshot), "Drift D12"), 31-PATTERNS.md ("parity-stack.sh", "Fail-closed scripts", "No Analog Found"). From the PHP contract with `git show` at the resolved pins: the config files that name the environment variables for Centrifugo, LiveKit (the chatvideo config also used by DM calls), VAPID, Turnstile, the queue, the cache and Scout + Per D-08, D-12 and D-20, closing threats T-31-08, T-31-10, T-31-40 and T-31-41. 1. `scripts/parity-stack.sh`: a header comment listing every subcommand and environment variable and the rule that lines starting with `refuse:` or `missing:` mean the script stopped and `warn:` lines never stop it. Helpers `say`, `warn`, `refuse`, `fail` in the style of fonoteka's; `set -euo pipefail`; `unset FORCE_COLOR`; a `curl --noproxy '*'` wrapper; env files parsed as `KEY=value` data, never executed. Subcommands: - - `up [--mode readonly|record]`. Mode `record` exports `BROADCAST_DRIVER=centrifugo`, `BROADCAST_ENABLED=true`, `CENTRIFUGO_API_URL=http://127.0.0.1:RECORDER_PORT/api`, `QUEUE_CONNECTION=sync`, `HTTPS_PROXY` and `https_proxy` at `http://127.0.0.1:PROXY_PORT`, `NO_PROXY=127.0.0.1,localhost`, the parity CA through `-d curl.cainfo` and `-d openssl.cafile` on the PHP server, `LIVEKIT_URL=https://livekit.example.test` (a name that never resolves, so a call that bypasses the proxy fails), and the LiveKit, VAPID and Turnstile values of `parity/parity.env`. Before starting PHP it waits up to `PARITY_LISTENER_WAIT` seconds (default 60) for the recorder and the proxy to accept connections and then prints `refuse: recorder not listening on …` or `refuse: upstream proxy not listening on …` and exits 1. Mode `readonly` is Task 1's. - - `down` stops this instance's process groups (TERM, then KILL after 10 seconds); `down --all` also stops the container when no other instance has a pid file. - - `status` lists the instance, mode, ports, database and whether each process answers. - - `check` verifies: the export's `.parity-export` equals `parity/pins.env`; the chat class-path assertion; the database name contains `parity` and the host is loopback; the vars file is mode 0600; the keys of the vars file equal `parity/scenario.vars.keys` once that file exists; in record mode both listeners answer. It prints every failed check and exits 1 if any failed. - - `selftest` runs each refusal against planted input in a scratch directory with no real service: a database name without `parity`, a non-loopback `DB_HOST`, a non-loopback target, record mode with nothing listening, a `pins.env` that differs from the export record, a vars file with mode 0644. Each must print its `refuse:` line and exit non-zero; `selftest` prints `selftest: ok` only when all did. - - Ports per instance: `corpus` uses 8423 (PHP), 8424 (recorder), 8425 (upstream proxy), 8422 (session proxy); any other instance name adds 100 to each. The MariaDB container is shared, one database per instance. -2. `parity/php_parity.sh`: add `snapshot` (dump the instance database after `reset` into `$PARITY_ROOT/$PARITY_INSTANCE/snapshot.sql`, AUTO_INCREMENT floors included) and `restore` (load the snapshot, clear the export's file cache so rate-limit counters start at zero); add `script FILE [ARGS]` (run a PHP file through `artisan tinker` with the overlay, for plan 31-08). Keep the `rows` guard. -3. `parity/case_hook.sh` (executable): reads `PARITY_ROUTE_ID`, `PARITY_CASE_ID` and `PARITY_SEED_HOOK`, calls `php_parity.sh restore`, and applies the case's scenario variant when the reset script defines one for that case id. Exit non-zero on any failure. Measure one restore and write the time into the README. -4. `parity/README.md`: the runbook so far: what the parity root holds, the pins, the two modes, the instance rule, every refusal and what it means, how to bring the stack up and down, and the rule that nothing is written in the PHP checkout. -5. Commit: `feat(parity): fail-closed stack with record mode, instances and per-case restore`. + - `up [--mode readonly|record]`. Mode `record` exports `BROADCAST_DRIVER=centrifugo`, `BROADCAST_ENABLED=true`, `CENTRIFUGO_API_URL=http://127.0.0.1:RECORDER_PORT/api`, `QUEUE_CONNECTION=sync`, `HTTPS_PROXY` and `https_proxy` at `http://127.0.0.1:PROXY_PORT`, `NO_PROXY=127.0.0.1,localhost`, the parity CA through `-d curl.cainfo` and `-d openssl.cafile` on the PHP server, `LIVEKIT_URL=https://livekit.example.test` (a name that never resolves, so a call that bypasses the proxy fails; group-call and DM-call LiveKit requests both use it), and the LiveKit, VAPID and Turnstile values of `parity/parity.env`. It starts PHP with `PHP_CLI_SERVER_WORKERS` set to `PARITY_PHP_WORKERS` (default 8) so the parallel warm-ups of a 429 case (tide `repeat_parallel`) reach PHP concurrently. Rate-limit counters must count every concurrent warm-up: when the exported schema has the `cache` table (`Schema::hasTable('cache')` through `artisan tinker`), record mode uses `CACHE_DRIVER=database`, whose increments are row-locked and which the per-case database restore resets with the snapshot; otherwise it keeps `file`, prints `warn: file cache; record 429 cases without repeat_parallel` and the README says so. Before starting PHP it waits up to `PARITY_LISTENER_WAIT` seconds (default 60) for the recorder and the proxy to accept connections and then prints `refuse: recorder not listening on …` or `refuse: upstream proxy not listening on …` and exits 1; it refuses `refuse: typesense not answering on 127.0.0.1:38108` when `/health` does not answer. Mode `readonly` is Task 1's. + - `down` stops this instance's process groups (TERM, then KILL after 10 seconds); `down --all` also stops both containers when no other instance has a pid file. + - `status` lists the instance, mode, ports, database, Typesense prefix and whether each process answers. + - `check` verifies: `.parity-export` lists exactly the superproject and the gitlinks of `parity/pins.env` with the same commits; every `client` gitlink's checkout is still at its pin; the chat class-path assertion; the database name contains `parity` and the host is loopback; Typesense answers on loopback with the parity key; the vars file is mode 0600; the keys of the vars file equal `parity/scenario.vars.keys` once that file exists; in record mode both listeners answer. It prints every failed check and exits 1 if any failed. + - `selftest` runs each refusal against planted input in a scratch directory with no real service: a database name without `parity`, a non-loopback `DB_HOST`, a non-loopback `TYPESENSE_HOST`, a non-loopback target, record mode with nothing listening, a `pins.env` that lacks one gitlink a planted scratch superproject's `ls-tree` lists, a `.parity-export` whose commit differs from `pins.env`, a planted client repository whose HEAD is not its pin, a vars file with mode 0644. Each must print its `refuse:` line and exit non-zero; `selftest` prints `selftest: ok` only when all did. + - Ports per instance: `corpus` uses 8423 (PHP), 8424 (recorder), 8425 (upstream proxy), 8422 (session proxy); any other instance name adds 100 to each. The MariaDB and Typesense containers are shared: one database and one `SCOUT_PREFIX` per instance. +2. `parity/php_parity.sh`: add `snapshot` (dump the instance database after `reset` into `$PARITY_ROOT/$PARITY_INSTANCE/snapshot.sql`, AUTO_INCREMENT floors included) and `restore` (load the snapshot, clear the export's file cache so rate-limit counters start at zero, and run `reindex` when `PARITY_REINDEX=1`); add `script FILE [ARGS]` (run a PHP file through `artisan tinker` with the overlay, for plan 31-08). Keep the `rows` guard. +3. `parity/case_hook.sh` (executable): reads `PARITY_ROUTE_ID`, `PARITY_CASE_ID` and `PARITY_SEED_HOOK`, calls `php_parity.sh restore` with `PARITY_REINDEX=1` when the last path segment of the route id's path is `search` (the index then equals the restored database), and applies the case's scenario variant when the reset script defines one for that case id. Exit non-zero on any failure. Measure one restore with and without re-index and write both times into the README. +4. `parity/README.md`: the runbook so far: what the parity root holds, how `pin` resolves the pins (and that 31-05 re-runs it at recording start), the export of `plugins/` gitlinks and the at-pin rule for client checkouts, the two modes, the PHP worker and cache-store rule for 429 cases, Typesense (container, prefix per instance, re-index before search cases), the instance rule, every refusal and what it means, how to bring the stack up and down, and the rule that nothing is written in the PHP checkout. +5. Commit: `feat(parity): fail-closed stack with record mode, instances, search and per-case restore`. OUT="$(../sm-wavepath-app/scripts/parity-stack.sh selftest 2>&1)" && printf '%s\n' "$OUT" | grep -qx 'selftest: ok' - Non-zero exit, or the line `selftest: ok` is absent: a planted bad input (database name without parity, non-loopback host or target, missing listeners, pin mismatch, vars mode) was accepted. - ( ../sm-wavepath-app/scripts/parity-stack.sh up --mode readonly && ../sm-wavepath-app/scripts/parity-stack.sh check && ../sm-wavepath-app/parity/php_parity.sh snapshot && PARITY_ROUTE_ID=x PARITY_CASE_ID=y PARITY_SEED_HOOK=community ../sm-wavepath-app/parity/case_hook.sh && OUT="$(../sm-wavepath-app/scripts/parity-stack.sh self-replay 2>&1)" && printf '%s\n' "$OUT" | grep -q 'failing 0 unrecorded 0'; RC=$?; ../sm-wavepath-app/scripts/parity-stack.sh down; exit $RC ) - Non-zero exit: `up` or `check` printed a `refuse:` line, the snapshot or the case hook failed, or the self-replay after a restore no longer prints `failing 0 unrecorded 0` (the restore does not bring back the recorded state). + Non-zero exit, or the line `selftest: ok` is absent: a planted bad input (database name without parity, non-loopback database, Typesense or target host, missing listeners, a gitlink missing from pins.env, an export commit mismatch, a client checkout off its pin, vars mode) was accepted. + ( ../sm-wavepath-app/scripts/parity-stack.sh up --mode readonly && ../sm-wavepath-app/scripts/parity-stack.sh check && ../sm-wavepath-app/parity/php_parity.sh snapshot && PARITY_ROUTE_ID='GET /_wave/api/v1/community/groups/{id}/search jwt' PARITY_CASE_ID=y PARITY_SEED_HOOK=community ../sm-wavepath-app/parity/case_hook.sh && OUT="$(../sm-wavepath-app/scripts/parity-stack.sh self-replay 2>&1)" && printf '%s\n' "$OUT" | grep -q 'failing 0 unrecorded 0'; RC=$?; ../sm-wavepath-app/scripts/parity-stack.sh down; exit $RC ) + Non-zero exit: `up` or `check` printed a `refuse:` line, the snapshot, the restore or the re-index of the case hook failed, or the self-replay after a restore no longer prints `failing 0 unrecorded 0` (the restore does not bring back the recorded state). - `PARITY_LISTENER_WAIT=2 ../sm-wavepath-app/scripts/parity-stack.sh up --mode record` with nothing on 8424 exits non-zero and prints a line starting with `refuse: recorder not listening`. - - `grep -c 'refuse:' ../sm-wavepath-app/scripts/parity-stack.sh` prints at least 6. + - `grep -c 'refuse:' ../sm-wavepath-app/scripts/parity-stack.sh` prints at least 9. - `grep -vE '^\s*#' ../sm-wavepath-app/parity/php_parity.sh ../sm-wavepath-app/scripts/parity-stack.sh ../sm-wavepath-app/parity/case_hook.sh | grep -cE 'worktree add|git (-C [^ ]+ )?(checkout|stash|commit|fetch|pull)|composer (install|update)|(npm|pnpm) (install|ci|add)'` prints 0. - `test -x ../sm-wavepath-app/parity/case_hook.sh` exits 0. - - `docker ps --format '{{.Names}} {{.Ports}}' | grep wavepath-parity-mariadb` shows the port published on `127.0.0.1` only. + - `docker ps --format '{{.Names}} {{.Ports}}' | grep -E 'wavepath-parity-(mariadb|typesense)'` shows both containers with their ports published on `127.0.0.1` only. + - `grep -c 'PHP_CLI_SERVER_WORKERS' ../sm-wavepath-app/scripts/parity-stack.sh` prints at least 1 and `grep -ci 'typesense' ../sm-wavepath-app/parity/README.md` prints at least 1. - The stack cannot serve PHP in record mode without the recorder and the proxy, cannot use a database that is not a parity database, and can return to the recorded state before every case. + The stack cannot serve PHP in record mode without the recorder, the proxy and Typesense, cannot use a database or index that is not a parity one, cannot export commits other than the resolved pins, and can return to the recorded state (index included) before every case. Task 5: Go-ahead for the remote of sm-wavepath-app and its module path - `git -C ../sm-wavepath-app log --oneline`, the module path in ../sm-wavepath-app/go.mod and summer.yaml, the gate's summary line from Task 4, memory note "sm- repo naming" + `git -C ../sm-wavepath-app log --oneline`, the module path in ../sm-wavepath-app/go.mod and summer.yaml, the gate's summary line from Task 1, memory note "sm- repo naming" - The user's answer is recorded in the SUMMARY with the confirmed module path and remote URL, or "local". @@ -174,7 +197,7 @@ Output: the artifacts and machine evidence named below. ../sm-wavepath-app/go.mod, ../sm-wavepath-app/go.work, ../sm-wavepath-app/summer.yaml, ../sm-wavepath-app/plugins.gen.go, ../sm-wavepath-app/main.go, ../sm-wavepath-app/app/app.go, ../sm-wavepath-app/plugins/golem15/wavepath/go.mod, ../sm-wavepath-app/README.md The Task 5 answer, ../sm-wavepath-app/go.mod, summer.yaml and every Go file that imports the module path (`grep -rl 'sm-wavepath-app' ../sm-wavepath-app --include=*.go --include=*.yaml --include=go.mod --include=go.work`) Per D-02. -- "rename NAMESPACE/NAME": change the module path in `go.mod`, the app plugin's `go.mod`, `summer.yaml` and every import; regenerate `plugins.gen.go` and `main.go` with `summer build`; if the directory name changes too, stop and ask (the plans of this phase name `../sm-wavepath-app`). Run Task 4's first verify command again, commit `chore: module path NAMESPACE/NAME`, then continue as "push" with the new URL. +- "rename NAMESPACE/NAME": change the module path in `go.mod`, the app plugin's `go.mod`, `summer.yaml` and every import; regenerate `plugins.gen.go` and `main.go` with `summer build`; if the directory name changes too, stop and ask (the plans of this phase name `../sm-wavepath-app`). Run Task 1's first verify command again, commit `chore: module path NAMESPACE/NAME`, then continue as "push" with the new URL. - "push": `git -C ../sm-wavepath-app remote add origin URL`, `git push -u origin master`, and check that `git ls-remote origin refs/heads/master` equals `git rev-parse HEAD`. A refused push (the remote does not exist, no permission) is reported with the exact message; nothing else is tried. - "local": add no remote. Record it. In every case: no tag. Post the g15office comment on task `hgol7otp` (plan 31-03 executed; repository local or pushed). @@ -204,10 +227,12 @@ In every case: no tag. Post the g15office comment on task `hgol7otp` (plan 31-03 | Threat ID | Category | Component | Severity | Disposition | Mitigation Plan | |-----------|----------|-----------|----------|-------------|-----------------| -| T-31-07 | Tampering | scripts touching the other agent's checkout | high | mitigate | export by `git archive` at commit ids and rsync with the checkout as source only; `GIT_OPTIONAL_LOCKS=0`; acceptance greps the scripts for checkout, stash, commit, fetch, pull, worktree and install commands; the PHP server's cwd and storage are the export | -| T-31-08 | Information disclosure | a recording run reaching real vendors | high | mitigate | record mode refuses to start PHP unless the recorder and the upstream proxy listen; read-only mode sets the HTTPS proxy to a closed loopback port and a queue with no worker; LiveKit uses a host name that never resolves; the overlay holds test-only values from `parity/parity.env`; `selftest` proves the refusals | +| T-31-07 | Tampering | scripts touching the other agent's checkout | high | mitigate | export by `git archive` at commit ids and rsync with the checkout as source only; `GIT_OPTIONAL_LOCKS=0`; client checkouts are only read and compared with their pins; acceptance greps the scripts for checkout, stash, commit, fetch, pull, worktree and install commands; the PHP server's cwd and storage are the export | +| T-31-08 | Information disclosure | a recording run reaching real vendors | high | mitigate | record mode refuses to start PHP unless the recorder and the upstream proxy listen; read-only mode sets the HTTPS proxy to a closed loopback port and a queue with no worker; LiveKit (group and DM calls) uses a host name that never resolves; `KLIPY_TOKEN` and `X_CAPTURE_BEARER_TOKEN` are exported empty; the overlay holds test-only values from `parity/parity.env`; `selftest` proves the refusals | | T-31-10 | Tampering | recording against a real database | high | mitigate | the database is a container published on loopback only; the name must contain `parity`; the checkout's `.env` is never read or copied; `selftest` plants a bad name and a non-loopback host | -| T-31-13 | Tampering | recording a version other than the freeze | medium | mitigate | export by the commit ids of `parity/pins.env`; `.parity-export` compared by `check`; the class-path assertion on a class that exists only at the chat pin | +| T-31-13 | Tampering | recording a version other than the freeze | medium | mitigate | `pin` resolves the superproject and every gitlink `ls-tree` lists into `parity/pins.env`; the export uses exactly those commits and writes `.parity-export`, which `check` compares line by line; the class-path assertion proves PHP loads the exported chat; `selftest` plants a missing gitlink and a commit mismatch | +| T-31-40 | Information disclosure | the search index of the recording stack | medium | mitigate | the Typesense container is published on 127.0.0.1 only, uses the test-only key of `parity/parity.env`, and each instance indexes under its own `SCOUT_PREFIX`; a non-loopback `TYPESENSE_HOST` is refused and `selftest` plants one | +| T-31-41 | Repudiation | client requests recorded from a client tree that is not at its pin | medium | mitigate | `export` and `check` refuse when a client checkout's HEAD differs from its pin and warn on a dirty tree; `selftest` plants an off-pin client repository | | T-31-SC | Tampering | npm/pip/cargo installs | high | mitigate | no package install; use existing dependencies and explicit lockfiles | @@ -216,7 +241,7 @@ Run every task's automated command and preserve its fails_when semantics. Do not -sm-wavepath-app skeleton and fail-closed isolated PHP parity stack is complete, its named tests ran, and no locked decision or D-16 phase boundary drifted. +sm-wavepath-app skeleton and fail-closed isolated PHP parity stack (resolved pins over every gitlink, Typesense-backed search) are complete, their named tests ran, and no locked decision or D-16 phase boundary drifted. diff --git a/.planning/phases/31-chat-polish-against-wavepath-clients/31-04-PLAN.md b/.planning/phases/31-chat-polish-against-wavepath-clients/31-04-PLAN.md index f8c6ca32..917727e1 100644 --- a/.planning/phases/31-chat-polish-against-wavepath-clients/31-04-PLAN.md +++ b/.planning/phases/31-chat-polish-against-wavepath-clients/31-04-PLAN.md @@ -10,42 +10,64 @@ files_modified: - ../sm-wavepath-app/parity/scenario-deferred.txt - ../sm-wavepath-app/parity/wavepath_reset.php - ../sm-wavepath-app/parity/fixtureplugin/ + - ../sm-wavepath-app/parity/seed_test.go - ../sm-wavepath-app/parity/fixtures/seed/bootstrap.yaml - ../sm-wavepath-app/parity/manifest.yaml - ../sm-wavepath-app/parity/routes.snapshot + - ../sm-wavepath-app/parity/buckets.snapshot - ../sm-wavepath-app/parity/foundation-routes.txt - ../sm-wavepath-app/parity/check_corpus.go - ../sm-wavepath-app/parity/parity_test.go - ../sm-wavepath-app/parity/harness_test.go - ../sm-wavepath-app/parity/upstream_replay_test.go + - ../sm-wavepath-app/parity/README.md + - ../sm-wavepath-app/README.md + - ../sm-wavepath-app/plugins/golem15/wavepath/plugin_test.go - ../sm-wavepath-app/scripts/check-parity.sh autonomous: true -requirements: [SC-1, SC-3, D-04, D-09, D-15, D-16, D-18, D-19] +requirements: [SC-1, SC-3, D-04, D-09, D-11, D-12, D-15, D-16, D-18, D-19] estimate: - tokens: 180000 - raw_tokens: 180000 + tokens: 200000 + raw_tokens: 200000 tasks: 2 confidence: low must_haves: truths: - - "Scenario on both sides, 196 pending-route manifest, corpus checker, harness and fail-closed gate is delivered against the frozen PHP corpus and locked decisions." + - "One scenario is seeded on both sides with the same ids and variable names, including a collapsed-threads (CRT) identity, one rate-limit identity per user-keyed bucket the route file defines, healed participant rows with one deliberate gap, and no X/Twitter status or KLIPY URL anywhere." + - "The manifest holds every route the corpus parser derives at the resolved wavepath pin, all pending; no route count is a constant: manifest ids equal snapshot ids, snapshot ids equal the parsed route file, buckets equal the parsed throttles (withoutMiddleware applied), and the foundation list equals the routes of the four foundation controllers plus the two realtime ids." + - "The gate prints `check-parity: recorded R/T ported P pending N foundation-pending G` with T, F and the bucket count derived, refuses inconsistent counts, and refuses to pass early." - "Verification fails closed: missing, skipped, pending or mismatching evidence is not counted as a pass." - "D-16 remains intact: messaging, satellites, Range support, guest/bot/webhook host services, zero total pending and final security review stay in Phases 31.1/31.2." artifacts: - path: "../sm-wavepath-app/parity/scenario.md" - provides: "Scenario on both sides, 196 pending-route manifest, corpus checker, harness and fail-closed gate" + provides: "the single scenario definition" + - path: "../sm-wavepath-app/parity/check_corpus.go" + provides: "route and bucket parser, snapshot and manifest sync, consistency checks, secret and URL scans" + - path: "../sm-wavepath-app/scripts/check-parity.sh" + provides: "the fail-closed gate with derived counts" key_links: - - from: "../sm-wavepath-app/parity/scenario.md" - to: "the plan's automated verification" - via: "the named tracer and fail-closed checks" + - from: "../sm-wavepath-app/parity/check_corpus.go" + to: "../sm-wavepath-app/parity/routes.snapshot" + via: "--write-snapshot from the exported routes.php at the resolved wavepath pin; every later run compares" + - from: "../sm-wavepath-app/scripts/check-parity.sh" + to: "../sm-wavepath-app/parity/check_corpus.go" + via: "the corpus stage runs the checker and parses its count lines" --- ## Phase Goal -WavePath's complete 196-route PHP community corpus is recorded and self-replays green; Phase 31 ports and proves only the 36-route foundation slice, leaving exactly 160 routes pending for Phases 31.1 and 31.2 per D-16. +WavePath's complete PHP community corpus is recorded and self-replays green: every route the corpus parser derives from `routes.php` at the commits resolved when the recording starts, plus the two realtime routes. Phase 31 ports and proves only the foundation slice listed in `parity/foundation-routes.txt`; every other corpus route stays pending for Phases 31.1 and 31.2 per D-16. Counts are derived at recording time and checked for consistency, never pinned (reference snapshot 2026-11-22, not a target: 218 tracked, 36 foundation, 182 pending). + +## Artifacts this phase produces (this plan) + +- `parity/scenario.md`, `parity/scenario.vars.keys`, `parity/scenario-deferred.txt`, the full `parity/wavepath_reset.php`, `parity/fixtureplugin/seed.go` (the scenario through the Go models), `parity/seed_test.go` with `TestScenarioSeeds`, `TestScenarioVarsMatch`, `TestFixtureAbsentFromProduction`, `TestSeededJWTAuthenticates`. +- Scenario identities `alice`, `bob`, `carol`, `dave`, `erin`, `frank`, `olive`, `grace` (CRT), one `rl-` per user-keyed bucket, a bot, a guest; groups `harbor`, `plaza`, `cellar`; harbor's public channels `general` and `lounge`. +- `parity/check_corpus.go` (package main) with flags `--manifest`, `--snapshot`, `--buckets`, `--routes`, `--fixtures`, `--allow-incomplete`, `--require-recorded`, `--require-clients`, `--require-rate-cases`, `--require-reference`, `--check-secrets`, `--foundation`, `--write-snapshot`, `--write-foundation`, `--sync-manifest`, `--list-ids` (with optional `--status pending|ported`); output lines `routes T`, `buckets B`, `recorded R`, `ported P pending N`, `foundation F foundation-pending G`. +- `parity/routes.snapshot` (`sha256:` and `source:` header lines, then one route id per line), `parity/buckets.snapshot` (`bucket NAME limit N window W key KIND` and `route BUCKETS ID` lines), `parity/foundation-routes.txt`, `parity/manifest.yaml` with every snapshot id. +- `parity/harness_test.go` with `TestParityHarnessCanFail`, `parity/upstream_replay_test.go` with `TestUpstreamSidecarsAreReplayed`, `plugins/golem15/wavepath/plugin_test.go` with `TestNoWaveRoutesYet`, the complete `scripts/check-parity.sh` (stages `self-test`, `corpus`, `replay`, `foundation`, `consumers`, optional `--self-replay`; env `BM_DIR`, `DEMO_DIR`). -Scenario on both sides, 196 pending-route manifest, corpus checker, harness and fail-closed gate. +Scenario on both sides (CRT identity and derived rate-limit identities included), the derived pending-route manifest, the corpus checker with consistency checks, the harness and the fail-closed gate. Purpose: preserve the frozen client/PHP contract while keeping this executor slice cohesive and within the authorized hybrid re-slice. Output: the artifacts and machine evidence named below. @@ -68,28 +90,30 @@ Output: the artifacts and machine evidence named below. Task 3: The whole scenario is seeded on both sides with the same ids and variable names ../sm-wavepath-app/parity/scenario.md, ../sm-wavepath-app/parity/scenario.vars.keys, ../sm-wavepath-app/parity/scenario-deferred.txt, ../sm-wavepath-app/parity/wavepath_reset.php, ../sm-wavepath-app/parity/fixtureplugin/plugin.go, ../sm-wavepath-app/parity/fixtureplugin/seed.go, ../sm-wavepath-app/parity/seed_test.go, ../sm-wavepath-app/parity/fixtures/seed/bootstrap.yaml - ../sm-wavepath-app/parity/wavepath_reset.php and ../sm-wavepath-app/parity/fixtureplugin/seed.go (as Task 1 left them), ../fonoteka.go/parity/fonoteka_reset.php (whole file), ../fonoteka.go/parity/fonoteka_seed_test.go (lines 1-120 and 600-700), 31-CONTEXT.md (D-04, D-11, D-18, D-19, D-21), 31-RESEARCH.md ("Rate buckets in the corpus", "Route table", "Gap map", "Upstream vendors the corpus reaches", "Pattern 2", pitfalls 2, 4, 6 and 10), the models of the eight shared Go plugins (`../sm-wavepath-app/plugins/golem15/*/models/`) and their test fixture plugins (`fixture_plugin_test.go`) for how rows are created. From the PHP contract with `git show`: the models of the wavepath plugin and of the shared plugins, `Plugin.php` lines 160-558 (what a created group, a new member and a message trigger), and the migrations under `updates/` that add host columns to shared tables + ../sm-wavepath-app/parity/wavepath_reset.php and ../sm-wavepath-app/parity/fixtureplugin/seed.go (as plan 31-03 left them), ../sm-wavepath-app/parity/pins.env (the resolved wavepath pin), ../fonoteka.go/parity/fonoteka_reset.php (whole file), ../fonoteka.go/parity/fonoteka_seed_test.go (lines 1-120 and 600-700), 31-CONTEXT.md (D-04, D-11, D-18, D-19, D-21), 31-RESEARCH.md ("Rate buckets in the corpus", "Route table", "Gap map", "Upstream vendors the corpus reaches", "Pattern 2", pitfalls 2, 4, 6 and 10, and "Drift D5" (xcapture and KLIPY URLs), "Drift D6" (buckets), "Drift D7" (self-heal, CRT summary, member-join enrolment), "Drift D9" (new host tables and columns)), the models of the eight shared Go plugins (`../sm-wavepath-app/plugins/golem15/*/models/`) and their test fixture plugins (`fixture_plugin_test.go`) for how rows are created. From the PHP contract with `git show` at the resolved pins: the models of the wavepath plugin and of the shared plugins, `Plugin.php` (what a created group, a new member and a message trigger), `classes/chat/PublicChannelParticipation.php`, `classes/threads/ThreadInboxService.php` (groupRollupFor, followedQuery), the `RateLimiter::for` definitions in `routes.php`, and the migrations under `updates/` that add host columns to shared tables (`add_collapsed_threads_to_users.php`, the thread subscription, draft and DM call tables) - `TestScenarioSeeds` (Docker): `fixtureplugin.Seed` on a migrated database succeeds twice in a row (idempotent) and every seeded row has the id the scenario names. - `TestScenarioVarsMatch`: the variable names the Go seeder wrote, together with the names in `parity/scenario-deferred.txt`, equal the names in `parity/scenario.vars.keys`; a name missing on one side fails with that name. - `TestFixtureAbsentFromProduction`: `parity.fixtureplugin` is not in `app.PluginIDs`, `summer.yaml` or `plugins.gen.go`. - `TestSeededJWTAuthenticates` (Docker): a request to a route of the user plugin behind `jwt.auth` with `Cookie: token=` and the seeded JWT of alice is authenticated as alice. - Per D-04, D-21, D-11 (a user on each side of every access rule), D-18 and D-19. + Per D-04, D-21, D-11 (a user on each side of every access rule), D-18, D-19 and the session decision to record a collapsed-threads user in Phase 31. 1. `parity/scenario.md` is the single definition. It names every identity, row and explicit id, and for each the variable it produces (`id:NAME`, `jwt:IDENTITY`, `token:NAME`, `code:NAME`). Minimum content: - - Identities: `alice` (owner of the group `harbor`), `bob` (admin of `harbor`, two push subscriptions, offline), `carol` (member, with a user status), `dave` (no group; accepted friend of alice), `erin` (banned from `harbor`), `frank` (stranger: no friendship, no group), `olive` (member, the one user the presence script reports online), an unclaimed imported member, one user per rate bucket for the ten 429 cases (`rl-wave-api`, `rl-community-join` and so on), and a bot user with a `wave_` token of scope `chat:bot`. + - Identities: `alice` (owner of the group `harbor`), `bob` (admin of `harbor`, two push subscriptions, offline), `carol` (member, with a user status), `dave` (no group; accepted friend of alice), `erin` (banned from `harbor`), `frank` (stranger: no friendship, no group), `olive` (member, the one user the presence script reports online), `grace` (member of `harbor` with `users.collapsed_threads = true`: she follows three thread roots in harbor channels, one with replies after her `last_read_at`, one whose later reply mentions her, one followed but muted, and her notify preference on one channel is `mentions`, so every branch of the CRT group rollup and the roots-only `unread_count` has a non-zero, distinguishable value), an unclaimed imported member, one rate-limit identity `rl-` for every bucket that the `RateLimiter::for` definitions of `routes.php` at the resolved wavepath pin key by user (Task 4's checker cross-checks the set against `parity/buckets.snapshot`; buckets keyed by guest session, bot token, webhook or IP use those credentials instead), and a bot user with a `wave_` token of scope `chat:bot`. - Groups: `harbor` (closed, with an invite code and a custom code free for the invite cases), `plaza` (open, for the open-join cases), `cellar` (closed, alice is not a member, for denials), each with its chat and channels as the PHP lifecycle creates them. - - Channels of `harbor`: the system default `general`, a private channel, an archived channel, a category, a personal category, pins, a favourite, a muted channel. - - Messages: plain messages, one thread with replies, a message per delete, edit, pin and reaction case, a webhook message, an attachment; no http(s) URL in any message except in the unfurl cases. + - Channels of `harbor`: the system default `general`, a second public channel `lounge`, a private channel, an archived channel, a category, a personal category, pins, a favourite, a muted channel. + - Chat participants: the rows the v1.22.0 backfill and `PublicChannelParticipation::selfHeal` would write (every member participates in every public channel they can see; bots, non-members and users who left are skipped), with one deliberate gap: `carol` has no participant row in `lounge`, so carol's `GET community/groups` case records the self-heal insert. Every other identity starts healed, so no other case changes participant state by reading. + - Messages: plain messages, threads with replies (including grace's three), a message per delete, edit, pin and reaction case, a webhook message, an attachment; no http(s) URL in any message except in the unfurl cases, never an X/Twitter status URL (the pattern of the xcapture plugin's `Detector::URL_RE`: a send would dispatch a capture job and could add an `edited` publication) and never a KLIPY URL. `scenario.md` states this rule in words only, without a sample URL or host name. - Direct messages: a conversation between alice and dave with a thread. - Friendships: alice and dave accepted, bob to alice pending, alice to carol sent, each case that changes one having its own row. - - Video: a call link, a channel guest link, a guest session in each state the guest routes need. + - Video: a call link, a channel guest link, a guest session in each state the guest routes need; DM calls between alice and dave: none, ringing, active and ended. - Forum: categories, threads and posts in `harbor`. Notes (D-18): diary entries of alice, one shared publicly and one shared with `harbor`. - - Push: the VAPID test pair and subscriptions whose endpoints are on real public push host names (the PHP endpoint rule resolves them); the subscription key pairs are test-only and listed in the scenario. - - A webhook on `general` with its token, a custom emoji, and the rows the 17 uncalled routes need for a success case each (D-19). + - Push: the VAPID test pair and subscriptions whose endpoints are on real public push host names (the PHP endpoint rule resolves them); the subscription key pairs are test-only and listed in the scenario; `users.preferred_locale` is set explicitly for every push recipient so push payloads are deterministic. + - Composer drafts (main composer, a thread draft, a tombstone, a draft in a channel the actor can no longer read), thread follow and read state for the thread routes, a webhook on `general` with its token and its sender account, a custom emoji, one `important` and one `urgent` root message (`priority` column), and the rows the uncalled routes need for a success case each (D-19; RESEARCH "Routes that none of the three clients calls" lists them, 17 at the reference snapshot; 31-05's coverage map is final). + - A section "Deferred on the Go side" listing, per host table or column that the Go plugins do not have yet, the phase that ports it: drafts (31.1), DM calls (31.2), webhook sender account (31.2), the chat `priority` column (31.1; recorded in Phase 31, ported with `sm-chat-plugin` in 31.1), thread follow and read state of the non-CRT thread routes (31.1). grace's `collapsed_threads` flag and her thread follow and read rows are marked `Go: 31-07` (seeded on the Go side by plan 31-07: the flag through the app's companion column, the thread rows into sm-chat-plugin's `golem15_chat_thread_mutes` extended with `is_following` and `last_read_at`, the storage the user chose on 2026-11-22; they write no variable). Each access rule of D-11 has an identity on each side of it; the document says which. 2. `parity/wavepath_reset.php`: the whole scenario, idempotent, wiping the scenario's state by id before recreating it, with explicit ids and AUTO_INCREMENT floors per table (steps of 10000000, so ids of different tables never collide when values become variables). Per-case variants are selected by an environment variable naming the case. It mints the session JWT of every identity and writes only the vars file. It never prints a secret. -3. `parity/fixtureplugin/seed.go`: the same rows through the Go plugins' models for every table that exists (the shared plugins' tables, and the user rows), with the same explicit ids, Postgres sequences set to the same floors, and the same variable names written into the `*tide.Store`. The JWTs are minted through the user plugin with the secret from `parity/parity.env`. A scenario row whose host table does not exist yet is not seeded and its variable names go into `parity/scenario-deferred.txt`, one per line with the phase that ports the table (31.1 or 31.2); this plan adds no host table. +3. `parity/fixtureplugin/seed.go`: the same rows through the Go plugins' models for every table that exists (the shared plugins' tables, and the user rows), with the same explicit ids, Postgres sequences set to the same floors, and the same variable names written into the `*tide.Store`. The JWTs are minted through the user plugin with the secret from `parity/parity.env`. A scenario row whose host table or column does not exist yet is not seeded and its variable names go into `parity/scenario-deferred.txt`, one per line with the phase that ports the table (31.1 or 31.2); this plan adds no host table or column (plan 31-07 adds the CRT ones). 4. `parity/scenario.vars.keys`: the sorted variable names, written from a PHP reset run (names only, no values). `parity/fixtures/seed/bootstrap.yaml`: the seed flow without a login step (D-21). 5. `parity/seed_test.go`: the behavior block. 6. Run `scripts/parity-stack.sh up`, `check` (it now compares the vars keys), `php_parity.sh snapshot`, `down`. Commit: `feat(parity): the community scenario on PHP and Go`. @@ -97,50 +121,55 @@ Output: the artifacts and machine evidence named below. go -C ../sm-wavepath-app vet ./parity/... && go -C ../sm-wavepath-app test -count=1 -run '^(TestScenarioSeeds|TestScenarioVarsMatch|TestFixtureAbsentFromProduction|TestSeededJWTAuthenticates)$' -v ./parity 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 4 Non-zero exit: fewer than four `--- PASS: Test` lines (a seeding error, a variable name on one side only, the fixture plugin listed for production, or the seeded cookie JWT not accepted by the Go guard; a skipped Docker test also yields fewer than four). ( ../sm-wavepath-app/scripts/parity-stack.sh up --mode readonly && ../sm-wavepath-app/scripts/parity-stack.sh check; RC=$?; ../sm-wavepath-app/scripts/parity-stack.sh down; exit $RC ) - Non-zero exit: the PHP reset failed on the fresh MariaDB database, or `check` printed a `refuse:` line because the vars file's key set differs from `parity/scenario.vars.keys`. + Non-zero exit: the PHP reset failed on the fresh MariaDB database, the re-index failed, or `check` printed a `refuse:` line because the vars file's key set differs from `parity/scenario.vars.keys`. - - `grep -cE '^(jwt|id):(alice|bob|carol|dave|erin|frank|olive)$' ../sm-wavepath-app/parity/scenario.vars.keys` prints 14. - - `grep -c '^jwt:rl-' ../sm-wavepath-app/parity/scenario.vars.keys` prints at least 8 (the buckets keyed by user; the guest, bot and webhook buckets use their own credentials). + - `grep -cE '^(jwt|id):(alice|bob|carol|dave|erin|frank|olive|grace)$' ../sm-wavepath-app/parity/scenario.vars.keys` prints 16. + - `grep -c 'collapsed_threads' ../sm-wavepath-app/parity/wavepath_reset.php` prints at least 1 and `grep -c 'Go: 31-07' ../sm-wavepath-app/parity/scenario.md` prints at least 1. + - `grep -c '^jwt:rl-' ../sm-wavepath-app/parity/scenario.vars.keys` prints at least 1 (the exact set is checked against the parsed buckets in Task 4). - Every line of `../sm-wavepath-app/parity/scenario-deferred.txt` names a variable and one of `31.1` or `31.2`: `grep -vcE ' (31\.1|31\.2)$' ../sm-wavepath-app/parity/scenario-deferred.txt` prints 0. - `grep -cE 'eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.' ../sm-wavepath-app/parity/scenario.md ../sm-wavepath-app/parity/scenario.vars.keys ../sm-wavepath-app/parity/wavepath_reset.php | awk -F: '{s+=$2} END {print s}'` prints 0. + - `grep -ciE '(x|twitter|fxtwitter|fixupx|vxtwitter|xcancel)\.com/[A-Za-z0-9_]+/status/|klipy\.com' ../sm-wavepath-app/parity/scenario.md ../sm-wavepath-app/parity/wavepath_reset.php ../sm-wavepath-app/parity/fixtureplugin/seed.go | awk -F: '{s+=$2} END {print s}'` prints 0. - Both backends start every case from the same named state, and a request can log in on either side with a seeded cookie. + Both backends start every case from the same named state (a CRT member and a self-heal gap included), and a request can log in on either side with a seeded cookie. - Task 4: The 196-route manifest with every route pending, the corpus checker and snapshot, a harness that can fail, and the complete gate - ../sm-wavepath-app/parity/manifest.yaml, ../sm-wavepath-app/parity/routes.snapshot, ../sm-wavepath-app/parity/foundation-routes.txt, ../sm-wavepath-app/parity/check_corpus.go, ../sm-wavepath-app/parity/parity_test.go, ../sm-wavepath-app/parity/harness_test.go, ../sm-wavepath-app/parity/upstream_replay_test.go, ../sm-wavepath-app/scripts/check-parity.sh, ../sm-wavepath-app/parity/README.md, ../sm-wavepath-app/README.md, ../sm-wavepath-app/plugins/golem15/wavepath/plugin_test.go - ../sm-wavepath-app/parity/manifest.yaml, parity_test.go and scripts/check-parity.sh (as Task 1 left them), ../fonoteka.go/parity/check_corpus.go (whole file: flags at 120-129, run at 138-206, scanSecrets at 437-515, the PHP route parser at 549-648, sanitizeFile at 717, the ported-versus-fixture check at 766-779), ../fonoteka.go/parity/check_corpus_test.go (how the checker is built and tested beside a test package), ../fonoteka.go/parity/routes.snapshot, ../fonoteka.go/parity/parity_test.go (lines 106-310), ../fonoteka.go/parity/synthetic_test.go, ../fonoteka.go/parity/upstream_replay_test.go (whole file), scripts/check-phase19.1.sh (lines 1-80: stages, the go test -json detectors, the self-test stage, the Docker message), ../sm-demo-app/scripts/check-all.sh (lines 42-82), 31-RESEARCH.md ("Count", "Route table", "Consumer gate"), 31-PATTERNS.md ("check_corpus.go", "check-parity.sh", "parity_test.go"). The route file, read-only: `GIT_OPTIONAL_LOCKS=0 git -C /media/nvme/dev/jz/wavepath.org/plugins/golem15/wavepath show a08ed0a34d1af72314a3453bb25593c6a1660056:routes.php` + Task 4: The derived pending-route manifest, the corpus checker with consistency checks and snapshots, a harness that can fail, and the complete gate + ../sm-wavepath-app/parity/manifest.yaml, ../sm-wavepath-app/parity/routes.snapshot, ../sm-wavepath-app/parity/buckets.snapshot, ../sm-wavepath-app/parity/foundation-routes.txt, ../sm-wavepath-app/parity/check_corpus.go, ../sm-wavepath-app/parity/parity_test.go, ../sm-wavepath-app/parity/harness_test.go, ../sm-wavepath-app/parity/upstream_replay_test.go, ../sm-wavepath-app/scripts/check-parity.sh, ../sm-wavepath-app/parity/README.md, ../sm-wavepath-app/README.md, ../sm-wavepath-app/plugins/golem15/wavepath/plugin_test.go + ../sm-wavepath-app/parity/manifest.yaml, parity_test.go and scripts/check-parity.sh (as plan 31-03 left them), ../sm-wavepath-app/parity/pins.env, ../fonoteka.go/parity/check_corpus.go (whole file: flags at 120-129, run at 138-206, scanSecrets at 437-515, the PHP route parser at 549-648, sanitizeFile at 717, the ported-versus-fixture check at 766-779), ../fonoteka.go/parity/check_corpus_test.go (how the checker is built and tested beside a test package), ../fonoteka.go/parity/routes.snapshot, ../fonoteka.go/parity/parity_test.go (lines 106-310), ../fonoteka.go/parity/synthetic_test.go, ../fonoteka.go/parity/upstream_replay_test.go (whole file), scripts/check-phase19.1.sh (lines 1-80: stages, the go test -json detectors, the self-test stage, the Docker message), ../sm-demo-app/scripts/check-all.sh (lines 42-82), 31-RESEARCH.md ("Count", "Route table", "Rate buckets in the corpus", "Consumer gate", "Drift D2" (the second `/_wave/api/v1` frame outside D-09), "Drift D6" (withoutMiddleware, bucket table), "Drift D13" (every derived value)), 31-PATTERNS.md ("check_corpus.go", "check-parity.sh", "parity_test.go"). The route file, read-only: the export's `${XDG_CACHE_HOME:-$HOME/.cache}/summercms/wavepath-parity/corpus/php/plugins/golem15/wavepath/routes.php`, which is `routes.php` at the wavepath pin of `parity/pins.env`; the xcapture detector pattern in the export's `plugins/wavepath/xcapture/classes/trigger/Detector.php` - - `go run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --allow-incomplete` (run in the app directory) exits 0 and prints `routes 196` and the recorded and pending counts; with `--routes FILE` it also checks the SHA-256 of the route file against the snapshot and that the parsed ids equal the snapshot. - - It exits non-zero when: the manifest has a route the snapshot lacks or the reverse; a route's auth group differs from the classifier's; `--require-recorded` is set and a case has no fixture; a ported case's manifest status differs from its fixture; `--check-secrets` finds a JWT shape, a `wave_` token, an invite code, a webhook token, a call-link code or a cookie value in a fixture or sidecar that is not an allow-listed test constant. + - `go run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --buckets parity/buckets.snapshot --routes --allow-incomplete` (run in the app directory) exits 0 and prints `routes T`, `buckets B`, `recorded R`, `ported P pending N`, where T equals the number of route ids in the snapshot, the parsed route file and the manifest alike, and `P + N` equals T. + - It exits non-zero, naming the offending ids or values, when: the manifest has a route the snapshot lacks or the reverse; the parsed route file differs from the snapshot (digest, ids) or its parsed buckets differ from `buckets.snapshot`; a route's auth group differs from the classifier's; a bucket a corpus route uses has no parseable `Limit::per…(N)` definition; `--foundation FILE` lists an id outside the snapshot, a duplicate, lacks a realtime id, or differs from the derived foundation set; `--require-recorded` is set and a case has no fixture; a ported case's manifest status differs from its fixture; `--require-rate-cases` is set and a parsed bucket lacks exactly one case `rate-limit-` on a route that carries it, recorded with status 429, with `repeat` at least the bucket's smallest limit plus one and at most `tide.MaxRepeat`; `--require-reference` is set and `manifest.reference` differs from `parity/pins.env` (every key, full ids); `--require-clients` is set and a route lacks a provenance line in `parity/provenance.txt`; `--check-secrets` finds a JWT shape, a `wave_` token, an invite code, a webhook token, a call-link code or a cookie value in a fixture or sidecar that is not an allow-listed test constant; any scanned file holds an X/Twitter status URL or a KLIPY URL. + - `--write-snapshot` writes `routes.snapshot` and `buckets.snapshot` from `--routes`; `--write-foundation` writes the foundation list; `--list-ids` prints the manifest's route ids, one per line, and nothing else (with `--status ported` or `--status pending`, only the routes of that status); `--sync-manifest` adds every snapshot id the manifest lacks as a `pending` route and refuses, naming the ids, when the manifest holds a route the snapshot no longer has. - `TestParityHarnessCanFail`: over a synthetic manifest and handler, the suite fails for a ported route whose response differs, for a ported route without a fixture, for a ported route with an unknown seed hook and for a mutated recorded response; a pending route is reported as pending and is not in the passing count. - `TestUpstreamSidecarsAreReplayed`: fails on an upstream sidecar of a ported route that no case replayed (it passes while no route is ported). - `TestNoWaveRoutesYet` in the app plugin: the shell registers no route (the foundation slice adds them in plans 31-06 and 31-07). - - The gate: `scripts/check-parity.sh --self-test` feeds planted go test -json output (a failed test, zero tests, a skipped required test, a missing required test name) and planted checker output to its detectors and passes only when each is refused. + - The gate: `scripts/check-parity.sh --self-test` feeds planted go test -json output (a failed test, zero tests, a skipped required test, a missing required test name), planted checker output with inconsistent counts (`P + N` different from T, R above T), and a planted spec holding an X status URL to its detectors and passes only when each is refused. - Per D-09, D-15 as amended by D-16, D-10 (the realtime routes are ordinary routes) and D-05. -1. `parity/check_corpus.go` (`package main`, run with `go run`, built beside the test package the way fonoteka does it): constants for the 194 routes of the route file and the 196 expected ids; the PHP route parser over `Route::group` frames and `Route::` verbs, filtered to the D-09 prefixes (`/_wave/api/v1/community`, `/_wave/api/v1/guest`, `/_wave/api/v1/push`, the four bot and token routes under `/api/v1`, `/hooks/{token}`); the classifier mapping prefix and middleware to `jwt`, `guest`, `bot`, `webhook`; the two realtime ids as extras in group `realtime`. Flags `--manifest`, `--snapshot`, `--routes`, `--fixtures`, `--allow-incomplete`, `--require-recorded`, `--require-clients`, `--check-secrets`, `--foundation FILE` (prints `foundation F pending G`), `--write-snapshot` (writes the snapshot from `--routes`). Route id is `METHOD path auth_group`; a fixture name is the id with slashes and spaces replaced, as `sanitizeFile` does. Secret patterns beyond fonoteka's: `wave_` bearer tokens, 40-character webhook tokens, invite and call-link codes that equal a vars entry, any cookie value; the test-only constants of `parity/parity.env` are allow-listed by exact value. -2. `parity/routes.snapshot`: written once with `--write-snapshot` from the route file at `a08ed0a` (digest and the 196 ids). `parity/manifest.yaml`: all 196 routes, status `pending`, seed hook `community`, the auth group of each, the tracer route keeping its two cases; no other cases yet (plan 31-05 writes them). `parity/foundation-routes.txt`: the 36 foundation-slice route ids, one per line. -3. `parity/parity_test.go`: assert the manifest has 196 routes; one subtest per route; the pending and ported branches as in the tracer; a `coverage` subtest. `parity/harness_test.go`: `TestParityHarnessCanFail` over a synthetic manifest and handler. `parity/upstream_replay_test.go`: the upstream switch (the fake put on each request's context with `fetchguard.WithTransport`; a case without a sidecar gets an empty fake, so any vendor call fails it) and `TestUpstreamSidecarsAreReplayed`, copied from fonoteka's with this suite's names. -4. `scripts/check-parity.sh`, complete: stages `self-test`, `corpus` (the checker with `--check-secrets`, and `--require-recorded` unless `--allow-unrecorded`), `replay` (`go test -count=1 -json ./parity`, parsed: a failed test, a skipped required test, zero tests, a missing required test name or an unreachable Docker daemon fails the stage; required names `TestParityCorpus`, `TestParityHarnessCanFail`, `TestUpstreamSidecarsAreReplayed`, `TestScenarioVarsMatch`, `TestFixtureAbsentFromProduction`), `foundation` (every id in `parity/foundation-routes.txt` is `ported` unless `--allow-pending-foundation`), `consumers` (`sm-bm-app`: `go build ./...` and its tests `TestChatMounted`, `TestRealtimeDefaultDriver`, `TestRealtimeRoutes`, `TestRealtimeConfigDefaults`, `TestRemoteKeyOverride`; `sm-demo-app`: `go vet` and `go test -short` of the root package and `./plugins/demo/...`; directories from `BM_DIR` and `DEMO_DIR` with `../` defaults), optional `--self-replay`. One summary line: `check-parity: recorded R/196 ported P pending N foundation-pending F`. Each allow flag prints `NOT COMPLETE: …` with the count it let through. Exit 0 only when no stage failed. -5. `parity/README.md`: the corpus boundary (D-09), the manifest conventions, the checker's flags, the harness rules (pending never passes), the gate's stages and flags. `README.md` at the root: what the repository is, the plugin list, quick start (`summer build`, `go test -short ./...`), a pointer to `parity/README.md`. -6. Commit in steps: checker and snapshot; manifest; harness; gate and READMEs. + Per D-09, D-15 as amended by D-16, D-10 (the realtime routes are ordinary routes), D-11 (one 429 case per bucket), D-12 (freeze at recording time) and D-05, and the session decision that no route, bucket or pending count is a constant. +1. `parity/check_corpus.go` (`package main`, run with `go run`, built beside the test package the way fonoteka does it). No route-count or bucket-count constant: every count is computed from the parsed file and the snapshots; do not copy the snapshot-count constant check of fonoteka's `run` (31-PATTERNS "check_corpus.go", fonoteka line 151). The parser is a tokenizer that drops comments and strings, tracks `Route::group` frames by brace depth with their `prefix` and `middleware`, and reads each `Route::(` statement up to its `;` with its action (controller class and method), `->middleware(...)` and `->withoutMiddleware(...)` calls. It filters by full path prefix first, to the D-09 set (`/_wave/api/v1/community`, `/_wave/api/v1/guest`, `/_wave/api/v1/push`, the bot and token routes under `/api/v1`: `conversations`, `conversations/{id}/messages`, `realtime/token`, and `/hooks/{token}`), so any other frame under `/_wave/api/v1` cannot leak in. The classifier maps prefix and middleware to `jwt`, `guest`, `bot`, `webhook`; the two realtime ids (`GET /api/realtime/token realtime`, `POST /api/realtime/subscribe realtime`) are extras in group `realtime`. A route's effective buckets are its frames' `throttle:` middleware plus its own `->middleware('throttle:…')` minus its `->withoutMiddleware('throttle:…')`. Bucket definitions come from every `RateLimiter::for('NAME', …)` in the file: the smallest `Limit::perSecond|perMinute|perHour|perDay(N)` with its window, and the key kind read from `->by(...)` (`user` when it uses the request user, `guest`, `bot`, `webhook`, else `ip`). The foundation set is derived: every corpus route whose action class is `CommunityGroupController`, `CommunityMemberController`, `CommunityInviteController` or `CommunityFriendsController` (D-16 foundation families), plus the two realtime ids. Route id is `METHOD path auth_group`; a fixture name is the id with slashes and spaces replaced, as `sanitizeFile` does. Flags and checks as in the behavior block; output one line per count (`routes T`, `buckets B`, `recorded R`, `ported P pending N`, and with `--foundation` also `foundation F foundation-pending G`). Secret patterns beyond fonoteka's: `wave_` bearer tokens, 40-character webhook tokens, invite and call-link codes that equal a vars entry, any cookie value; the test-only constants of `parity/parity.env` are allow-listed by exact value. URL scan, always on: the xcapture status-URL pattern (copied into a Go `regexp` with a comment naming the PHP file it mirrors and the rule to re-check it at a re-record) and the host `klipy.com`, over `parity/scenario.md`, `parity/wavepath_reset.php`, `parity/fixtureplugin/*.go`, every manifest request body and `parity/fixtures/clients/**`, printing file and line. +2. Run, with `--routes` pointing at the exported route file: `--write-snapshot` (writes `parity/routes.snapshot`: a `sha256:` line, a `source:` line with the wavepath path and pin from `parity/pins.env`, then the ids; and `parity/buckets.snapshot`), `--write-foundation parity/foundation-routes.txt`, then `--sync-manifest` on a manifest that holds only the tracer route: every other id becomes `pending`, seed hook `community`, its auth group, no cases (plan 31-05 writes them); the tracer route keeps its two cases. +3. `parity/parity_test.go`: assert the manifest's route ids equal the snapshot's ids (no count constant); one subtest per route; the pending and ported branches as in the tracer; a `coverage` subtest. `parity/harness_test.go`: `TestParityHarnessCanFail` over a synthetic manifest and handler. `parity/upstream_replay_test.go`: the upstream switch (the fake put on each request's context with `fetchguard.WithTransport`; a case without a sidecar gets an empty fake, so any vendor call fails it) and `TestUpstreamSidecarsAreReplayed`, copied from fonoteka's with this suite's names. +4. `scripts/check-parity.sh`, complete: stages `self-test`, `corpus` (the checker with `--check-secrets`, `--foundation parity/foundation-routes.txt`, `--routes` when the export exists, and `--require-recorded --require-rate-cases --require-reference --require-clients` unless `--allow-unrecorded`; it parses the count lines and fails on `P + N` different from T, on R above T and on a missing count line), `replay` (`go test -count=1 -json ./parity`, parsed: a failed test, a skipped required test, zero tests, a missing required test name or an unreachable Docker daemon fails the stage; required names `TestParityCorpus`, `TestParityHarnessCanFail`, `TestUpstreamSidecarsAreReplayed`, `TestScenarioVarsMatch`, `TestFixtureAbsentFromProduction`), `foundation` (every id in `parity/foundation-routes.txt` is `ported` unless `--allow-pending-foundation`), `consumers` (`sm-bm-app`: `go build ./...` and its tests `TestChatMounted`, `TestRealtimeDefaultDriver`, `TestRealtimeRoutes`, `TestRealtimeConfigDefaults`, `TestRemoteKeyOverride`; `sm-demo-app`: `go vet` and `go test -short` of the root package and `./plugins/demo/...`; directories from `BM_DIR` and `DEMO_DIR` with `../` defaults), optional `--self-replay`. One summary line: `check-parity: recorded R/T ported P pending N foundation-pending G`, with T from the checker. Each allow flag prints `NOT COMPLETE: …` with the count it let through. Exit 0 only when no stage failed. +5. `parity/README.md`: the corpus boundary (D-09), how the inventory, buckets and foundation set are derived and re-derived at a new pin (`--write-snapshot`, `--write-foundation`, `--sync-manifest`), the manifest conventions, the checker's flags and count lines, the URL rule, the harness rules (pending never passes), the gate's stages and flags. `README.md` at the root: what the repository is, the plugin list, quick start (`summer build`, `go test -short ./...`), a pointer to `parity/README.md`. +6. Commit in steps: checker and snapshots; manifest; harness; gate and READMEs. - go -C ../sm-wavepath-app vet . ./app/... ./parity/... ./plugins/golem15/wavepath/... && go -C ../sm-wavepath-app run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --allow-incomplete --check-secrets --foundation parity/foundation-routes.txt 2>&1 | grep -qx 'routes 196' && go -C ../sm-wavepath-app test -count=1 -run '^(TestParityCorpus|TestParityHarnessCanFail|TestUpstreamSidecarsAreReplayed)$' -v ./parity 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 3 - Non-zero exit: vet fails, the checker does not print the line `routes 196` (a route missing, extra or in the wrong group, or a secret found), or fewer than three `--- PASS: Test` lines are printed. - OUT="$(../sm-wavepath-app/scripts/check-parity.sh --allow-unrecorded --allow-pending-foundation 2>&1)" && printf '%s\n' "$OUT" | grep -qE '^check-parity: recorded [0-9]+/196 ported 0 pending 196 foundation-pending 36$' && ! ../sm-wavepath-app/scripts/check-parity.sh >/dev/null 2>&1 - Non-zero exit: the gate with both allow flags failed a stage (self-test, corpus, replay or a consumer build), the summary line is absent or has other counts, or the gate without flags exited 0 although routes are unrecorded and the foundation slice is pending. + cd ../sm-wavepath-app && R="${XDG_CACHE_HOME:-$HOME/.cache}/summercms/wavepath-parity/corpus/php/plugins/golem15/wavepath/routes.php" && T="$(grep -cE '^(GET|POST|PUT|PATCH|DELETE) ' parity/routes.snapshot)" && test "$T" -gt 0 && go vet . ./app/... ./parity/... ./plugins/golem15/wavepath/... && OUT="$(go run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --buckets parity/buckets.snapshot --routes "$R" --allow-incomplete --check-secrets --foundation parity/foundation-routes.txt 2>&1)" && printf '%s\n' "$OUT" | grep -qx "routes $T" && printf '%s\n' "$OUT" | grep -qx "ported 0 pending $T" && go test -count=1 -run '^(TestParityCorpus|TestParityHarnessCanFail|TestUpstreamSidecarsAreReplayed)$' -v ./parity 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 3 + Non-zero exit: the snapshot is empty, vet fails, the checker refused (the manifest, snapshot and parsed route file disagree, a bucket or the foundation list differs from the parse, a secret or a status URL was found), the line `routes T` or `ported 0 pending T` with T counted from the snapshot is absent, or fewer than three `--- PASS: Test` lines are printed. + cd ../sm-wavepath-app && T="$(grep -cE '^(GET|POST|PUT|PATCH|DELETE) ' parity/routes.snapshot)" && F="$(grep -c . parity/foundation-routes.txt)" && OUT="$(scripts/check-parity.sh --allow-unrecorded --allow-pending-foundation 2>&1)" && printf '%s\n' "$OUT" | grep -qE "^check-parity: recorded [0-9]+/$T ported 0 pending $T foundation-pending $F\$" && ! scripts/check-parity.sh >/dev/null 2>&1 + Non-zero exit: the gate with both allow flags failed a stage (self-test, corpus, replay or a consumer build), the summary line is absent or its counts differ from the ones derived from the snapshot and the foundation list, or the gate without flags exited 0 although routes are unrecorded and the foundation slice is pending. - - `grep -c '^ - id: ' ../sm-wavepath-app/parity/manifest.yaml` prints 196 and `grep -c 'status: ported' ../sm-wavepath-app/parity/manifest.yaml` prints 0. - - `wc -l < ../sm-wavepath-app/parity/foundation-routes.txt` prints 36. - - `go -C ../sm-wavepath-app run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --require-recorded` exits non-zero (195 routes have no fixture yet). - - `../sm-wavepath-app/scripts/check-parity.sh --self-test` exits 0 and prints a line for each planted case it refused. + - The manifest and the snapshot hold the same ids: `cd ../sm-wavepath-app && diff <(grep -E '^(GET|POST|PUT|PATCH|DELETE) ' parity/routes.snapshot | sort) <(go run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --allow-incomplete --list-ids | sort)` prints nothing, and `grep -c 'status: ported' parity/manifest.yaml` prints 0. + - Every foundation id is a snapshot id and both realtime ids are listed: `cd ../sm-wavepath-app && grep -vxFf <(grep -E '^(GET|POST|PUT|PATCH|DELETE) ' parity/routes.snapshot) parity/foundation-routes.txt | wc -l` prints 0 and `grep -cE '^(GET /api/realtime/token|POST /api/realtime/subscribe) realtime$' parity/foundation-routes.txt` prints 2. + - Every user-keyed bucket has its identity: `cd ../sm-wavepath-app && K="$(awk '$1=="bucket" && $8=="user" {print "jwt:rl-" $2}' parity/buckets.snapshot)" && test -n "$K" && printf '%s\n' "$K" | grep -vxFf parity/scenario.vars.keys | wc -l` prints 0. + - `grep -vE '^\s*//' ../sm-wavepath-app/parity/check_corpus.go | grep -cE 'expectedRouteCount|expectedBucketCount'` prints 0 (no count constant in code). + - `go -C ../sm-wavepath-app run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --require-recorded` exits non-zero (only the tracer route has fixtures yet). + - `../sm-wavepath-app/scripts/check-parity.sh --self-test` exits 0 and prints a line for each planted case it refused, including the inconsistent counts and the status URL. - `git -C ../sm-wavepath-app status --porcelain` prints nothing. - The corpus has its full route list, a checker that ties it to the PHP route file, a replay suite proven able to fail, and a gate that says how many routes are recorded, ported and pending and refuses to pass early. + The corpus has its full, derived route list, a checker that ties manifest, snapshots, buckets and foundation set to the PHP route file at the resolved pin, a replay suite proven able to fail, and a gate that says how many routes are recorded, ported and pending, checks those counts against each other and refuses to pass early. @@ -161,6 +190,8 @@ Output: the artifacts and machine evidence named below. | T-31-09 | Information disclosure | secrets in committed fixtures | high | mitigate | captured values live in the mode-0600 vars file under the parity root; the reset script writes only that file; `check_corpus --check-secrets` scans fixtures and sidecars for JWT shapes, `wave_` tokens, webhook tokens, codes and cookie values; `.gitignore` covers vars files | | T-31-11 | Spoofing | a gate that passes on nothing | high | mitigate | the gate parses `go test -json`, requires named tests, fails on zero tests, skips and a missing Docker daemon; its self-test feeds planted output to each detector; `TestParityHarnessCanFail` proves a pending route is never a pass | | T-31-12 | Elevation of privilege | the fixture plugin in a production binary | high | mitigate | constructed in process by tests only; never registered with `party.Register`, never in `summer.yaml`, `plugins.gen.go` or `app.PluginIDs`; `TestFixtureAbsentFromProduction` | +| T-31-42 | Tampering | a scenario or spec URL that makes PHP queue a capture job or an unfurl and adds an unrecorded publication | medium | mitigate | the scenario holds no X/Twitter status and no KLIPY URL; the checker scans scenario, reset script, Go seeder, manifest bodies and client specs on every run with the detector's own pattern; the gate self-test plants one | +| T-31-47 | Spoofing | derived counts drifting apart, so a gate line looks complete while routes are missing | high | mitigate | manifest ids must equal snapshot ids, snapshot ids and buckets the parsed route file, the foundation list the derived set; the gate re-checks `P + N == T` and `R <= T` from the checker's count lines; no count is a constant (acceptance greps for one) | | T-31-SC | Tampering | npm/pip/cargo installs | high | mitigate | no package install; use existing dependencies and explicit lockfiles | @@ -169,7 +200,7 @@ Run every task's automated command and preserve its fails_when semantics. Do not -Scenario on both sides, 196 pending-route manifest, corpus checker, harness and fail-closed gate is complete, its named tests ran, and no locked decision or D-16 phase boundary drifted. +The scenario on both sides, the derived pending-route manifest, the corpus checker with consistency checks, the harness and the fail-closed gate are complete, their named tests ran, and no locked decision or D-16 phase boundary drifted. diff --git a/.planning/phases/31-chat-polish-against-wavepath-clients/31-05-PLAN.md b/.planning/phases/31-chat-polish-against-wavepath-clients/31-05-PLAN.md index ca972c21..2c693be4 100644 --- a/.planning/phases/31-chat-polish-against-wavepath-clients/31-05-PLAN.md +++ b/.planning/phases/31-chat-polish-against-wavepath-clients/31-05-PLAN.md @@ -6,12 +6,18 @@ wave: 4 depends_on: [31-02, 31-04] files_modified: - ../sm-wavepath-app/parity/manifest.yaml + - ../sm-wavepath-app/parity/pins.env + - ../sm-wavepath-app/parity/routes.snapshot + - ../sm-wavepath-app/parity/buckets.snapshot + - ../sm-wavepath-app/parity/foundation-routes.txt + - ../sm-wavepath-app/parity/provenance.txt - ../sm-wavepath-app/parity/capture-rules.yaml - ../sm-wavepath-app/parity/capture_clients.mjs - ../sm-wavepath-app/parity/record_corpus.sh - ../sm-wavepath-app/parity/presence.yaml - ../sm-wavepath-app/parity/accepted-differences.yaml - ../sm-wavepath-app/parity/README.md + - ../sm-wavepath-app/parity/fixtures/clients/ - ../sm-wavepath-app/parity/fixtures/routes/ - ../sm-wavepath-app/parity/upstream/ - ../sm-wavepath-app/parity/parity_test.go @@ -22,30 +28,48 @@ files_modified: autonomous: true requirements: [SC-1, SC-2, D-06, D-07, D-09, D-10, D-11, D-12, D-13, D-17, D-19] estimate: - tokens: 260000 - raw_tokens: 260000 + tokens: 280000 + raw_tokens: 280000 tasks: 3 confidence: low must_haves: truths: - - "Full 196-route PHP recording with client provenance, publications, upstreams and green self-replay is delivered against the frozen PHP corpus and locked decisions." + - "The full PHP recording covers every route of the inventory derived at recording start, with client provenance, publications, upstreams and a green self-replay, against the frozen PHP corpus and locked decisions." + - "The recording resolves wavepath.org HEAD and every gitlink pin when it starts, re-derives snapshot, buckets, foundation list and manifest from the route file at that commit, and writes the pins into `manifest.reference`; a resumed run at other pins is refused (D-12)." + - "Counts are checked for consistency, not against constants: called + uncalled + realtime extras equals the snapshot total, the hand-written routes equal the uncalled list, and there is exactly one 429 case per parsed bucket." + - "Search cases are recorded against a real Typesense index (31.2 D-03); CRT, priority, threads, drafts, who-reacted and DM-call journeys are recorded although most of them are ported later." - "Verification fails closed: missing, skipped, pending or mismatching evidence is not counted as a pass." - "D-16 remains intact: messaging, satellites, Range support, guest/bot/webhook host services, zero total pending and final security review stay in Phases 31.1/31.2." artifacts: + - path: "../sm-wavepath-app/parity/record_corpus.sh" + provides: "pin, re-derive, reference, record and self-replay in one fail-closed run" + - path: "../sm-wavepath-app/parity/provenance.txt" + provides: "one provenance line per corpus route" - path: "../sm-wavepath-app/parity/manifest.yaml" - provides: "Full 196-route PHP recording with client provenance, publications, upstreams and green self-replay" + provides: "every derived route with its cases, writes flags and reference" key_links: - - from: "../sm-wavepath-app/parity/manifest.yaml" - to: "the plan's automated verification" - via: "the named tracer and fail-closed checks" + - from: "../sm-wavepath-app/parity/record_corpus.sh" + to: "../sm-wavepath-app/parity/php_parity.sh" + via: "pin and export at recording start, then check_corpus --write-snapshot --write-foundation --sync-manifest" + - from: "../sm-wavepath-app/parity/capture_clients.mjs" + to: "../sm-wavepath-app/parity/provenance.txt" + via: "--check-coverage maps every proxy request to a snapshot id" --- ## Phase Goal -WavePath's complete 196-route PHP community corpus is recorded and self-replays green; Phase 31 ports and proves only the 36-route foundation slice, leaving exactly 160 routes pending for Phases 31.1 and 31.2 per D-16. +WavePath's complete PHP community corpus is recorded and self-replays green: every route the corpus parser derives from `routes.php` at the commits resolved when the recording starts, plus the two realtime routes. Phase 31 ports and proves only the foundation slice listed in `parity/foundation-routes.txt`; every other corpus route stays pending for Phases 31.1 and 31.2 per D-16. Counts are derived at recording time and checked for consistency, never pinned (reference snapshot 2026-11-22, not a target: 218 tracked, 199 called, 17 uncalled, 14 buckets, 36 foundation, 182 pending). + +## Artifacts this phase produces (this plan) + +- `parity/record_corpus.sh` (flags `--tracer`, `--route ID`, `--case ID`, `--resume`, `--self-replay`, `--check-upstream-confinement`; summary line `record_corpus: recorded R/T failing X unrecorded U`). +- `parity/capture_clients.mjs` (flags `--check-deps`, `--check-coverage --manifest FILE`; coverage line `coverage: called C uncalled U extras X total T`), `parity/capture-rules.yaml` (client labels `nuxt`, `hubot`), `parity/presence.yaml`, `parity/provenance.txt` (lines `PROVENANCE ROUTE-ID`, provenance `proxy:nuxt`, `proxy:hubot`, `hand-written:D-19`, `realtime:D-10`). +- `parity/accepted-differences.yaml` (version 1, empty `differences`), `parity/upstream/scripts/` and `parity/upstream/helpers/` (LiveKit Twirp for group and DM calls, web-push, unfurl, webhook icons, Turnstile). +- Tests `TestBroadcastSidecarsAreComplete`, `TestPHPFixturesComplete` (and the extended `TestUpstreamSidecarsAreReplayed`); `manifest.reference` with the key `superproject` and one key per gitlink path; `writes: true` on every GET route whose PHP handler writes. +- Committed fixtures, broadcast goldens and upstream sidecars for every case of every derived route. -Full 196-route PHP recording with client provenance, publications, upstreams and green self-replay. +Full PHP recording of the derived inventory with client provenance, publications, upstreams, Typesense-backed search and green self-replay, at pins resolved when the recording starts. Purpose: preserve the frozen client/PHP contract while keeping this executor slice cohesive and within the authorized hybrid re-slice. Output: the artifacts and machine evidence named below. @@ -66,89 +90,92 @@ Output: the artifacts and machine evidence named below. - Task 1: Tracer: one client writing route records its response, every publication and every vendor call, then self-replays green - 31-01 and 31-02 summaries exist; `scripts/parity-stack.sh selftest` passes; the manifest has 196 routes and the tracer route is still pending. - ../sm-wavepath-app/parity/capture-rules.yaml, ../sm-wavepath-app/parity/capture_clients.mjs, ../sm-wavepath-app/parity/record_corpus.sh, ../sm-wavepath-app/parity/presence.yaml, ../sm-wavepath-app/parity/manifest.yaml, ../sm-wavepath-app/parity/fixtures/clients/, ../sm-wavepath-app/parity/fixtures/routes/, ../sm-wavepath-app/parity/upstream/scripts/, ../sm-wavepath-app/parity/README.md, ../sm-wavepath-app/scripts/parity-stack.sh - ../sm-wavepath-app/parity/README.md, manifest.yaml, scenario.md, scenario.vars.keys, capture-rules.yaml if present, scripts/parity-stack.sh, parity/php_parity.sh, parity/case_hook.sh, 31-01-SUMMARY.md, 31-02-SUMMARY.md, 31-03-SUMMARY.md, 31-04-SUMMARY.md, modules/tide/README.md sections for proxy, manifest recording, broadcasts and upstream scripts, ../fonoteka.go/parity/capture_clients.mjs, ../fonoteka.go/parity/capture-rules.yaml, /media/nvme/dev/jz/wavepath.org/vue-wavepath-app/src/stores/channelChatStore.ts and the API module for the selected writing route, /media/nvme/dev/jz/wavepath.org/hubot-wavepath/src/rest.mjs - Per D-07, D-10, D-11, D-17, D-20 and D-21. -1. Choose one writing route called by the SPA whose seeded path is short and deterministic; prefer a friendship request or a group update rather than a messaging route reserved for 31.1. Run the SPA through `summer parity:proxy` against the `corpus` PHP instance and capture the exact method, path, headers and body. The script resolves Playwright from the existing client tree and writes nothing there. It starts client processes with environment variables only and tracks and terminates every child. -2. `capture-rules.yaml`: client labels `nuxt` and `hubot`; keep only contract headers; capture server-minted ids/codes/cookies into the mode-0600 vars store; scrub every credential. Add route-specific captures only where the request-only spec cannot carry them. Keep Cookie but never its value. -3. Convert the observed tracer session into a committed request-only spec and merge its success plus D-11 denial/422 cases into the manifest. Use a fresh scenario identity for a rate-bucket case if the selected route has a named secondary bucket. -4. Add the smallest upstream script needed by the route. When no vendor call is expected, the attached proxy remains empty and fails on any unexpected call. Add `presence.yaml` with `olive` online so the online branch is deterministic. -5. `record_corpus.sh`: fail-closed wrapper around stack check, pin/reference check, `summer parity:record` with the manifest, vars, `--broadcasts true`, recorder and proxy loopback addresses, upstream script, presence table, case hook and wait; then `summer parity:replay --self-check true --require-recorded false`. It accepts a route/case selector for the tracer and no selector for the full run. It never evaluates env files as shell. -6. Record the tracer. Require its fixture and, because it writes, its broadcast sidecar. Require an upstream sidecar exactly when the reference made a vendor call. Re-run against PHP and require zero diffs. Document the command and generated files in `parity/README.md`. -7. Commit request/spec/script changes separately from generated fixtures: `feat(parity): capture one community writing route`; `test(parity): record the community tracer from PHP`. + Task 1: Tracer: pins resolved at start, then one client writing route records its response, every publication and every vendor call, and self-replays green + 31-01 and 31-02 summaries exist; `scripts/parity-stack.sh selftest` passes; `go run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --allow-incomplete` exits 0 in `../sm-wavepath-app` (manifest ids equal snapshot ids) and the tracer route is still pending. + ../sm-wavepath-app/parity/capture-rules.yaml, ../sm-wavepath-app/parity/capture_clients.mjs, ../sm-wavepath-app/parity/record_corpus.sh, ../sm-wavepath-app/parity/presence.yaml, ../sm-wavepath-app/parity/manifest.yaml, ../sm-wavepath-app/parity/pins.env, ../sm-wavepath-app/parity/routes.snapshot, ../sm-wavepath-app/parity/buckets.snapshot, ../sm-wavepath-app/parity/foundation-routes.txt, ../sm-wavepath-app/parity/fixtures/clients/, ../sm-wavepath-app/parity/fixtures/routes/, ../sm-wavepath-app/parity/upstream/scripts/, ../sm-wavepath-app/parity/README.md, ../sm-wavepath-app/scripts/parity-stack.sh + ../sm-wavepath-app/parity/README.md, manifest.yaml, scenario.md, scenario.vars.keys, pins.env, routes.snapshot, buckets.snapshot, capture-rules.yaml if present, scripts/parity-stack.sh, parity/php_parity.sh (`pin`, `export`, `reindex`), parity/case_hook.sh, parity/check_corpus.go (flags `--write-snapshot`, `--write-foundation`, `--sync-manifest`, `--require-reference`), 31-01-SUMMARY.md, 31-02-SUMMARY.md, 31-03-SUMMARY.md, 31-04-SUMMARY.md, modules/tide/README.md sections for proxy, manifest recording, `writes`, broadcasts and upstream scripts, ../fonoteka.go/parity/capture_clients.mjs, ../fonoteka.go/parity/capture-rules.yaml, /media/nvme/dev/jz/wavepath.org/vue-wavepath-app/src/stores/channelChatStore.ts and the API module for the selected writing route, /media/nvme/dev/jz/wavepath.org/hubot-wavepath/src/rest.mjs, 31-RESEARCH.md "Drift D1", "Drift D11" and "Drift D13" + Per D-07, D-10, D-11, D-12 (freeze at recording time), D-17, D-20 and D-21. +1. `parity/record_corpus.sh` (bash, `set -euo pipefail`, env files parsed as data, never evaluated): a fail-closed wrapper that, in this order and stopping at the first refusal: (a) unless `--resume`, runs `php_parity.sh pin` (wavepath.org HEAD, or `PARITY_PIN_REF`) and `export`; with `--resume` it keeps `parity/pins.env` and refuses when `manifest.reference` differs from it (a corpus is never recorded across two sets of pins); (b) re-derives the inventory from the exported route file: `check_corpus.go --write-snapshot --write-foundation parity/foundation-routes.txt --routes /plugins/golem15/wavepath/routes.php`, then `--sync-manifest`, printing the ids it added (pending, no cases yet) and stopping when a manifest route disappeared (a person decides); (c) writes `manifest.reference` from `pins.env`: the key `superproject` and one key per gitlink path, each with its full 40-character id, every gitlink `pins.env` lists (no fixed repository list); (d) `scripts/parity-stack.sh up --mode record` and `check` (Typesense, listeners, pins, client checkouts at their pins); (e) `summer parity:record` with the manifest, vars, `--broadcasts true`, the recorder and proxy loopback addresses, the upstream script, `parity/presence.yaml`, `parity/case_hook.sh` and `--wait`; (f) with `--self-replay`, `summer parity:replay --self-check true`; (g) prints `record_corpus: recorded R/T failing X unrecorded U` (R and T from the checker's count lines, X and U from the replay summary) and brings the stack down. It accepts a route and case selector (`--tracer` selects the tracer route) and no selector for the full run. +2. Choose one writing route called by the SPA whose seeded path is short and deterministic; prefer a friendship request or a group update rather than a messaging route reserved for 31.1. Run the SPA through `summer parity:proxy` against the `corpus` PHP instance and capture the exact method, path, headers and body. The script resolves Playwright from the existing client tree (at its pin, as `check` asserts) and writes nothing there. It starts client processes with environment variables only and tracks and terminates every child. +3. `capture-rules.yaml`: client labels `nuxt` and `hubot`; keep only contract headers; capture server-minted ids/codes/cookies into the mode-0600 vars store; scrub every credential. Add route-specific captures only where the request-only spec cannot carry them. Keep Cookie but never its value. +4. Convert the observed tracer session into a committed request-only spec and merge its success plus D-11 denial/422 cases into the manifest. Use a fresh scenario identity for a rate-bucket case if the selected route carries a named secondary bucket in `parity/buckets.snapshot`. No spec body holds an X/Twitter status URL or a KLIPY URL (the checker scans for both). +5. Add the smallest upstream script needed by the route. When no vendor call is expected, the attached proxy remains empty and fails on any unexpected call. Add `presence.yaml` with `olive` online so the online branch is deterministic. +6. Record the tracer with `parity/record_corpus.sh --tracer --self-replay`. Require its fixture and, because it writes (`tide.RouteWrites`), its broadcast golden. Require an upstream sidecar exactly when the reference made a vendor call. Re-run against PHP and require zero diffs. Document the command, the pin step, the re-derivation and the generated files in `parity/README.md`. +7. Commit request/spec/script changes separately from generated fixtures and from re-derived snapshots: `feat(parity): capture one community writing route`; `chore(parity): re-derive the inventory at the resolved pins` (only if the snapshot changed); `test(parity): record the community tracer from PHP`. OUT="$(cd ../sm-wavepath-app && parity/record_corpus.sh --tracer --self-replay 2>&1)" && printf '%s\n' "$OUT" | grep -qE 'failing 0 unrecorded 0' && printf '%s\n' "$OUT" | grep -q 'broadcast' - Non-zero exit, no `failing 0 unrecorded 0` line, or no broadcast evidence: the stack or pin check refused, the observed request did not record, a publication differed, an unexpected vendor call escaped the script, or self-replay was not executed. - cd ../sm-wavepath-app && go run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --allow-incomplete --check-secrets --foundation parity/foundation-routes.txt - Non-zero exit: the tracer changed the route inventory, wrote a live secret, used an invalid fixture name, or marked a pending route as passed. + Non-zero exit, no `failing 0 unrecorded 0` line, or no broadcast evidence: the pin step, the re-derivation, the stack or pin check refused, the observed request did not record, a publication differed, an unexpected vendor call escaped the script, or self-replay was not executed. + cd ../sm-wavepath-app && go run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --buckets parity/buckets.snapshot --allow-incomplete --require-reference --check-secrets --foundation parity/foundation-routes.txt + Non-zero exit: `manifest.reference` differs from `parity/pins.env`, the manifest and the re-derived snapshot disagree, the tracer wrote a live secret or a status URL, used an invalid fixture name, or marked a pending route as passed. - The tracer's request method, path, request headers and body are byte-for-byte derived from a proxy session, not reconstructed from controller code. - Its success fixture exists and contains no JWT, session cookie, bot token, webhook token or vendor credential. - Its `.broadcasts.yaml` exists and contains all publications emitted before the settle interval ended; deleting one publication makes self-replay fail. + - `manifest.reference` has one key per `PIN_` line of `parity/pins.env` plus `superproject`: `cd ../sm-wavepath-app && test "$(grep -c '^PIN_' parity/pins.env)" -gt 0` exits 0 and the checker's `--require-reference` (second verify command) exits 0. - `git -C /media/nvme/dev/jz/wavepath.org status --porcelain` is not run or changed by the scripts; script source contains no checkout, stash, fetch, pull, install or commit command. - One real writing path is observed from a real client, recorded with all side effects and self-replays green from committed files. + One real writing path is observed from a real client, recorded at freshly resolved pins with all side effects and self-replays green from committed files. Task 2: Expand proxy-derived specs and case depth across every route the SPA and bot call The tracer self-replay is green and both clients resolve their existing dependencies without an install. - ../sm-wavepath-app/parity/capture_clients.mjs, ../sm-wavepath-app/parity/capture-rules.yaml, ../sm-wavepath-app/parity/manifest.yaml, ../sm-wavepath-app/parity/fixtures/clients/, ../sm-wavepath-app/parity/upstream/scripts/, ../sm-wavepath-app/parity/upstream/helpers/, ../sm-wavepath-app/parity/presence.yaml, ../sm-wavepath-app/parity/README.md - Task 1 outputs, 31-RESEARCH.md "Route table", "Rate buckets in the corpus", "Routes that none of the three clients calls", "Upstream vendors", /media/nvme/dev/jz/wavepath.org/vue-wavepath-app/src/ request call sites including src/sw.js, /media/nvme/dev/jz/wavepath.org/hubot-wavepath/src/rest.mjs, the pinned PHP route file and controller validation rules through read-only `git show`, modules/tide/README.md minted credentials and body comparers - Per D-07, D-09, D-10, D-11 and D-17. -1. Drive named, deterministic SPA journeys over the seeded scenario: group administration, membership and invite paths; chat/channel/DM/thread/commands; reactions, emoji, prefs, pins and attachments; presence/status; forum; notes; push; video and guest. Drive the bot's four REST paths with its seeded token. Capture request sessions only; do not use `wavepath-mcp`. -2. Build a coverage map from every proxy request to one of the 196 manifest ids. Deduplicate the same route shape while preserving materially different client bodies and headers. A request outside D-09 is reported and excluded; a D-09 client-called route with no captured request stops the task. -3. For each captured route add the observed client cases and D-11 depth: unauthenticated, non-member/forbidden or not-found per access rule, UI-triggerable 422, and exactly one repeated 429 case per named rate bucket across the corpus. Do not invent statuses or envelopes; record them. -4. Add script answers for LiveKit Twirp, web-push, unfurl HTML/images, webhook icons and Turnstile. Helpers may decode protobuf or decrypt push payloads using scenario test keys and register a tide body comparer. If push decryption proves impossible (research A6), compare endpoint, headers, non-empty body and request count and record the limitation in README; do not accept arbitrary empty bodies. -5. Prove pinned requests stay inside the upstream proxy before running the broad recording: a planted public hostname resolves to a test address, the proxy sees the original host, and a closed proxy makes the PHP request fail. Keep scenario text free of URLs except explicit unfurl cases. -6. Write client flow provenance into README: client commit, session name, manifest routes covered, and excluded out-of-corpus requests. Commit specs and scripts; generated fixtures remain for Task 3. + ../sm-wavepath-app/parity/capture_clients.mjs, ../sm-wavepath-app/parity/capture-rules.yaml, ../sm-wavepath-app/parity/manifest.yaml, ../sm-wavepath-app/parity/provenance.txt, ../sm-wavepath-app/parity/fixtures/clients/, ../sm-wavepath-app/parity/upstream/scripts/, ../sm-wavepath-app/parity/upstream/helpers/, ../sm-wavepath-app/parity/presence.yaml, ../sm-wavepath-app/parity/README.md + Task 1 outputs, ../sm-wavepath-app/parity/buckets.snapshot, ../sm-wavepath-app/parity/scenario.md, 31-RESEARCH.md "Route table", "Rate buckets in the corpus", "Routes that none of the three clients calls", "Upstream vendors", "Drift D3" (new routes), "Drift D5" (out-of-corpus routes, gifs and xcapture), "Drift D6" (buckets), "Drift D7" (self-heal, CRT), "Drift D8" (priority), "Drift D11" (new journeys, CORS), /media/nvme/dev/jz/wavepath.org/vue-wavepath-app/src/ request call sites including src/sw.js, `components/chat/MessagePriorityPicker.vue`, `api/threadApi.ts`, `api/draftApi.ts`, `api/dmCallApi.ts`, /media/nvme/dev/jz/wavepath.org/hubot-wavepath/src/rest.mjs, the PHP route file and controller validation rules at the resolved pins through the export or read-only `git show`, modules/tide/README.md minted credentials, body comparers, `repeat` and `repeat_parallel` + Per D-07, D-09, D-10, D-11, D-13, D-17 and the session decisions (CRT recorded in Phase 31; Typesense-backed search; counts derived). +1. Drive named, deterministic SPA journeys over the seeded scenario: group administration, membership and invite paths; chat/channel/DM/thread/commands; reactions, emoji, prefs, pins and attachments; presence/status; forum; notes; push; video and guest; and the journeys added since the old freeze: the message priority picker (an `important` and an `urgent` send, a reply with a priority, an invalid value for the 422; the column is ported with `sm-chat-plugin` in 31.1), the Threads section (counts, summary, list, read, unread, read-all), server-synced drafts (PUT, DELETE, GET, the count and the list), the who-reacted lists, DM calls (start, accept, decline, hangup, rejoin, status, the incoming-call poll), the CRT toggle (`PATCH community/prefs`) and grace's group list with collapsed threads on, carol's group list (the self-heal case), and the group search against the Typesense index. Drive the bot's REST paths with its seeded token. Capture request sessions only; do not use `wavepath-mcp`. +2. `capture_clients.mjs --check-coverage`: map every proxy request to one snapshot id; deduplicate the same route shape while preserving materially different client bodies and headers (instant channel switching produces many near-duplicate `after_id` GETs). A request outside D-09 (`web-extensions`, `security/2fa/status` and every other non-corpus path) is reported and excluded; a D-09 route that a session called but has no captured request stops the task. Write `parity/provenance.txt`: one line per snapshot id, `proxy:nuxt` or `proxy:hubot` for a called route, `realtime:D-10` for the two realtime ids, `hand-written:D-19` for every other route. Print `coverage: called C uncalled U extras X total T` and exit non-zero unless `C + U + X` equals the number of snapshot ids and every snapshot id has exactly one line (reference snapshot 2026-11-22: 199 called, 17 uncalled). +3. For each captured route add the observed client cases and D-11 depth: unauthenticated, non-member/forbidden or not-found per access rule, UI-triggerable 422. Set `writes: true` on every GET route whose PHP handler writes at the resolved pin (`GET community/groups` and the channel list self-heal participant rows; add any other found while reading the controllers), so each gets a broadcast golden. Do not invent statuses or envelopes; record them. +4. Rate buckets: exactly one case `rate-limit-` per `bucket` line of `parity/buckets.snapshot`, on a route whose `route` line carries that bucket (a `wave-api` case on a route that did not drop it), with the bucket's own credential (`rl-` for user-keyed buckets, the guest session, bot token or webhook otherwise) and `headers: {Retry-After: present}`. Measure the latency of one request on the corpus instance and write it into the README. `repeat` is the bucket's smallest limit plus one; when `limit × latency` exceeds half of the bucket's window, set `repeat_parallel` (at most `tide.MaxRepeatParallel`), add a margin of a tenth of the limit to `repeat` for counter races, and keep `repeat` at most `tide.MaxRepeat`. A case that does not answer 429 at PHP stops the task; it is never accepted as recorded. +5. Add script answers for LiveKit Twirp (group calls and DM calls), web-push (including the incoming-call push), unfurl HTML/images, webhook icons and Turnstile. No KLIPY answer is needed (the gifs plugin registers no route and the browser calls KLIPY) and no capture answer (no status URL in any body). Helpers may decode protobuf or decrypt push payloads using scenario test keys and register a tide body comparer. If push decryption proves impossible (research A6), compare endpoint, headers, non-empty body and request count and record the limitation in README; do not accept arbitrary empty bodies. +6. Prove pinned requests stay inside the upstream proxy before running the broad recording: a planted public hostname resolves to a test address, the proxy sees the original host, and a closed proxy makes the PHP request fail. Keep scenario text free of URLs except explicit unfurl cases. +7. Write client flow provenance into README: client commits (the pins), session names, manifest routes covered, excluded out-of-corpus requests, and whether any kept request carries `Origin` (then plan 31-06 sets `http.cors.exposed_headers: [Retry-After]`, RESEARCH "Drift D11"). Commit specs and scripts; generated fixtures remain for Task 3. - cd ../sm-wavepath-app && node parity/capture_clients.mjs --check-deps && node parity/capture_clients.mjs --check-coverage --manifest parity/manifest.yaml - Non-zero exit: existing client dependencies cannot be resolved, a client-called D-09 route lacks a captured request, a session maps to an unknown route, or wavepath-mcp appears as a corpus client. + cd ../sm-wavepath-app && node parity/capture_clients.mjs --check-deps && OUT="$(node parity/capture_clients.mjs --check-coverage --manifest parity/manifest.yaml 2>&1)" && T="$(grep -cE '^(GET|POST|PUT|PATCH|DELETE) ' parity/routes.snapshot)" && printf '%s\n' "$OUT" | grep -qE "^coverage: called [0-9]+ uncalled [0-9]+ extras [0-9]+ total $T\$" && test "$(grep -c . parity/provenance.txt)" = "$T" + Non-zero exit: existing client dependencies cannot be resolved, a client-called D-09 route lacks a captured request, a session maps to an unknown route, wavepath-mcp appears as a corpus client, the coverage line is absent or its total differs from the snapshot count, or `provenance.txt` does not have one line per snapshot id. cd ../sm-wavepath-app && parity/record_corpus.sh --check-upstream-confinement Non-zero exit: a pinned PHP request bypasses the loopback proxy, loses its host name, accepts a closed proxy, or a script answer does not match the vendor request. - - Coverage output reports 177 client-called route ids and 17 no-client route ids. - - The manifest contains exactly ten 429 cases, one for each named bucket, with the required repeat count. + - The coverage line's `C + U + X` equals the snapshot count, and each snapshot id appears once in `provenance.txt`: `cd ../sm-wavepath-app && diff <(cut -d' ' -f2- parity/provenance.txt | sort) <(grep -E '^(GET|POST|PUT|PATCH|DELETE) ' parity/routes.snapshot | sort)` prints nothing. + - The manifest has one 429 case per parsed bucket: `cd ../sm-wavepath-app && test "$(grep -cE 'id: rate-limit-' parity/manifest.yaml)" = "$(grep -c '^bucket ' parity/buckets.snapshot)"` exits 0, and every case's `repeat` is at most `tide.MaxRepeat`. + - `grep -c 'writes: true' ../sm-wavepath-app/parity/manifest.yaml` prints at least 1 (the self-healing group list). - Client source trees have no modified or untracked file caused by capture. - - Every upstream script host is a test/public vendor hostname from the pinned PHP code; no private, production credential or developer endpoint is present. + - Every upstream script host is a test/public vendor hostname from the PHP code at the resolved pins; no private, production credential or developer endpoint is present. - Every client-called corpus route has a proxy-derived request contract and complete denial, validation and rate-limit depth ready for unattended recording. + Every client-called corpus route has a proxy-derived request contract and complete denial, validation and rate-limit depth ready for unattended recording, and every route of the derived inventory has its provenance. - Task 3: Add the 17 hand-written success specs, record all 196 routes and freeze a green PHP self-replay - Task 2 reports exactly 177 client-called and 17 no-client routes, and the stack's pin check matches the reference revisions. + Task 3: Add the hand-written success specs, record every derived route and freeze a green PHP self-replay + Task 2's coverage line is consistent with the snapshot and the stack's pin check matches `parity/pins.env`. ../sm-wavepath-app/parity/manifest.yaml, ../sm-wavepath-app/parity/fixtures/routes/, ../sm-wavepath-app/parity/upstream/scripts/, ../sm-wavepath-app/parity/accepted-differences.yaml, ../sm-wavepath-app/parity/parity_test.go, ../sm-wavepath-app/parity/broadcast_test.go, ../sm-wavepath-app/parity/upstream_replay_test.go, ../sm-wavepath-app/parity/README.md, ../sm-wavepath-app/scripts/check-parity.sh - Task 2 coverage output, 31-CONTEXT.md D-12/D-13/D-19, 31-RESEARCH.md table of 17 uncalled routes, pinned controllers and validation rules through read-only `git show`, ../fonoteka.go/parity/broadcast_goldens_test.go, ../fonoteka.go/parity/upstream_replay_test.go, ../sm-oauthserver-plugin/testdata/parity/deviations.yaml + Task 2 coverage output and `parity/provenance.txt`, 31-CONTEXT.md D-12/D-13/D-19, 31-RESEARCH.md table of the uncalled routes, the controllers and validation rules at the resolved pins through the export or read-only `git show`, ../fonoteka.go/parity/broadcast_goldens_test.go, ../fonoteka.go/parity/upstream_replay_test.go, ../sm-oauthserver-plugin/testdata/parity/deviations.yaml Per D-06, D-09, D-10, D-11, D-12, D-13 and D-19. -1. Add one request-only success spec for each of the 17 no-client routes: three forum category operations; nine channel category/show/restore/mute operations; five note compatibility routes; webhook ingest; webhook icon (use the exact final list from the coverage map—if the research table's grouping count differs, the route ids, not prose arithmetic, win). Derive bodies from the pinned controller validation rules and scenario rows, then record PHP's actual result. Add denial and validation cases where applicable. -2. Fill `manifest.reference` from the `.parity-export`/pins produced by 31-02: superproject plus wavepath, user, chat, chatchannels, chatbots, chatvideo, forum, herald, userfriends, websockets, oauthserver and journal commits. The recording wrapper refuses any mismatch. +1. Add one request-only success spec for each `hand-written:D-19` line of `parity/provenance.txt` (at the reference snapshot: forum category operations, channel category/show/restore/mute operations, note compatibility routes, webhook ingest, webhook icon; the route ids of the provenance file, not prose arithmetic, win). Derive bodies from the controller validation rules at the resolved pins and scenario rows, then record PHP's actual result. Add denial and validation cases where applicable. +2. `manifest.reference` is written by `record_corpus.sh` from `parity/pins.env` (produced by plan 31-03's `pin` step and re-run at recording start): `superproject` plus every gitlink the export used, full ids. The recording wrapper refuses any mismatch (`--require-reference`). 3. Create `accepted-differences.yaml` version 1 with an empty `differences` list and schema comments requiring id, route, case, path, reason, security rationale and sign-off. The replay loader rejects an entry without all fields; no entry is needed for PHP self-replay. -4. Run the full unattended recording from a fresh snapshot. For every writing case require a broadcast sidecar, including an explicit empty golden when the PHP reference emits none. For every case require either the expected upstream sidecar or proof that no upstream call occurred. Capture all generated ids/codes/cookies in the vars store and scan again before commit. -5. Extend parity checks: `TestBroadcastSidecarsAreComplete` rejects an orphan sidecar, a writing case without a golden and an unexpected publication; `TestUpstreamSidecarsAreReplayed` rejects orphans and unexpected calls; `TestPHPFixturesComplete` requires all 196 routes and all cases recorded. Keep all routes pending—the corpus is recorded, not ported. -6. Run PHP self-replay across all fixtures and sidecars. Re-record a nondeterministic case only after fixing its capture/normalization/spec; never edit the expected response. Update README with duration, counts, revisions and the one-command rerun. Commit generated corpus in reviewable groups without mixing code changes. -7. Tighten `scripts/check-parity.sh`: without `--allow-unrecorded`, corpus completeness is mandatory; with `--allow-pending-foundation`, the still-pending foundation is the only allowed incompleteness. It prints `recorded 196/196 ported 0 pending 196 foundation-pending 36` at this point. +4. Run the full unattended recording with `parity/record_corpus.sh --self-replay` from a fresh snapshot (it re-pins and re-derives first). For every writing route (`tide.RouteWrites`, the `writes: true` GETs included) require a broadcast golden, an explicit empty one when PHP emits nothing. For every case require either the expected upstream sidecar or proof that no upstream call occurred. Search cases run after the case hook's re-index. Capture all generated ids/codes/cookies in the vars store and scan again before commit. The chat `priority` field is recorded as PHP emits it; its Go port is 31.1 and the column stays listed as deferred in `parity/scenario.md`. +5. Extend parity checks: `TestBroadcastSidecarsAreComplete` rejects an orphan sidecar, a writing route without a golden and an unexpected publication; `TestUpstreamSidecarsAreReplayed` rejects orphans and unexpected calls; `TestPHPFixturesComplete` requires every snapshot route and every case recorded, and every `rate-limit-*` fixture at status 429. Keep all routes pending: the corpus is recorded, not ported. +6. Run PHP self-replay across all fixtures and sidecars. Re-record a nondeterministic case only after fixing its capture/normalization/spec (for example a `mask: epoch-ms` rule on a server clock key, tide 31-01); never edit the expected response. Update README with duration, the derived counts, the pins and the one-command rerun. Commit generated corpus in reviewable groups without mixing code changes. +7. Tighten `scripts/check-parity.sh`: without `--allow-unrecorded`, corpus completeness (`--require-recorded --require-clients --require-rate-cases --require-reference`) is mandatory; with `--allow-pending-foundation`, the still-pending foundation is the only allowed incompleteness. At this point it prints `check-parity: recorded T/T ported 0 pending T foundation-pending F` with T and F derived. - cd ../sm-wavepath-app && parity/record_corpus.sh --self-replay 2>&1 | tee "${TMPDIR:-/tmp}/wavepath-self-replay.log" && grep -qE 'recorded 196/196.*failing 0.*unrecorded 0' "${TMPDIR:-/tmp}/wavepath-self-replay.log" - Non-zero exit or missing summary: any route/case is unrecorded, a response/header/publication/vendor call differs, a reference pin differs, a sidecar is absent or orphaned, or a secret scan fails. - cd ../sm-wavepath-app && go run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --require-recorded --require-clients --check-secrets --foundation parity/foundation-routes.txt && go test -count=1 -run '^(TestPHPFixturesComplete|TestBroadcastSidecarsAreComplete|TestUpstreamSidecarsAreReplayed)$' -v ./parity 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 3 - Non-zero exit, corpus checker refusal, or fewer than three PASS lines: route/client coverage is incomplete, a secret exists, or fixture/broadcast/upstream completeness is not proven. - OUT="$(../sm-wavepath-app/scripts/check-parity.sh --allow-pending-foundation 2>&1)" && printf '%s\n' "$OUT" | grep -qx 'check-parity: recorded 196/196 ported 0 pending 196 foundation-pending 36' - Non-zero exit or exact summary absent: the fail-closed gate did not run all corpus, replay and consumer stages or accepted an unrecorded case. + cd ../sm-wavepath-app && parity/record_corpus.sh --self-replay 2>&1 | tee "${TMPDIR:-/tmp}/wavepath-self-replay.log" && T="$(grep -cE '^(GET|POST|PUT|PATCH|DELETE) ' parity/routes.snapshot)" && test "$T" -gt 0 && grep -qx "record_corpus: recorded $T/$T failing 0 unrecorded 0" "${TMPDIR:-/tmp}/wavepath-self-replay.log" + Non-zero exit or the derived summary line is missing: any route/case is unrecorded, a response/header/publication/vendor call differs, a pin differs from `manifest.reference`, a sidecar is absent or orphaned, a 429 case did not reach 429, or a secret scan fails. + cd ../sm-wavepath-app && go run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --buckets parity/buckets.snapshot --require-recorded --require-clients --require-rate-cases --require-reference --check-secrets --foundation parity/foundation-routes.txt && go test -count=1 -run '^(TestPHPFixturesComplete|TestBroadcastSidecarsAreComplete|TestUpstreamSidecarsAreReplayed)$' -v ./parity 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 3 + Non-zero exit, corpus checker refusal, or fewer than three PASS lines: route/client/bucket coverage is incomplete, the reference differs from the pins, a secret or status URL exists, or fixture/broadcast/upstream completeness is not proven. + cd ../sm-wavepath-app && T="$(grep -cE '^(GET|POST|PUT|PATCH|DELETE) ' parity/routes.snapshot)" && F="$(grep -c . parity/foundation-routes.txt)" && OUT="$(scripts/check-parity.sh --allow-pending-foundation 2>&1)" && printf '%s\n' "$OUT" | grep -qx "check-parity: recorded $T/$T ported 0 pending $T foundation-pending $F" + Non-zero exit or the derived summary absent: the fail-closed gate did not run all corpus, replay and consumer stages, found inconsistent counts, or accepted an unrecorded case. - - `manifest.reference` equals the export pins and has no abbreviated commit. - - Exactly 196 manifest route entries have recorded fixtures; exactly 17 are marked with hand-written provenance, and none of those 17 lacks a success case. - - Every writing case has a broadcast sidecar, including an explicit zero-publication golden; every sidecar belongs to one manifest case. + - `manifest.reference` equals the pins and has no abbreviated commit (`--require-reference` in the second verify command exits 0). + - Every snapshot route has recorded fixtures, and the `hand-written:D-19` routes are exactly the uncalled ones: `cd ../sm-wavepath-app && test "$(grep -c '^hand-written:D-19 ' parity/provenance.txt)" -gt 0` exits 0 and none of them lacks a success case (`TestPHPFixturesComplete`). + - Every writing route has a broadcast golden, including an explicit zero-publication golden; every sidecar belongs to one manifest case. - `accepted-differences.yaml` has zero entries. - - Every route remains `pending`; neither Phase 31.1 nor 31.2 implementation is pulled into this plan. + - Every route remains `pending`: `grep -c 'status: ported' ../sm-wavepath-app/parity/manifest.yaml` prints 0; neither Phase 31.1 nor 31.2 implementation is pulled into this plan. - The committed corpus is a complete, secret-free observation of all 196 PHP routes at frozen commits, with publications and vendor calls, and it self-replays green unattended. + The committed corpus is a complete, secret-free observation of every route of the derived inventory at pins resolved when the recording started, with publications, vendor calls and real search results, and it self-replays green unattended. @@ -167,11 +194,12 @@ Output: the artifacts and machine evidence named below. | Threat ID | Category | Component | Severity | Disposition | Mitigation Plan | |-----------|----------|-----------|----------|-------------|-----------------| | T-31-14 | Information disclosure | proxy sessions and generated fixtures | high | mitigate | mode-0600 vars store, tide capture and scrub rules, second `check_corpus --check-secrets` scan, exact secret-shape tests, and client source trees remain read-only | -| T-31-15 | Information disclosure | sync PHP jobs reaching real vendors | high | mitigate | stack refuses record mode unless the loopback upstream proxy listens; confinement test proves pinned requests traverse it and a closed proxy fails | -| T-31-16 | Tampering | recording wrong PHP revisions | high | mitigate | manifest.reference is populated from the export pins; stack check compares full commits and refuses before recording | -| T-31-17 | Repudiation | hand-written cases presented as client traffic | medium | mitigate | per-route provenance marks `proxy:nuxt`, `proxy:hubot` or `hand-written:D-19`; coverage check requires exactly the decided 17 hand-written routes | -| T-31-18 | Tampering | missing publications or vendor calls treated as success | high | mitigate | explicit broadcast golden for every writing case, empty fake for cases without upstream sidecars, orphan/completeness tests and PHP self-replay | -| T-31-19 | Denial of service | repeated 429 cases and broad client journeys | medium | mitigate | bounded tide repeat, dedicated identities, snapshot restore per case, loopback-only services and child-process cleanup | +| T-31-15 | Information disclosure | sync PHP jobs reaching real vendors | high | mitigate | stack refuses record mode unless the loopback upstream proxy listens; confinement test proves pinned requests traverse it and a closed proxy fails; no status URL reaches the capture queue | +| T-31-16 | Tampering | recording wrong PHP revisions | high | mitigate | `record_corpus.sh` resolves the pins, exports exactly them and writes `manifest.reference` from `pins.env`; stack check compares full commits and refuses before recording | +| T-31-17 | Repudiation | hand-written cases presented as client traffic | medium | mitigate | `parity/provenance.txt` marks `proxy:nuxt`, `proxy:hubot`, `hand-written:D-19` or `realtime:D-10` per route; `--require-clients` requires one line per snapshot id and the coverage line must add up to the snapshot total | +| T-31-18 | Tampering | missing publications or vendor calls treated as success | high | mitigate | explicit broadcast golden for every writing route (GETs that write included), empty fake for cases without upstream sidecars, orphan/completeness tests and PHP self-replay | +| T-31-19 | Denial of service | repeated 429 cases and broad client journeys | medium | mitigate | `repeat` and `repeat_parallel` bounded by tide, dedicated identities, snapshot restore per case, loopback-only services and child-process cleanup | +| T-31-46 | Tampering | one corpus recorded across two sets of pins (HEAD moved between runs) | high | mitigate | a full run re-pins and re-derives before recording anything; `--resume` keeps `pins.env` and refuses when `manifest.reference` differs; `--require-reference` in the checker and the gate | | T-31-SC | Tampering | npm/pip/cargo installs | high | mitigate | no package install; use existing dependencies and explicit lockfiles | @@ -180,9 +208,9 @@ Run every task's automated command and preserve its fails_when semantics. Do not -Full 196-route PHP recording with client provenance, publications, upstreams and green self-replay is complete, its named tests ran, and no locked decision or D-16 phase boundary drifted. +The full PHP recording of the derived inventory with client provenance, publications, upstreams, Typesense-backed search and green self-replay is complete at pins resolved when it started, its named tests ran, and no locked decision or D-16 phase boundary drifted. -Create `.planning/phases/31-chat-polish-against-wavepath-clients/31-05-SUMMARY.md` with commits, final identifiers, verification evidence, deviations, and remaining D-16 pending work. +Create `.planning/phases/31-chat-polish-against-wavepath-clients/31-05-SUMMARY.md` with commits, final identifiers, verification evidence, the resolved pins and derived counts, deviations, and remaining D-16 pending work. diff --git a/.planning/phases/31-chat-polish-against-wavepath-clients/31-06-PLAN.md b/.planning/phases/31-chat-polish-against-wavepath-clients/31-06-PLAN.md index ebf27361..b7e1790f 100644 --- a/.planning/phases/31-chat-polish-against-wavepath-clients/31-06-PLAN.md +++ b/.planning/phases/31-chat-polish-against-wavepath-clients/31-06-PLAN.md @@ -17,35 +17,51 @@ files_modified: - ../sm-wavepath-app/plugins/golem15/wavepath/classes/forum_access.go - ../sm-wavepath-app/plugins/golem15/wavepath/classes/authorizer.go - ../sm-wavepath-app/plugins/golem15/wavepath/updates/ + - ../sm-wavepath-app/plugins/golem15/wavepath/README.md + - ../sm-wavepath-app/config/app.yaml - ../sm-wavepath-app/parity/manifest.yaml - ../sm-wavepath-app/parity/foundation_smoke_test.go autonomous: true requirements: [SC-1, SC-2, D-01, D-03, D-10, D-11, D-16, D-21] estimate: - tokens: 150000 - raw_tokens: 150000 + tokens: 155000 + raw_tokens: 155000 tasks: 2 confidence: low must_haves: truths: - - "Foundation infrastructure: envelope, actor, buckets, contexts, resolvers, authorizers and realtime is delivered against the frozen PHP corpus and locked decisions." + - "Foundation infrastructure is delivered against the frozen PHP corpus and locked decisions: envelope, actor, buckets, contexts, resolvers, authorizers and realtime." + - "Every ported route carries exactly the buckets its `route` line in `parity/buckets.snapshot` lists, with the parsed limits; no group-level throttle exists, so a route PHP removed `wave-api` from never gets it (A15)." - "Verification fails closed: missing, skipped, pending or mismatching evidence is not counted as a pass." - "D-16 remains intact: messaging, satellites, Range support, guest/bot/webhook host services, zero total pending and final security review stay in Phases 31.1/31.2." artifacts: - - path: "../sm-wavepath-app/plugins/golem15/wavepath/plugin.go" - provides: "Foundation infrastructure: envelope, actor, buckets, contexts, resolvers, authorizers and realtime" + - path: "../sm-wavepath-app/plugins/golem15/wavepath/routes.go" + provides: "the app's route table with per-route bucket names" + - path: "../sm-wavepath-app/plugins/golem15/wavepath/buckets.go" + provides: "app-owned buckets registered from the parsed limits" + - path: "../sm-wavepath-app/plugins/golem15/wavepath/realtime.go" + provides: "realtime token and subscribe routes" key_links: - - from: "../sm-wavepath-app/plugins/golem15/wavepath/plugin.go" - to: "the plan's automated verification" - via: "the named tracer and fail-closed checks" + - from: "../sm-wavepath-app/plugins/golem15/wavepath/routes.go" + to: "../sm-wavepath-app/parity/buckets.snapshot" + via: "TestRouteBucketsMatchSnapshot compares every ported route's buckets with its snapshot line" + - from: "../sm-wavepath-app/plugins/golem15/wavepath/classes/authorizer.go" + to: "../sm-wavepath-app/plugins/golem15/wavepath/realtime.go" + via: "the subscribe route asks the wave and presence authorizers" --- ## Phase Goal -WavePath's complete 196-route PHP community corpus is recorded and self-replays green; Phase 31 ports and proves only the 36-route foundation slice, leaving exactly 160 routes pending for Phases 31.1 and 31.2 per D-16. +WavePath's complete PHP community corpus is recorded and self-replays green: every route the corpus parser derives from `routes.php` at the commits resolved when the recording starts, plus the two realtime routes. Phase 31 ports and proves only the foundation slice listed in `parity/foundation-routes.txt`; every other corpus route stays pending for Phases 31.1 and 31.2 per D-16. Counts are derived at recording time and checked for consistency, never pinned (reference snapshot 2026-11-22, not a target: 218 tracked, 36 foundation, 182 pending). + +## Artifacts this phase produces (this plan) + +- In `plugins/golem15/wavepath`: `routes.go` (the route table, each entry naming its buckets), `buckets.go` (app-owned buckets with limits from `parity/buckets.snapshot`, `userfriends.JoinBucket` reused), `api/response.go` (typed success and error envelopes), `api/actor.go` (cookie actor, path and body helpers), `classes/context.go` (host group context), `classes/channel_access.go` and `classes/forum_access.go` (resolvers installed in `lagoon.OnDatabase`), `classes/authorizer.go` (strict `wave:group:{id}` and `presence:wave:group:{id}` authorizers), `chat.go`, `realtime.go`, companion migrations under `updates/`. +- `parity/foundation_smoke_test.go` with `TestFoundationTracer` and `TestRouteBucketsMatchSnapshot`. +- When a kept recorded request carries `Origin` (31-05 README): `http.cors.exposed_headers: [Retry-After]` in `config/app.yaml`. -Foundation infrastructure: envelope, actor, buckets, contexts, resolvers, authorizers and realtime. +Foundation infrastructure: envelope, actor, buckets from the parsed table, contexts, resolvers, authorizers and realtime. Purpose: preserve the frozen client/PHP contract while keeping this executor slice cohesive and within the authorized hybrid re-slice. Output: the artifacts and machine evidence named below. @@ -67,23 +83,38 @@ Output: the artifacts and machine evidence named below. Task 1: Tracer: recorded foundation write through envelope, cookie actor, buckets, shared service and broadcast - ../sm-wavepath-app/plugins/golem15/wavepath/plugin.go, ../sm-wavepath-app/plugins/golem15/wavepath/routes.go, ../sm-wavepath-app/plugins/golem15/wavepath/buckets.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/response.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/actor.go, ../sm-wavepath-app/plugins/golem15/wavepath/updates/, ../sm-wavepath-app/parity/manifest.yaml, ../sm-wavepath-app/parity/foundation_smoke_test.go - Per D-01, D-03, D-10, D-11 and D-21, select one recorded foundation write with a deterministic publication. Start with a failing TestFoundationTracer that sends the fixture's token cookie through app.Handler and compares response and broadcast sidecar. Implement typed PHP-compatible success/error envelopes, actor/path/body helpers, app-owned wave-api and presence-state buckets, reuse userfriends.JoinBucket, mount only the selected unchanged /_wave path, and call the shared service through a host serializer. Add only migration-backed companion data needed by the route. Mark only the tracer route ported; fix implementation rather than fixtures. + 31-05's gate prints `check-parity: recorded T/T ported 0 pending T foundation-pending F` with T and F derived from `parity/routes.snapshot` and `parity/foundation-routes.txt`. + ../sm-wavepath-app/plugins/golem15/wavepath/plugin.go, ../sm-wavepath-app/plugins/golem15/wavepath/routes.go, ../sm-wavepath-app/plugins/golem15/wavepath/buckets.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/response.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/actor.go, ../sm-wavepath-app/plugins/golem15/wavepath/updates/, ../sm-wavepath-app/config/app.yaml, ../sm-wavepath-app/parity/manifest.yaml, ../sm-wavepath-app/parity/foundation_smoke_test.go + 31-05-SUMMARY.md (the tracer route, the derived counts, the CORS note), ../sm-wavepath-app/parity/buckets.snapshot, ../sm-wavepath-app/parity/foundation-routes.txt, the selected route's fixture and `.broadcasts.yaml`, ../sm-wavepath-app/plugins/golem15/wavepath/plugin.go (the shell), ../fonoteka.go/plugins/golem15/fonoteka (an app plugin's routes and envelope helpers), ../sm-userfriends-plugin/routes.go (lines 22 and 85: `JoinBucket`), modules/surf/limiter.go (lines 21-65: `surf.Bucket`, `RegisterBucket`), modules/surf/cors.go (line 21), 31-PATTERNS.md (the app plugin sections, "Pattern 1: host handler over plugin services"), 31-RESEARCH.md "Rate buckets in the corpus" (the name collision note), "Drift D6" and assumption A15, the PHP controller of the selected route and `classes/responses/ApiResponse.php` at the resolved pin (read-only) + Per D-01, D-03, D-10, D-11 and D-21, select one recorded foundation write with a deterministic publication. Start with a failing `TestFoundationTracer` that sends the fixture's token cookie through `app.Handler` and compares response and broadcast golden. Implement typed PHP-compatible success/error envelopes, actor/path/body helpers, and the bucket layer: `routes.go` is a table of route entries that each name their buckets; `buckets.go` registers each app-owned bucket once with the limit and window of its `bucket` line in `parity/buckets.snapshot` (read when the plan is executed and written into Go as named constants with a comment naming the snapshot line), reuses `userfriends.JoinBucket` for `community-join` instead of a second definition, and attaches no group-level throttle, so a route whose snapshot line lacks `wave-api` never gets it. Add `TestRouteBucketsMatchSnapshot`: for every route marked ported in the manifest, the bucket names of its `routes.go` entry equal its `route` line in `parity/buckets.snapshot`. Mount only the selected unchanged `/_wave` path and call the shared service through a host serializer. Add only migration-backed companion data needed by the route. If 31-05's README says a kept request carries `Origin`, set `http.cors.exposed_headers: [Retry-After]` in `config/app.yaml`. Mark only the tracer route ported; fix implementation rather than fixtures. - go -C ../sm-wavepath-app vet ./plugins/golem15/wavepath/... ./parity/... && go -C ../sm-wavepath-app test -count=1 -run '^TestFoundationTracer$' -v ./parity 2>&1 | grep -q -- '^--- PASS: TestFoundationTracer' - Non-zero exit, a named test does not run, or the expected corpus count is absent. + go -C ../sm-wavepath-app vet ./plugins/golem15/wavepath/... ./parity/... && go -C ../sm-wavepath-app test -count=1 -run '^(TestFoundationTracer|TestRouteBucketsMatchSnapshot)$' -v ./parity 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 2 + Non-zero exit, or fewer than two `--- PASS: Test` lines: the tracer's response or broadcast differs from the recording, a ported route's buckets differ from its snapshot line, Docker was not reachable, or a filter matched nothing. - One real foundation write is green end to end with exact PHP envelope, persistence and publications. + + - `grep -c 'status: ported' ../sm-wavepath-app/parity/manifest.yaml` prints 1 (only the tracer route). + - `grep -c 'JoinBucket' ../sm-wavepath-app/plugins/golem15/wavepath/buckets.go ../sm-wavepath-app/plugins/golem15/wavepath/routes.go | awk -F: '{s+=$2} END {print s}'` prints at least 1, and no second `community-join` bucket is registered: `grep -c 'RegisterBucket("community-join"' ../sm-wavepath-app/plugins/golem15/wavepath/buckets.go` prints 0. + - `git -C ../sm-wavepath-app diff --stat HEAD -- parity/fixtures` prints nothing after the commit (fixtures unchanged). + + One real foundation write is green end to end with exact PHP envelope, persistence, buckets and publications. Task 2: Contexts, access resolvers, wave/presence authorizers and realtime routes ../sm-wavepath-app/plugins/golem15/wavepath/chat.go, ../sm-wavepath-app/plugins/golem15/wavepath/realtime.go, ../sm-wavepath-app/plugins/golem15/wavepath/classes/context.go, ../sm-wavepath-app/plugins/golem15/wavepath/classes/channel_access.go, ../sm-wavepath-app/plugins/golem15/wavepath/classes/forum_access.go, ../sm-wavepath-app/plugins/golem15/wavepath/classes/authorizer.go, ../sm-wavepath-app/plugins/golem15/wavepath/README.md, ../sm-wavepath-app/parity/manifest.yaml - Per D-03 and D-10, implement the host group context over userfriends membership and roles, use the existing friendgroup alias, and add only the channel alias. Install channel/forum resolvers inside lagoon.OnDatabase and deny on missing database or errors. Read lighthouse channel parsing before implementing strict wave:group:{id} and presence:wave:group:{id} authorizers; register wave once and match recorded info/capabilities. Mount token and subscribe routes with their recorded auth and cache behavior. Mark only the two realtime routes ported after all success and denial fixtures pass. + Task 1 outputs, the fixtures and goldens of the two realtime routes, modules/lighthouse (channel parsing and the authorizer registry; README lines 231-232 for the default paths), ../sm-demo-app/plugins/demo/realtime_access.go (lines 18-27), ../sm-demo-app (how it wires contexts and resolvers), ../sm-userfriends-plugin (membership and roles, the `friendgroup` alias), ../sm-chatchannels-plugin and ../sm-forum-plugin (resolver seams), modules/lagoon (`OnDatabase`), 31-PATTERNS.md (resolver, authorizer and realtime sections), 31-RESEARCH.md "Drift D7" item 5 (no behaviour change in the resolver and realtime), the PHP `WaveChannelAccessResolver`, `WaveGroupChannelAuthorizer` and the seam bindings in `Plugin.php` at the resolved pin (read-only) + Per D-03 and D-10, implement the host group context over userfriends membership and roles, use the existing friendgroup alias, and add only the channel alias. Install channel/forum resolvers inside `lagoon.OnDatabase` and deny on missing database or errors. Read lighthouse channel parsing before implementing strict `wave:group:{id}` and `presence:wave:group:{id}` authorizers; register `wave` once and match recorded info/capabilities. Mount token and subscribe routes with their recorded auth and cache behavior, and buckets per their `parity/buckets.snapshot` lines. Mark only the two realtime routes ported after all success and denial fixtures pass. Update the app plugin README (Overview, Features: context, resolvers, authorizers, realtime routes). - go -C ../sm-wavepath-app test -count=1 -run 'TestParityCorpus/.+realtime' -v ./parity 2>&1 | grep -q -- '^--- PASS:' - Non-zero exit, a named test does not run, or the expected corpus count is absent. + go -C ../sm-wavepath-app test -count=1 -run 'TestParityCorpus/.+realtime' -v ./parity 2>&1 | tee "${TMPDIR:-/tmp}/phase31-realtime.log" && test "$(grep -c -- '^ --- PASS:' "${TMPDIR:-/tmp}/phase31-realtime.log")" -ge 2 && ! grep -q -- '--- FAIL:' "${TMPDIR:-/tmp}/phase31-realtime.log" + Non-zero exit, fewer than two passing realtime subtests, or any `--- FAIL:` line: a realtime success or denial case differs from the recording, or the filter matched nothing (the routes being ported is checked by the acceptance criteria). + go -C ../sm-wavepath-app test -count=1 -run '^TestRouteBucketsMatchSnapshot$' -v ./parity 2>&1 | grep -q -- '^--- PASS: TestRouteBucketsMatchSnapshot' + The `--- PASS: TestRouteBucketsMatchSnapshot` line is absent: a realtime route carries a bucket its snapshot line does not list, or lacks one it lists. + + - `grep -c 'status: ported' ../sm-wavepath-app/parity/manifest.yaml` prints 3 (the tracer route and the two realtime routes). + - The authorizers deny a malformed channel name, a zero user and a non-member: the denial fixtures of the subscribe route pass in the run above. + - `grep -cE 'OnDatabase' ../sm-wavepath-app/plugins/golem15/wavepath/classes/channel_access.go ../sm-wavepath-app/plugins/golem15/wavepath/classes/forum_access.go ../sm-wavepath-app/plugins/golem15/wavepath/chat.go | awk -F: '{s+=$2} END {print s}'` prints at least 1. + Foundation infrastructure and both realtime routes match the corpus and deny malformed or cross-group access. @@ -104,7 +135,7 @@ Output: the artifacts and machine evidence named below. |-----------|----------|-----------|----------|-------------|-----------------| | T-31-20 | Elevation of privilege | auth-group crossover on /_wave and realtime routes | high | mitigate | route groups use only jwt.auth for member routes; fixtures test guest/bot/invalid credentials; actor rejects backend/zero principals | | T-31-22 | Elevation of privilege | wave/presence channel authorization | high | mitigate | strict channel parser, runtime membership check, deny on DB/error/malformed input, exact success/denial subscribe fixtures | -| T-31-23 | Denial of service | route and join/presence buckets | medium | mitigate | global bucket ownership checked, named buckets reused instead of duplicated, stacked limits and recorded 429 repeat cases | +| T-31-23 | Denial of service | route and join/presence buckets | medium | mitigate | buckets and limits come from the parsed table; `TestRouteBucketsMatchSnapshot` pins each ported route's buckets; named buckets reused instead of duplicated; no group-level throttle; recorded 429 repeat cases | | T-31-25 | Spoofing | app host serializer diverges from shared service state | medium | mitigate | handlers derive state from services/models and strict fixture replay; typed structs prevent accidental generic API envelopes | | T-31-SC | Tampering | npm/pip/cargo installs | high | mitigate | no package install; use existing dependencies and explicit lockfiles | @@ -114,7 +145,7 @@ Run every task's automated command and preserve its fails_when semantics. Do not -Foundation infrastructure: envelope, actor, buckets, contexts, resolvers, authorizers and realtime is complete, its named tests ran, and no locked decision or D-16 phase boundary drifted. +Foundation infrastructure (envelope, actor, buckets from the parsed table, contexts, resolvers, authorizers and realtime) is complete, its named tests ran, and no locked decision or D-16 phase boundary drifted. diff --git a/.planning/phases/31-chat-polish-against-wavepath-clients/31-07-PLAN.md b/.planning/phases/31-chat-polish-against-wavepath-clients/31-07-PLAN.md index bd835740..92b4102a 100644 --- a/.planning/phases/31-chat-polish-against-wavepath-clients/31-07-PLAN.md +++ b/.planning/phases/31-chat-polish-against-wavepath-clients/31-07-PLAN.md @@ -3,49 +3,102 @@ phase: 31-chat-polish-against-wavepath-clients plan: 07 type: execute wave: 6 -depends_on: [31-06] +depends_on: [31-06, 31-10] files_modified: - ../sm-wavepath-app/plugins/golem15/wavepath/plugin.go - ../sm-wavepath-app/plugins/golem15/wavepath/routes.go - ../sm-wavepath-app/plugins/golem15/wavepath/lifecycle.go - ../sm-wavepath-app/plugins/golem15/wavepath/api/groups.go + - ../sm-wavepath-app/plugins/golem15/wavepath/api/group_summary.go - ../sm-wavepath-app/plugins/golem15/wavepath/api/members.go - ../sm-wavepath-app/plugins/golem15/wavepath/api/invites.go - ../sm-wavepath-app/plugins/golem15/wavepath/api/join.go - ../sm-wavepath-app/plugins/golem15/wavepath/api/friends.go + - ../sm-wavepath-app/plugins/golem15/wavepath/classes/participation.go + - ../sm-wavepath-app/plugins/golem15/wavepath/classes/thread_rollup.go - ../sm-wavepath-app/plugins/golem15/wavepath/updates/ + - ../sm-wavepath-app/plugins/golem15/wavepath/README.md + - ../sm-wavepath-app/plugins/golem15/chat + - ../sm-wavepath-app/plugins/golem15/chatchannels - ../sm-wavepath-app/parity/manifest.yaml + - ../sm-wavepath-app/parity/scenario.md + - ../sm-wavepath-app/parity/fixtureplugin/seed.go - ../sm-wavepath-app/parity/parity_test.go - ../sm-wavepath-app/parity/broadcast_test.go - ../sm-wavepath-app/parity/foundation_smoke_test.go - ../sm-wavepath-app/scripts/check-parity.sh + - ../sm-chat-plugin/classes/queries.go + - ../sm-chat-plugin/models/thread_mute.go + - ../sm-chat-plugin/updates/202611220001_add_golem15_chat_thread_follow_state.go + - ../sm-chat-plugin/updates/baseline_test.go + - ../sm-chat-plugin/thread_state_test.go + - ../sm-chat-plugin/roots_only_test.go + - ../sm-chat-plugin/README.md + - ../sm-chatchannels-plugin/classes/channel_service.go + - ../sm-chatchannels-plugin/roots_only_test.go + - ../sm-chatchannels-plugin/README.md + - ../sm-bm-app/plugins/golem15/chat + - ../sm-bm-app/plugins/golem15/chatchannels + - ../sm-demo-app/plugins/golem15/chat + - ../sm-demo-app/plugins/golem15/chatchannels autonomous: true -requirements: [SC-1, SC-2, SC-3, D-03, D-10, D-11, D-13, D-16] +requirements: [SC-1, SC-2, SC-3, D-03, D-10, D-11, D-12, D-13, D-14, D-16] estimate: - tokens: 190000 - raw_tokens: 190000 - tasks: 2 + tokens: 240000 + raw_tokens: 240000 + tasks: 4 confidence: low +scope_exception: "The collapsed-threads (CRT) group summary was moved into this plan by the user on 2026-11-22, together with its storage decision (chat-owned thread follow and read state) and two additive shared-plugin variants. Splitting it out would add a plan, which the project's lean-planning rule reserves for the user." must_haves: truths: - - "Foundation handlers and lifecycle green: groups, members, invites, join, friends and phase gate is delivered against the frozen PHP corpus and locked decisions." + - "Foundation handlers and lifecycle are green against the frozen PHP corpus and locked decisions: groups, members, invites, join, friends and the phase gate." + - "Every group summary carries `thread_unread_count` and `thread_mention_count`; for a CRT actor (`users.collapsed_threads`) the rollup and a roots-only `unread_count` are computed from the chat-owned thread follow and read state and the chat/chatchannels roots-only counts, and grace's recorded cases replay green." + - "Thread follow and read state live in sm-chat-plugin: `golem15_chat_thread_mutes` gains additive `is_following` and `last_read_at` columns next to `is_muted` (decision recorded 2026-11-22 by the user); the existing mute API behaves and answers as before, and 31.1 D-08 stays valid with the table extended." + - "`sm-chat-plugin` and `sm-chatchannels-plugin` gain additive roots-only count variants; every existing exported signature is unchanged, and sm-bm-app and sm-demo-app build and pass at the candidate commits (D-14)." + - "`GET community/groups` heals missing participant rows (bots, non-members and users who left skipped, existing read markers kept) and a joining member is enrolled in every visible public channel with `last_read_at = now` (bots skipped)." + - "The gate without allow flags prints `check-parity: recorded T/T ported F pending T-F foundation-pending 0`, T counted from `parity/routes.snapshot` and F from `parity/foundation-routes.txt`." - "Verification fails closed: missing, skipped, pending or mismatching evidence is not counted as a pass." - - "D-16 remains intact: messaging, satellites, Range support, guest/bot/webhook host services, zero total pending and final security review stay in Phases 31.1/31.2." + - "D-16 remains intact: messaging, satellites, Range support, guest/bot/webhook host services, zero total pending and final security review stay in Phases 31.1/31.2; the thread routes stay in 31.1." artifacts: - - path: "../sm-wavepath-app/plugins/golem15/wavepath/plugin.go" - provides: "Foundation handlers and lifecycle green: groups, members, invites, join, friends and phase gate" + - path: "../sm-wavepath-app/plugins/golem15/wavepath/api/group_summary.go" + provides: "the PHP serializeGroupSummary port with the CRT branch" + - path: "../sm-wavepath-app/plugins/golem15/wavepath/classes/thread_rollup.go" + provides: "ThreadRollup and its implementation over chat's thread state" + - path: "../sm-wavepath-app/plugins/golem15/wavepath/classes/participation.go" + provides: "TryEnsure and SelfHeal" + - path: "../sm-chatchannels-plugin/classes/channel_service.go" + provides: "CountOptions, UnreadCountForContextWith, MentionCountForWith, MentionCountForContextWith" + - path: "../sm-chat-plugin/classes/queries.go" + provides: "UnreadOptions, GetTotalUnreadCountWith, GetConversationsForUserWith, ThreadStates" + - path: "../sm-chat-plugin/updates/202611220001_add_golem15_chat_thread_follow_state.go" + provides: "additive is_following and last_read_at on golem15_chat_thread_mutes" key_links: - - from: "../sm-wavepath-app/plugins/golem15/wavepath/plugin.go" - to: "the plan's automated verification" - via: "the named tracer and fail-closed checks" + - from: "../sm-wavepath-app/plugins/golem15/wavepath/api/group_summary.go" + to: "../sm-chatchannels-plugin/classes/channel_service.go" + via: "UnreadCountForContextWith with RootsOnly for a CRT actor" + - from: "../sm-wavepath-app/plugins/golem15/wavepath/classes/thread_rollup.go" + to: "../sm-chat-plugin/classes/queries.go" + via: "ThreadStates returns the actor's follow, mute and read marker per root" + - from: "../sm-wavepath-app/plugins/golem15/wavepath/lifecycle.go" + to: "../sm-wavepath-app/plugins/golem15/wavepath/classes/participation.go" + via: "the MemberJoined listener calls TryEnsure inside ev.Tx" --- ## Phase Goal -WavePath's complete 196-route PHP community corpus is recorded and self-replays green; Phase 31 ports and proves only the 36-route foundation slice, leaving exactly 160 routes pending for Phases 31.1 and 31.2 per D-16. +WavePath's complete PHP community corpus is recorded and self-replays green: every route the corpus parser derives from `routes.php` at the commits resolved when the recording starts, plus the two realtime routes. Phase 31 ports and proves only the foundation slice listed in `parity/foundation-routes.txt`; every other corpus route stays pending for Phases 31.1 and 31.2 per D-16. Counts are derived at recording time and checked for consistency, never pinned (reference snapshot 2026-11-22, not a target: 218 tracked, 36 foundation, 182 pending). + +## Artifacts this phase produces (this plan) + +- In `plugins/golem15/wavepath`: `api/groups.go`, `api/group_summary.go` (fields `thread_unread_count`, `thread_mention_count`, the CRT `unread_count`), `api/members.go`, `api/invites.go`, `api/join.go`, `api/friends.go`, `classes/participation.go` (`TryEnsure`, `SelfHeal`), `classes/thread_rollup.go` (interface `ThreadRollup` with `GroupRollup`, and its implementation), `lifecycle.go` (GroupCreated, MemberJoined, MemberLeft, GroupDeleted listeners), the companion migration under `updates/` for `users.collapsed_threads`. +- In `../sm-chatchannels-plugin/classes/channel_service.go`: `classes.CountOptions` (field `RootsOnly`), `(*ChannelService).UnreadCountForContextWith`, `(*ChannelService).MentionCountForWith`, `(*ChannelService).MentionCountForContextWith`; test file `roots_only_test.go` with `TestRootsOnlyChannelCounts`. +- In `../sm-chat-plugin/classes/queries.go`: `classes.UnreadOptions` (field `RootsOnly`), `(*Service).GetTotalUnreadCountWith`, `(*Service).GetConversationsForUserWith`; test file `roots_only_test.go` with `TestRootsOnlyUnreadCounts`; `(*Service).ThreadStates` in `classes/queries.go`; `models.ThreadMute` fields `IsFollowing` (column `is_following`) and `LastReadAt` (column `last_read_at`); migration `202611220001_add_golem15_chat_thread_follow_state` in `updates/`; test file `thread_state_test.go` with `TestThreadFollowState`. +- Tests `TestFoundationLifecycle`, `TestGroupListSelfHeals`, `TestCRTGroupSummary` in `parity/foundation_smoke_test.go`. -Foundation handlers and lifecycle green: groups, members, invites, join, friends and phase gate. +Foundation handlers and lifecycle green (groups, members, invites, join, friends), the CRT group summary with its additive shared-plugin variants, participation self-heal and member-join enrolment, and the phase gate with derived counts. + +Decision recorded 2026-11-22 by the user: thread follow and read state are chat-owned. `golem15_chat_thread_mutes` gains `is_following` and `last_read_at` in an additive migration next to `is_muted`; sm-chat-plugin is a shared plugin, so nothing existing changes and the sm-bm-app / sm-demo-app consumer gate (D-14) applies. 31.1 D-08 (thread mute on chat `ThreadMute`, no host table) stays valid with the table extended, which answers RESEARCH "Drift D14" note 1 for the 31.1 planner. Purpose: preserve the frozen client/PHP contract while keeping this executor slice cohesive and within the authorized hybrid re-slice. Output: the artifacts and machine evidence named below. @@ -61,30 +114,114 @@ Output: the artifacts and machine evidence named below. @.planning/phases/31-chat-polish-against-wavepath-clients/31-RESEARCH.md @.planning/phases/31-chat-polish-against-wavepath-clients/31-PATTERNS.md @.planning/phases/31-chat-polish-against-wavepath-clients/31-VALIDATION.md +@.planning/phases/31.1-wavepath-messaging-parity/31.1-CONTEXT.md - Task 1: Port groups, members, invites, join and friends against recorded cases - ../sm-wavepath-app/plugins/golem15/wavepath/routes.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/groups.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/members.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/invites.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/join.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/friends.go, ../sm-wavepath-app/plugins/golem15/wavepath/updates/, ../sm-wavepath-app/parity/manifest.yaml, ../sm-wavepath-app/parity/foundation_smoke_test.go - Per D-03, D-11, D-13 and D-16, expand from the tracer one vertical family at a time: groups, members, invites/join, then friends. Use GroupService and FriendshipService for generic operations and app-side transactions for host-only fields without changing shared serializers. Define typed requests/responses from fixtures, preserve nil/empty/conditional keys, scope parent before nested ids, and reproduce recorded 401/403/404/422/429 behavior. Stack wave-api with community-join only where recorded. Mark each family ported only after all of its cases and broadcasts pass; finish with 34 non-realtime foundation routes ported. + Task 1: Port groups, members, invites, join and friends against recorded cases, with the summary fields and the group-list self-heal + 31-06 is complete: the tracer route and the two realtime routes are `ported` and `TestRouteBucketsMatchSnapshot` passes. + ../sm-wavepath-app/plugins/golem15/wavepath/routes.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/groups.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/group_summary.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/members.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/invites.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/join.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/friends.go, ../sm-wavepath-app/plugins/golem15/wavepath/classes/participation.go, ../sm-wavepath-app/plugins/golem15/wavepath/classes/thread_rollup.go, ../sm-wavepath-app/plugins/golem15/wavepath/updates/, ../sm-wavepath-app/parity/fixtureplugin/seed.go, ../sm-wavepath-app/parity/manifest.yaml, ../sm-wavepath-app/parity/foundation_smoke_test.go + 31-06-SUMMARY.md, ../sm-wavepath-app/parity/foundation-routes.txt, the fixtures and goldens of every foundation route, ../sm-wavepath-app/parity/scenario.md (grace, carol's `lounge` gap), ../sm-wavepath-app/plugins/golem15/wavepath/ (as 31-06 left it), ../sm-userfriends-plugin/classes/group_service.go and its friendship service, ../sm-chatchannels-plugin/classes/channel_service.go (ChannelsFor, prefMap, UnreadCountForContext at line 1015), 31-PATTERNS.md (handler sections), 31-RESEARCH.md "Drift D7" items 1 to 3, and from the PHP contract at the resolved pin (read-only): `controllers/api/CommunityGroupController.php` (index with `PublicChannelParticipation::selfHeal`, `serializeGroupSummary`), `CommunityMemberController.php`, `CommunityInviteController.php`, `CommunityFriendsController.php`, `classes/chat/PublicChannelParticipation.php`, `classes/threads/ThreadInboxService.php` (groupRollupFor: zeros unless `collapsed_threads`), `updates/add_collapsed_threads_to_users.php` + Per D-03, D-11, D-13 and D-16, expand from the tracer one vertical family at a time: groups, members, invites/join, then friends. Use GroupService and FriendshipService for generic operations and app-side transactions for host-only fields without changing shared serializers. Define typed requests/responses from fixtures, preserve nil/empty/conditional keys, scope parent before nested ids, and reproduce recorded 401/403/404/422/429 behavior. Stack wave-api with community-join only where `parity/buckets.snapshot` lists both for the route. +- Group summary (`api/group_summary.go`, the port of PHP `serializeGroupSummary`, embedded in index, store, show, update and join exactly where the fixtures show it): it carries `thread_unread_count` and `thread_mention_count`. Add the companion migration for `users.collapsed_threads` (boolean, default false, as WavePath's own migration; the app reads the column itself and leaves `sm-user-plugin`'s model untouched) and seed grace's `true` in `parity/fixtureplugin/seed.go`. For an actor without collapsed threads, PHP returns `0` for both fields before reading any thread state and computes `unread_count` with today's channel count; port that branch. For a CRT actor the serializer calls a `classes.ThreadRollup` (interface in `classes/thread_rollup.go`: `GroupRollup(ctx, actorID, groupID uint) (unread, mentions int64, err error)`) and a roots-only `unread_count`; both are implemented in Task 3 over the chat thread state of Task 2, and until then a CRT actor's summary returns an error, so every route with a grace case stays pending (never a fabricated count). +- Self-heal (`classes/participation.go`): `TryEnsure(ctx, tx, groupID uint, userIDs []uint, now time.Time) error` inserts the missing `golem15_chat_participants` rows for every public channel of the group each user can see (insert-or-ignore; existing rows keep their read marker; bots, non-members and users who left a public channel are skipped) and `SelfHeal(ctx, groupID, userID uint) error` calls it with now. The groups index calls `SelfHeal` for every group before serializing it, as PHP does; carol's recorded case heals her `lounge` row and its broadcast golden (the route is `writes: true`) must match. `TestGroupListSelfHeals` asserts carol's row exists after the request, with `last_read_at` set, and that a bot member gets none. +Mark each family ported only after all of its cases and broadcasts pass. Finish with every non-realtime route of `parity/foundation-routes.txt` ported, except the routes that have a case of the CRT identity grace (they are ported in Task 3). - go -C ../sm-wavepath-app test -count=1 -run 'TestParityCorpus/.+(groups|members|invites|join|friends)' -v ./parity 2>&1 | tee /tmp/phase31-foundation.log && ! grep -q -- '^--- FAIL:' /tmp/phase31-foundation.log && grep -q -- '^--- PASS:' /tmp/phase31-foundation.log - Non-zero exit, a named test does not run, or the expected corpus count is absent. + go -C ../sm-wavepath-app test -count=1 -run 'TestParityCorpus/.+(groups|members|invites|join|friends)|^TestGroupListSelfHeals$' -v ./parity 2>&1 | tee "${TMPDIR:-/tmp}/phase31-foundation.log" && ! grep -q -- '--- FAIL:' "${TMPDIR:-/tmp}/phase31-foundation.log" && grep -q -- '^--- PASS: TestGroupListSelfHeals' "${TMPDIR:-/tmp}/phase31-foundation.log" && grep -q -- '--- PASS: TestParityCorpus/' "${TMPDIR:-/tmp}/phase31-foundation.log" + Non-zero exit, any `--- FAIL:` line, or a missing PASS line: a ported foundation case or broadcast differs from the recording, the self-heal test failed or did not run, or the filter matched nothing. - All group/member/invite/join/friend routes and their denial, validation, rate and publication cases pass. + + - Every foundation route without a grace case is ported: `cd ../sm-wavepath-app && go run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --allow-incomplete --foundation parity/foundation-routes.txt 2>&1 | grep -E '^foundation '` prints a line whose foundation-pending count equals the number of foundation routes that have a grace case (recorded in the SUMMARY with their ids). + - `grep -c 'thread_unread_count' ../sm-wavepath-app/plugins/golem15/wavepath/api/group_summary.go` prints at least 1 and `grep -c 'collapsed_threads' ../sm-wavepath-app/plugins/golem15/wavepath/updates/*.go | awk -F: '{s+=$2} END {print s}'` prints at least 1. + - `git -C ../sm-wavepath-app diff --stat HEAD -- parity/fixtures` prints nothing (fixtures unchanged; implementation was fixed instead). + + All group/member/invite/join/friend routes and their denial, validation, rate and publication cases pass for every non-CRT identity, and the group list heals participant rows as PHP does. + + + + Task 2: Chat-owned thread follow and read state: additive `is_following` and `last_read_at` on `golem15_chat_thread_mutes` (decision recorded 2026-11-22) + The MariaDB import and the 31.1 thread routes map PHP's `golem15_wavepath_thread_subscriptions` rows onto these columns; the user chose this storage on 2026-11-22. + Task 1 is committed; `git -C ../sm-chat-plugin status --porcelain` shows no uncommitted change of another session in the files this task touches, and its HEAD contains 31-10's chat commit. + ../sm-chat-plugin/updates/202611220001_add_golem15_chat_thread_follow_state.go, ../sm-chat-plugin/updates/baseline_test.go, ../sm-chat-plugin/models/thread_mute.go, ../sm-chat-plugin/classes/queries.go, ../sm-chat-plugin/thread_state_test.go, ../sm-chat-plugin/README.md + ../sm-chat-plugin/models/thread_mute.go (UserID, RootID, IsMuted), ../sm-chat-plugin/classes/service.go (the mute upsert near line 448: `OnConflict` on `user_id, root_id` updating only `is_muted` and `updated_at`), ../sm-chat-plugin/updates/registry.go and updates/202610260001_create_golem15_chat_reactions.go (raw-SQL, idempotent migration style, `Register` in `init`), ../sm-chat-plugin/updates/baseline_test.go, ../sm-chat-plugin/http_tracer_test.go (`TestThreadMute`, which must stay green unchanged), ../sm-chat-plugin/README.md (models and API reference sections), 31.1-CONTEXT.md D-08, 31-RESEARCH.md "Drift D7" item 2 and "Drift D14" note 1, and from the PHP contract at the resolved pin (read-only): `updates/create_thread_subscriptions_table.php`, `updates/add_last_read_at_to_thread_subscriptions.php`, `classes/threads/ThreadInboxService.php` (`followedQuery`, `whereUnread`) + + - `TestThreadFollowState` (Docker): after the migration, an existing mute row reads `IsFollowing` false and `LastReadAt` nil; a row written with `IsFollowing` true and a read marker keeps both after a mute and an unmute through the existing mute API (the upsert still updates only `is_muted` and `updated_at`); `ThreadStates(ctx, userID, rootIDs)` returns exactly the actor's rows for the requested roots, keyed by root id, and nothing for another user's rows or for roots without a row; an empty `rootIDs` returns an empty map without a query error. + - The migration is idempotent: running it on a database that already has the columns changes nothing; `TestThreadMute` and the existing mute API responses are unchanged. + + Per the user's decision of 2026-11-22 (thread state chat-owned; recorded in this plan's objective), D-12 and D-14 (additive change to a shared plugin, consumers follow). +1. Red first: `thread_state_test.go` with `TestThreadFollowState` from the behavior block, in the style of the plugin's existing Docker-backed tests. Run it and see it fail. +2. `updates/202611220001_add_golem15_chat_thread_follow_state.go`: one migration with ID `202611220001_add_golem15_chat_thread_follow_state`, registered with `Register` in `init`, raw SQL in the package style: add `is_following` (boolean, not null, default false) and `last_read_at` (nullable timestamp, the type the baseline uses for timestamps) to `golem15_chat_thread_mutes` with `ADD COLUMN IF NOT EXISTS`, and an index on `(user_id, is_muted)` as PHP's `wp_thread_subs_user_muted_idx`, also `IF NOT EXISTS`; the rollback drops what it added. Extend `updates/baseline_test.go` (or its migration-list check) with the new ID. +3. `models/thread_mute.go`: fields `IsFollowing bool` (`gorm:"column:is_following"`) and `LastReadAt *time.Time` (`gorm:"column:last_read_at"`); update the type's doc comment: one row per (user, root) holding mute, follow and the per-thread read marker. A row exists for a muted thread whether or not it is followed; a thread is followed when `is_following` is true (PHP: a subscription row exists). +4. `classes/queries.go`: `(*Service).ThreadStates(ctx context.Context, userID uint, rootIDs []uint) (map[uint]models.ThreadMute, error)`, read-only. No write API for follow or the read marker is added here: Phase 31 writes these columns only through the parity seeder, and the thread routes that write them are ported in 31.1. Leave the mute upsert's `DoUpdates` list exactly as it is, so a mute never clears follow or read state. +5. README: the model row and the API reference row for `ThreadStates`, and one sentence that the table holds mute, follow and the per-thread read marker. +6. Commit in sm-chat-plugin: `feat(chat): additive thread follow and read state`. + + go -C ../sm-chat-plugin vet ./... && go -C ../sm-chat-plugin test -count=1 -short ./... && go -C ../sm-chat-plugin test -count=1 -run '^(TestThreadFollowState|TestThreadMute)$' -v . 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 2 + Non-zero exit or fewer than two PASS lines: the plugin does not vet or test, the migration or `ThreadStates` misbehaves, the existing mute API changed (`TestThreadMute` failed), Docker was not reachable, or a filter matched nothing. + + + - `grep -c 'column:is_following' ../sm-chat-plugin/models/thread_mute.go` prints 1, `grep -c 'column:last_read_at' ../sm-chat-plugin/models/thread_mute.go` prints 1 and `grep -c 'column:is_muted' ../sm-chat-plugin/models/thread_mute.go` prints 1. + - `grep -c '202611220001_add_golem15_chat_thread_follow_state' ../sm-chat-plugin/updates/202611220001_add_golem15_chat_thread_follow_state.go` prints at least 1 and `grep -c 'IF NOT EXISTS' ../sm-chat-plugin/updates/202611220001_add_golem15_chat_thread_follow_state.go` prints at least 2. + - The mute upsert is unchanged: with BASE the sm-chat-plugin HEAD recorded before Task 2's first commit (written into the SUMMARY), `git -C ../sm-chat-plugin diff "$BASE" HEAD -- classes/service.go` prints nothing. + - `grep -c 'ThreadStates' ../sm-chat-plugin/README.md` prints at least 1. + + sm-chat-plugin holds per-thread follow and read state next to mute, additively, readable through `ThreadStates`, and every existing mute behaviour is unchanged. + + + + Task 3: Roots-only count variants in chat and chatchannels, the thread rollup over chat's thread state, and the CRT summary green + The added exported variants become part of two published plugin APIs (D-14). + Task 2 is committed in sm-chat-plugin; `git -C ../sm-chat-plugin status --porcelain` and `git -C ../sm-chatchannels-plugin status --porcelain` show no uncommitted change of another session in the files this task touches. + ../sm-chat-plugin/classes/queries.go, ../sm-chat-plugin/roots_only_test.go, ../sm-chat-plugin/README.md, ../sm-chatchannels-plugin/classes/channel_service.go, ../sm-chatchannels-plugin/roots_only_test.go, ../sm-chatchannels-plugin/README.md, ../sm-wavepath-app/plugins/golem15/wavepath/classes/thread_rollup.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/group_summary.go, ../sm-wavepath-app/plugins/golem15/wavepath/plugin.go, ../sm-wavepath-app/plugins/golem15/chat, ../sm-wavepath-app/plugins/golem15/chatchannels, ../sm-wavepath-app/parity/fixtureplugin/seed.go, ../sm-wavepath-app/parity/scenario.md, ../sm-wavepath-app/parity/manifest.yaml, ../sm-wavepath-app/parity/foundation_smoke_test.go, ../sm-bm-app/plugins/golem15/chat, ../sm-bm-app/plugins/golem15/chatchannels, ../sm-demo-app/plugins/golem15/chat, ../sm-demo-app/plugins/golem15/chatchannels + Task 2 outputs (`ThreadStates`, the new `ThreadMute` fields), ../sm-chatchannels-plugin/classes/channel_service.go (UnreadCountForContext at 1015, prefMap, MentionCountFor at 1462, MentionCountForContext at 1479), ../sm-chat-plugin/classes/queries.go (GetConversationsForUser, unreadIn at 111, GetTotalUnreadCount at 210), ../sm-chat-plugin/README.md and ../sm-chatchannels-plugin/README.md (API reference sections), 31-10-SUMMARY.md (the chat candidate commit this builds on), .planning/notes/core-plugins-own-repos.md, 31-RESEARCH.md "Drift D8" (the chat and chatchannels rootsOnly deltas), and from the PHP contract at the resolved pins (read-only `git diff` from the old chat and chatchannels pins in RESEARCH "Drift D1" to the resolved ones): `Conversation::scopeWithUnreadCount`, `ChannelService::unreadCountForContext`, `mentionCountFor`, `mentionCountForContext`, and `ThreadInboxService::groupTerms`, `unreadStatsByConversation`, `followedQuery`, `whereUnread` + + - `TestRootsOnlyChannelCounts` (chatchannels): with replies after the read marker, `UnreadCountForContextWith(..., CountOptions{RootsOnly: true})` counts only root messages and the zero-options call equals `UnreadCountForContext`; the same for `MentionCountForWith` and `MentionCountForContextWith` (a mention on a reply is excluded only on the roots-only path); notify-pref filtering is unchanged. + - `TestRootsOnlyUnreadCounts` (chat): `GetTotalUnreadCountWith` and `GetConversationsForUserWith` with `RootsOnly` exclude replies; with `UnreadOptions{}` they equal the existing functions. + - `TestCRTGroupSummary` (app, Docker): for grace, `thread_unread_count` and `thread_mention_count` equal the PHP-recorded values (her unread thread counts, her mention counts, the muted thread excluded, a mute-only row that is not followed excluded, the `mentions` channel contributing mentions only), `unread_count` is the roots-only count; for a group grace cannot access the rollup is zero; for a non-CRT member the fields are zero and `unread_count` is unchanged. + + Per D-12 and D-14 (additive shared-plugin changes, consumers follow) and the session decision that the CRT summary is ported in Phase 31; the thread routes themselves stay in 31.1. +1. `../sm-chatchannels-plugin/classes/channel_service.go`: add `type CountOptions struct { RootsOnly bool }` and `UnreadCountForContextWith`, `MentionCountForWith`, `MentionCountForContextWith`, each taking the existing parameters plus `opts CountOptions`; the roots-only path adds the root-message condition the PHP delta adds (for mentions, the join to `golem15_chat_messages`). The three existing methods keep their signatures and call the new ones with `CountOptions{}`. `roots_only_test.go`: the behavior block. README API reference rows. Commit in the plugin repo: `feat(chatchannels): additive roots-only unread and mention counts`. +2. `../sm-chat-plugin/classes/queries.go`: add `type UnreadOptions struct { RootsOnly bool }`, `GetTotalUnreadCountWith` and `GetConversationsForUserWith` (existing parameters plus `opts UnreadOptions`), the existing functions delegating with `UnreadOptions{}`. `roots_only_test.go`: the behavior block. README API reference rows. Commit: `feat(chat): additive roots-only unread counts`, on top of Task 2's commit (which sits on 31-10's chat commit). +3. Consumers (D-14) before anything else uses the commits: point the chat and chatchannels submodules of `../sm-bm-app` and `../sm-demo-app` at the candidate commits locally (the chat candidate holds Task 2's thread-state migration and this task's variants), run `go -C ../sm-bm-app build ./...` with its required tests and `go -C ../sm-demo-app vet` and `test -short` (root and `./plugins/demo/...`). Point `../sm-wavepath-app/plugins/golem15/chat` and `chatchannels` at the candidate commits and commit that pointer bump in sm-wavepath-app separately. No tag, push or changelog post without the user's explicit go-ahead; when authorized, tag each plugin with its next patch version, post its changelog on `/changelog/plugins`, then commit the consumer pointers separately; otherwise record the release-ready hashes in the SUMMARY. +4. Seed grace's thread rows on the Go side in `parity/fixtureplugin/seed.go` as `models.ThreadMute` rows with the scenario's ids: each PHP subscription row becomes one row with `is_following` true, its `is_muted` and its `last_read_at`. Update `parity/scenario.md`: the `Go: 31-07` rows name `golem15_chat_thread_mutes` and the mapping (PHP subscription row present = `is_following` true). +5. `classes/thread_rollup.go`: implement `ThreadRollup` as the port of `groupTerms` and `unreadStatsByConversation`, reading follow, mute and the read marker through chat's `ThreadStates` (or the same columns in one query over `golem15_chat_thread_mutes` joined to `golem15_chat_thread_summaries` and `golem15_chat_messages`, as PHP's `followedQuery`): over the channels `ChannelsFor` returns for the actor (minus public channels the actor left), with each channel's notify preference; per channel conversation count the followed (`is_following`), unmuted roots whose last reply is after the actor's marker (or that have no marker) (`unread`, added when the preference is `all`) and the actor's mentions on live replies after the marker (`mentions`, added unless the preference is `none`); a context-access error yields zero for that group (PHP's fail-safe). `api/group_summary.go`: the CRT branch uses it and `UnreadCountForContextWith(..., CountOptions{RootsOnly: true})`; `plugin.go` wires the implementation. `TestCRTGroupSummary`: the behavior block. +6. Mark the routes with grace cases ported once every case passes. Commit in sm-wavepath-app: `feat(wavepath): collapsed-threads group summary`. + + for r in sm-chat-plugin sm-chatchannels-plugin; do go -C ../$r vet ./... && go -C ../$r test -count=1 -short ./... || exit 1; done && go -C ../sm-chat-plugin test -count=1 -run '^TestRootsOnlyUnreadCounts$' -v . 2>&1 | grep -q -- '^--- PASS: TestRootsOnlyUnreadCounts' && go -C ../sm-chatchannels-plugin test -count=1 -run '^TestRootsOnlyChannelCounts$' -v . 2>&1 | grep -q -- '^--- PASS: TestRootsOnlyChannelCounts' + Non-zero exit or a PASS line absent: a plugin does not vet or test, an existing count changed its result, or a named roots-only test did not run. + go -C ../sm-bm-app build ./... && go -C ../sm-bm-app test -count=1 -run '^(TestChatMounted|TestRealtimeDefaultDriver|TestRealtimeRoutes|TestRealtimeConfigDefaults|TestRemoteKeyOverride)$' -v . 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 5 && go -C ../sm-demo-app vet . ./plugins/demo/... && go -C ../sm-demo-app test -count=1 -short . ./plugins/demo/... + Non-zero exit or fewer than five bm PASS lines: a consumer does not build or pass at the candidate commits, or the required bm tests did not run. + go -C ../sm-wavepath-app test -count=1 -run '^TestCRTGroupSummary$|TestParityCorpus/.+groups' -v ./parity 2>&1 | tee "${TMPDIR:-/tmp}/phase31-crt.log" && ! grep -q -- '--- FAIL:' "${TMPDIR:-/tmp}/phase31-crt.log" && grep -q -- '^--- PASS: TestCRTGroupSummary' "${TMPDIR:-/tmp}/phase31-crt.log" + Any `--- FAIL:` line or the `--- PASS: TestCRTGroupSummary` line absent: grace's recorded counts differ, the rollup misreads chat's thread state, or the test did not run. + + + - The existing signatures are unchanged: `grep -c 'func (s \*ChannelService) UnreadCountForContext(ctx context.Context, actorID uint, contextType string, contextID uint) (int64, error)' ../sm-chatchannels-plugin/classes/channel_service.go` prints 1 and `grep -c 'func (s \*Service) GetTotalUnreadCount(ctx context.Context, userID uint, alias string, contextID uint) (int64, error)' ../sm-chat-plugin/classes/queries.go` prints 1. + - `grep -c 'type CountOptions struct' ../sm-chatchannels-plugin/classes/channel_service.go` prints 1 and `grep -c 'type UnreadOptions struct' ../sm-chat-plugin/classes/queries.go` prints 1; both READMEs name the new identifiers. + - The submodule HEADs of chat and chatchannels in sm-bm-app, sm-demo-app and sm-wavepath-app equal the candidate commits recorded in the SUMMARY. + - No tag, push or changelog post happened without the user's explicit go-ahead. + + A collapsed-threads member sees the same group summary on Go as on PHP, the shared plugins gained only additive variants, and their consumers still build and pass. - Task 2: Transactional group lifecycle and foundation-pending zero gate + Task 4: Transactional group lifecycle with public-channel enrolment, and the foundation-pending zero gate ../sm-wavepath-app/plugins/golem15/wavepath/plugin.go, ../sm-wavepath-app/plugins/golem15/wavepath/lifecycle.go, ../sm-wavepath-app/plugins/golem15/wavepath/README.md, ../sm-wavepath-app/parity/parity_test.go, ../sm-wavepath-app/parity/broadcast_test.go, ../sm-wavepath-app/parity/foundation_smoke_test.go, ../sm-wavepath-app/scripts/check-parity.sh - Per D-03, listen for GroupCreated, MemberJoined/Left and GroupDeleted. Work on ev.Tx so failures roll back; create group chat/default channel once, avoid duplicate owner work, update memberships idempotently, and on delete end video and remove forum/host context in PHP order. Add lifecycle smoke coverage for rows, rollback and publications. Prove exactly foundation-routes.txt is ported and run the gate without allow flags; it must report recorded 196/196, ported 36, pending 160, foundation-pending 0. + Task 1 and Task 3 outputs, ../sm-userfriends-plugin/events/events.go (lines 8-31: every event carries `Tx`), the fixtures and goldens of the group create, join, leave and delete cases, 31-PATTERNS.md (lifecycle section), 31-RESEARCH.md "Drift D7" items 3 and 4, and from the PHP contract at the resolved pin (read-only): `classes/services/CommunityChatService.php` (`enrollMember`, `onMemberJoined`), the new-group seed, the member auto-join and the group wind-down in `Plugin.php` + Per D-03 and D-16, listen for GroupCreated, MemberJoined/Left and GroupDeleted. Work on ev.Tx so failures roll back; create group chat/default channel once, avoid duplicate owner work, update memberships idempotently, and on delete end video and remove forum/host context in PHP order. On MemberJoined, after the group chat, `#general` and `is_default` enrolment, call `TryEnsure` inside `ev.Tx` so the new member participates in every other visible public channel with `last_read_at` set to now; bots are skipped. Add `TestFoundationLifecycle` for rows, rollback, the public-channel enrolment (a joining member gets a row per visible public channel, a bot none, an existing row keeps its marker) and publications. Prove exactly `parity/foundation-routes.txt` is ported and run the gate without allow flags; its summary line must equal the derived one: T counted from `parity/routes.snapshot`, F from `parity/foundation-routes.txt`, ported F, pending T − F, foundation-pending 0. Update the app plugin README (lifecycle, CRT summary, self-heal). Post the g15office comment on task `hgol7otp` (foundation slice ported). - OUT="$(../sm-wavepath-app/scripts/check-parity.sh 2>&1)" && printf '%s\n' "$OUT" | grep -qx 'check-parity: recorded 196/196 ported 36 pending 160 foundation-pending 0' - Non-zero exit, a named test does not run, or the expected corpus count is absent. + go -C ../sm-wavepath-app test -count=1 -run '^TestFoundationLifecycle$' -v ./parity 2>&1 | grep -q -- '^--- PASS: TestFoundationLifecycle' + The `--- PASS: TestFoundationLifecycle` line is absent: a lifecycle row, the rollback, the public-channel enrolment or a publication differs, or the test did not run. + cd ../sm-wavepath-app && T="$(grep -cE '^(GET|POST|PUT|PATCH|DELETE) ' parity/routes.snapshot)" && F="$(grep -c . parity/foundation-routes.txt)" && test "$T" -gt "$F" && OUT="$(scripts/check-parity.sh 2>&1)" && printf '%s\n' "$OUT" | grep -qx "check-parity: recorded $T/$T ported $F pending $((T - F)) foundation-pending 0" + Non-zero exit, or the summary line differs from the derived one: a stage failed (corpus, replay, foundation, consumers or self-test), a foundation route is still pending, a non-foundation route was marked ported, or the counts are inconsistent. - Lifecycle is rollback-safe and the Phase 31 foundation gate closes at zero foundation pending while 160 later-phase routes remain pending. + + - The ported set is exactly the foundation list: `cd ../sm-wavepath-app && diff <(sort parity/foundation-routes.txt) <(go run ./parity/check_corpus.go --manifest parity/manifest.yaml --snapshot parity/routes.snapshot --list-ids --status ported | sort)` prints nothing. + - `grep -c 'TryEnsure' ../sm-wavepath-app/plugins/golem15/wavepath/lifecycle.go` prints at least 1. + - `git -C ../sm-wavepath-app status --porcelain` prints nothing. + + Lifecycle is rollback-safe, a joining member participates in every visible public channel, and the Phase 31 foundation gate closes at zero foundation pending while every later-phase route remains pending. @@ -103,7 +240,11 @@ Output: the artifacts and machine evidence named below. | Threat ID | Category | Component | Severity | Disposition | Mitigation Plan | |-----------|----------|-----------|----------|-------------|-----------------| | T-31-21 | Information disclosure | group/member/invite/friend IDOR | high | mitigate | parent-first scope checks, membership/role gate before nested lookup, recorded 403/404 collapse and cross-group denial cases | -| T-31-24 | Tampering | partial group lifecycle | high | mitigate | listeners use ev.Tx and return errors; create/delete side effects and rollback behavior tested with broadcasts | +| T-31-24 | Tampering | partial group lifecycle | high | mitigate | listeners use ev.Tx and return errors; create/delete side effects, the public-channel enrolment and rollback behavior tested with broadcasts | +| T-31-43 | Tampering | shared count changes breaking consumers of sm-chat-plugin and sm-chatchannels-plugin | high | mitigate | only additive `...With` variants and option structs; existing exported signatures are grep-checked and delegate with zero options; sm-bm-app and sm-demo-app build and pass at the candidate commits before anything uses them; no tag without the user | +| T-31-44 | Elevation of privilege | self-heal and enrolment inserting participant rows | high | mitigate | `TryEnsure` covers only public channels the user can see, skips bots, non-members and users who left, never rewrites an existing read marker; `TestGroupListSelfHeals` and `TestFoundationLifecycle` assert the skips | +| T-31-45 | Information disclosure | the CRT rollup counting threads of channels the actor cannot read | high | mitigate | the rollup iterates only `ChannelsFor(actor)` minus left public channels, honours notify preferences, and yields zero on a context-access error; `TestCRTGroupSummary` covers an inaccessible group | +| T-31-48 | Tampering | thread-state columns on the shared chat table changing mute behaviour or clearing follow and read state | medium | mitigate | additive `IF NOT EXISTS` columns with defaults; the mute upsert's update list stays `is_muted, updated_at` (acceptance checks `classes/service.go` is unchanged); `TestThreadFollowState` and the unchanged `TestThreadMute`; bm and demo consumer gate at the candidate commit | | T-31-SC | Tampering | npm/pip/cargo installs | high | mitigate | no package install; use existing dependencies and explicit lockfiles | @@ -112,9 +253,9 @@ Run every task's automated command and preserve its fails_when semantics. Do not -Foundation handlers and lifecycle green: groups, members, invites, join, friends and phase gate is complete, its named tests ran, and no locked decision or D-16 phase boundary drifted. +Foundation handlers, the CRT group summary, self-heal, lifecycle and the phase gate are green, the shared plugins changed only additively with their consumers passing, the named tests ran, and no locked decision or D-16 phase boundary drifted. -Create `.planning/phases/31-chat-polish-against-wavepath-clients/31-07-SUMMARY.md` with commits, final identifiers, verification evidence, deviations, and remaining D-16 pending work. +Create `.planning/phases/31-chat-polish-against-wavepath-clients/31-07-SUMMARY.md` with commits (per repository), the recorded thread-state decision (chat-owned, 2026-11-22) flagged for the 31.1 planner, the candidate plugin commits, final identifiers, verification evidence, deviations, and remaining D-16 pending work. diff --git a/.planning/phases/31-chat-polish-against-wavepath-clients/31-08-PLAN.md b/.planning/phases/31-chat-polish-against-wavepath-clients/31-08-PLAN.md index 6d4141cf..a45eeeb8 100644 --- a/.planning/phases/31-chat-polish-against-wavepath-clients/31-08-PLAN.md +++ b/.planning/phases/31-chat-polish-against-wavepath-clients/31-08-PLAN.md @@ -11,7 +11,7 @@ files_modified: - ../sm-oauthserver-plugin/testdata/parity/id_token_shape.json - ../sm-oauthserver-plugin/testdata/parity/README.md autonomous: true -requirements: [SC-3, D-08, D-20, TODO-OIDC] +requirements: [SC-3, D-08, D-12, D-20, TODO-OIDC] estimate: tokens: 80000 raw_tokens: 80000 @@ -19,7 +19,7 @@ estimate: confidence: low must_haves: truths: - - "Folded OIDC PHP parity recording in sm-oauthserver-plugin is delivered against the frozen PHP corpus and locked decisions." + - "Folded OIDC PHP parity recording in sm-oauthserver-plugin is delivered at the pins resolved when it starts, against the frozen PHP corpus and locked decisions." - "Verification fails closed: missing, skipped, pending or mismatching evidence is not counted as a pass." - "D-16 remains intact: messaging, satellites, Range support, guest/bot/webhook host services, zero total pending and final security review stay in Phases 31.1/31.2." artifacts: @@ -33,7 +33,13 @@ must_haves: ## Phase Goal -WavePath's complete 196-route PHP community corpus is recorded and self-replays green; Phase 31 ports and proves only the 36-route foundation slice, leaving exactly 160 routes pending for Phases 31.1 and 31.2 per D-16. +WavePath's complete PHP community corpus is recorded and self-replays green: every route the corpus parser derives from `routes.php` at the commits resolved when the recording starts, plus the two realtime routes. Phase 31 ports and proves only the foundation slice listed in `parity/foundation-routes.txt`; every other corpus route stays pending for Phases 31.1 and 31.2 per D-16. Counts are derived at recording time and checked for consistency, never pinned (reference snapshot 2026-11-22, not a target: 218 tracked, 36 foundation, 182 pending). + +## Artifacts this phase produces (this plan) + +- Recorded responses in the ten existing request-only flows under `../sm-oauthserver-plugin/testdata/parity/flows/` (discovery, jwks, authorize_errors, login_handoff, consent_allow, consent_silent, token_errors, userinfo_errors, consent_deny, authorizations). +- `../sm-oauthserver-plugin/testdata/parity/seed.json`, `winter-export.jsonl` (hashes only), `id_token_shape.json`; the runbook section for the automated `oidc` instance in `testdata/parity/README.md`, naming the superproject and oauthserver commits of the `oidc` instance's pins file. +- The private vars file `~/.config/summercms/parity-oauthserver.vars` (mode 0600, never committed). Folded OIDC PHP parity recording in sm-oauthserver-plugin. @@ -58,11 +64,11 @@ Output: the artifacts and machine evidence named below. Task 1: Record the ten PHP OIDC flows on the isolated oidc instance and make the existing parity harness mandatory-green - 31-02's stack supports `PARITY_INSTANCE=oidc`; the pinned oauthserver commit is present; `../sm-oauthserver-plugin/testdata/parity/README.md` lists the ten flows and the plugin's unrelated go.work change is left unstaged. + 31-03's stack supports `PARITY_INSTANCE=oidc`; `../sm-wavepath-app/parity/php_parity.sh pin` honours `PARITY_PINS_FILE`; `../sm-oauthserver-plugin/testdata/parity/README.md` lists the ten flows and the plugin's unrelated go.work change is left unstaged. ../sm-oauthserver-plugin/testdata/parity/flows/, ../sm-oauthserver-plugin/testdata/parity/seed.json, ../sm-oauthserver-plugin/testdata/parity/winter-export.jsonl, ../sm-oauthserver-plugin/testdata/parity/id_token_shape.json, ../sm-oauthserver-plugin/testdata/parity/README.md - ../sm-oauthserver-plugin/testdata/parity/README.md (whole file), parity_test.go tests TestPHPParityReplay and TestIDTokenShapeParity, scripts/winter-export.sql, all ten existing request-only flows, 31-03-SUMMARY.md instance/port contract, ../sm-wavepath-app/parity/php_parity.sh and scripts/parity-stack.sh, pinned PHP oauthserver models and migrations through the parity export + ../sm-oauthserver-plugin/testdata/parity/README.md (whole file), parity_test.go tests TestPHPParityReplay and TestIDTokenShapeParity, jwt_only_test.go (lines 1-40), testdata/parity/deviations.yaml, scripts/winter-export.sql, all ten existing request-only flows, 31-03-SUMMARY.md instance/port/pin contract, 31-RESEARCH.md "Drift D8" (the oauthserver row), ../sm-wavepath-app/parity/php_parity.sh and scripts/parity-stack.sh, pinned PHP oauthserver models and migrations through the parity export Per the folded OIDC todo, D-08 and D-20. -1. Start `PARITY_INSTANCE=oidc` with its isolated database/export/ports. Seed one activated parity user and the `Parity RP` client (`https://rp.example.test/callback`, openid/profile/email, active, non-development, no prior consent), and mint the user's session token into `~/.config/summercms/parity-oauthserver.vars` with mode 0600. Add no committed secret. +1. Resolve the pins as the corpus does, into the instance's own file so the committed corpus pins stay untouched (`PARITY_INSTANCE=oidc PARITY_PINS_FILE="$PARITY_ROOT/oidc/pins.env" php_parity.sh pin`, wavepath.org HEAD unless `PARITY_PIN_REF` is set; D-12 freeze at recording time) and start `PARITY_INSTANCE=oidc` with the same `PARITY_PINS_FILE` with its isolated database/export/ports; write the superproject and oauthserver commits into the runbook. Since the oauthserver delta in RESEARCH "Drift D8", WavePath turns on `resolve_user_jwt_only` in its boot, so PHP treats a request carrying only a Winter session as signed out, as the Go plugin always does (`jwt_only_test.go`); no Go change is expected, no new deviation entry is added, and a flow that differs only because of it is recorded as PHP answers. Seed one activated parity user and the `Parity RP` client (`https://rp.example.test/callback`, openid/profile/email, active, non-development, no prior consent), and mint the user's session token into `~/.config/summercms/parity-oauthserver.vars` with mode 0600. Add no committed secret. 2. Record, in this exact order and stopping on first failure: discovery, jwks, authorize_errors, login_handoff, consent_allow, consent_silent, token_errors, userinfo_errors, consent_deny, authorizations. Invoke `summer parity:record --spec FLOW --output FLOW --target BASE --vars PRIVATE --update true`; do not pass `--rules`. 3. Remove every Set-Cookie entry from recorded responses. Generate `seed.json`, `winter-export.jsonl` through the runbook's MariaDB export (hashes, not plaintext secrets), and `id_token_shape.json`. Reject a real hostname, token, client secret, authorization code or cookie in any committed file. 4. Run the two mandatory parity tests. Resolve only observed documented differences through the existing deviation mechanism; do not broaden masks. Update the runbook with the automated `oidc` instance steps and exact green output. @@ -78,6 +84,8 @@ Output: the artifacts and machine evidence named below. - No flow contains Set-Cookie; export values are hashes only. - `git -C ../sm-oauthserver-plugin diff -- go.work` is exactly the pre-existing other-session diff and is not staged. - Both mandatory parity tests pass without a skip. + - The runbook names the superproject and oauthserver commits the flows were recorded at, and they equal the `SUPERPROJECT` and `plugins/golem15/oauthserver` lines of the `oidc` instance's pins file; `git -C ../sm-wavepath-app status --porcelain -- parity/pins.env` prints nothing (the corpus pins were not changed). + - `git -C ../sm-oauthserver-plugin diff --stat HEAD -- testdata/parity/deviations.yaml` prints nothing (no deviation added for the JWT-only identity). PHP OIDC behavior is a committed, secret-free reference corpus and the existing Go provider passes it under the mandatory parity flag. diff --git a/.planning/phases/31-chat-polish-against-wavepath-clients/31-09-PLAN.md b/.planning/phases/31-chat-polish-against-wavepath-clients/31-09-PLAN.md index a6d42571..fc73dfa5 100644 --- a/.planning/phases/31-chat-polish-against-wavepath-clients/31-09-PLAN.md +++ b/.planning/phases/31-chat-polish-against-wavepath-clients/31-09-PLAN.md @@ -31,7 +31,12 @@ must_haves: ## Phase Goal -WavePath's complete 196-route PHP community corpus is recorded and self-replays green; Phase 31 ports and proves only the 36-route foundation slice, leaving exactly 160 routes pending for Phases 31.1 and 31.2 per D-16. +WavePath's complete PHP community corpus is recorded and self-replays green: every route the corpus parser derives from `routes.php` at the commits resolved when the recording starts, plus the two realtime routes. Phase 31 ports and proves only the foundation slice listed in `parity/foundation-routes.txt`; every other corpus route stays pending for Phases 31.1 and 31.2 per D-16. Counts are derived at recording time and checked for consistency, never pinned (reference snapshot 2026-11-22, not a target: 218 tracked, 36 foundation, 182 pending). + +## Artifacts this phase produces (this plan) + +- In `../vue-chat-layer/app/composables/useChat.ts`: the `//` escape and the catalog check of the first token in `send` (known trigger dispatches through `runCommand`, unknown trigger keeps the draft and adds the local hint, bare `/` and an empty loaded catalog use ordinary send). +- Test cases in `../vue-chat-layer/tests/store.test.ts` for known, unknown, `//`, bare `/`, empty catalog and null/loading catalog; the README's command-behaviour section. Folded vue-chat-layer slash-command parity fix. diff --git a/.planning/phases/31-chat-polish-against-wavepath-clients/31-10-PLAN.md b/.planning/phases/31-chat-polish-against-wavepath-clients/31-10-PLAN.md index f2dfffa2..1f38527c 100644 --- a/.planning/phases/31-chat-polish-against-wavepath-clients/31-10-PLAN.md +++ b/.planning/phases/31-chat-polish-against-wavepath-clients/31-10-PLAN.md @@ -42,7 +42,14 @@ must_haves: ## Phase Goal -WavePath's complete 196-route PHP community corpus is recorded and self-replays green; Phase 31 ports and proves only the 36-route foundation slice, leaving exactly 160 routes pending for Phases 31.1 and 31.2 per D-16. +WavePath's complete PHP community corpus is recorded and self-replays green: every route the corpus parser derives from `routes.php` at the commits resolved when the recording starts, plus the two realtime routes. Phase 31 ports and proves only the foundation slice listed in `parity/foundation-routes.txt`; every other corpus route stays pending for Phases 31.1 and 31.2 per D-16. Counts are derived at recording time and checked for consistency, never pinned (reference snapshot 2026-11-22, not a target: 218 tracked, 36 foundation, 182 pending). + +## Artifacts this phase produces (this plan) + +- `../sm-chat-plugin`: the `MessageSaving` field for claimed attachment filenames (final neutral plural name, for example `AttachmentFilenames`), tests in `saving_test.go`. +- `../sm-userfriends-plugin`: `events.GroupSaving` with operation constants, `contracts.Rejection`, the 422 mapping in `api/errors.go`, tests in `saving_test.go`. +- `../sm-user-plugin`: `SavingEvent`, operation constants, `FireSavingEvent`, `contracts.Rejection`, fire points in registration, profile update and backend-admin create/update, tests in `saving_test.go`. +- `../sm-demo-app/plugins/demo/moderation.go` listeners for profile, group and filename fields; `../sm-demo-app/moderation_test.go` with `TestDemoModeration`; release-ready candidate commits recorded in the SUMMARY (plan 31-07 builds its chat commit on top of the chat one). Folded additive moderation seams for users, friend groups and attachment filenames. diff --git a/.planning/phases/31-chat-polish-against-wavepath-clients/31-11-PLAN.md b/.planning/phases/31-chat-polish-against-wavepath-clients/31-11-PLAN.md index 3c8960aa..b6f6eeca 100644 --- a/.planning/phases/31-chat-polish-against-wavepath-clients/31-11-PLAN.md +++ b/.planning/phases/31-chat-polish-against-wavepath-clients/31-11-PLAN.md @@ -11,39 +11,57 @@ files_modified: - ../sm-wavepath-app/parity/ - ../sm-wavepath-app/scripts/check-parity.sh - ../sm-chat-plugin/saving_test.go + - ../sm-chat-plugin/roots_only_test.go + - ../sm-chat-plugin/thread_state_test.go + - ../sm-chatchannels-plugin/roots_only_test.go - ../sm-userfriends-plugin/saving_test.go - ../sm-user-plugin/saving_test.go - ../sm-demo-app/moderation_test.go - ../vue-chat-layer/tests/store.test.ts autonomous: true -requirements: [SC-1, SC-2, SC-3, SC-4, D-01, D-03, D-06, D-09, D-10, D-11, D-13, D-14, D-16, D-22] +requirements: [SC-1, SC-2, SC-3, SC-4, D-01, D-03, D-06, D-09, D-10, D-11, D-12, D-13, D-14, D-16, D-22] estimate: - tokens: 260000 - raw_tokens: 260000 + tokens: 280000 + raw_tokens: 280000 tasks: 3 confidence: low scope_exception: "This closing unit-and-gate plan intentionally groups test matrices across the phase; splitting it would violate the project rule that the last plan owns unit coverage and the closing gate." must_haves: truths: - - "Unit tests last: tide, app foundation, parity/gate and folded-todo regression matrices is delivered against the frozen PHP corpus and locked decisions." + - "Unit tests come last and cover tide, the app foundation, the parity checker and gate, and the folded-todo and shared-plugin regressions, delivered against the frozen PHP corpus and locked decisions." + - "The new tide numeric-clock masks, bounded parallel repeat and writing-route rule, the checker's derived-count consistency checks, the CRT foundation counts, the self-heal and enrolment, the roots-only variants and chat's thread follow and read state each have positive, edge and fail-closed table rows." - "Verification fails closed: missing, skipped, pending or mismatching evidence is not counted as a pass." - "D-16 remains intact: messaging, satellites, Range support, guest/bot/webhook host services, zero total pending and final security review stay in Phases 31.1/31.2." - - "The final gate reports recorded 196/196, ported 36, pending 160 and foundation-pending 0." + - "The final gate prints `check-parity: recorded T/T ported F pending T-F foundation-pending 0`, with T counted from `parity/routes.snapshot` and F from `parity/foundation-routes.txt`." artifacts: - path: "modules/tide/" - provides: "Unit tests last: tide, app foundation, parity/gate and folded-todo regression matrices" + provides: "table-driven tests for every Phase 31 tide addition" + - path: "../sm-wavepath-app/parity/gate_test.go" + provides: "TestGateFailClosed" + - path: "../sm-wavepath-app/parity/check_corpus_test.go" + provides: "checker failure matrix including derived-count consistency" key_links: - - from: "modules/tide/" - to: "the plan's automated verification" - via: "the named tracer and fail-closed checks" + - from: "../sm-wavepath-app/parity/gate_test.go" + to: "../sm-wavepath-app/scripts/check-parity.sh" + via: "planted detector input for every false-green signal" + - from: "../sm-wavepath-app/parity/check_corpus_test.go" + to: "../sm-wavepath-app/parity/check_corpus.go" + via: "temp manifests, snapshots and sidecars for every refusal" --- ## Phase Goal -WavePath's complete 196-route PHP community corpus is recorded and self-replays green; Phase 31 ports and proves only the 36-route foundation slice, leaving exactly 160 routes pending for Phases 31.1 and 31.2 per D-16. +WavePath's complete PHP community corpus is recorded and self-replays green: every route the corpus parser derives from `routes.php` at the commits resolved when the recording starts, plus the two realtime routes. Phase 31 ports and proves only the foundation slice listed in `parity/foundation-routes.txt`; every other corpus route stays pending for Phases 31.1 and 31.2 per D-16. Counts are derived at recording time and checked for consistency, never pinned (reference snapshot 2026-11-22, not a target: 218 tracked, 36 foundation, 182 pending). + +## Artifacts this phase produces (this plan) + +- `../sm-wavepath-app/parity/gate_test.go` with `TestGateFailClosed`; `TestFoundationParityFailClosed` in `../sm-wavepath-app/parity/parity_test.go`. +- `../sm-wavepath-app/parity/check_corpus_test.go` (`TestCheckCorpus…` tables), app-plugin tests `api/response_test.go`, `api/groups_test.go`, `api/group_summary_test.go`, `api/members_test.go`, `api/invites_test.go`, `api/friends_test.go`, `classes/context_test.go`, `classes/authorizer_test.go`, `classes/thread_rollup_test.go`, `classes/participation_test.go`, `lifecycle_test.go`. +- Table-driven tide tests in `modules/tide/normalize_test.go`, `centrifugo_test.go`, `centrifugo_golden_test.go`, `manifest_test.go`, `upstream_test.go`, `variables_test.go`, `headers_test.go`, `rules_test.go`, `fixture_test.go`; CLI tests in `cmd/summer/parity_test.go`. +- Expanded tables in `../sm-chat-plugin/roots_only_test.go`, `../sm-chat-plugin/thread_state_test.go` (`TestThreadFollowState`), `../sm-chatchannels-plugin/roots_only_test.go` and the saving, moderation and slash test files. -Unit tests last: tide, app foundation, parity/gate and folded-todo regression matrices. +Unit tests last: tide, app foundation (CRT counts, self-heal and enrolment included), parity checker and gate (derived-count consistency included), shared-plugin roots-only variants and folded-todo regression matrices, then the closing gate. Purpose: preserve the frozen client/PHP contract while keeping this executor slice cohesive and within the authorized hybrid re-slice. Output: the artifacts and machine evidence named below. @@ -64,92 +82,96 @@ Output: the artifacts and machine evidence named below. - Task 1: Tracer test: mutate one foundation case at each side-effect boundary and prove replay and the gate fail closed - 31-04's gate summary is `recorded 196/196 ported 36 pending 160 foundation-pending 0` and 31-05's repo suites are green. + Task 1: Tracer test: mutate one foundation case at each side-effect boundary and each derived count, and prove replay and the gate fail closed + 31-07's gate summary equals `check-parity: recorded T/T ported F pending T-F foundation-pending 0` with T counted from `parity/routes.snapshot` and F from `parity/foundation-routes.txt`, and 31-05's repo suites are green. ../sm-wavepath-app/parity/parity_test.go, ../sm-wavepath-app/parity/broadcast_test.go, ../sm-wavepath-app/parity/upstream_replay_test.go, ../sm-wavepath-app/parity/gate_test.go, ../sm-wavepath-app/scripts/check-parity.sh - 31-05-SUMMARY.md fixture/sidecar counts, 31-07-SUMMARY.md tracer route and gate output, parity_test.go, broadcast_test.go, upstream_replay_test.go, scripts/check-parity.sh, ../fonoteka.go/parity/parity_test.go negative subtests, scripts/check-phase19.1.sh self-test detector pattern - Per D-10, D-11, D-13 and D-16. -1. Add `TestFoundationParityFailClosed` using a temp copy of the tracer fixture and sidecars. Table cases: response status/body mutation, removed broadcast, extra broadcast, changed broadcast body, removed expected upstream call, extra upstream sidecar/call, route set back to pending, missing seed hook and a planted accepted-difference without sign-off. Each mutation must produce a non-empty error naming route and case; the untouched control passes. -2. Add `TestGateFailClosed` around extracted/testable detector functions or `scripts/check-parity.sh --self-test`: planted go-test JSON for fail, skip, zero tests and missing required name; checker output with unrecorded case, foundation pending, wrong counts/reference, secret residue; consumer command failure. Each is refused. + 31-05-SUMMARY.md fixture/sidecar counts and pins, 31-07-SUMMARY.md tracer route, thread-state decision and gate output, parity_test.go, broadcast_test.go, upstream_replay_test.go, scripts/check-parity.sh, parity/check_corpus.go (count lines and consistency checks), ../fonoteka.go/parity/parity_test.go negative subtests, scripts/check-phase19.1.sh self-test detector pattern + Per D-10, D-11, D-12, D-13 and D-16. +1. Add `TestFoundationParityFailClosed` using a temp copy of the tracer fixture, sidecars, manifest and snapshots. Table cases: response status/body mutation, removed broadcast, extra broadcast, changed broadcast body, the golden of a `writes: true` route removed, removed expected upstream call, extra upstream sidecar/call, route set back to pending, missing seed hook, a planted accepted-difference without sign-off, a snapshot id missing from the manifest, a manifest route missing from the snapshot, a foundation line that is not a snapshot id, a bucket line without its `rate-limit-` case, a `rate-limit-` fixture recorded with status 200, a `manifest.reference` entry that differs from `pins.env`, and a missing `provenance.txt` line. Each mutation must produce a non-empty error naming route and case (or the count, file and id); the untouched control passes. +2. Add `TestGateFailClosed` around extracted/testable detector functions or `scripts/check-parity.sh --self-test`: planted go-test JSON for fail, skip, zero tests and missing required name; checker output with an unrecorded case, foundation pending, `ported P pending N` that does not add up to `routes T`, a missing count line, a wrong reference, secret residue and a status URL; consumer command failure. Each is refused. 3. Keep the real gate script's behavior unchanged except for factoring detector helpers and adding checks that mutation tests expose. No allow flag in its normal path. 4. Commit: `test(parity): prove foundation replay and gate fail closed`. go -C ../sm-wavepath-app test -count=1 -run '^(TestFoundationParityFailClosed|TestGateFailClosed)$' -v ./parity 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 2 - Non-zero exit or fewer than two PASS lines: an altered response/sidecar/manifest/gate signal was accepted, the untouched control failed, or a named test did not run. + Non-zero exit or fewer than two PASS lines: an altered response/sidecar/manifest/snapshot/count/gate signal was accepted, the untouched control failed, or a named test did not run. ../sm-wavepath-app/scripts/check-parity.sh --self-test 2>&1 | grep -q 'self-test: ok' Non-zero exit or marker absent: at least one planted false-green condition is not rejected by the executable gate. - - Every table mutation fails for the intended reason and names the route/case or gate stage. - - Committed fixtures and sidecars remain byte-identical; all mutation happens in a temp directory. + - Every table mutation fails for the intended reason and names the route/case, the count or the gate stage. + - Committed fixtures, sidecars, manifest and snapshots remain byte-identical; all mutation happens in a temp directory (`git -C ../sm-wavepath-app status --porcelain -- parity` prints nothing after the run). - The untouched control traverses response, broadcast and upstream checks and passes. - A single end-to-end foundation case proves that no missing or altered observable can produce a green parity or gate verdict. + A single end-to-end foundation case proves that no missing or altered observable, and no drifted derived count, can produce a green parity or gate verdict. - Task 2: Complete table-driven tide, foundation handler, resolver, authorizer, lifecycle and corpus-checker coverage - modules/tide/normalize_test.go, modules/tide/centrifugo_test.go, modules/tide/centrifugo_golden_test.go, modules/tide/manifest_test.go, modules/tide/upstream_test.go, modules/tide/variables_test.go, modules/tide/headers_test.go, modules/tide/rules_test.go, modules/tide/fixture_test.go, cmd/summer/parity_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/response_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/groups_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/members_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/invites_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/friends_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/classes/context_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/classes/authorizer_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/lifecycle_test.go, ../sm-wavepath-app/parity/check_corpus_test.go - 31-01-SUMMARY.md and 31-02-SUMMARY.md final tide APIs, every tide smoke test and adjacent existing unit tests, cmd/summer/parity_test.go, 31-06-SUMMARY.md and 31-07-SUMMARY.md final handler/type/route names, app-plugin production files, all foundation recorded denial/validation fixtures, parity/check_corpus.go and fonoteka's checker tests + Task 2: Complete table-driven tide, foundation handler, CRT summary, participation, resolver, authorizer, lifecycle and corpus-checker coverage + modules/tide/normalize_test.go, modules/tide/centrifugo_test.go, modules/tide/centrifugo_golden_test.go, modules/tide/manifest_test.go, modules/tide/upstream_test.go, modules/tide/variables_test.go, modules/tide/headers_test.go, modules/tide/rules_test.go, modules/tide/fixture_test.go, cmd/summer/parity_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/response_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/groups_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/group_summary_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/members_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/invites_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/api/friends_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/classes/context_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/classes/authorizer_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/classes/thread_rollup_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/classes/participation_test.go, ../sm-wavepath-app/plugins/golem15/wavepath/lifecycle_test.go, ../sm-wavepath-app/parity/check_corpus_test.go + 31-01-SUMMARY.md and 31-02-SUMMARY.md final tide APIs, every tide smoke test and adjacent existing unit tests, cmd/summer/parity_test.go, 31-06-SUMMARY.md and 31-07-SUMMARY.md final handler/type/route names and the chat thread-state columns (31-07 Task 2), app-plugin production files, all foundation recorded denial/validation fixtures and grace's CRT fixtures, parity/check_corpus.go, parity/routes.snapshot and parity/buckets.snapshot formats, and fonoteka's checker tests - - Tide T-1..T-10 and Reference: valid, malformed, disabled/absent/default, strict YAML round-trip and old-format compatibility cases. - - Tide security: undeclared credentials/cookies refused; wrong JWT scheme/claims rejected; body comparer scoped by host/content type; case hook has no shell interpolation; listeners require loopback; repeat bound enforced. + - Tide T-1..T-11 and Reference: valid, malformed, disabled/absent/default, strict YAML round-trip and old-format compatibility cases. T-11: 13-digit and 10-digit epoch integers at `*_at` keys mask to distinct tokens; a fraction, a sign, another digit count, a string against an integer, and an integer `_ms` key without a rule are diffs; a `mask: epoch-ms` rule masks only 13-digit integers; an unknown mask mode is refused on load; the same rows for publication payloads through `CaseBroadcastOptions.Normalize`. + - Tide repeat and writes: `repeat` at 0, 1, `tide.MaxRepeat` and one above; `repeat_parallel` bounds and its pairing rule; warm-ups never exceed the parallel bound and the final request is sent alone; `RouteWrites` for every method with and without an explicit flag; a writing route without a golden fails replay, a non-writing route without one replays as zero publications. + - Tide security: undeclared credentials/cookies refused; wrong JWT scheme/claims rejected; body comparer scoped by host/content type; case hook has no shell interpolation; listeners require loopback; repeat bounds enforced. - Foundation handlers: each family has success, malformed JSON, missing actor, role denial, missing/cross-group nested id, validation rejection, nil service/database and unexpected error; exact status, envelope and row-count effects. + - CRT group summary and rollup: non-CRT actor gives zero thread fields and the default `unread_count`; CRT actor gives the roots-only `unread_count`; a muted followed thread is excluded; a `mentions` channel adds mentions but not threads; a `none` channel adds neither; a left public channel is excluded; an inaccessible group gives zero; each of chat's thread-state fields (`is_following`, `is_muted`, `last_read_at`) changes the result when flipped, and a mute-only row that is not followed is not counted. + - Participation: `TryEnsure` inserts missing rows, keeps existing read markers, skips bots, non-members and users who left; `SelfHeal` is idempotent. - Authorizers/resolvers: malformed channel/context, zero user, absent/error DB, non-member/member/role cases and exact allowed info/capabilities. - - Lifecycle: create is idempotent, owner MemberJoined does not duplicate default channel, member leave/join behavior, delete cleanup, child failure rolls back all changes. - - Corpus checker: route/snapshot/auth mismatch, missing fixture, wrong ported status, missing/orphan broadcast/upstream, every secret pattern, wrong reference commit, missing D-19 provenance and wrong foundation set. + - Lifecycle: create is idempotent, owner MemberJoined does not duplicate default channel, member join enrols every visible public channel with the marker at now and skips bots, member leave behavior, delete cleanup, child failure rolls back all changes. + - Corpus checker: route/snapshot/auth mismatch; parsed route file against snapshot (digest, ids); `->withoutMiddleware` removes a bucket; a frame under the same prefix outside D-09 is filtered; a bucket without a parseable limit is refused; key kinds; foundation set derivation by action class and the realtime extras; `ported P pending N` adding up to `routes T`; one 429 case per bucket with status 429 and repeat bounds; `--sync-manifest` adding and refusing; missing fixture; wrong ported status; missing/orphan broadcast/upstream; every secret pattern; the status-URL and KLIPY scan; wrong reference commit; missing provenance line and hand-written set against the uncalled list. Per SC-4. -1. Replace or extend the 31-01 smoke coverage with table-driven tests in the canonical tide test files. Cover all final exported options and strict loaders/writers; load representative pre-Phase-31 fixtures/manifests/sidecars to prove backward compatibility. +1. Replace or extend the 31-01 and 31-02 smoke coverage with table-driven tests in the canonical tide test files. Cover all final exported options and strict loaders/writers; load representative pre-Phase-31 fixtures/manifests/sidecars to prove backward compatibility. 2. Add CLI tests that parse the final record/replay flags, reject their use outside manifest mode, reject non-loopback listeners and non-executable case hooks, and prove hook ids are environment data rather than shell input. -3. Add app-plugin unit matrices with injected services/checks and `httptest`. Use real fixture snippets for exact envelope/key/null behavior, but keep database integration in the existing parity tests. -4. Add resolver/authorizer pure tables and lifecycle transaction tests over testcontainers or the app's test DB. Assert rows and event/publication calls before and after rollback. -5. Extend `check_corpus_test.go` with temp manifests/sidecars for every behavior row. Include all secret forms: JWT, wave token, cookie, invite/webhook/call-link code and minted vendor credential. -6. Commit framework tests separately from app tests: `test(tide): cover Phase 31 recording additions`; `test(wavepath): cover foundation handlers and access`; `test(parity): cover corpus checker failures`. +3. Add app-plugin unit matrices with injected services/checks and `httptest`. Use real fixture snippets for exact envelope/key/null behavior (grace's for the CRT rows), but keep database integration in the existing parity tests. +4. Add resolver/authorizer pure tables, rollup and participation tables, and lifecycle transaction tests over testcontainers or the app's test DB. Assert rows and event/publication calls before and after rollback. +5. Extend `check_corpus_test.go` with temp route files, manifests, snapshots and sidecars for every behavior row. Include all secret forms: JWT, wave token, cookie, invite/webhook/call-link code and minted vendor credential. +6. Commit framework tests separately from app tests: `test(tide): cover Phase 31 recording additions`; `test(wavepath): cover foundation handlers, CRT summary and access`; `test(parity): cover corpus checker failures`. - go vet ./modules/tide/ ./cmd/summer/ && go test -count=1 -short ./modules/tide/ ./cmd/summer/ && go test -count=1 -run '^(TestRelative|TestManifest|TestUpstream|TestCookie|TestExtraHeaders|TestClient|TestRepeat|TestCentrifugo)' -v ./modules/tide/ 2>&1 | tee "${TMPDIR:-/tmp}/tide-unit.log" && grep -q -- '^--- PASS:' "${TMPDIR:-/tmp}/tide-unit.log" && ! grep -q -- '^--- FAIL:' "${TMPDIR:-/tmp}/tide-unit.log" - Non-zero exit, no PASS line or any FAIL line: tide/cmd tests do not compile, a compatibility/security/edge table fails, or the filter matched nothing. - go -C ../sm-wavepath-app vet ./plugins/golem15/wavepath/... ./parity/... && go -C ../sm-wavepath-app test -count=1 -run '^(Test(Response|Groups|Members|Invites|Friends|Context|Authorize|Lifecycle|CheckCorpus))' -v ./plugins/golem15/wavepath/... ./parity 2>&1 | tee "${TMPDIR:-/tmp}/wavepath-unit.log" && grep -q -- '^--- PASS:' "${TMPDIR:-/tmp}/wavepath-unit.log" && ! grep -q -- '^--- FAIL:' "${TMPDIR:-/tmp}/wavepath-unit.log" - Non-zero exit, no PASS line or any FAIL line: handler/access/lifecycle/checker unit matrices fail, Docker-backed lifecycle setup fails, or named tests did not run. + go vet ./modules/tide/ ./cmd/summer/ && go test -count=1 -short ./modules/tide/ ./cmd/summer/ && go test -count=1 -run '^(TestRelative|TestNumericClock|TestManifest|TestRouteWrites|TestCaseBroadcast|TestUpstream|TestCookie|TestExtraHeaders|TestClient|TestRepeat|TestCentrifugo)' -v ./modules/tide/ 2>&1 | tee "${TMPDIR:-/tmp}/tide-unit.log" && grep -q -- '^--- PASS: TestNumericClock' "${TMPDIR:-/tmp}/tide-unit.log" && grep -q -- '^--- PASS: TestRepeat' "${TMPDIR:-/tmp}/tide-unit.log" && ! grep -q -- '^--- FAIL:' "${TMPDIR:-/tmp}/tide-unit.log" + Non-zero exit, a missing `TestNumericClock` or `TestRepeat` PASS line, or any FAIL line: tide/cmd tests do not compile, a compatibility/security/edge table fails, or the filter matched nothing. + go -C ../sm-wavepath-app vet ./plugins/golem15/wavepath/... ./parity/... && go -C ../sm-wavepath-app test -count=1 -run '^(Test(Response|Groups|GroupSummary|Members|Invites|Friends|Context|Authorize|ThreadRollup|Participation|Lifecycle|CheckCorpus))' -v ./plugins/golem15/wavepath/... ./parity 2>&1 | tee "${TMPDIR:-/tmp}/wavepath-unit.log" && grep -q -- '^--- PASS: TestThreadRollup' "${TMPDIR:-/tmp}/wavepath-unit.log" && grep -q -- '^--- PASS: TestCheckCorpus' "${TMPDIR:-/tmp}/wavepath-unit.log" && ! grep -q -- '^--- FAIL:' "${TMPDIR:-/tmp}/wavepath-unit.log" + Non-zero exit, a missing `TestThreadRollup` or `TestCheckCorpus` PASS line, or any FAIL line: handler/CRT/participation/access/lifecycle/checker unit matrices fail, Docker-backed lifecycle setup fails, or named tests did not run. - Every behavior bullet has at least one named table row and failure output names the row. - Old tide fixture/manifest/upstream files from before Phase 31 load unchanged. - - Every high threat T-31-01..T-31-32 that belongs to tide/foundation/checkers has a direct regression test or gate mutation. + - Every high threat T-31-01..T-31-48 that belongs to tide/foundation/checkers has a direct regression test or gate mutation. - Production changes, if any bug is found, are minimal and listed in the summary. - The generic recording toolkit, foundation app plugin and parity checkers have deterministic positive, edge, compatibility and fail-closed unit coverage. + The generic recording toolkit, foundation app plugin (CRT summary included) and parity checkers have deterministic positive, edge, compatibility and fail-closed unit coverage. - Task 3: Run folded-todo regressions, full foundation gate, consumer suites and framework docs checks - ../sm-chat-plugin/saving_test.go, ../sm-userfriends-plugin/saving_test.go, ../sm-user-plugin/saving_test.go, ../sm-demo-app/moderation_test.go, ../vue-chat-layer/tests/store.test.ts, ../sm-wavepath-app/scripts/check-parity.sh - 31-08-SUMMARY.md, 31-09-SUMMARY.md and 31-10-SUMMARY.md final flow/event/field names and commits, saving tests in all three plugins, demo moderation tests, layer slash tests, 31-VALIDATION.md, project CLAUDE.md commands, scripts/check-parity.sh required test list + Task 3: Run shared-plugin and folded-todo regressions, the full foundation gate, consumer suites and framework docs checks + ../sm-chat-plugin/saving_test.go, ../sm-chat-plugin/roots_only_test.go, ../sm-chat-plugin/thread_state_test.go, ../sm-chatchannels-plugin/roots_only_test.go, ../sm-userfriends-plugin/saving_test.go, ../sm-user-plugin/saving_test.go, ../sm-demo-app/moderation_test.go, ../vue-chat-layer/tests/store.test.ts, ../sm-wavepath-app/scripts/check-parity.sh + 31-07-SUMMARY.md, 31-08-SUMMARY.md, 31-09-SUMMARY.md and 31-10-SUMMARY.md final flow/event/field/variant names and candidate commits, saving and roots-only tests in the touched plugins, demo moderation tests, layer slash tests, 31-VALIDATION.md, project CLAUDE.md commands, scripts/check-parity.sh required test list Per SC-3, SC-4, D-14 and D-22. 1. Expand the three saving test files into tables for every fire path, operation, field default, listener-free control, owning Rejection, plain error and no-write/no-post-event behavior. Expand demo moderation to each requested field and filename position. -2. Keep the slash test matrix explicit for known, unknown, `//`, bare `/`, empty loaded catalog and null/loading catalog; run the full layer suite and playground build. -3. Run each touched plugin's full short suite, demo's root/plugin suite and bm's build/required tests at the exact candidate commits recorded in 31-05. -4. Run `scripts/check-parity.sh` with no allow flags. It must execute corpus completeness, strict ported replay, broadcasts, upstream, foundation, consumers and self-tests and print exactly `recorded 196/196 ported 36 pending 160 foundation-pending 0`. -5. Run framework vet/short tests and both docs checks. Confirm the framework diff contains no consuming-application name and module docs match final tide identifiers/flags. -6. Update `31-VALIDATION.md` status through the validation workflow when execution reaches its sign-off; do not raw-edit STATE.md. Post the Phase 31 g15office progress comment through the configured integration. -7. Commit test-only expansions per repository. Planning/code commits remain separate. +2. Expand the roots-only and thread-state tables in `sm-chat-plugin` and `sm-chatchannels-plugin`: each new `...With` variant with and without `RootsOnly`, the zero-options call equal to the existing function for every fixture row (compatibility), replies and mentions on replies excluded only on the roots-only path, notify preferences unchanged. Expand `TestThreadFollowState` into a table: column defaults on pre-existing rows, the migration run twice, `ThreadStates` scoping by user and root, an empty root list, and follow and read state surviving a mute and an unmute through the unchanged mute API. +3. Keep the slash test matrix explicit for known, unknown, `//`, bare `/`, empty loaded catalog and null/loading catalog; run the full layer suite and playground build. +4. Assert that the chat and chatchannels submodule HEADs of sm-bm-app and sm-demo-app equal the candidate commits recorded in the 31-07 and 31-10 SUMMARYs, then run each touched plugin's full short suite, demo's root/plugin suite and bm's build/required tests. +5. Run `scripts/check-parity.sh` with no allow flags. It must execute corpus completeness, strict ported replay, broadcasts, upstream, foundation, consumers and self-tests and print the derived summary line (T from `parity/routes.snapshot`, F from `parity/foundation-routes.txt`). +6. Run framework vet/short tests and both docs checks. Confirm the framework diff contains no consuming-application name and module docs match final tide identifiers/flags. +7. Update `31-VALIDATION.md` status through the validation workflow when execution reaches its sign-off; do not raw-edit STATE.md. Post the Phase 31 g15office progress comment through the configured integration. +8. Commit test-only expansions per repository. Planning/code commits remain separate. - for r in sm-chat-plugin sm-userfriends-plugin sm-user-plugin; do go -C ../$r vet ./... && go -C ../$r test -count=1 -short ./... || exit 1; done && go -C ../sm-demo-app vet . ./plugins/demo/... && go -C ../sm-demo-app test -count=1 -short . ./plugins/demo/... && go -C ../sm-bm-app build ./... && go -C ../sm-bm-app test -count=1 -run '^(TestChatMounted|TestRealtimeDefaultDriver|TestRealtimeRoutes|TestRealtimeConfigDefaults|TestRemoteKeyOverride)$' . - Non-zero exit: a saving seam, demo listener or existing consumer behavior fails at the candidate commits, or a required bm test fails. + for r in sm-chat-plugin sm-chatchannels-plugin sm-userfriends-plugin sm-user-plugin; do go -C ../$r vet ./... && go -C ../$r test -count=1 -short ./... || exit 1; done && go -C ../sm-demo-app vet . ./plugins/demo/... && go -C ../sm-demo-app test -count=1 -short . ./plugins/demo/... && go -C ../sm-bm-app build ./... && go -C ../sm-bm-app test -count=1 -run '^(TestChatMounted|TestRealtimeDefaultDriver|TestRealtimeRoutes|TestRealtimeConfigDefaults|TestRemoteKeyOverride)$' -v . 2>&1 | grep -c -- '^--- PASS: Test' | grep -qx 5 + Non-zero exit or fewer than five bm PASS lines: a saving seam, a roots-only variant, demo listener or existing consumer behavior fails at the candidate commits, or a required bm test fails or does not run. pnpm --dir ../vue-chat-layer test -- --run && pnpm --dir ../vue-chat-layer run build:playground Non-zero exit: any slash regression or existing layer test fails, or the playground does not build. - OUT="$(../sm-wavepath-app/scripts/check-parity.sh 2>&1)" && printf '%s\n' "$OUT" | grep -qx 'check-parity: recorded 196/196 ported 36 pending 160 foundation-pending 0' - Non-zero exit or exact summary absent: a corpus/golden/upstream/foundation/consumer/self-test stage failed, a required test skipped, Docker was unavailable, or an allow flag was needed. + cd ../sm-wavepath-app && T="$(grep -cE '^(GET|POST|PUT|PATCH|DELETE) ' parity/routes.snapshot)" && F="$(grep -c . parity/foundation-routes.txt)" && test "$T" -gt "$F" && OUT="$(scripts/check-parity.sh 2>&1)" && printf '%s\n' "$OUT" | grep -qx "check-parity: recorded $T/$T ported $F pending $((T - F)) foundation-pending 0" + Non-zero exit or the derived summary absent: a corpus/golden/upstream/foundation/consumer/self-test stage failed, a required test skipped, Docker was unavailable, the counts are inconsistent, or an allow flag was needed. go vet ./... && go test -count=1 -short ./... && go run ./cmd/summer docs:build --check 2>&1 | grep -q 'no problems found' && go test -count=1 -run '^TestDocsTree$' -v ./cmd/summer 2>&1 | grep -q -- '^--- PASS: TestDocsTree' Non-zero exit: framework vet/short tests fail, docs drift or name an absent identifier/command, or TestDocsTree did not run and pass. - - All folded-todo regression tables pass, including no-listener controls. - - Full gate uses no allow flag and prints the exact 196/36/160/0 counts. + - All folded-todo, roots-only and thread-state regression tables pass, including no-listener and zero-options controls; `go -C ../sm-chat-plugin test -count=1 -run '^TestThreadFollowState$' -v .` prints `--- PASS: TestThreadFollowState`. + - The full gate uses no allow flag and prints the summary line derived from the snapshot and the foundation list. - Framework docs build/check and TestDocsTree pass; no consuming app name was added to framework source/docs/tests. - Each touched repository is clean for files owned by this phase; unrelated changes remain unstaged. - Phase 31's unit suites, consumers, foundation gate and documentation checks are green, with remaining 160 routes explicitly pending for Phases 31.1 and 31.2. + Phase 31's unit suites, shared-plugin variants, consumers, foundation gate and documentation checks are green, with every non-foundation route explicitly pending for Phases 31.1 and 31.2. @@ -168,9 +190,9 @@ Output: the artifacts and machine evidence named below. | Threat ID | Category | Component | Severity | Disposition | Mitigation Plan | |-----------|----------|-----------|----------|-------------|-----------------| | T-31-33 | Spoofing | gate passes on zero, skipped or missing tests | high | mitigate | planted go-test JSON detector matrix, exact required test names and PASS/count checks | -| T-31-34 | Tampering | negative tests modify committed corpus | high | mitigate | copy fixture/manifest/sidecar trees to t.TempDir; clean-tree and hash checks after mutation suite | -| T-31-35 | Repudiation | untested threat mitigations | medium | mitigate | map high threats to named unit/gate cases and record command evidence in summary | -| T-31-36 | Spoofing | consumer tests resolve wrong plugin commit | high | mitigate | assert submodule HEAD equals 31-05 candidate hash before bm/demo tests | +| T-31-34 | Tampering | negative tests modify committed corpus | high | mitigate | copy fixture/manifest/snapshot/sidecar trees to t.TempDir; clean-tree and hash checks after mutation suite | +| T-31-35 | Repudiation | untested threat mitigations | medium | mitigate | map high threats (T-31-01..T-31-48) to named unit/gate cases and record command evidence in summary | +| T-31-36 | Spoofing | consumer tests resolve wrong plugin commit | high | mitigate | assert the chat and chatchannels submodule HEADs of bm and demo equal the 31-07 and 31-10 candidate hashes before bm/demo tests | | T-31-37 | Denial of service | Docker failure represented as skip | medium | mitigate | TestMain skips only under testing.Short; full gate treats unavailable Docker and skipped required names as failure | | T-31-SC | Tampering | npm/pip/cargo installs | high | mitigate | no package install; use existing dependencies and explicit lockfiles | @@ -180,7 +202,7 @@ Run every task's automated command and preserve its fails_when semantics. Do not -Unit tests last: tide, app foundation, parity/gate and folded-todo regression matrices is complete, its named tests ran, and no locked decision or D-16 phase boundary drifted. +Unit tests (tide, app foundation with CRT, checker and gate with derived counts, shared-plugin roots-only variants and folded-todo matrices) are complete, the closing gate prints the derived line, the named tests ran, and no locked decision or D-16 phase boundary drifted. diff --git a/.planning/phases/31-chat-polish-against-wavepath-clients/31-VALIDATION.md b/.planning/phases/31-chat-polish-against-wavepath-clients/31-VALIDATION.md index 6d74ccc1..4ab646b8 100644 --- a/.planning/phases/31-chat-polish-against-wavepath-clients/31-VALIDATION.md +++ b/.planning/phases/31-chat-polish-against-wavepath-clients/31-VALIDATION.md @@ -45,7 +45,12 @@ Task IDs are filled in by the planner. The rows below are the behaviours every p |---------|------|------|-------------|------------|-----------------|-----------|-------------------|-------------|--------| | TBD | TBD | TBD | SC-1 every corpus route recorded from PHP | — | fixtures carry no secrets (`--check-secrets`) | corpus check | `go run ./parity/check_corpus.go --manifest parity/manifest.yaml --routes --require-recorded --check-secrets` | ❌ W0 | ⬜ pending | | TBD | TBD | TBD | SC-1 Go replays every ported route; pending never passes | — | denial cases (401, 403, 404) replay | integration | `go test ./parity -run TestParityCorpus` | ❌ W0 | ⬜ pending | -| 31-07-T2 | 31-07 | 6 | SC-1 foundation-pending 0 with 160 routes explicitly pending for Phases 31.1/31.2 (D-16) | T-31-24 | fail-closed foundation gate | gate | `scripts/check-parity.sh` | ❌ W0 | ⬜ pending | +| 31-07-T4 | 31-07 | 6 | SC-1 foundation-pending 0 with every non-foundation route explicitly pending for Phases 31.1/31.2 (D-16): pending = snapshot total minus the foundation list, both derived (reference snapshot 2026-11-22: 182) | T-31-24, T-31-47 | fail-closed foundation gate with derived counts | gate | `scripts/check-parity.sh` (summary line compared with counts from `parity/routes.snapshot` and `parity/foundation-routes.txt`) | ❌ W0 | ⬜ pending | +| 31-03-T1, 31-05-T1 | 31-03, 31-05 | 1, 4 | D-12 pins resolved at recording time over every gitlink, written into `manifest.reference` | T-31-13, T-31-46 | export and record only at the resolved pins; a resumed run at other pins is refused | corpus check | `go run ./parity/check_corpus.go … --require-reference` | ❌ W0 | ⬜ pending | +| 31-04-T4 | 31-04 | 3 | SC-1 inventory, buckets and foundation set derived from the route file; manifest, snapshots and gate counts consistent | T-31-47 | no count constant; `P + N == T`; one 429 case per parsed bucket | corpus check | `go run ./parity/check_corpus.go --routes --foundation parity/foundation-routes.txt …` | ❌ W0 | ⬜ pending | +| 31-03-T2 | 31-03 | 1 | 31.2 D-03 search cases recorded against Typesense | T-31-40 | loopback-only Typesense, per-instance prefix, re-index before a search case | stack self-test | `scripts/parity-stack.sh selftest` | ❌ W0 | ⬜ pending | +| 31-01-T2 | 31-01 | 1 | SC-4 numeric epoch clocks compare by shape (T-11) | T-31-38 | seconds and milliseconds stay distinct; `_ms` keys masked only by an explicit rule | unit | `go test ./modules/tide -run TestNumericClockMaskSmoke` | ✅ (extend) | ⬜ pending | +| 31-07-T2, 31-07-T3 | 31-07 | 6 | SC-3 chat-owned thread follow and read state (additive `is_following`, `last_read_at`; user decision 2026-11-22), CRT group summary and additive roots-only counts in chat and chatchannels; bm and demo pass (D-14) | T-31-43, T-31-45, T-31-48 | existing signatures and the mute API unchanged; rollup only over channels the actor can read | integration | `go test -run '^(TestThreadFollowState\|TestThreadMute)$' .` and `go test -run '^TestRootsOnly' ./...` in the plugins; `go test ./parity -run TestCRTGroupSummary` | ❌ W0 | ⬜ pending | | TBD | TBD | TBD | SC-2 publications of each writing case match the golden (D-10) | — | no publication reaches a non-member channel | integration | `go test ./parity -run TestBroadcasts` | ❌ W0 | ⬜ pending | | TBD | TBD | TBD | SC-2 channel authorization routes replay | — | subscribe proxy and `realtime/token` deny non-members | integration | `go test ./parity -run 'TestParityCorpus/.*realtime'` | ❌ W0 | ⬜ pending | | TBD | TBD | TBD | D-11 vendor calls match the sidecars | — | N/A | integration | `go test ./parity -run TestUpstreamSidecarsAreReplayed` | ❌ W0 | ⬜ pending | @@ -70,7 +75,7 @@ Task IDs are filled in by the planner. The rows below are the behaviours every p - [ ] `parity/fixtureplugin` and `wavepath_reset.php` for the scenario - [ ] `scripts/parity-stack.sh` and `parity/php_parity.sh` - [ ] `scripts/check-parity.sh` -- [ ] tide tests for each addition (T-1 to T-10 in `31-RESEARCH.md`) +- [ ] tide tests for each addition (T-1 to T-10 in `31-RESEARCH.md`, and T-11 numeric clocks from its "Drift D10") ---