Repository navigation
feat(campaign): failures by code with a cursor, and the outcomes aggregate (admin-contract R4.2 + R4.3, #296) - #575
omercelikdev wants to merge 8 commits into
Conversation
…egate (admin-contract R4.2 + R4.3, #296) R4.2 (R4-S3): GET /campaign/{id}/failures?afterSeq= walks the whole failed set by keyset on the item's own key, and each row carries its errorCode (an init-only property on the shipped positional record). The shipped GetFailedItemsAsync(id, take, ct) is the overload with afterSeq: 0, so an R3 client gets today's first page. take keeps its [1, 500] clamp. R4.3 (R4-S4): GET /campaign/{id}/outcomes answers the items counted by state and the failures counted by error code - at most 20 codes, count descending, code ordinal, no code last among equal counts, with failedCodesTruncated; 404 for an unknown id. The database ranks by count and brings one code more than the page; the final order is the service's, because providers disagree on NULL placement and on collation. It derives nothing (no ratio, no ETA). Proof: R4FailuresAndOutcomesTests (unit, SQLite) - codes from a handler's Failed(code) and from a callback, the 1,203-row walk in three pages, the counts, the 25-code truncation in ordinal order, the routes over HTTP. Red with each fault planted (code not projected, cursor ignored, null-last rule removed, truncation off by one, case-insensitive order, route renamed). CampaignOutcomesProof on PostgreSQL (ICU en-US collation, where the database's own order disagrees - red with the order left to the database) and on Oracle. RouteContractTests gains the outcomes line. A bench fact measures the call on a 1M-item campaign. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018AFdNcUHVZCtRVq4DLoW71
…atabase; byState order pinned (#296) The scoped mutation run on the new lines (Goldpath.Campaign config, the outcomes and failures members only) scored 83.87%: four survivors were the database-side NULL-placement clause, which cannot change the answer (one NULL group, and the extra row it may take is the row the page drops), and one was byState's key order, which no test pinned. The clause is gone, the comment says why, and the unit test asserts the keys in state order. Re-run: 27 of 27 killed, 100%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018AFdNcUHVZCtRVq4DLoW71
… the upgrade guide, the bench and the ledgers (#296) - admin contract: the campaign inventory gains afterSeq and /{id}/outcomes. - ops: runbooks §5 reads /outcomes first, then walks /failures; the bench page records /outcomes on a 1M-item campaign at abbd4c9 (104 and 118 ms median). - upgrade guide preview.10: additive, nothing to do; CHANGELOG [Unreleased]. - README: the R4 reads. - stryker/README: the scoped run on the new lines, 83.87% then 100%. - open-threads T69: the console half (R4-S7) and the binding constraint, which only the leader's meter holds today; and the tie at the twentieth code, whose membership is the database collation's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018AFdNcUHVZCtRVq4DLoW71
…snapshot (#296) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018AFdNcUHVZCtRVq4DLoW71
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018AFdNcUHVZCtRVq4DLoW71
|
CI, as observed after opening:
Generated by Claude Code |
Verifier verdict (run 2026-11-12)Head verified: Steps 1–6
Deep review
Edge-case probes (throwaway, not pushed)
Findings
NITs (optional): measure one Question for the owner (
|
… chosen ordinally on every proven provider (#296) The outcomes query broke count ties under the database's own collation, so on an ICU PostgreSQL or a linguistic Oracle session a code that is ordinal-earlier but collation-later was never fetched, and the service's ordinal re-sort could not bring it back. The tie-break now runs under the provider's bytewise collation (PostgreSQL "C", Oracle BINARY; SQLite is bytewise by default). A boundary-tie campaign joins CampaignOutcomesProof on both databases (red without the fix on each: B-UPPER expected, a-lower answered), with a SQLite twin and the provider mapping in the unit suite. T69 drops the closed limit and keeps its residuals. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018AFdNchYxTtB7tJ7kURQXf
|
Addressed verifier findings: 1 (MAJOR, the boundary tie), 2 (MINOR, the closing keyword). Head: Finding 1: fix (a), the one that keeps R4.3's accepted text. The owner question still stands: if the owner prefers (b), revert
Finding 2: the body now ends Pre-PR self-check (whole PR at
Gates:
Generated by Claude Code |
Owner decision (2026-11-12): option (a)The owner chose option (a) for the verifier's question. R4.3's accepted text stands: Why:
This answers the Recorded by the owner's session (Claude Code), on the owner's instruction. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s no closed claim (#296) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Synced with The merge. #560 conflicted in two ledgers, both side-by-side additions:
For each ledger, the merge's diff against
Local, on
The Owner's session (Claude Code), on the owner's instruction. |
Verifier verdict (run 2026-11-12, daytime)Head verified: My last verdict was on
Verdict: no blocking findings. 0 BLOCKER, 0 MAJOR, 0 MINOR, 1 NIT. Tier C: the owner merges; this is never an auto-merge. Previous findings
Steps 1–6
Deep review (delta)
Edge-case probes (throwaway file, not pushed; run on real PostgreSQL 17 with an ICU tr-TR default collation, and on Oracle with
|
| # | Probe | PostgreSQL | Oracle |
|---|---|---|---|
| P1 | 19 codes × 10, then NULL, a, B × 1: the 20th must be B, and the list truncated |
✓ B, truncated |
✓ B, truncated |
| P2 | 19 × 10, then ı-x, İ-x, i-x, I-x × 1: the 20th must be I-x (ordinal) |
✓ I-x |
✓ I-x |
| P3 | Exactly 20 distinct codes: 20 entries, not truncated | ✓ | ✓ |
| P4 | Oracle COLLATE BINARY with MAX_STRING_SIZE=STANDARD (sqlplus, by hand) |
— | ✓ works |
| P5 | Plant: no collation at all | red on both | red on both |
NIT (optional)
packages/Goldpath.Campaign/README.md:215: the re-wrapped sentence leaves one long line, "…every provider Campaign is proven on. It answers from two grouped counts…". This is cosmetic.
Labels: changes-requested removed, agent-verified added. Tier C: the owner merges after adding owner-approved. I do not merge.
Owner: safe to merge. Summary: the campaign admin surface gains /failures?afterSeq=&errorCode= (a cursor over failed items) and /{id}/outcomes (counts by state, and the top 20 failure codes in ordinal order on PostgreSQL, Oracle and SQLite, the tie at 20th place included). Existing R3 clients see no change.
Generated by Claude Code
What and why
This is #296's server half: admin-contract R4 slices R4-S3 (R4.2) and R4-S4 (R4.3), built to the text accepted on
main. Before this, the governor could not answer "what is failing, and why"./failuresstopped at 500 rows with no cursor, its rows left out the error code the store has kept since R2.1, and nothing counted failures by code.GET /goldpath/admin/campaign/{id}/failures?afterSeq=&take=Seq.afterSeqis exclusive; absent or0gives the first page, as before.errorCode.takekeeps its[1, 500]clamp.GoldpathCampaignFailedItem.ErrorCodeis init-only, because the record is shipped and positional. The new overload isGetFailedItemsAsync(id, afterSeq, take, ct), and the shipped(id, take, ct)calls it withafterSeq: 0.GET /goldpath/admin/campaign/{id}/outcomesbyState: items per state, in state order, with empty states omitted.failedByCode: at most 20 entries, ordered by count descending, then code ordinal, with no code last among equal counts.failedCodesTruncated: true when more codes exist.404with no body. The route counts and derives nothing.C, OracleBINARY; SQLite is bytewise by default), and returns one code more than the page holds. So the rows it returns are the contract's first 21, including when equal counts straddle the twentieth place. The final order is applied by the service, because providers disagree on where NULL sorts.GetOutcomesAsync,GoldpathCampaignOutcomesandGoldpathCampaignCodeCount, as the RFC lists them, plus the members records synthesize. The cap and the collation helper areinternal, so no public line was added that the RFC does not list./outcomeson a 1M-item campaign takes a 104 ms and 118 ms median of 5, over two runs. Profile: the agent's sandbox (4 vCPU Xeon, 15 GB), PostgreSQL 17, Testcontainers, commitabbd4c9, 2026-11-11 21:00 UTC, local run, recorded inops/campaign-benchmarks.md. That is well under the 5 s poll, so R4.3's "poll it less often" fallback is not needed. (The tie-break collation added in2804f21was not re-benched.)Not in this PR: the console half (R4-S7). It covers #296's criteria 1, 2 and 4: the 5-second poll, the binding constraint and outcomes on screen, and the vitest/axe floors. The RFC's slice table files it separately, so it is now #574, labelled
needs-owner. It needs one decision first: the binding constraint (#294) exists only in the leader's memory as a metric, and no admin route or field can return it on every replica. The question and my recommendation (a pacer-written column, on the next train) are in #574 and open-threads T69. This PR therefore does not close #296; the owner closes it when #574 lands or replaces those criteria.Reproduce
I ran every plant (A–H) and saw each one go red as described. With the code restored, all are green.
Acceptance criteria (#296), with evidence
/outcomes, proven above. The panel is not met: R4-S7: the live campaign governor in the console — 5-second poll, outcomes by code, the failures walk, the binding constraint (#296's console half) #574, which is blocked on the binding-constraint decision (T69)./failuresreturnsErrorCodeand takes a keyset cursor; a new aggregate route returns counts by outcome and code; the route-freeze test is updated in the same PR.RouteContractTestsgainsGET /goldpath/admin/campaign/{id:guid}/outcomes, and the contract inventory gainsafterSeqand/outcomes.take=500is 3 pages, with no gap and no repeat, and a page after the lastseqis empty;Failed(code)) or its callback gave;failedCodesTruncatedand a stable order;404;Pre-PR self-check
Every criterion is either met with its evidence or stated plainly as not met (above).
Ledgers and docs:
[Unreleased];campaign-benchmarks.md;stryker/README.md(the scoped run);mainends at T67.Not touched, because nothing in them changed:
ga-gate-status.md,ai-sdlc-status.mdandcoverage-matrix.md.api-review-gate.shis green with the 34 new lines.XML docs: the new members are new, and
ErrorCodesits in a new record body. No member is inserted between an existing///and its declaration.Honesty:
postgres:17-alpine's defaulten_US.utf8sorts bytewise (checked), so the proof runs with ICUen-US; the Oracle proof setsNLS_SORT = GENERIC_Mon every connection.Wired: the HTTP fact runs through
MapGoldpathCampaignAdminon a TestServer (afterSeq,/outcomes,404, and a400forafterSeq=abc).AdminReadRoleSurfaceTests(which enumerates every admin route) is green, so/outcomesreads undergoldpath-ops-read.Contracts: the field names, the defaults (
afterSeq= 0,take= 100), the404and the 20-code cap match R4.2/R4.3.Bench: the new fact is in
CampaignBenchTests(Category=Bench), serial with that class's other facts, and never in CI's integration job. Its numbers carry profile, date, commit and run.Deep self-review:
goldpath-ops-read, plus R1's all-tenants filter on multi-tenant apps), with no new input beyond alongand aGuidthat model binding types. Bad input answers400(tested). The collation name is a constant chosen by provider, never input. Nothing is logged, there are no secrets, and there is no new dependency.afterSeqnegative, 0 and past the end;take0 and 1,000 (clamped); no items; an unknown id; R1 rows with no code; another campaign's failures excluded; a code on a non-failed item not counted; exactly 20 codes not truncated, 25 truncated; mixed case; a collation-divergent tie across the 20th place.DOTNET_CULTURE=tr-TR LANG=tr_TR.UTF-8(16/16); the comparisons areStringComparer.Ordinal, and the provider match is ordinal.(CampaignId, State, …)indexes, as R4 requires.byStatekey order, which is now asserted. The re-run is 27/27, 100% (before2804f21; the collation lines are covered by RED H and the provider-mapping theory).Gates run (at
2804f21)dotnet build(Campaign + test projects)-c ReleaseGoldpath.Campaign.TestsCampaignOutcomesPostgresTests,CampaignOutcomesOracleTestsdocs-freshness.sh,ledger-check.sh,schema-honesty.sh,skills-parity.sh,template-pins.sh,api-review-gate.shdotnet format whitespace --verify-no-changeson the touched filesWhat I could not verify
Part of #296 (the console half is #574)