From f8574377a56edd27d2eb5a9b53d92e2afd2c55b5 Mon Sep 17 00:00:00 2001 From: Cemil ILIK Date: Sat, 10 Oct 2026 20:23:07 +0300 Subject: [PATCH 01/35] docs(roadmap): close merged P02d-6 and record next packet Record PR #27's merged head and independently verified merge-run evidence so current status surfaces agree with the delivered public renderer. Keep dated delivery history intact and name P02d-7's remaining decisions, demo, Lighthouse and phase-exit obligations without starting that packet. --- CLAUDE.md | 12 +-- README.md | 8 +- docs/roadmap/README.md | 8 +- docs/roadmap/phase-02d-walking-skeleton.md | 76 ++++++++++++++++++- .../roadmap/phase-06-renderer-admin-studio.md | 5 +- docs/standards/README.md | 7 +- 6 files changed, 102 insertions(+), 14 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index a0632c14..8890612d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -134,18 +134,20 @@ with actual-config planted controls. Its owns verification and review status. Step 4 adds concurrent host/locale, theme, freshness and content-fault product proofs; its [delivery record](docs/roadmap/phase-02d-walking-skeleton.md#p02d-6-step-4-product-proof-and-accessibility-closeout) -records both completed review rounds. **P02d-6 implementation is complete — -2026-10-10, unmerged**: the +records both completed review rounds. **P02d-6 is complete and merged** through +[PR #27](https://github.com/HodeTech/LearnStack/pull/27) on 2026-10-10; its +[merge closeout](docs/roadmap/phase-02d-walking-skeleton.md#p02d-6-merge-and-closeout-2026-10-10) +records final verification. The [packet closeout](docs/roadmap/phase-02d-walking-skeleton.md#p02d-6-packet-closeout-2026-10-10) records passing manual browser checks and the maintainer's VoiceOver smoke. -Maintainer PR review and merge remain pending. ADR-0055 remediation delivers +ADR-0055 remediation delivers single-bootstrap admission and passing production replacement proofs. All three steps completed both independent review rounds; the [Step 3 record](docs/roadmap/phase-02d-walking-skeleton.md#adr-0055-step-3--production-admission-proof-and-closeout) owns completed Step 3 reviews, verified fixes and delivery evidence. The five new catalogue rules are Implemented. -P02d-7 owns the browser demo and Lighthouse; Phase 06 retains -the full renderer/Studio expansion. +P02d-7's demo, Lighthouse and phase-exit decision pass is next and has not started. +Phase 02d remains in progress; Phase 06 retains the full renderer/Studio expansion. **Phase 01** shipped the .NET 10 solution scaffold under `backend/` (core + 7 modules × 4 projects + 4 test projects including the diff --git a/README.md b/README.md index ffe643e6..289c7a1d 100644 --- a/README.md +++ b/README.md @@ -101,8 +101,12 @@ The original P02d-6 implementation is complete. ADR-0055 remediation delivers single-bootstrap admission and passing production replacement proofs; all three steps completed both independent review rounds, and the [Step 3 record](docs/roadmap/phase-02d-walking-skeleton.md#adr-0055-step-3--production-admission-proof-and-closeout) -owns completed Step 3 reviews, verified fixes and delivery evidence. Maintainer -PR review and merge remain pending. The browser demo remains P02d-7. The +owns completed Step 3 reviews, verified fixes and delivery evidence. **P02d-6 is +complete and merged** through [PR #27](https://github.com/HodeTech/LearnStack/pull/27) +on 2026-10-10; its +[merge closeout](docs/roadmap/phase-02d-walking-skeleton.md#p02d-6-merge-and-closeout-2026-10-10) +records final verification. P02d-7's demo, Lighthouse and phase-exit decision pass +is next and has not started. The [P02d-4 decision package](docs/roadmap/phase-02d-walking-skeleton.md#p02d-4-decision-package-2026-10-03) is Accepted — 2026-10-03. All four implementation steps and their review loops are complete. P02d-5 supplies trusted server rendering; P02d-6 supplies public diff --git a/docs/roadmap/README.md b/docs/roadmap/README.md index e9e837d8..c92eff02 100644 --- a/docs/roadmap/README.md +++ b/docs/roadmap/README.md @@ -77,8 +77,12 @@ not deferred to the showcase phase. single-bootstrap admission and passing production replacement proofs. All three steps completed both independent review rounds; the [Step 3 record](phase-02d-walking-skeleton.md#adr-0055-step-3--production-admission-proof-and-closeout) - owns completed Step 3 reviews, verified fixes and delivery evidence. Maintainer - PR review and merge remain pending. P7 owns the browser/demo. + owns completed Step 3 reviews, verified fixes and delivery evidence. P02d-6 is + complete and merged through [PR #27](https://github.com/HodeTech/LearnStack/pull/27) + on 2026-10-10; its + [merge closeout](phase-02d-walking-skeleton.md#p02d-6-merge-and-closeout-2026-10-10) + records final verification. P02d-7's demo, Lighthouse and phase-exit decision + pass is next and has not started; Phase 02d remains in progress. - [Phase 02b: Events, Background Jobs, Identity, and Session](phase-02b-events-auth.md) - [Phase 03: Identity Domain, Authorization, and Admin Foundation](phase-03-identity-admin.md) - [Phase 04: Headless CMS, Page Builder, and Media Library](phase-04-cms-media-pages.md) diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index e7073dd5..4a06ce72 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -14,7 +14,7 @@ > | P02d-3 | Read internals | ✅ complete and merged — 2026-10-03; [merge closeout](#p02d-3-merge-and-closeout-2026-10-03) | > | P02d-4 | Public read API and contract checks | ✅ complete and merged — 2026-10-08; [merge closeout](#p02d-4-merge-and-closeout-2026-10-08) | > | P02d-5 | Server-rendering path | ✅ complete and merged — 2026-10-09; [merge closeout](#p02d-5-merge-and-closeout-2026-10-09) | -> | P02d-6 | Public renderer | ✅ implementation complete — 2026-10-10; all four steps and both review rounds per step complete; scoped browser/VoiceOver smoke passed; [packet closeout](#p02d-6-packet-closeout-2026-10-10); maintainer PR review/merge pending | +> | P02d-6 | Public renderer | ✅ complete and merged — 2026-10-10; [merge closeout](#p02d-6-merge-and-closeout-2026-10-10) | > | P02d-7 | Demo, full-stack CI and exit | not started | **Acceptance update — 2026-10-02.** P02d-1 remains merged. The maintainer accepted @@ -126,6 +126,13 @@ manual browser observations and the maintainer's passing VoiceOver smoke. P02d-6 awaits maintainer PR review and merge. P02d-7's demo, browser/Lighthouse harness and phase-exit decision pass are next; they have not started. +**P02d-6 merge complete — 2026-10-10.** The preceding notes record pre-merge +milestones. P02d-6 is now closed through +[PR #27](https://github.com/HodeTech/LearnStack/pull/27); its +[merge closeout](#p02d-6-merge-and-closeout-2026-10-10) records the final head, +verification and merge. Phase 02d remains in progress. P02d-7's demo, Lighthouse +and phase-exit decision pass is next; implementation has not started. + ## Goal Put a working education site in a browser — twice, on two hosts, for two tenants in @@ -5553,6 +5560,73 @@ transformation syntax, one shared-constant listener, adjacent source anchors, registration order and cleanup. Both rounds are read-only and start no runtime services. The PR description owns final exact-head CI after this record commit. +### P02d-6 merge and closeout (2026-10-10) + +The maintainer merged [PR #27](https://github.com/HodeTech/LearnStack/pull/27) at +2026-10-10 17:07:50 UTC. GitHub records final PR head +`46ed971bf976514fb451a162cc9450d147ed0441` and merge commit +`378346126949c90bb286b5217c24513fc2044f06`. The merge's second parent is that +head, and both commits have the identical tree. Development is fast-forwarded to +the verified merge without changing branches or rewriting history. The final +head includes the testing-standard correction marking both ADR-0055 Step 3 +review rounds complete. + +- All six required checks pass on the + [final PR head](https://github.com/HodeTech/LearnStack/actions/runs/38070332107) + and the [merge commit](https://github.com/HodeTech/LearnStack/actions/runs/38070479860). + Independently downloaded merge-run TRX confirms **2,946 passed**, zero failures + or skips: 1,705 unit, 198 architecture, four contract, 172 Docker-free + integration and 867 Docker integration cases. +- Merge-run frontend logs confirm **1,402 passed** (1,342 web, 60 SDK), successful + typecheck, lint, production build and SDK drift verification. Native production + ingress verification and all **19** setup/cleanup and negative controls pass. + Release builds report zero warnings and errors. These are merge-run receipts; + the documentation closeout does not rerun the full runtime suites. +- Read-only verification confirms `strict: true` and the same six required Actions + contexts, including OpenAPI diff and Docker integration. No protection setting + changes. Lighthouse remains disabled with activation owned by P02d-7. + +**P02d-6 is closed.** Localized catalog, course/outline and ordered plain-text +lesson pages, safe four-color themes, exact-locale metadata, scoped pagination +and controlled public states are delivered. ADR-0055 adds middleware-owned single +bootstrap admission, immutable request-local reuse and production lifecycle/ +isolation proofs. All implementation steps and focused fixes retain their +recorded independent review rounds. The +[packet closeout](#p02d-6-packet-closeout-2026-10-10) owns scoped keyboard, focus, +reflow and contrast observations and the maintainer's VoiceOver smoke; this +merge adds no new manual observation or full WCAG-conformance claim. + +**Next: P02d-7 — Demo, full-stack CI and exit.** Its decision pass and +implementation have not started. Resolve the remaining G20/G33/G38/G44/G45 parts +against the delivered renderer before harness implementation: + +- Define `make demo` and stop/re-run ownership on a clean checkout, environment + projection, readiness, non-destructive seeding and the printed host/locale URLs + (G45). Local use and CI reuse the selected entrypoint. +- Select Lighthouse's tools, both-host/locale URL set, assertions, budgets, + aggregation and artifacts; activate its currently disabled job and reconcile + standards/required-check carriers with the chosen enforcement (G44). +- Complete the shared full-stack/browser demo and trusted-hop CI evidence + (G33/G38), including anonymous catalog-to-lesson flows with Keycloak stopped. +- Implement and prove G20's remaining production/seed and frontend genericity + fences in required checks, preserving tenant-data-driven differences. +- Reconcile every exit criterion and register row with its evidence and record + the Education/seed preservation obligations and premises `P02b-0` re-verifies. + [Phase 02b](phase-02b-events-auth.md) follows only after the Phase 02d exit + decision, not this packet merge. + +Phase 06 retains full Studio/portal, authored composition and Playwright/axe; +Phase 11 retains broader production hardening and telemetry. Course Marketplace +commerce is not delivered by this closeout. Earlier dated delivery records, +including their pre-merge pending statements, remain historical and unchanged. + +**Documentation-only closeout validation.** All **198** local Release architecture +cases and seven ADR lifecycle/workflow controls pass, with zero failures/skips. +The six changed Markdown files resolve **873** relative links and **371** fragments +with zero errors in the local audit. Added prose wrapping and diff checks pass. +Earlier dated phase records are byte-preserved; no Accepted ADR or production +code changes. + ### P02d-1 decision pass (2026-09-14) **Accepted — 2026-09-14, verified against `6c58343`.** The maintainer approved diff --git a/docs/roadmap/phase-06-renderer-admin-studio.md b/docs/roadmap/phase-06-renderer-admin-studio.md index 94f0f8c0..2ac7c9d1 100644 --- a/docs/roadmap/phase-06-renderer-admin-studio.md +++ b/docs/roadmap/phase-06-renderer-admin-studio.md @@ -22,8 +22,9 @@ and a non-developer tenant admin can maintain it. ### What Phase 02d supplies -Rows identify implemented P02d-6 scope; its PR review and merge remain pending. Planned -P02d-7 work is not current behavior. +Rows identify P02d-6 scope merged through PR #27; its +[merge closeout](phase-02d-walking-skeleton.md#p02d-6-merge-and-closeout-2026-10-10) +records final verification. Planned P02d-7 work is not current behavior. | Phase 02d foundation | Phase 06 adds | |---|---| diff --git a/docs/standards/README.md b/docs/standards/README.md index 0d6dbf7e..21a9ae12 100644 --- a/docs/standards/README.md +++ b/docs/standards/README.md @@ -68,7 +68,7 @@ bookkeeping pass. ### Honest status today The table below describes the implementation as of 2026-10-10: -[Phase 02a](../roadmap/phase-02a-kernel-tenancy.md) and P02d-1–5 are complete and +[Phase 02a](../roadmap/phase-02a-kernel-tenancy.md) and P02d-1–6 are complete and merged. P02d-5's ingress, configured server caller, dynamic entry and frontend guards are delivered through PR #26; the [merge closeout](../roadmap/phase-02d-walking-skeleton.md#p02d-5-merge-and-closeout-2026-10-09) @@ -87,7 +87,10 @@ and passing production replacement proofs. All three steps completed both independent review rounds. The [Step 3 record](../roadmap/phase-02d-walking-skeleton.md#adr-0055-step-3--production-admission-proof-and-closeout) owns completed Step 3 reviews, verified fixes and delivery evidence; its five rules -are Implemented. Acceptance alone promotes no standard or test status. +are Implemented. P6's +[merge closeout](../roadmap/phase-02d-walking-skeleton.md#p02d-6-merge-and-closeout-2026-10-10) +records PR #27's merge and final verification; P7 has not started. Acceptance +alone promotes no standard or test status. **The documents and this table say the same thing, and a test holds them to it.** [Phase 02a Packet 10](../roadmap/phase-02a-kernel-tenancy.md) reconciled the twenty-two From 3160714ead228c288da627760e22922cc5514ec9 Mon Sep 17 00:00:00 2001 From: Cemil ILIK Date: Sun, 11 Oct 2026 02:46:30 +0300 Subject: [PATCH 02/35] docs(decisions): accept P02d-7 demo and audit contracts Record the approved lifecycle, genericity scope and serial browser/audit measurement boundaries before implementation. Register the four proof obligations without claiming passing runtime evidence or activating CI. ADR: 0056 --- CLAUDE.md | 6 +- README.md | 6 +- ...demo-browser-and-lighthouse-enforcement.md | 318 ++++++++++++++++++ docs/decisions/README.md | 1 + docs/roadmap/README.md | 6 +- docs/roadmap/phase-02d-walking-skeleton.md | 231 ++++++++++++- docs/standards/15-performance.md | 11 + .../21-architecture-tests-catalogue.md | 73 +++- frontend/apps/web/README.md | 5 +- 9 files changed, 640 insertions(+), 17 deletions(-) create mode 100644 docs/decisions/0056-public-demo-browser-and-lighthouse-enforcement.md diff --git a/CLAUDE.md b/CLAUDE.md index 8890612d..17c55185 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -146,7 +146,11 @@ steps completed both independent review rounds; the [Step 3 record](docs/roadmap/phase-02d-walking-skeleton.md#adr-0055-step-3--production-admission-proof-and-closeout) owns completed Step 3 reviews, verified fixes and delivery evidence. The five new catalogue rules are Implemented. -P02d-7's demo, Lighthouse and phase-exit decision pass is next and has not started. +P02d-7's demo, Lighthouse and phase-exit +[decision package](docs/roadmap/phase-02d-walking-skeleton.md#p02d-7-decision-package-2026-10-10) +was approved on 2026-10-11, including bounded seventh-check activation after real +success. ADR-0056 was accepted on the same date. Implementation follows the +approved four-step plan; no P7 enforcement delivery is claimed yet. Phase 02d remains in progress; Phase 06 retains the full renderer/Studio expansion. **Phase 01** shipped the .NET 10 solution scaffold under `backend/` diff --git a/README.md b/README.md index 289c7a1d..1848598b 100644 --- a/README.md +++ b/README.md @@ -105,8 +105,10 @@ owns completed Step 3 reviews, verified fixes and delivery evidence. **P02d-6 is complete and merged** through [PR #27](https://github.com/HodeTech/LearnStack/pull/27) on 2026-10-10; its [merge closeout](docs/roadmap/phase-02d-walking-skeleton.md#p02d-6-merge-and-closeout-2026-10-10) -records final verification. P02d-7's demo, Lighthouse and phase-exit decision pass -is next and has not started. The +records final verification. P02d-7's demo, Lighthouse and phase-exit +[decision package](docs/roadmap/phase-02d-walking-skeleton.md#p02d-7-decision-package-2026-10-10) +and ADR-0056 were approved on 2026-10-11; implementation follows the four-step +plan. The [P02d-4 decision package](docs/roadmap/phase-02d-walking-skeleton.md#p02d-4-decision-package-2026-10-03) is Accepted — 2026-10-03. All four implementation steps and their review loops are complete. P02d-5 supplies trusted server rendering; P02d-6 supplies public diff --git a/docs/decisions/0056-public-demo-browser-and-lighthouse-enforcement.md b/docs/decisions/0056-public-demo-browser-and-lighthouse-enforcement.md new file mode 100644 index 00000000..231d01e8 --- /dev/null +++ b/docs/decisions/0056-public-demo-browser-and-lighthouse-enforcement.md @@ -0,0 +1,318 @@ +# ADR-0056: Public Demo Browser and Lighthouse Enforcement + +## Status + +Accepted + +No implementation, passing audit or gate acceptance is claimed. + +**Date:** 2026-10-11 +**Deciders:** @cemil + +## Decision Drivers + +- P02d-7 must demonstrate two tenant sites from one production build and database. +- G44 already assigns Lighthouse activation to P7; its measurements are undecided. +- A fast error page must never satisfy a performance or accessibility check. +- The delivered visitor and peer limiters remain active during the entire proof. +- Reproducible gzip, browser and lab measurements need explicit semantics. +- The evidence must preserve the existing ingress, request-local and TLS boundaries. + +## Considered Options + +1. **Direct Lighthouse with managed Chromium** (chosen). + Pin Lighthouse and the Playwright library/browser; validate the actual audited + page, complete report inventory and explicitly defined budgets. +2. **LHCI with the runner's stock Chrome** (rejected). LHCI supplies useful + assertions but still needs page-identity and gzip checks; stock Chrome drifts. + LHCI 0.15.1 pins Lighthouse 12.6.1, rather than this proposal's 13.5.0. +3. **Human walkthrough or static HTML audit only** (rejected). Neither exercises + the delivered navigation in a browser or closes G44's required full-stack job. + This rejects human evidence as the sole gate; G33's human walkthrough remains. +4. **Make all existing timing targets hard immediately** (rejected). The landing + page and lesson player are absent, and a shared CI lab is not a production + p95 or field-INP baseline. + +## Decision + +LearnStack gates the delivered public catalog, course and lesson pages with a +seed-derived browser walkthrough and pinned Lighthouse audits over the shared +demo lifecycle. Every audit proves the identity of its actual product document; +normalized initial JavaScript gzip size, CLS and automated accessibility are hard +checks, while per-URL median timing measurements are advisory. A required CI job +runs these checks without changing the production anonymous admission budgets. + +## Context + +The maintainer accepted this enforcement decision on 2026-10-11. It +implements P02d-7's remaining G33/G38/G44 evidence; the +[phase package](../roadmap/phase-02d-walking-skeleton.md#p02d-7-decision-package-2026-10-10) +owns G20, G45, implementation steps and phase exit. The maintainer approved that +package's lifecycle and bounded seventh-check activation on 2026-10-11; this +revised ADR is accepted on the same date. G45 names the approved `make demo` +lifecycle and G33 names the approved CI topology in the register. The decision +commit records both dependencies before implementation; ADR acceptance does not +replace the lifecycle decision. It adds no production +API, new request authority, shared representation cache or deployment mode. + +[ADR-0053](0053-trusted-public-server-rendering.md), +[ADR-0054](0054-bounded-public-renderer-admission.md) and +[ADR-0055](0055-public-renderer-bootstrap-failures.md) remain unchanged. Native +HTTPS ingress is mandatory; ordinary product documents cost two API calls. +The 60-call/minute visitor and 600-call/minute peer policies remain registered. + +### Toolchain and page matrix + +Use exact development-tool pins: `lighthouse@13.5.0` and +`playwright@1.64.0` as a library, without a new Playwright Test runner or a +separate axe suite. Install Playwright's managed full Chromium: revision 1248, +version 156.0.8078.4, with the new headless mode. The repository's Node 22.23.1 +satisfies Lighthouse's Node >=22.19 requirement. Record resolved versions and the +OS/runner image; refuse a missing or mismatched browser instead of skipping. +Both tools are Apache-2.0 licensed. Pin them as development tools in +`frontend/package.json` and `frontend/pnpm-lock.yaml`, outside application runtime +dependencies. Record transitive license/security review with implementation. + +Derive the URL/identity/expected-content manifest from `SeedData`; do not maintain +another list of seed slugs, titles, colors or field labels. + +| Lane | Locale | Pages | +|---|---|---| +| English tenant-wide host | en | Catalog, public course, first public lesson | +| Yoga default-organization host | tr-TR | Catalog, public course, first public lesson | +| Yoga default-organization host | en | The same three resource kinds in English | + +The exact seeded organization-scoped Yoga course supplies both Yoga lanes. This +is nine URLs and three cold audits per URL: exactly 27 JSON/HTML report pairs. +The browser opens each catalog, then follows rendered course and lesson links. +It checks host/locale, expected headings, ordered authored fields, distinct field +sets, computed theme colors, and exclusion of foreign/draft/restricted content. +It uses the same running API, web build and database across all lanes. +Keycloak is started for the existing seed gate, then stopped in the CI-owned +project before these fresh anonymous navigations. + +These flows supplement the existing HTML/Flight and schema-replacement proofs. +[Phase 06](../roadmap/phase-06-renderer-admin-studio.md) still owns the broader +Playwright/axe golden-flow suite. Existing P6 manual/VoiceOver evidence keeps its +recorded scope and date; this ADR establishes neither a new manual pass nor full +WCAG conformance. + +### Actual audited document and report admission + +Before scoring, each run requires the expected URL and a successful live product +preflight. The audit additionally checks its own final URL, main-document status, +tenant/locale/content markers and original document/DOM. A healthy preflight +alone is insufficient. Inspect the audited target or its gathered artifacts +without a second post-audit navigation. A bounded custom gatherer is permitted. + +Reject controlled error/noindex/fallback documents, wrong-tenant content, missing +expected fields, unexpected redirects and any API 429, including a content +refusal rendered as HTTP 200. Observe API responses as well as browser responses; +a genuine product DOM cannot turn a hidden API failure into a clean receipt. + +Each report must belong to this invocation's commit, build, URL, run index, +configuration and browser. Missing, duplicate or stale reports, runtime errors, +audit errors, missing categories and null/nonfinite budgeted measurements fail +independently of the hard/advisory split. Both tenants and every locale/run must +pass; results are never averaged across URLs. + +### Lab profile and budgets + +Run only `performance` and `accessibility` from the pinned default configuration, +explicitly skipping `bf-cache`, whose gatherer navigates away and back. Preserve +the complete pinned accessibility audit/weight set and the four budgeted numeric +audits: `cumulative-layout-shift`, `largest-contentful-paint`, +`server-response-time` and `total-blocking-time`. The selected performance +category also gathers and scores FCP and Speed Index in Lighthouse's report; +neither has a P7 threshold, and the performance category score is not asserted. +Assert the resolved audit/artifact census and refuse missing or changed scoring +entries. Do not select `seo`, `best-practices` or `agentic-browsing`; no active +secondary-navigation probes run. Product-identity/gzip gatherers observe the +initial navigation and introduce no fetch or navigation of their own. + +Use Lighthouse 13.5's mobile simulated slow-4G profile, recorded explicitly: +412 × 823 CSS pixels, DPR 1.75, 150 ms RTT, 1638.4 Kbps throughput and 4× CPU +slowdown. Record resolved settings in every run manifest. This is not the +fast-4G landing-page profile in Performance Standards. + +| Measurement | Threshold | Verdict | +|---|---|---| +| `initial-js-gzip-bytes`, defined below | Strictly < 200000 bytes | Hard, every run | +| `cumulative-layout-shift.numericValue` | Strictly < 0.05 | Hard, every run | +| `categories.accessibility.score` | Exactly 1 | Hard, every run | +| `largest-contentful-paint.numericValue` | Median of three < 1500 ms | Advisory, per URL | +| `server-response-time.numericValue` | Median of three < 300 ms | Advisory, per URL | +| `total-blocking-time.numericValue` | Median of three < 200 ms | Advisory, per URL | + +The advisory thresholds are P7 lab baselines across the nine delivered pages. +Main-document server response is not full-navigation TTFB; TBT is not INP. +No landing-page, lesson-player, production p95 or load-test result follows. +The 250 KB forbidden line does not replace the 200 KB route budget. +Accessibility score 1 covers Lighthouse's automated scored checks, not every +accessibility criterion. + +### Normalized initial JavaScript gzip size + +`initial-js-gzip-bytes` adopts an explicit, potentially stricter interpretation +of the existing public-route gzip budget in +[Performance Standards](../standards/15-performance.md#bundle-size): + +- Use a cold navigation with no interactions or speculative prefetch. The + collection window is that audit's navigation through collection completion. +- Inventory every actual external Script response in that window, same-origin + and cross-origin, including async/lazy scripts loaded by initial scripts + without interaction. Count each delivered response once; gzip its complete + decoded UTF-8 source with Node `gzipSync` at level 9 and sum the byte lengths. +- Add the gzip length of original-document inline executable script bodies, + concatenated in document order with one newline between bodies. Include Next's + inline Flight push scripts; exclude inert JSON/data blocks and external-script + elements already counted above. Scripts first requested after collection + completion or through later user interaction are outside this measurement. +- Record source URL, digest, decoded byte length and gzip length, plus inline + count/digest/lengths. Reconcile the network inventory with collected sources. +- Missing, undecodable or truncated bodies, inventory disagreement and an + unexpectedly empty script census fail; unavailable sources never count as zero. + +This is a deterministic normalized payload measurement using decimal KB. It is +neither actual wire bytes nor Next's build-time First Load JS. Lighthouse's +Script `transferSize` may use another content encoding; it cannot substitute for +this budget. Evaluation-generated code is not a delivered source response. +The collection window and inline/async coverage can reject a route that passed +a narrower build-time or entry-chunk-only reading. This tightening is intentional; +the enforcing Standards 15 update links this exact scope and its exclusions. + +### Pacing, runtime and artifacts + +Keep one running API throughout the proof. Use exactly four sequential batches: +one batch containing all three browser click paths, followed by three audit +batches, one per host/locale lane, each containing nine audits. Use one worker: +preflight/audit pairs execute serially, with at most one active browser target +and no overlapping audits. Record the runner's CPU count and OS/image; do not +parallelize Chromium to meet a deadline on a shared runner. +Leave at least 61 seconds after a batch completes before starting the next. +With one navigating preflight per audit, each audit batch expects 36 API calls; +the click paths expect 18. Count readiness and other documents separately. + +Cap each batch at 48 observed API calls and refuse any 429 or unexplained extra +traffic. Do not spoof visitors, raise quotas, reset the API/limiter, retry 429s or +silently audit a refusal page. Prove the counting observer has a positive control. +Startup checks also consume quota: finish them before the first 61-second quiet +interval. Real counts, not the arithmetic alone, own the passing evidence. + +The proof has one 12-minute wall-clock deadline after setup/build, starting +before the first quiet interval and ending after report validation. All four +61-second quiet intervals consume it: 244 seconds, leaving at most 476 seconds +for browser paths, all preflights, 27 audits and validation. Audit/preflight +pairs must therefore average less than 17.6 seconds even before deducting the +browser paths and validation; no measured feasibility is claimed yet. + +Navigation and audit timeouts are upper bounds, not reserved time allocations: +each navigation gets at most 15 seconds and each audit at most 60 seconds, +both shortened to the remaining proof deadline. Exhaustion aborts the active +operation, refuses unstarted work and fails the run; partial evidence cannot +pass. In particular, 27 audits taking 60 seconds each cannot pass this deadline. +Owned cleanup has a separate maximum of 30 seconds. The 20-minute CI job ceiling +includes setup/build, proof, cleanup and artifact handling; record each duration +and reserve cleanup/artifact time within that ceiling. + +The first full serial run is a feasibility gate before required-check activation. +If the complete run cannot meet these limits, record a failed result and obtain +a revised decision for changed time ceilings or execution topology. Do not +silently run parallel audits, reduce the 27-run census or weaken checks to fit. + +Keep reports and sanitized receipts in GitHub workflow artifacts only: +all 27 JSON/HTML pairs, expected/run census, metrics verdicts, version/config/ +commit manifest, browser screenshots, API status/count totals and cleanup result. +Upload bounded failure evidence on failure. Never archive private environments, +raw process logs, browser profiles, certificates or keys, and never upload to a +public Lighthouse service. + +### Trust and required-check activation + +Use the shared lifecycle's ownership and verified TLS contract. Human local use +retains explicit manual hosts/CA/leaf setup. CI uses disposable certificates, +certificate-specific browser SPKI trust, resolver mappings and independent Node +CA/hostname verification with wrong-key/untrusted-certificate controls. +Global certificate bypass or system hosts/trust modifications are forbidden. + +The job is named `public demo + lighthouse`, runs on the normal PR/push triggers +without the deferred condition, and fails if any proof or cleanup is incomplete. +After its first real successful PR run, add that exact GitHub Actions context as +the seventh required check. Read back protection and preserve all six existing +contexts, strict freshness and every unrelated setting. Acceptance authorizes +only this bounded activation after the successful run; it does not claim activation. + +## Consequences + +### Positive + +- Browser navigation, product identity and budgets become repeatable merge gates. +- Error pages, missing metrics and empty/stale evidence cannot produce green CI. +- Seed-derived expectations preserve the same-code/different-data claim. + +### Negative + +- Managed Chromium and Lighthouse increase dependency and CI setup costs. +- Real-window pacing adds deliberate waiting; browser/lab maintenance remains work. +- The normalized gzip collector and audit-page admission need their own controls. + +### Neutral + +- Performance becomes Active only for implemented hard checks, in the enforcing PR. +- Broader performance baselines and telemetry remain Phase 11. +- Local demo lifecycle details remain G45 phase decisions, rather than a new runtime. + +## Implementation Notes + +Acceptance precedes runtime/dependency/CI changes. Reconcile Testing 06's current +“Phase 02d … gates on a human opening them, not on a Playwright run” statement +when the narrow P7 browser job ships; preserve Phase 06's broader suite ownership. +Make the public-route size unit explicit in Standards 15 as decimal KB +(`< 200000` bytes), alongside its normalized-gzip window, same-/cross-origin +scope, exclusions and potentially stricter interpretation. + +Register the canonical rules below in Standards 21 on acceptance as +**Kind: behavioural**, owned by the planned +Node entrypoint `frontend/apps/web/scripts/verify-public-demo.mjs` and the +`public demo + lighthouse` job; these are not C# architecture-test methods. +Mark them Implemented only with named, executed enforcing tests. The phase +package owns four implementation steps and two fresh independent review rounds +per step. Update Standards 06/15/16, the +standards index, CI, CONTRIBUTING and test/setup skills alongside enforcement. +Acceptance registers proof obligations, not passing tests or delivered enforcement. + +## Architecture Tests + +- `Public_Demo_Uses_Seeded_Production_Pages`: real link navigation and page/role/ + theme/locale observations, with wrong-page and error-page controls. +- `Public_Lighthouse_Reports_Enforce_Budgets`: exact census and hard/advisory + validation, with missing/stale/error/budget offenders and clean reports. +- `Public_Initial_JavaScript_Gzip_Budget_Is_Measured`: real source inventory and + byte accounting, with omitted/empty/malformed sources and over-budget controls. +- `Public_Demo_Preserves_Admission_And_Cleanup`: real quotas, Keycloak-stopped + reads, TLS refusal and owned lifecycle, with observer and cleanup controls. + +These are registered behavioral obligations for that Node/CI proof owner, not +existing scripts or C# test methods. + +## References + +- [P02d-7 package](../roadmap/phase-02d-walking-skeleton.md#p02d-7-decision-package-2026-10-10). +- [Performance Standards](../standards/15-performance.md). +- [Testing Standards](../standards/06-testing.md#end-to-end-tests). +- [Accessibility Standards](../standards/16-accessibility.md#tooling). +- [Lighthouse 13.5.0 package and Node requirement](https://github.com/GoogleChrome/lighthouse/blob/v13.5.0/package.json). +- [Lighthouse programmatic use](https://github.com/GoogleChrome/lighthouse/blob/v13.5.0/docs/readme.md#using-programmatically). +- [Lighthouse mobile profile selection](https://github.com/GoogleChrome/lighthouse/blob/v13.5.0/core/config/constants.js). +- [Pinned slow-4G upstream constants](https://github.com/ChromeDevTools/devtools-frontend/blob/v1.0.1684555/front_end/models/trace/lantern/simulation/Constants.ts#L12-L18), matching Lighthouse's trace-engine 0.0.65 dependency. +- [Lighthouse default audit set](https://github.com/GoogleChrome/lighthouse/blob/v13.5.0/core/config/default-config.js). +- [Lighthouse audit/artifact filtering](https://github.com/GoogleChrome/lighthouse/blob/v13.5.0/core/config/filters.js). +- [Lighthouse Script source collection](https://github.com/GoogleChrome/lighthouse/blob/v13.5.0/core/gather/gatherers/scripts.js). +- [Lighthouse resource-summary transfer semantics](https://github.com/GoogleChrome/lighthouse/blob/v13.5.0/core/audits/resource-summary.js). +- [Lighthouse TBT](https://developer.chrome.com/docs/lighthouse/performance/lighthouse-total-blocking-time). +- [Lighthouse accessibility scoring](https://developer.chrome.com/docs/lighthouse/accessibility/scoring). +- [Playwright library](https://playwright.dev/docs/library). +- [Playwright 1.64.0 package/license](https://github.com/microsoft/playwright/blob/v1.64.0/packages/playwright/package.json). +- [Playwright 1.64.0 browser manifest](https://github.com/microsoft/playwright/blob/v1.64.0/packages/playwright-core/browsers.json). +- [Playwright browser installation](https://playwright.dev/docs/browsers). +- [LHCI 0.15.1 dependency](https://github.com/GoogleChrome/lighthouse-ci/blob/v0.15.1/packages/cli/package.json). diff --git a/docs/decisions/README.md b/docs/decisions/README.md index 6083b93f..769cfc3a 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -71,6 +71,7 @@ an amendment is not a lifecycle status change. | 0053 | [Trusted Public Server Rendering](0053-trusted-public-server-rendering.md) | Accepted 2026-10-08: P02d-5 delivers native ingress, configured transport, dynamic entry and source/runtime proofs. [ADR-0054](0054-bounded-public-renderer-admission.md) replaces bounded accounting/native/query contracts. P02d-5 is complete and merged through PR #26 on 2026-10-09; the [merge closeout](../roadmap/phase-02d-walking-skeleton.md#p02d-5-merge-and-closeout-2026-10-09) owns final verification ([Amendment 8](0053-trusted-public-server-rendering.md#amendment-8--merge-closeout-2026-10-09)); P6/P7 remain separate | | 0054 | [Bounded Public Renderer Admission](0054-bounded-public-renderer-admission.md) | Accepted 2026-10-09: coordinated anonymous accounting, native GET/HEAD/production-upgrade admission and equivalent redirect-query encoding are delivered. All five remediation steps are complete and merged through PR #26; the [merge closeout](../roadmap/phase-02d-walking-skeleton.md#p02d-5-merge-and-closeout-2026-10-09) owns final verification ([Amendment 6](0054-bounded-public-renderer-admission.md#amendment-6--merge-closeout-2026-10-09)) | | 0055 | [Handle Public Renderer Bootstrap Failures in Middleware](0055-public-renderer-bootstrap-failures.md) | Accepted 2026-10-10: one live middleware bootstrap and an immutable native same-request snapshot; exact bootstrap 404/429/503, bounded renderer Retry-After and two/one/three-call accounting implemented. Production replacement proofs pass; all three steps completed both review rounds and focused fix verification. [Step 3](../roadmap/phase-02d-walking-skeleton.md#adr-0055-step-3--production-admission-proof-and-closeout) owns delivery evidence, completed reviews and verified fixes; five new catalogue rules are Implemented | +| 0056 | [Public Demo Browser and Lighthouse Enforcement](0056-public-demo-browser-and-lighthouse-enforcement.md) | Accepted 2026-10-11: pinned Lighthouse/Playwright Chromium, seed-derived nine-page browser proof, 27 serial audits, actual-page admission, normalized gzip/CLS/accessibility hard checks, advisory timings and bounded seventh-check activation; proof rules Registered, implementation pending | ## Proposed ADRs diff --git a/docs/roadmap/README.md b/docs/roadmap/README.md index c92eff02..c67a4b89 100644 --- a/docs/roadmap/README.md +++ b/docs/roadmap/README.md @@ -81,8 +81,10 @@ not deferred to the showcase phase. complete and merged through [PR #27](https://github.com/HodeTech/LearnStack/pull/27) on 2026-10-10; its [merge closeout](phase-02d-walking-skeleton.md#p02d-6-merge-and-closeout-2026-10-10) - records final verification. P02d-7's demo, Lighthouse and phase-exit decision - pass is next and has not started; Phase 02d remains in progress. + records final verification. P02d-7's demo, Lighthouse and phase-exit + [decision package](phase-02d-walking-skeleton.md#p02d-7-decision-package-2026-10-10) + and ADR-0056 were approved on 2026-10-11; implementation follows the four-step + plan. Phase 02d remains in progress. - [Phase 02b: Events, Background Jobs, Identity, and Session](phase-02b-events-auth.md) - [Phase 03: Identity Domain, Authorization, and Admin Foundation](phase-03-identity-admin.md) - [Phase 04: Headless CMS, Page Builder, and Media Library](phase-04-cms-media-pages.md) diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index 4a06ce72..f40d3719 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -15,7 +15,7 @@ > | P02d-4 | Public read API and contract checks | ✅ complete and merged — 2026-10-08; [merge closeout](#p02d-4-merge-and-closeout-2026-10-08) | > | P02d-5 | Server-rendering path | ✅ complete and merged — 2026-10-09; [merge closeout](#p02d-5-merge-and-closeout-2026-10-09) | > | P02d-6 | Public renderer | ✅ complete and merged — 2026-10-10; [merge closeout](#p02d-6-merge-and-closeout-2026-10-10) | -> | P02d-7 | Demo, full-stack CI and exit | not started | +> | P02d-7 | Demo, full-stack CI and exit | decision pass Accepted — 2026-10-11; [decision package](#p02d-7-decision-package-2026-10-10); implementation starts with Step 1 | **Acceptance update — 2026-10-02.** P02d-1 remains merged. The maintainer accepted ADR-0050/0051 and the [P02d-2 package](#p02d-2-decision-package-2026-10-02), including @@ -433,7 +433,7 @@ premise a row cites is re-verified at that pass rather than trusted. | G17 | Does `TenantSetting.Value` carry `[PiiSensitive]`? [Phase 03](phase-03-identity-admin.md) sequences the decision before the first command writing `tenant_settings`, and this phase ships that command | Not marked, provided `tenancy.setting.write` admits only G16's closed key set, so the answer cannot stretch to keys a tenant invents; modelling a sensitive part as its own property stays open to Phase 03 | Contract: a dated phase-doc statement, reflected in `TenantSetting.cs`, the Tenancy spec and `audit.md`. Whole-value redaction of `jsonb` is settled by [ADR-0044](../decisions/0044-audit-write-path.md) Amendment 4 § 1 | P02d-2 (the first MUST-class settings audit row is written by the seed, and rows cannot be redacted retroactively); closes with G16 (a) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): generic whole-value PII redaction before the writer | | G18 | How is a tenant content type presented? `json_schema` is `jsonb`, which keeps no key order, and the schema profile collects only `x-renderer`, `x-taxonomy` and `x-language`. How are field order, a label per enabled locale and a composite's field roles carried; which registered composite draws a lesson for each seeded type; which primitives does this phase implement, and does `markdown` render; how do types with no primitive row (`integer`, `number`, `boolean`, enums) map; may a rendered type declare a field outside the subset; and is a presentation entry naming a missing property refused at save? | A LearnStack extension — `x-order` and `x-label`, or one ordered `x-fields` list — carrying Pattern B labels, resolved at write like `x-taxonomy`; one composite already in both registries; the reviews split on the subset — `text`, `list` and `link`, with `markdown` without raw HTML, or a placeholder until Phase 05's sanitiser; the seed uses only the subset | Contract: a dated ADR-0043 amendment for a keyword or a save-time refusal; a dated ADR-0018 amendment for a presentation column; a phase-doc statement for `title` plus `required`, which cannot carry two locales. Detail: [Tenant Customization Model § 2](../architecture/32-tenant-customization-model.md) and § 8.1, the Customization spec, the profile's extension and reference-graph skip lists, `composites.ts` | P02d-2 (the seed publishes both content types as `schema_version` 1 with their renderer keys and field kinds; a later answer needs successor revisions) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): ADR-0051 profile and first-render subset. Component placement/fallback remains G41 | | G19 | URL and markup policy for tenant-authored values on an anonymous page: which schemes (`https` only, or `http` too), credentials and `target`, which media origins, whether the rule is enforced on write — in the Education command, or as a validation gate Phase 04's entries share — whether the public API filters too, and whether URLs inside markdown fall under it. The write-time check constrains structure, not schemes: `format: uri` admits `javascript:` and `data:` | The reviews split on `http`; all refuse `javascript:`, dangerous `data:` and credentials; checked on write by a LearnStack rule and again on render; no third-party media in the seed | Detail: one home for the scheme list — [Security Standards § XSS & Output Encoding](../standards/11-security.md#xss--output-encoding) or [Frontend Architecture Standards § Security](../standards/07-frontend-architecture.md#security), not both; the Education spec's write rules; Tenant Customization Model § 8.1 if checked on write. Contract: a dated ADR-0043 amendment if it becomes a shared validation gate | P02d-2 (the lesson command's validation and the seed values; the render-time check reuses the answer) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): no active sink in the seeded text profile; future URL/markup contracts precede Phase 04/05 sinks | -| G20 | What mechanically backs "no production code branches on which tenant it serves"? The shipped domain-term scan strips literals and exempts seed data. (a) The mechanism and its literal source; (b) its subjects, matching and the platform built-ins; (c) its exemptions, including development hosts in frontend or infrastructure configuration; (d) whether a ban on production references to `LearnStack.Tools.Seeder` and a behavioural same-code, different-data test accompany it | A Standards 21 sibling row scanning production backend and `frontend/` sources, comments stripped, for exact identity literals read from `SeedData` (slugs, ids, hosts, display names, customization keys), built-ins excluded, with planted offenders; plus the behavioural test. The exemption policy is the owner's judgement | Detail: a Standards 21 row Registered in the first pass that uses it and Implemented before exit; a phase-doc statement in § Genericity proof. No ADR | P02d-2 (a: every seed literal lives where the source reads it), P02d-5 (c: the first host outside `SeedData`), P02d-6 (b: frontend subjects), P02d-7 (Implemented and required) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): (a) SeedData literal source and Registered guard. [Accepted — 2026-10-08](#p02d-5-accepted-answers): (c) exemptions; [Accepted — 2026-10-09](#p02d-6-accepted-answers): (b) frontend subjects; implementation and behavioral proof remain P7 | +| G20 | What mechanically backs "no production code branches on which tenant it serves"? The shipped domain-term scan strips literals and exempts seed data. (a) The mechanism and its literal source; (b) its subjects, matching and the platform built-ins; (c) its exemptions, including development hosts in frontend or infrastructure configuration; (d) whether a ban on production references to `LearnStack.Tools.Seeder` and a behavioural same-code, different-data test accompany it | A Standards 21 sibling row scanning production backend and `frontend/` sources, comments stripped, for exact identity literals read from `SeedData` (slugs, ids, hosts, display names, customization keys), built-ins excluded, with planted offenders; plus the behavioural test. The exemption policy is the owner's judgement | Detail: a Standards 21 row Registered in the first pass that uses it and Implemented before exit; a phase-doc statement in § Genericity proof. No ADR | P02d-2 (a: every seed literal lives where the source reads it), P02d-5 (c: the first host outside `SeedData`), P02d-6 (b: frontend subjects), P02d-7 (Implemented and required) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): (a) SeedData literal source and Registered guard. [Accepted — 2026-10-08](#p02d-5-accepted-answers): (c) exemptions; [Accepted — 2026-10-09](#p02d-6-accepted-answers): (b) frontend subjects; implementation and behavioral proof remain P7; [Accepted — 2026-10-11](#p02d-7-decision-package-2026-10-10): matching, canonical built-ins, Seeder-reference fence and behavioral ownership; enforcement remains pending | | G21 | Does the anonymous public path set any cookie — the [Frontend Architecture Standards § Tenant Resolution](../standards/07-frontend-architecture.md#tenant-resolution) flowchart sets them — and may a public page load any cross-origin subresource, such as the CDN-hosted logo and font assets Frontend Architecture describes? | No cookies, since the locale is already in the path and a locale-less request redirects ([Localization Standards § URL Strategy](../standards/08-localization.md#url-strategy)); same-origin subresources only; both asserted by a check. Whether tenant branding may point visitors' browsers at third-party hosts is a data-protection choice for the owner | Detail: a phase-doc statement; the Standards 07 flowchart and Frontend Architecture § Theming reconciled in the deciding pass | P02d-2 (subresources, if G16 admits a URL-valued token), P02d-5 (cookies: the middleware replacement is the first code that could set one) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): subresources. Cookies remain open for P02d-5; [Accepted — 2026-10-08](#p02d-5-accepted-answers): cookies; prior subresource answer retained | | G22 | How does the customization definition projection load and stay correct? In the request's ambient transaction, or as a ninth out-of-band tenant-context setter (ADR-0040's set is closed at eight)? In what order are the generation and the rows read; what does an absent generation row mean; how is a cache filled inside a transaction that bumped and rolled back kept unreachable, when the bump is an upsert increment that can reissue a number; what does an absent definition set return; which families are registered, and how does the adapter's exact-tuple `cache.name` mapping match generation-embedded names; what do the TTLs bound; and is the contract batched so a public read issues a bounded number of statements? | Load in the ambient transaction; read the generation first, then the rows; fill only from non-bumping transactions; treat cache faults as misses; restate the module's cache-hit budget; a batched contract, with statement-count assertions cold and warm | Contract: the Customization spec § Primary read flow and a [Tenant Customization Model § 8.2](../architecture/32-tenant-customization-model.md#82-cache-strategy) statement on how a request learns the generation; a dated ADR-0040 amendment and a setters row only if the loader is out-of-band. Detail: the [Infrastructure Stack Standards](../standards/20-infrastructure-stack.md) cache table, the `cache.name` mapping, the Observability Standards metrics family list | P02d-3 | [Accepted — 2026-10-02](#p02d-3-decision-package-2026-10-02) | | G23 | The typed settings accessor and its freshness. With no `learnstack.tenancy.settings` event until Phase 02b and the seed writing from its own process, what bounds staleness: a TTL with a stated bound, a writer-coupled Tenancy settings generation counter, or no settings cache here? What are the accessor's name and glossary headword; how is a cached read keyed so tenant-wide and organization rows never cross organizations — a settings read depends on `app.organization_id` today, and the policy's tenant-scope read gains a carrier in Phase 03; and does its loader run in the ambient transaction? | The reviews split on freshness — a TTL bound until 02b, a counter, or no cache. For keys: tenant-wide rows loaded with an explicit `organization_id IS NULL` predicate under `CacheKey.ForTenant`, each organization's overrides under `CacheKey.ForOrganization`, merged in memory; an ambient loader. The documented tenant-only key is rejected, because it would serve one organization's overrides to another | Detail: if settings are cached, the Infrastructure Stack Standards cheat-sheet rows and `cache.name` mapping; the Tenancy spec's event row and budget; a glossary headword. Contract only for a counter (the Tenancy spec, Database Standards § Table classes and § GRANT matrix) or an out-of-band loader (an ADR-0040 amendment) | P02d-2 (a counter is bumped inside the setting command's transaction), P02d-3 (name, keys, loader) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): no settings cache in P02d-2/3. [Accepted — 2026-10-02](#p02d-3-decision-package-2026-10-02): typed ambient accessor/scoped merge | @@ -446,19 +446,19 @@ premise a row cites is re-verified at that pass rather than trusted. | G30 | The locale error matrix and transport. On each read, what answers an empty, repeated, malformed, over-length, non-canonical, not-enabled or enabled-but-untranslated locale? Does a not-enabled locale answer the Active `unsupported_locale` `400` or the not-found body? Is `X-Locale`, which [Frontend Architecture Standards § Locale Resolution](../standards/07-frontend-architecture.md#locale-resolution) still names as the API carrier, withdrawn, so that locale reaches the API only as the query parameter? | Missing or malformed → `400` `validation_failed` naming `locale`; untranslated → an empty catalog page; the query parameter only. The reviews split on not-enabled — not-found, amending the Error Handling row, or the Active `400`; a uniform answer after the enabled check hides pre-launch rows under either | Detail: a phase-doc statement; the [Error Handling Standards](../standards/09-error-handling.md) table only if not-found; Standards 07 § Locale Resolution; the Frontend Architecture SDK sketch; the API Standards § Pagination example gains `locale` | P02d-4 (validators, OpenAPI parameters and responses), P02d-5 (the server SDK's header set) | [Accepted — 2026-10-03](#p02d-4-accepted-answers): query/error matrix; trusted server header transport remains P02d-5; [Accepted — 2026-10-08](#p02d-5-accepted-answers): header transport; prior API query-locale answer retained | | G31 | Contract checks and the SDK surface. The committed OpenAPI snapshot's path, and how the contract suite proves it equals the served document; how the base copy is read; how the first run behaves; which `oasdiff` version and fail level, and which ADR-0024 rows that level detects (a tightened validator or a changed status may be invisible to any diff); what is uploaded on failure. The drift gate's source — the committed snapshot through `LEARNSTACK_OPENAPI`, or a running API — and its job. Whether an activated deferred job keeps its `if: vars.ENABLE_*` condition, given that GitHub treats a skipped required job as passing, or loses it as the integration job's did. And what the SDK surface becomes when regeneration makes `paths` non-empty: a hand-written transport over `paths` or a typed client library, the fate of `createClientSdk`, and whether the package root keeps re-exporting the server entry | A committed snapshot the contract suite asserts equal, diffed against the base ref's copy with `oasdiff` pinned; drift generated from the snapshot in the required `frontend` job; the condition removed on activation; a thin hand-written transport, and no root re-export of the server entry | Detail: [Testing Standards § API Contract Tests](../standards/06-testing.md#api-contract-tests), the API Standards § OpenAPI links, `ci.yml`, [CONTRIBUTING § Branch protection](../../.github/CONTRIBUTING.md#branch-protection-settings-on-main) (its activation procedure follows the answer), [Frontend Architecture Standards § SDK](../standards/07-frontend-architecture.md#sdk); a package pin with its licence verdict if a client library is chosen | P02d-4 (the first operation, its snapshot and assertion, the drift gate, and the regenerated types the factories must compile against) | [Accepted — 2026-10-03](#p02d-4-accepted-answers): snapshot, SDK, diff/drift and approved required-check activation | | G32 | **The development-transport part of [Phase 02b](phase-02b-events-auth.md#the-decision-register)'s G12.** Which development hostnames and transport serve the two seed tenants — keep `*.learnstack.local`, with a hosts-file step and local TLS with a trust step, or move the seed hosts under `*.localhost`? What does a reviewer do between a clean checkout and both sites, and which carriers move, including host rows already on warm databases, where the host is the primary key and the seeder removes no mapping? | `*.localhost` over HTTP, provided the pass verifies in each browser the team uses and in CI's Chrome that both hosts resolve with no hosts entry and that a `Secure` cookie set on them is stored and returned; otherwise `*.learnstack.local` with local TLS and a named trust step. Tenants are never told apart by port: the effective host strips it | Detail: a dated phase-doc statement in [§ Host-based tenant resolution, end to end](#host-based-tenant-resolution-end-to-end), with `SeedData`, `scripts/seed.sh`, the README Quickstart, the `seed-tenant` and `local-dev-setup` skills and `apps/web`'s dev script and Next configuration in the same packet; Infrastructure Standards only if a TLS proxy publishes a port. No ADR | P02d-5 (the development transport, and the hop configuration a TLS proxy would change), or the first earlier packet that writes a seed-host literal outside `SeedData` | [Accepted — 2026-10-08](#p02d-5-accepted-answers): local hosts and TLS | -| G33 | The server-rendering topology and its evidence. Where do Next.js and the API run relative to each other — the workstation loopback, containers, gated APISIX; which networks are trusted; how does one hop secret reach both processes; what is the server-only API origin — and the same for the CI job that renders the pages? What evidence discharges ADR-0036's "Phase 02d's browser test" and its matrix rows "a direct socket bypassing the hop" and "the Phase 02d anonymous two-host browser render", given that Testing Standards gate this phase on a human? And ADR-0036 § Consequences says the root refuses to start outside Development when the secret list is empty or short, while the shipped rule, in every mode, refuses a half-configured hop, a network entry that is not CIDR and a blank secret or one under 32 characters (characters, not bytes), and admits both lists empty: is that recorded or restored, and is non-development hop configuration this phase's or Phase 11's? | Both processes on the loopback, networks `127.0.0.1/32` and `::1/128`, one generated secret from a single source and never under `NEXT_PUBLIC_`, with networks and secrets arriving together (committing networks without secrets breaks every Development-environment fixture); the API called directly; a per-run secret in CI. Evidence: request-level hop tests as `learnstack_app` — no `X-Tenant-Id`, a non-hop peer, a wrong secret, a repeated header — beside the human walkthrough, with one review adding an automated browser smoke. Record the shipped startup rule; non-development hop configuration is Phase 11's | Contract: one dated [ADR-0036](../decisions/0036-tenant-resolution-trusted-inputs.md) amendment if the evidence departs from the ADR's words, recording the startup rule, and carrying G34 if G34 changes the key or budget. Detail: `.env.example`, `apps/web/.env.local.example`, `appsettings.Development.json` or the demo recipe; a Standards 21 row for the hop runtime test; a Testing Standards § End-to-End Tests sentence only if ownership moves; a Phase 11 scope row | P02d-5 (the hop configuration and the fixture shape — in-process test hosts have no socket peer), P02d-7 (the CI part) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): local topology, shared source and ingress | +| G33 | The server-rendering topology and its evidence. Where do Next.js and the API run relative to each other — the workstation loopback, containers, gated APISIX; which networks are trusted; how does one hop secret reach both processes; what is the server-only API origin — and the same for the CI job that renders the pages? What evidence discharges ADR-0036's "Phase 02d's browser test" and its matrix rows "a direct socket bypassing the hop" and "the Phase 02d anonymous two-host browser render", given that Testing Standards gate this phase on a human? And ADR-0036 § Consequences says the root refuses to start outside Development when the secret list is empty or short, while the shipped rule, in every mode, refuses a half-configured hop, a network entry that is not CIDR and a blank secret or one under 32 characters (characters, not bytes), and admits both lists empty: is that recorded or restored, and is non-development hop configuration this phase's or Phase 11's? | Both processes on the loopback, networks `127.0.0.1/32` and `::1/128`, one generated secret from a single source and never under `NEXT_PUBLIC_`, with networks and secrets arriving together (committing networks without secrets breaks every Development-environment fixture); the API called directly; a per-run secret in CI. Evidence: request-level hop tests as `learnstack_app` — no `X-Tenant-Id`, a non-hop peer, a wrong secret, a repeated header — beside the human walkthrough, with one review adding an automated browser smoke. Record the shipped startup rule; non-development hop configuration is Phase 11's | Contract: one dated [ADR-0036](../decisions/0036-tenant-resolution-trusted-inputs.md) amendment if the evidence departs from the ADR's words, recording the startup rule, and carrying G34 if G34 changes the key or budget. Detail: `.env.example`, `apps/web/.env.local.example`, `appsettings.Development.json` or the demo recipe; a Standards 21 row for the hop runtime test; a Testing Standards § End-to-End Tests sentence only if ownership moves; a Phase 11 scope row | P02d-5 (the hop configuration and the fixture shape — in-process test hosts have no socket peer), P02d-7 (the CI part) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): local topology, shared source and ingress; [Accepted — 2026-10-11](#p02d-7-decision-package-2026-10-10): shared CI lifecycle/topology; ADR-0056 measurement Accepted on the same date; implementation pending | | G34 | How does the pre-classification anonymous limiter treat a request arriving over the authenticated trusted hop? Every server-rendered call reaches the API from the renderer's peer, so every visitor of both tenants shares one partition, and one client sending random `Host` values through the renderer can starve both sites. The partition key, the budget and how the renderer derives any visitor identity it states — while unknown-host floods stay bounded before database work, and a direct peer is still limited per peer | The reviews differ: a visitor address stated over the hop, in a dedicated single-valued header or through `X-Forwarded-For` with the peer captured first, as ADR-0036 anticipates; a separate hop budget with limiting in the renderer; or an explicitly sized shared quota. A per-host ceiling as the only backstop multiplies under a random-`Host` flood | Contract: a dated ADR-0036 amendment if the hop changes the key or the budget, stating the new input's trust rule and whether it may be logged or audited; otherwise a phase-doc statement. Detail: API Standards § Request and Response Limits, [Security Standards § Rate Limiting](../standards/11-security.md#rate-limiting), the catalogue's per-peer rule. `P02b-0` re-verifies Phase 02b's G14 against the answer | P02d-5 | [Accepted — 2026-10-08](#p02d-5-accepted-answers): authenticated visitor and peer budgets | | G35 | The server SDK transport. Its options — visitor host, locale, an optional assertion, never a tenant id as selector; where the host comes from; how the API origin is configured; the server-only guard, timeouts and cancellation; and whether it forwards W3C `traceparent`. With it: which parts of [Observability Standards § Frontend Observability](../standards/10-observability.md#frontend-observability) — Next.js error capture, web vitals — ship here, and which phase owns the rest, since no phase names them | Host and locale plus an optional assertion; hop headers and origin from server configuration, never from request input; a `server-only` guard; Problem Details mapped to the `AppError` union [Error Handling Standards](../standards/09-error-handling.md) already fixes; `traceparent` forwarded; Next.js error capture and web vitals assigned to Phase 11, whose § Observability lists error tracking | Detail: Frontend Architecture Standards § SDK and the Frontend Architecture SDK sketch; a pin and licence verdict if a guard package is added; an exclusion row naming frontend observability's owner, with an Observability Standards sentence | P02d-5 (the transport's headers and configuration read); the ownership half closes by exit, because a deferral names its phase | [Accepted — 2026-10-08](#p02d-5-accepted-answers): configured caller, deadlines and observability owners | | G36 | The edge middleware and entry behaviour. Does the middleware resolve anything (with G25)? What does it carry inward, and under which header name — the Frontend Architecture sketch reuses `x-learnstack-host`, the hop header's own name? Which inbound internal headers are removed or overwritten, including `x-organization-id` when resolution has none — a deny-strip or an allowlist rebuild? What does the matcher exclude? What do `/` and a locale-less path answer, with which status, target and default-locale source; what do a disabled, malformed or non-canonical locale segment (G6 c), a platform host and an unknown host answer; does this run in middleware or the route tree, and may an i18n library own the middleware? Does this phase build the locale-less redirect [Localization Standards § URL Strategy](../standards/08-localization.md#url-strategy) requires, or keep the standards index's i18n-runtime carve-out while Phase 06 claims redirect handling? | Normalise the host; strip every client-supplied `x-tenant-id`, `x-organization-id`, `x-locale` and `x-learnstack-*`; drop the scaffold's `503` guard and TODOs; `/` redirects to the tenant's default locale; a disabled locale is a `404` before any content call; a platform or unknown host gets a `404` with no platform text; the redirect built minimally here, with Phase 06's rows reworded to "deepens" | Detail: a phase-doc statement; the Standards 07 § Tenant Resolution flowchart and the Frontend Architecture middleware sketch; Phase 06's rows in the same diff; if less is built, a dated narrowing of the standards index row for Localization Standards naming the owning phase | P02d-5 (the middleware replacement rewrites the scaffold's locale fallback, so every placement answer changes it first) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): membership-first entry and redirects | | G37 | How do tenant-varying `(public)` routes render, and which Next.js caches may hold tenant data — the full-route cache, the fetch data cache, `unstable_cache`, `generateStaticParams` — so one host's page is never served on the other? A public URL carries no tenant, and both tenants send the same request line over the hop, so a path-keyed cache leaks. What freshness does a page have after a customization or content write? | All three reviews: dynamic rendering with uncached SDK fetches — no `revalidate`, no `generateStaticParams`, no `unstable_cache` — relying on the API's generation-keyed cache; no ISR here | Detail: [Frontend Architecture Standards § Public Site Renderer](../standards/07-frontend-architecture.md#public-site-renderer), which prescribes `revalidate` today, and [Frontend Architecture § Rendering Strategies](../architecture/14-frontend-architecture.md#rendering-strategies), rewritten with the `add-frontend-route` skill; [Performance Standards § Caching](../standards/15-performance.md#caching) if the answer caches; an ADR if the pass judges the Standards 07 change non-trivial | P02d-5 (one mechanism: a host-bearing rewrite target is middleware code and fetch cache options are transport code, both written before the renderer) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): dynamic no-store renderer policy | -| G38 | The frontend test set. (a) Which predicates of the middleware and the server SDK does Vitest cover, and in which packages — `pnpm -r test` runs only packages with a test script, which `packages/sdk` lacks? (b) How are async Server Component pages and field components covered below the browser, given vendor guidance that Vitest does not render async Server Components? (c) What automated evidence, if any, re-proves the page-level two-host claim after exit — an HTTP smoke against `next start`, one narrow Playwright smoke pulled forward from Phase 06, or a dated manual record? (d) By what mechanism does the `frontend` job refuse skipped and todo cases, which it does not today, since `No_Architecture_Test_Is_Skippable`'s runner leg reads only the backend `.trx` files? | (a) host normalization and header stripping, locale parsing and entry answers, hop headers with no tenant selector, `not_found` mapping — each with an inversion companion; (b) async pages covered through their synchronous children; (c) the reviews split three ways; (d) a reporter-output check or a lint ban on disabled tests, failing also on a package with tests and no script, proven with a planted skip | Detail: a phase-doc statement; the test files; the Standards 21 entry `No_Architecture_Test_Is_Skippable` extended rather than a second name; `ci.yml`. Contract for (c) only if a browser smoke moves: a Testing Standards § End-to-End Tests edit citing this row, with its carriers | P02d-5 (a; d at the latest), P02d-6 (b, c), P02d-7 (c's job) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): (a,d) tests and non-skippability; [Accepted — 2026-10-09](#p02d-6-accepted-answers): (b,c) synchronous tests and required production HTML/RSC product proof; P7 owns the browser/demo job | +| G38 | The frontend test set. (a) Which predicates of the middleware and the server SDK does Vitest cover, and in which packages — `pnpm -r test` runs only packages with a test script, which `packages/sdk` lacks? (b) How are async Server Component pages and field components covered below the browser, given vendor guidance that Vitest does not render async Server Components? (c) What automated evidence, if any, re-proves the page-level two-host claim after exit — an HTTP smoke against `next start`, one narrow Playwright smoke pulled forward from Phase 06, or a dated manual record? (d) By what mechanism does the `frontend` job refuse skipped and todo cases, which it does not today, since `No_Architecture_Test_Is_Skippable`'s runner leg reads only the backend `.trx` files? | (a) host normalization and header stripping, locale parsing and entry answers, hop headers with no tenant selector, `not_found` mapping — each with an inversion companion; (b) async pages covered through their synchronous children; (c) the reviews split three ways; (d) a reporter-output check or a lint ban on disabled tests, failing also on a package with tests and no script, proven with a planted skip | Detail: a phase-doc statement; the test files; the Standards 21 entry `No_Architecture_Test_Is_Skippable` extended rather than a second name; `ci.yml`. Contract for (c) only if a browser smoke moves: a Testing Standards § End-to-End Tests edit citing this row, with its carriers | P02d-5 (a; d at the latest), P02d-6 (b, c), P02d-7 (c's job) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): (a,d) tests and non-skippability; [Accepted — 2026-10-09](#p02d-6-accepted-answers): (b,c) synchronous tests and required production HTML/RSC product proof; P7 owns the browser/demo job; [Accepted — 2026-10-11](#p02d-7-decision-package-2026-10-10): narrow browser-job scope; ADR-0056 measurement Accepted on the same date; implementation pending | | G39 | Is [ADR-0027](../decisions/0027-frontend-i18n.md), the frontend i18n library, Accepted in this phase rather than Phase 04, or do this phase's pages meet a library-neutral message contract under the standards index's carve-out? Where does the one UI string catalogue live — the carriers name three paths? | The reviews differ: Accept at first use (`next-intl` composed with the tenant middleware, with its pin and licence verdict), or move only the minimum slice — catalogue loading, lookup, layout locale, `lang`. A third option, no platform-authored text, is hard for a skip link or a not-found page | Contract: ADR-0027 Accepted, with the decisions index row, Phase 04's ADR-0027 lines and the standards index row in the same diff — which, under [the decisions index SLA](../decisions/README.md#open-adr-drafts), makes it an exit blocker here — or a narrowed carve-out plus a phase-doc statement. Detail: [Localization Standards § Strings in Code](../standards/08-localization.md#strings-in-code), [Localization § UI String Catalogue](../architecture/12-localization.md#ui-string-catalogue), the `add-i18n-key` and `add-frontend-route` skills | P02d-6 (the first platform string, message loading and catalogue files) | [Accepted — 2026-10-09](#p02d-6-accepted-answers): ADR-0027, exact pin and one checked UI catalogue home | | G40 | Route files, page states and site chrome. What happens to `(public)/page.tsx`'s platform placeholder, and to `/studio` and `/portal` on tenant hosts; is the `courses` segment fixed, and which phase owns localized section names? Does this phase ship `(public)` loading, error and not-found files — [Frontend Architecture Standards § Routing](../standards/07-frontend-architecture.md#routing) requires `loading.tsx` and `error.tsx` per route group, and a not-found page is this phase's own choice; how do SDK `not_found`, a cursor `validation_failed`, unavailable and `429` map to page states; what do an empty catalog and a course with no eligible lesson show; does the catalog render a next-page link? Does a minimal chrome ship? Are `hreflang`, canonical and `og:locale`, which [Localization Standards § SEO](../standards/08-localization.md#seo) requires on translated public pages, built here or carved out? | The placeholder leaves the public tree; a fixed `courses` segment with the section-name owner named; minimal state files in tenant tokens; `not_found` → an HTTP `404` page; unavailable or `429` → the route group's error page without disclosure; an explicit empty state; a next-page link over enough seeded courses; in-page links rather than chrome, keeping Phase 06's navigation rows true | Detail: a phase-doc statement; Phase 06's § What Phase 02d already shipped rows reworded; a dated carve-out in the standards index row for Frontend Architecture Standards or Localization Standards, naming the owning phase, for whatever this phase builds less of | P02d-6 | [Accepted — 2026-10-09](#p02d-6-accepted-answers): product routes, approved status/URL chain, page states and metadata | | G41 | How does the lesson page draw what the subset does not implement — an out-of-subset `x-renderer`, a missing optional field, an array of objects, a stored value whose type differs from its declaration, an `x-taxonomy` value and its missing band? And where do composite and primitive components live — Frontend Architecture Standards names `packages/blocks`, Frontend Architecture names `components/blocks/`, and the registry sits in `apps/web/src/lib/customization/`? | A safe placeholder, never an exception and never raw JSON; a missing optional field renders nothing; `integer`, `boolean` and enums as text; an `x-taxonomy` value as the band's display name in the requested locale. No review addresses the component home | Detail: Tenant Customization Model § 2 (the implemented subset, not a second list) and § 8.1; Frontend Architecture Standards § Public Site Renderer and the Frontend Architecture tree. A new primitive would be an ADR-0018 release, which this row must not assume, since Phase 04 owns the field-type set | P02d-6 | [Accepted — 2026-10-09](#p02d-6-accepted-answers): ordered plain-string components and bounded fallbacks | | G42 | How do validated branding tokens reach the server-rendered HTML — a `style` attribute on the root element, which needs `unsafe-inline` or `unsafe-hashes`; a nonce-compatible `` — never reaches a rendered document, and a refused write commits neither … | TenancyWriterTests branding refusal/atomicity, BrandingThemeTests, product theme defenses. | B, I, F | +| C28 | A branding key written as an organization-scoped `tenant_settings` row behaves as **G16** (e) records, checked request-level through a host mapped to the organization: refused … | PublicLocaleEvolutionHttpTests.Organization_branding_writer_is_refused_with_denied_audit_and_mapped_host_keeps_tenant_palette; local focused case passed; one expected Denied audit, no successful setting mutation; final I pending. | I, M | +| C29 | If **G19** includes a write-time rule, a lesson write holding a disallowed URL is refused with details naming the JSON pointer, and nothing is … | G19 Accepted text profile introduces no active URL sink or scheme write-time rule. | N | +| C30 | Whatever **G18** refuses at save — which may include a presentation entry naming a property absent from `properties`, a malformed label map or a … | TextCardPresentationTests, customization command/schema validation tests. | B | +| C31 | A course write naming a taxonomy revision or band key the tenant does not declare, including one only the other tenant declares, returns `validation_failed` … | EducationWriterTests and EducationWriterValidationTests taxonomy/band binding validation. | B, I | +| C32 | Under **G15**'s answer, `SeedRunner` either no longer announces its own tenant context or appears in ADR-0040's setter table, and a planted caller fails any … | SeederConventionTests and contextual ownership verification/caller fence with planted offenders. | B | +| C33 | With the API running, publishing a successor content type or taxonomy for one tenant through its command changes what the next read returns for … | CustomizationProjectionTests/cache suites and production presentation successor/rebinding fixture. | B, I | +| C34 | A second warm read for the same tenant and generation issues no definition-set query; a publish that rolls back after its generation bump leaves … | CustomizationProjectionTests (cache partial), composition/publication concurrency tests. | B, I | +| C35 | None of the public reads, and no definition or settings read, invokes `IJsonSchemaValidator`. | CustomizationProjectionTests and architecture read-path guards. | B, I | +| C36 | If **G23** caches settings, then after that cache is warmed in the yoga studio's default organization, a read in the sibling organization's context and … | G23 selects no cache; TenantSettingsAccessorTests/TenantSettingsTests prove ambient scoped reads/current values. | B, I, N | +| C37 | Every cache family this phase adds appears in the cheat sheet, the Observability Standards family list and the `cache.name` mapping, and none of its … | InMemoryCacheServiceTests and three named cache-family carrier lists. | B, M | +| C38 | For a request in an enabled `tr-TR`, a label authored only under `tr` resolves as the chain **G24** records, and a value missing in … | PublicEducationDisplayTests and locale-resolution/projection tests; P3/P4 fallback records. | B, I | +| C39 | The out-of-band setter guard stays green: either the setter table is unchanged, or the ADR-0040 amendment and Security Standards row land with the loader. | Out-of-band setter guards and P2/P3 approved setter decisions. | B, M | +| C40 | In one test, a course slug that exists only in tenant B returns `200` with that course on tenant B's host and `404` on … | PublicEducationHttpTests and TenantIsolationHttpTests paired positive/negative host cases. | I, M | +| C41 | In the same test, a course returns `200` at its slug in a locale it is translated into and `404` for that slug under … | PublicEducationHttpTests.Course_and_lesson_use_exact_translations_and_real_alternate_url_pairs and Missing_exact_translation_never_uses_default_content_or_advertises_disabled_alternates. | I | +| C42 | On the organization host, a sibling organization's course is absent from the catalog and its slug returns `404`, while a tenant-wide course and its … | PublicEducationHttpTests.Organization_host_never_serves_a_sibling_organization and isolation suite raw satellite cases. | I | +| C43 | A draft course is absent from the catalog, and its detail slug and every lesson requested under it answer per **G29**; a lesson of … | PublicEducationHttpTests.Course_draft_branch_foreign_and_unknown_are_uniformly_hidden and Lesson_masks_draft_parent_draft_restricted_scope_wrong_parent_and_foreign_rows. | I | +| C44 | Each of the reads without `locale` returns `400` `validation_failed` naming `locale`, never a `500` or a defaulted locale; sending a different `X-Locale` or `Accept-Language` … | PublicEducationHttpTests query/detail/unsupported-locale cases including Well_formed_unsupported_locale_is_400_and_headers_do_not_replace_explicit_locale. | I | +| C45 | A cursor value the catalog list cannot read — malformed or truncated — returns `400` `validation_failed` naming `cursor`, never `500`. Walking `nextCursor` with a … | PublicEducationHttpTests query-shape/cursor/seek cases, PublicReadProtocolTests and OpenAPI exact parameter controls. | B, I, O | +| C46 | A course's embedded lesson list returns the same order on every read, including for any sort values **G2**'s invariant permits to tie. | PublicEducationStoreTests and PublicEducationHttpTests catalog/outline seek-order cases. | I | +| C47 | A lesson whose bound `(key, schema_version)` revision cannot be resolved (a fixture removes it) answers as **G12** records — never a `500`, and never … | PublicEducationHttpTests/PublicEducationDisplayTests and product presentation fault mode. | B, I | +| C48 | A stored band that the resolved taxonomy revision does not declare yields the state **G5** records, never a `500` and never another tenant's band … | PublicEducationDisplayTests, PublicEducationHttpTests and product band-fault mode. | B, I | +| C49 | On each seed host, each shipped anonymous read returns `200` under a host-only context, and the same request on an unknown host returns the … | PublicSiteHttpTests/PublicEducationHttpTests; PublicSurfaceTests/PublicReadTransactionTests runtime refusal/positive control and structural dispatch offenders. | B, I, M | +| C50 | Accepted **G28** records `Off`; serving anonymous reads on both hosts adds no `audit_log` rows. | PublicEducationHttpTests.Catalog_is_exact_locale_host_scoped_and_only_marketing_with_no_normal_audit and PublicSiteHttpTests. | I | +| C51 | Every anonymous response — a catalog `200`, a detail `404`, a bad-cursor `400` and an unmapped-host `404` — carries the directive **G27** decides, and … | Public HTTP no-store/validator cases and PublicServerRenderingTests A/B/A product fixture. | I | +| C52 | The committed OpenAPI document lists exactly the public operations the register decides, each with `locale` required on the Education reads, and a planted extra … | OpenApiContractTests and PublicEducationHttpTests exact public operation/DTO/status/bounded-list/alternate cases. | B, I, O | +| C53 | P02d-4 proves SDK wrapper coverage of all four logical GET contracts and HTTP coverage of all eight GET/HEAD operations, with a planted missing-operation companion. … | P4 SDK missing-operation/wrapper tests and eight GET/HEAD HTTP coverage; P5 configured/P6 every logical-page consumers. | B, I, F | +| C54 | The contract suite fails when the served `/openapi/v1.json` differs from the committed snapshot, shown with a companion; the breaking-change job fails on a planted … | OpenApiContractTests served snapshot/deny-list controls; P4 pinned oasdiff policy/offender suite; SDK drift/typecheck controls. | B, F, O | +| C55 | Each activated check has no `(deferred …)` suffix in `ci.yml`, appears in CONTRIBUTING's required list and in the live required contexts, and its skip … | P1-P6 dated merge/check/protection receipts exist. | O, J | +| C56 | `Handlers_Return_Result` stays green with Education's handlers counted, and an Education handler changed to return a raw DTO fails the build (`backend`). | Handlers_Return_Result with nonempty Education handlers and raw-DTO companion. | B | +| C57 | On both seed hosts the catalog renders through the Next.js server while no server-to-API call carries `X-Tenant-Id`, each host showing only its own tenant's … | PublicServerRenderingTests/hop HTTP tests and P6 manual walkthrough; Step3 browser feasibility. | I, J, H | +| C58 | Neither the built client assets nor rendered HTML contain the hop secret value, and no `NEXT_PUBLIC_` variable carries it. Only `frontend/apps/web/src/server/configured-public-client.ts` sets hop headers … | public-boundaries.test.ts/configured-public-client.test.ts and real production client-import/build probes. | I, F | +| C59 | Client-supplied `x-tenant-id`, `x-organization-id`, `x-locale`, `x-learnstack-host` and `x-learnstack-hop-secret` never reach an SDK call's outbound headers unchanged; under the production build and mandatory native launcher, public … | public-entry/admission/runtime tests and PublicAdmissionRenderingTests. | I, F, M | +| C60 | With private hop configuration kept outside version control, ordinary no-hop API startup works under committed Development settings with no `.env` present, and every Development-environment … | TrustedHopConfigurationTests and ordinary Development fixture baseline. | B, I, M | +| C61 | A non-hop peer is still limited per socket peer, getting `429` with `Retry-After` over budget, and rotating `X-Forwarded-For` or any header **G34** introduces buys … | RateLimitingHttpTests, anonymous request identity/admission/lifecycle and unknown-host cache tests. | B, I, J | +| C62 | If **G35** places it here, a server-to-API call carries a `traceparent` whose trace id matches the API's Problem Details `traceId`. | PublicServerRenderingTests transport mode and configured-public-client.test.ts W3C propagation/refusal controls. | I, F | +| C63 | On a production build, one `(public)` path requested on host A, then B, then A returns each tenant's own markers every time; the build … | PublicServerRenderingTests.Production_rendering_is_host_isolated_fresh_and_private_through_the_real_public_API and frontend forbidden-cache offenders. | I, F | +| C64 | Each rendered public page's `` equals the locale in its path, on both locales of the bilingual tenant, and `dir` follows that locale. | P6 lang/dir product/route assertions; Step3 actual product-document checks. | I, F, J | +| C65 | Each tenant-host page has one `
`, no skipped heading level, a skip link and a descriptive `` rather than a fixed platform string, and … | P6 public-ui/route/metadata/lint-rule tests and product assertions. | I, F, H | +| C66 | Catalog to lesson works keyboard-only on both hosts with focus always visible, each page reflows at 320 CSS px, and the text and UI-component … | P6 manual record on 180dde0: Brave154.1.96.61/macOS27.0.1, keyboard English/Turkish flow, visible focus, 320CSSpx desktop reflow, calculated palettes; maintainer VoiceOver confirms both flows. PR27 description preserves attribution and links original manual evidence. | H | +| C67 | On the two-locale tenant, every visible platform-authored string resolves through the message layer **G39** records, in both locales; Localization Standards § Strings in Code, … | ADR-0027 i18n catalogue/ICU controls and WEB messages. | F, M | +| C68 | Tenant B's hidden course URL on host A returns a local HTTP `307` to the fixed `/{locale}/status/not-found` URL, followed by visible localized HTTP `404` … | public-route/resource/admission tests; PublicServerRenderingTests/PublicAdmissionRenderingTests fixed redirect/status and fault modes. | I, F | +| C69 | A page whose course or lesson carries a band the resolved revision does not declare renders the state **G5** records, without throwing and without … | P6 UI and product band-fault tests. | I, F | +| C70 | Field values containing `<script>`, an `<img onerror>` fragment and a `javascript:` URL render inert, and a `data:` or `http:` URL is rendered only if … | P6 inert plain-text/fallback renderer tests, shared ordered-field predicate and product presentation fault modes. | I, F | +| C71 | A branding token value containing `;`, `}`, `url(` or `</style>` never reaches rendered HTML, and the theme is emitted only as `--ls-*` custom properties … | Theme and public-boundaries tests; real production fixture and Step3 network/product checks. | I, F, J | +| C72 | A non-branding setting present for a tenant (the fixture's `tz` row) appears in no `[PublicSurface]` response body and in no rendered HTML, on either … | PublicSiteHttpTests/PublicEducationHttpTests and product rendering privacy checks. | I | +| C73 | A change that adds `it.skip`, `describe.skip` or `it.todo` to any Vitest file under `frontend/` fails the required `frontend` check, and each predicate in **G38**'s … | Guarded frontend runner planted controls; P5/P6 product predicates; Step3 browser hard admission. | I, F, J, M | +| C74 | No production code branches on which tenant it serves. The mechanism is **G20**'s: registered in the catalogue, Implemented and green in a required check … | Step2 DomainGenericityTests.DemoIdentities.cs, demo-genericity.test.ts, Seeder-reference fence and production presentation successor companion. | B, I, F | +| C75 | No Education type, member, column, key or DTO name carries a forbidden domain term, and Education references Customization only through its `Application.Contracts` assembly (`backend`). | DomainGenericityTests and module-dependency guards. | B | +| C76 | If **G44** activates it in this phase, the Lighthouse job runs real steps under a name without "(deferred to Phase 02d)", audits the URL … | Step3 complete local nineURL x threeRun feasibility, report/gzip/admission/offender controls and zero429 positive observer. | J | +| C77 | Every register row is closed in the form **G1** chose; every Deliverable is observed by at least one criterion; no catalogue row whose Phase … | Four P7 behavioral entries are Implemented with Node owners, planted controls and the always-running public-demo job; CorpusConsistencyTests enforces status/count alignment. | B, I, F, J, M | +| C78 | Every row in § Explicitly not in this phase names a phase whose own document carries that capability in its scope, its deliverables or … | Owner audit X01-X39 below; current output/seed-host carriers partly stale. | M | +| C79 | The documentation Deliverables are in the tree at exit: the Education spec's `README.md` and `permissions.md` beside `audit.md`, with its state diagram and the eligibility … | Existing Education/Customization/Testing/schema/skill files and Phase05 preservation baseline. | M | + +C07 is conditional: G32 retains `*.learnstack.local`, so no seed-host migration +is required. C29 is conditional: P6 introduces no authored URL/media sink; +Phase 04/05/06 retain the named future contracts. C36 is conditional: G23 selects +uncached settings, so no settings-cache eviction rule is claimed. Other named +rows retain their full canonical conditions even when a locator is abbreviated. + +The two new `PublicLocaleEvolutionHttpTests` cases passed locally with zero skips. +They use the normal API-root pipeline and actual mapped-host HTTP, under +`learnstack_app`, physical READ ONLY and non-BYPASSRLS. French-only new roots are +authored while Draft; published seeded roots are not edited to create the proof. +All five migration histories and complete pre-existing EN/TR DTOs remain equal. +The organization writer refusal commits exactly its expected Denied audit; +public reads remain audit Off. Final receipt I must include both cases. + +## Exclusions and future owners + +These are explicit phase boundaries, not unfinished P7 implementations. The +named owners' documents carry the handoff; no future decision gate is accepted +by listing its phase here. + +| ID | Exclusion locator | Named owner | Evidence and boundary | +|---|---|---|---| +| X01 | Authentication, sessions, login | [Phase 02b](phase-02b-events-auth.md) | Phase02b P02b-5/6/7, Identity/session scope and criteria. | +| X02 | Token-keyed authenticated and write rate-limit budgets, and what the pre-authentication limiter does once a caller is validated | [Phase 02b](phase-02b-events-auth.md) (G14) | Phase02b G14/P02b-5 and whole-chain two-principal quota criterion. | +| X03 | Keycloak realm reconciliation (a seed step that writes to Keycloak) | [Phase 02b](phase-02b-events-auth.md) (G12) | Phase02b G12/P02b-6 and warm-realm repeat-seed criteria. | +| X04 | The `learnstack.tenancy.settings` eager invalidation event | [Phase 02b](phase-02b-events-auth.md), per [the Tenancy spec](../modules/tenancy/README.md) | Phase 02b Event Bus scope, deliverable and completion criterion explicitly own learnstack.tenancy.settings; the Tenancy catalogue names the same owner. | +| X05 | Isolation tests through authenticated or id-addressed routes | [Phase 02b](phase-02b-events-auth.md) | Phase 02b completion criteria explicitly include authenticated and id-addressed tenant/organization isolation with app-role denial and successful controls. | +| X06 | Identity domain, roles, permissions, invitations; permission keys for public reads; the rule that every endpoint carries `[Authorize]` or `[AllowAnonymous]` | [Phase 03](phase-03-identity-admin.md) | Phase03 Identity/authorization/invitations scope and deliverables. | +| X07 | A tenant-scope read across all organizations on a tenant host (the `app.scope` carrier) | [Phase 03](phase-03-identity-admin.md) | Phase03 Authorization explicitly owns app.scope and tenant-wide cross-organization carrier. | +| X08 | CMS editing, page builder, media library and tenant media origins | [Phase 04](phase-04-cms-media-pages.md) | Phase 04 Media security owns the tenant media-origin allow-policy, active URL sinks and corresponding delivery/validation criteria. | +| X09 | Per-locale publish readiness workflow, `tenant_route_slugs` registry | [Phase 04](phase-04-cms-media-pages.md) | Phase04 Page Model/Localization and tenant_route_slugs deliverable. | +| X10 | Studio authoring of translated field values (titles, bodies, slugs) and the view of untranslated gaps — where it lives is an open question | [Phase 04](phase-04-cms-media-pages.md#admin-studio-cms-screens); its screen row goes in [Phase 06 § Admin Studio — screen ownership](phase-06-renderer-admin-studio.md#admin-studio--screen-ownership) | Phase04 Admin Studio CMS Screens explicitly registers question of translated-field/gap UI placement and points to Phase06 screen ownership table. | +| X11 | `Accept-Language` negotiation for API-returned messages; the per-tenant locale fallback chain; the `/{locale}/{slug}` page routing shape | [Phase 04](phase-04-cms-media-pages.md) | Phase04 Localization scope explicitly lists per-tenant fallback, /{locale}/{slug}, publish readiness and Accept-Language API-message negotiation. | +| X12 | Authoring and translating a content type's field order and labels; the closed set of built-in primitive field types (number, boolean, date/time, select) | [Phase 04](phase-04-cms-media-pages.md) | Phase 04 Content Type System explicitly owns field order and localized label authoring; built-in field types remain a platform release boundary. | +| X13 | The schema-version migration path for stored instances; deleting a content-type revision after a zero-instance count | [Phase 04](phase-04-cms-media-pages.md) | Phase04 exact revision deletion requires zero-instance count; lazy/bulk schema migration explicit. | +| X14 | Customization deprecate and revise commands, and per-band taxonomy editing | [Phase 04](phase-04-cms-media-pages.md) and [Phase 05](phase-05-education-learning-content.md), consolidated in [Phase 06](phase-06-renderer-admin-studio.md) | Phase 04 owns deprecate/revise commands; Phase 05 owns per-band taxonomy editing, with Phase 06 consolidating Studio screens. | +| X15 | Tenant-authored page composition (`TenantPageBlock` rows and their cache family) | [Phase 04](phase-04-cms-media-pages.md); the block resolver is [Phase 06](phase-06-renderer-admin-studio.md)'s | Phase04 TenantPageBlock aggregate/migration/editor/renderer deliverable; Phase06 complete block resolver. | +| X16 | Deciding whether a customization change owes an integration event | [Phase 04](phase-04-cms-media-pages.md), per [the Customization spec § Integration-event catalogue](../modules/customization/README.md#integration-event-catalogue) | Phase04 Content Type System explicitly owns whether customization change owes integration event. | +| X17 | The `Redirect` model the CMS auto-creates when a published slug changes | [Phase 04](phase-04-cms-media-pages.md) | Phase04 Page Model/Localization Redirect auto-creation and shared namespace. | +| X18 | Search — the `ITenantSearch` port and its PostgreSQL default | [Phase 04](phase-04-cms-media-pages.md) | Phase04 Search port/PostgreSQL default section. | +| X19 | Search — the Meilisearch adapter behind that port | [Phase 09](phase-09-billing-integrations-analytics.md) | Phase09 Search/Meilisearch adapter deliverables and trigger. | +| X20 | Course versioning, programs, lesson items, completion rules; richer publish-readiness validation and versioned publication; catalog visibility separate from publication | [Phase 05](phase-05-education-learning-content.md) | Phase05 Catalog/Course versioning/lesson items/completion/runtime scope. | +| X21 | The migration that brings this phase's courses and lessons under course versions and modules | [Phase 05](phase-05-education-learning-content.md) | Phase05 What Phase02d supplies explicitly preserves existing rows/IDs/URLs/order/scope/translated bodies/exact pins/access policy in migration; re-seeding forbidden. | +| X22 | The authenticated course and lesson authoring surface, with the commands that edit a course or lesson or reorder lessons after the seed | [Phase 05](phase-05-education-learning-content.md) | Phase 05 owns authenticated post-seed edit/reorder/unpublish/delete lifecycle and its decisions; no such writer is claimed by P7. | +| X23 | The `Level` aggregate and the catalog API's levels resource; the `TenantLevelTaxonomy` editor | [Phase 05](phase-05-education-learning-content.md) | Phase05 Catalog Level/resource inheritance and Studio TenantLevelTaxonomy editor explicit. | +| X24 | The `TenantLessonItemType` read, the batched reference walk and the measured customization cost model; the `embed-html` sanitisation contract | [Phase 05](phase-05-education-learning-content.md) | Phase05 inherited TenantLessonItemType read, batched reference/cost model and embed-html contract. | +| X25 | Admin Studio, navigation menus, SEO metadata beyond what G40 settles for translated public pages, full block registry | [Phase 06](phase-06-renderer-admin-studio.md) | Phase06 renderer/Studio/block registry/navigation/full SEO scope. | +| X26 | The full `UnknownVersionBlock` / `UnknownBlock` placeholders and per-block error boundary; tenant-authored error pages; redirect handling | [Phase 06](phase-06-renderer-admin-studio.md) | Phase06 renderer explicit UnknownVersionBlock/UnknownBlock/per-block boundary/tenant404/redirects. | +| X27 | Branding configuration surface — tenant-admin editor, theme preview, logo, header and footer settings; the per-organization branding override (`OrganizationBranding`) and the token merge | [Phase 06](phase-06-renderer-admin-studio.md) | Phase06 Tenant branding/own Studio work explicit logo/header/footer/preview/OrganizationBranding merge. | +| X28 | Preview of draft courses and lessons through the production renderer | [Phase 06](phase-06-renderer-admin-studio.md) | Phase06 own Studio work explicitly preview published/draft through production renderer. | +| X29 | Browser end-to-end flows (Playwright) and axe checks through Playwright | [Phase 06](phase-06-renderer-admin-studio.md), per [Testing Standards § End-to-End Tests](../standards/06-testing.md#end-to-end-tests); any narrow smoke this phase adopts is G38 | Phase 06 owns full Playwright Test/axe flows; the narrow P7 Playwright-library browser and Lighthouse proof is explicitly separated. | +| X30 | Enrollment, learner portal, progress tracking; Course Access — whether content published anonymously here stays on the public path once enrollment exists | [Phase 07](phase-07-enrollment-learner-portal.md) | Phase07 enrollment/portal/progress/CourseAccess and public-path-vs-enrollment boundary explicit. | +| X31 | Live classroom | [Phase 08c](phase-08c-classroom.md) | Phase08c Live classroom/ILiveClassProvider/LiveKit deliverables. | +| X32 | Billing | [Phase 09](phase-09-billing-integrations-analytics.md) | Phase09 billing scope/deliverables. | +| X33 | Hub, entitlement gating | [Phase 02c](phase-02c-hub-foundation.md) | Phase02c Hub-backed entitlement/provider/enforcement scope. | +| X34 | APISIX as the edge gateway for a non-development deployment; gateway or CDN caching; edge rate limiting | [Phase 11](phase-11-production-hardening.md#security), on [ADR-0035](../decisions/0035-demand-gated-infrastructure.md)'s trigger | Phase 11 explicitly owns gateway/CDN response caching, authority keys, invalidation, private-content exclusion and its demand trigger. | +| X35 | Plan-differentiated API rate limits (`LimitKeys.ApiRatePerMinute`) | [Phase 11](phase-11-production-hardening.md#security) for the key's gate; [Phase 02c](phase-02c-hub-foundation.md) for its enforcement path | Phase11 Security explicitly owns LimitKeys.ApiRatePerMinute gate and links Phase02c generic enforcement path. | +| X36 | The L2 cache tier behind `ICacheService` (default `InMemoryCacheService`) | [Phase 11](phase-11-production-hardening.md), on [ADR-0035](../decisions/0035-demand-gated-infrastructure.md)'s trigger | Phase11 explicit Valkey-backed ICacheService/L1-L2 trigger. | +| X37 | Content-Security-Policy and the other secure headers | [Phase 11 § Security](phase-11-production-hardening.md#security), per the [standards index](../standards/README.md#honest-status-today) row for Security Standards | Phase11 Security explicit secure headers/CSP. | +| X38 | `GET /readyz`; the production Dockerfile and image pipeline; the performance baseline and load tests against Performance Standards | [Phase 11](phase-11-production-hardening.md) | Phase11 readiness/deployment images/performance/load-test scope/deliverables. | +| X39 | Custom-domain TLS automation | [Phase 11](phase-11-production-hardening.md), on [ADR-0035](../decisions/0035-demand-gated-infrastructure.md)'s trigger | Phase11 explicit custom-domain TLS ACME/DNS/renewal trigger. | + +## Phase-exit reconciliation + +| ID | Obligation | Required evidence | +|---|---|---| +| E01 | Every Completion Criterion holds with named/manual evidence | All C01-C79 rows, the two new combined HTTP/pipeline cases; actual B/I/F/O/J/H receipts linked at exact final head where applicable. | +| E02 | Every register row closed through G1 vehicle and carriers, including G32 development transport | Dated closure/link census; Accepted ADRs retained, implementation receipts distinct from decisions; Phase02b native HTTPS carriers reconciled. | +| E03 | Phase02a and Education schema/request isolation green as app role, zero skips, required | Exact final backend/backend-integration TRX/rollup, role/isolation evidence and skip guard. | +| E04 | OpenAPI/SDK/Lighthouse required and shown able to fail; live list/date; no deferred job names | O/J offender controls, successful final real PR rollup, dated seven-context strict protection read-back, all other settings preserved. | +| E05 | Clean make demo prints both working addresses; sites render with Keycloak stopped | J clean lifecycle/readiness/Keycloak status/browser/artifact/cleanup receipt; H human context retained. | +| E06 | G20 Implemented and green required | B/F nonempty census and dirty/clean controls, I schema-replacement companion, Step2 record. | +| E07 | Accessibility and renderer PR record | D31/C66 PR27 link and original manual attribution plus F/I/J automated controls; no inferred new manual pass. | +| E08 | Zero 02d Registered/Awaiting catalogue rows and standard/index alignment | Four P7 promotions with actual behavioral owners and hard CI, computed counts and Standard_Status_Headers_Match_The_Index exact-head receipt. | +| E09 | Delivery record names moved P02b-0 premises | /api/v1 contract, *.learnstack.local native HTTPS/manual trust, visitor+peer quotas, seed default-org/tenant scopes, no-cache settings/eager event owner, single bootstrap; do not Accept auth/BFF future gates. | + +The [Step 4 preservation and P02b-0 handoff](phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) +names the retained Education data, live API/host/trust/limiter/bootstrap premises +and future settings-event ownership. Phase 05 migrates the existing records; it +does not treat reseeding as migration. Course Marketplace ADR-0049 and Phase 09a +remain Proposed and are outside this exit. + +A positive phase-exit verdict requires the final receipts and both Step 4 review +rounds above. Maintainer PR review and merge are separate actions. diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index 8413caa9..043ca445 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -15,7 +15,7 @@ > | P02d-4 | Public read API and contract checks | ✅ complete and merged — 2026-10-08; [merge closeout](#p02d-4-merge-and-closeout-2026-10-08) | > | P02d-5 | Server-rendering path | ✅ complete and merged — 2026-10-09; [merge closeout](#p02d-5-merge-and-closeout-2026-10-09) | > | P02d-6 | Public renderer | ✅ complete and merged — 2026-10-10; [merge closeout](#p02d-6-merge-and-closeout-2026-10-10) | -> | P02d-7 | Demo, full-stack CI and exit | decision pass Accepted — 2026-10-11; [decision package](#p02d-7-decision-package-2026-10-10); Steps 1–3 complete; [Step 3 validation](#p02d-7-step-3--browser-and-audit-proof-2026-10-11); Step 4 pending | +> | P02d-7 | Demo, full-stack CI and exit | decision pass Accepted — 2026-10-11; [decision package](#p02d-7-decision-package-2026-10-10); Steps 1–3 complete; [Step 4](#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) in progress | **Acceptance update — 2026-10-02.** P02d-1 remains merged. The maintainer accepted ADR-0050/0051 and the [P02d-2 package](#p02d-2-decision-package-2026-10-02), including @@ -433,7 +433,7 @@ premise a row cites is re-verified at that pass rather than trusted. | G17 | Does `TenantSetting.Value` carry `[PiiSensitive]`? [Phase 03](phase-03-identity-admin.md) sequences the decision before the first command writing `tenant_settings`, and this phase ships that command | Not marked, provided `tenancy.setting.write` admits only G16's closed key set, so the answer cannot stretch to keys a tenant invents; modelling a sensitive part as its own property stays open to Phase 03 | Contract: a dated phase-doc statement, reflected in `TenantSetting.cs`, the Tenancy spec and `audit.md`. Whole-value redaction of `jsonb` is settled by [ADR-0044](../decisions/0044-audit-write-path.md) Amendment 4 § 1 | P02d-2 (the first MUST-class settings audit row is written by the seed, and rows cannot be redacted retroactively); closes with G16 (a) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): generic whole-value PII redaction before the writer | | G18 | How is a tenant content type presented? `json_schema` is `jsonb`, which keeps no key order, and the schema profile collects only `x-renderer`, `x-taxonomy` and `x-language`. How are field order, a label per enabled locale and a composite's field roles carried; which registered composite draws a lesson for each seeded type; which primitives does this phase implement, and does `markdown` render; how do types with no primitive row (`integer`, `number`, `boolean`, enums) map; may a rendered type declare a field outside the subset; and is a presentation entry naming a missing property refused at save? | A LearnStack extension — `x-order` and `x-label`, or one ordered `x-fields` list — carrying Pattern B labels, resolved at write like `x-taxonomy`; one composite already in both registries; the reviews split on the subset — `text`, `list` and `link`, with `markdown` without raw HTML, or a placeholder until Phase 05's sanitiser; the seed uses only the subset | Contract: a dated ADR-0043 amendment for a keyword or a save-time refusal; a dated ADR-0018 amendment for a presentation column; a phase-doc statement for `title` plus `required`, which cannot carry two locales. Detail: [Tenant Customization Model § 2](../architecture/32-tenant-customization-model.md) and § 8.1, the Customization spec, the profile's extension and reference-graph skip lists, `composites.ts` | P02d-2 (the seed publishes both content types as `schema_version` 1 with their renderer keys and field kinds; a later answer needs successor revisions) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): ADR-0051 profile and first-render subset. Component placement/fallback remains G41 | | G19 | URL and markup policy for tenant-authored values on an anonymous page: which schemes (`https` only, or `http` too), credentials and `target`, which media origins, whether the rule is enforced on write — in the Education command, or as a validation gate Phase 04's entries share — whether the public API filters too, and whether URLs inside markdown fall under it. The write-time check constrains structure, not schemes: `format: uri` admits `javascript:` and `data:` | The reviews split on `http`; all refuse `javascript:`, dangerous `data:` and credentials; checked on write by a LearnStack rule and again on render; no third-party media in the seed | Detail: one home for the scheme list — [Security Standards § XSS & Output Encoding](../standards/11-security.md#xss--output-encoding) or [Frontend Architecture Standards § Security](../standards/07-frontend-architecture.md#security), not both; the Education spec's write rules; Tenant Customization Model § 8.1 if checked on write. Contract: a dated ADR-0043 amendment if it becomes a shared validation gate | P02d-2 (the lesson command's validation and the seed values; the render-time check reuses the answer) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): no active sink in the seeded text profile; future URL/markup contracts precede Phase 04/05 sinks | -| G20 | What mechanically backs "no production code branches on which tenant it serves"? The shipped domain-term scan strips literals and exempts seed data. (a) The mechanism and its literal source; (b) its subjects, matching and the platform built-ins; (c) its exemptions, including development hosts in frontend or infrastructure configuration; (d) whether a ban on production references to `LearnStack.Tools.Seeder` and a behavioural same-code, different-data test accompany it | A Standards 21 sibling row scanning production backend and `frontend/` sources, comments stripped, for exact identity literals read from `SeedData` (slugs, ids, hosts, display names, customization keys), built-ins excluded, with planted offenders; plus the behavioural test. The exemption policy is the owner's judgement | Detail: a Standards 21 row Registered in the first pass that uses it and Implemented before exit; a phase-doc statement in § Genericity proof. No ADR | P02d-2 (a: every seed literal lives where the source reads it), P02d-5 (c: the first host outside `SeedData`), P02d-6 (b: frontend subjects), P02d-7 (Implemented and required) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): (a) SeedData literal source and Registered guard. [Accepted — 2026-10-08](#p02d-5-accepted-answers): (c) exemptions; [Accepted — 2026-10-09](#p02d-6-accepted-answers): (b) frontend subjects; implementation and behavioral proof remain P7; [Accepted — 2026-10-11](#p02d-7-decision-package-2026-10-10): matching, canonical built-ins, Seeder-reference fence and behavioral ownership; enforcement remains pending | +| G20 | What mechanically backs "no production code branches on which tenant it serves"? The shipped domain-term scan strips literals and exempts seed data. (a) The mechanism and its literal source; (b) its subjects, matching and the platform built-ins; (c) its exemptions, including development hosts in frontend or infrastructure configuration; (d) whether a ban on production references to `LearnStack.Tools.Seeder` and a behavioural same-code, different-data test accompany it | A Standards 21 sibling row scanning production backend and `frontend/` sources, comments stripped, for exact identity literals read from `SeedData` (slugs, ids, hosts, display names, customization keys), built-ins excluded, with planted offenders; plus the behavioural test. The exemption policy is the owner's judgement | Detail: a Standards 21 row Registered in the first pass that uses it and Implemented before exit; a phase-doc statement in § Genericity proof. No ADR | P02d-2 (a: every seed literal lives where the source reads it), P02d-5 (c: the first host outside `SeedData`), P02d-6 (b: frontend subjects), P02d-7 (Implemented and required) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): (a) SeedData literal source and Registered guard. [Accepted — 2026-10-08](#p02d-5-accepted-answers): (c) exemptions; [Accepted — 2026-10-09](#p02d-6-accepted-answers): (b) frontend subjects; implementation and behavioral proof remain P7; [Accepted — 2026-10-11](#p02d-7-decision-package-2026-10-10): matching, canonical built-ins, Seeder-reference fence and behavioral ownership; Step 2 implements the required fences and schema-replacement companion | | G21 | Does the anonymous public path set any cookie — the [Frontend Architecture Standards § Tenant Resolution](../standards/07-frontend-architecture.md#tenant-resolution) flowchart sets them — and may a public page load any cross-origin subresource, such as the CDN-hosted logo and font assets Frontend Architecture describes? | No cookies, since the locale is already in the path and a locale-less request redirects ([Localization Standards § URL Strategy](../standards/08-localization.md#url-strategy)); same-origin subresources only; both asserted by a check. Whether tenant branding may point visitors' browsers at third-party hosts is a data-protection choice for the owner | Detail: a phase-doc statement; the Standards 07 flowchart and Frontend Architecture § Theming reconciled in the deciding pass | P02d-2 (subresources, if G16 admits a URL-valued token), P02d-5 (cookies: the middleware replacement is the first code that could set one) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): subresources. Cookies remain open for P02d-5; [Accepted — 2026-10-08](#p02d-5-accepted-answers): cookies; prior subresource answer retained | | G22 | How does the customization definition projection load and stay correct? In the request's ambient transaction, or as a ninth out-of-band tenant-context setter (ADR-0040's set is closed at eight)? In what order are the generation and the rows read; what does an absent generation row mean; how is a cache filled inside a transaction that bumped and rolled back kept unreachable, when the bump is an upsert increment that can reissue a number; what does an absent definition set return; which families are registered, and how does the adapter's exact-tuple `cache.name` mapping match generation-embedded names; what do the TTLs bound; and is the contract batched so a public read issues a bounded number of statements? | Load in the ambient transaction; read the generation first, then the rows; fill only from non-bumping transactions; treat cache faults as misses; restate the module's cache-hit budget; a batched contract, with statement-count assertions cold and warm | Contract: the Customization spec § Primary read flow and a [Tenant Customization Model § 8.2](../architecture/32-tenant-customization-model.md#82-cache-strategy) statement on how a request learns the generation; a dated ADR-0040 amendment and a setters row only if the loader is out-of-band. Detail: the [Infrastructure Stack Standards](../standards/20-infrastructure-stack.md) cache table, the `cache.name` mapping, the Observability Standards metrics family list | P02d-3 | [Accepted — 2026-10-02](#p02d-3-decision-package-2026-10-02) | | G23 | The typed settings accessor and its freshness. With no `learnstack.tenancy.settings` event until Phase 02b and the seed writing from its own process, what bounds staleness: a TTL with a stated bound, a writer-coupled Tenancy settings generation counter, or no settings cache here? What are the accessor's name and glossary headword; how is a cached read keyed so tenant-wide and organization rows never cross organizations — a settings read depends on `app.organization_id` today, and the policy's tenant-scope read gains a carrier in Phase 03; and does its loader run in the ambient transaction? | The reviews split on freshness — a TTL bound until 02b, a counter, or no cache. For keys: tenant-wide rows loaded with an explicit `organization_id IS NULL` predicate under `CacheKey.ForTenant`, each organization's overrides under `CacheKey.ForOrganization`, merged in memory; an ambient loader. The documented tenant-only key is rejected, because it would serve one organization's overrides to another | Detail: if settings are cached, the Infrastructure Stack Standards cheat-sheet rows and `cache.name` mapping; the Tenancy spec's event row and budget; a glossary headword. Contract only for a counter (the Tenancy spec, Database Standards § Table classes and § GRANT matrix) or an out-of-band loader (an ADR-0040 amendment) | P02d-2 (a counter is bumped inside the setting command's transaction), P02d-3 (name, keys, loader) | [Accepted — 2026-10-02](#p02d-2-accepted-answers): no settings cache in P02d-2/3. [Accepted — 2026-10-02](#p02d-3-decision-package-2026-10-02): typed ambient accessor/scoped merge | @@ -446,19 +446,19 @@ premise a row cites is re-verified at that pass rather than trusted. | G30 | The locale error matrix and transport. On each read, what answers an empty, repeated, malformed, over-length, non-canonical, not-enabled or enabled-but-untranslated locale? Does a not-enabled locale answer the Active `unsupported_locale` `400` or the not-found body? Is `X-Locale`, which [Frontend Architecture Standards § Locale Resolution](../standards/07-frontend-architecture.md#locale-resolution) still names as the API carrier, withdrawn, so that locale reaches the API only as the query parameter? | Missing or malformed → `400` `validation_failed` naming `locale`; untranslated → an empty catalog page; the query parameter only. The reviews split on not-enabled — not-found, amending the Error Handling row, or the Active `400`; a uniform answer after the enabled check hides pre-launch rows under either | Detail: a phase-doc statement; the [Error Handling Standards](../standards/09-error-handling.md) table only if not-found; Standards 07 § Locale Resolution; the Frontend Architecture SDK sketch; the API Standards § Pagination example gains `locale` | P02d-4 (validators, OpenAPI parameters and responses), P02d-5 (the server SDK's header set) | [Accepted — 2026-10-03](#p02d-4-accepted-answers): query/error matrix; trusted server header transport remains P02d-5; [Accepted — 2026-10-08](#p02d-5-accepted-answers): header transport; prior API query-locale answer retained | | G31 | Contract checks and the SDK surface. The committed OpenAPI snapshot's path, and how the contract suite proves it equals the served document; how the base copy is read; how the first run behaves; which `oasdiff` version and fail level, and which ADR-0024 rows that level detects (a tightened validator or a changed status may be invisible to any diff); what is uploaded on failure. The drift gate's source — the committed snapshot through `LEARNSTACK_OPENAPI`, or a running API — and its job. Whether an activated deferred job keeps its `if: vars.ENABLE_*` condition, given that GitHub treats a skipped required job as passing, or loses it as the integration job's did. And what the SDK surface becomes when regeneration makes `paths` non-empty: a hand-written transport over `paths` or a typed client library, the fate of `createClientSdk`, and whether the package root keeps re-exporting the server entry | A committed snapshot the contract suite asserts equal, diffed against the base ref's copy with `oasdiff` pinned; drift generated from the snapshot in the required `frontend` job; the condition removed on activation; a thin hand-written transport, and no root re-export of the server entry | Detail: [Testing Standards § API Contract Tests](../standards/06-testing.md#api-contract-tests), the API Standards § OpenAPI links, `ci.yml`, [CONTRIBUTING § Branch protection](../../.github/CONTRIBUTING.md#branch-protection-settings-on-main) (its activation procedure follows the answer), [Frontend Architecture Standards § SDK](../standards/07-frontend-architecture.md#sdk); a package pin with its licence verdict if a client library is chosen | P02d-4 (the first operation, its snapshot and assertion, the drift gate, and the regenerated types the factories must compile against) | [Accepted — 2026-10-03](#p02d-4-accepted-answers): snapshot, SDK, diff/drift and approved required-check activation | | G32 | **The development-transport part of [Phase 02b](phase-02b-events-auth.md#the-decision-register)'s G12.** Which development hostnames and transport serve the two seed tenants — keep `*.learnstack.local`, with a hosts-file step and local TLS with a trust step, or move the seed hosts under `*.localhost`? What does a reviewer do between a clean checkout and both sites, and which carriers move, including host rows already on warm databases, where the host is the primary key and the seeder removes no mapping? | `*.localhost` over HTTP, provided the pass verifies in each browser the team uses and in CI's Chrome that both hosts resolve with no hosts entry and that a `Secure` cookie set on them is stored and returned; otherwise `*.learnstack.local` with local TLS and a named trust step. Tenants are never told apart by port: the effective host strips it | Detail: a dated phase-doc statement in [§ Host-based tenant resolution, end to end](#host-based-tenant-resolution-end-to-end), with `SeedData`, `scripts/seed.sh`, the README Quickstart, the `seed-tenant` and `local-dev-setup` skills and `apps/web`'s dev script and Next configuration in the same packet; Infrastructure Standards only if a TLS proxy publishes a port. No ADR | P02d-5 (the development transport, and the hop configuration a TLS proxy would change), or the first earlier packet that writes a seed-host literal outside `SeedData` | [Accepted — 2026-10-08](#p02d-5-accepted-answers): local hosts and TLS | -| G33 | The server-rendering topology and its evidence. Where do Next.js and the API run relative to each other — the workstation loopback, containers, gated APISIX; which networks are trusted; how does one hop secret reach both processes; what is the server-only API origin — and the same for the CI job that renders the pages? What evidence discharges ADR-0036's "Phase 02d's browser test" and its matrix rows "a direct socket bypassing the hop" and "the Phase 02d anonymous two-host browser render", given that Testing Standards gate this phase on a human? And ADR-0036 § Consequences says the root refuses to start outside Development when the secret list is empty or short, while the shipped rule, in every mode, refuses a half-configured hop, a network entry that is not CIDR and a blank secret or one under 32 characters (characters, not bytes), and admits both lists empty: is that recorded or restored, and is non-development hop configuration this phase's or Phase 11's? | Both processes on the loopback, networks `127.0.0.1/32` and `::1/128`, one generated secret from a single source and never under `NEXT_PUBLIC_`, with networks and secrets arriving together (committing networks without secrets breaks every Development-environment fixture); the API called directly; a per-run secret in CI. Evidence: request-level hop tests as `learnstack_app` — no `X-Tenant-Id`, a non-hop peer, a wrong secret, a repeated header — beside the human walkthrough, with one review adding an automated browser smoke. Record the shipped startup rule; non-development hop configuration is Phase 11's | Contract: one dated [ADR-0036](../decisions/0036-tenant-resolution-trusted-inputs.md) amendment if the evidence departs from the ADR's words, recording the startup rule, and carrying G34 if G34 changes the key or budget. Detail: `.env.example`, `apps/web/.env.local.example`, `appsettings.Development.json` or the demo recipe; a Standards 21 row for the hop runtime test; a Testing Standards § End-to-End Tests sentence only if ownership moves; a Phase 11 scope row | P02d-5 (the hop configuration and the fixture shape — in-process test hosts have no socket peer), P02d-7 (the CI part) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): local topology, shared source and ingress; [Accepted — 2026-10-11](#p02d-7-decision-package-2026-10-10): shared CI lifecycle/topology; ADR-0056 measurement Accepted on the same date; implementation pending | +| G33 | The server-rendering topology and its evidence. Where do Next.js and the API run relative to each other — the workstation loopback, containers, gated APISIX; which networks are trusted; how does one hop secret reach both processes; what is the server-only API origin — and the same for the CI job that renders the pages? What evidence discharges ADR-0036's "Phase 02d's browser test" and its matrix rows "a direct socket bypassing the hop" and "the Phase 02d anonymous two-host browser render", given that Testing Standards gate this phase on a human? And ADR-0036 § Consequences says the root refuses to start outside Development when the secret list is empty or short, while the shipped rule, in every mode, refuses a half-configured hop, a network entry that is not CIDR and a blank secret or one under 32 characters (characters, not bytes), and admits both lists empty: is that recorded or restored, and is non-development hop configuration this phase's or Phase 11's? | Both processes on the loopback, networks `127.0.0.1/32` and `::1/128`, one generated secret from a single source and never under `NEXT_PUBLIC_`, with networks and secrets arriving together (committing networks without secrets breaks every Development-environment fixture); the API called directly; a per-run secret in CI. Evidence: request-level hop tests as `learnstack_app` — no `X-Tenant-Id`, a non-hop peer, a wrong secret, a repeated header — beside the human walkthrough, with one review adding an automated browser smoke. Record the shipped startup rule; non-development hop configuration is Phase 11's | Contract: one dated [ADR-0036](../decisions/0036-tenant-resolution-trusted-inputs.md) amendment if the evidence departs from the ADR's words, recording the startup rule, and carrying G34 if G34 changes the key or budget. Detail: `.env.example`, `apps/web/.env.local.example`, `appsettings.Development.json` or the demo recipe; a Standards 21 row for the hop runtime test; a Testing Standards § End-to-End Tests sentence only if ownership moves; a Phase 11 scope row | P02d-5 (the hop configuration and the fixture shape — in-process test hosts have no socket peer), P02d-7 (the CI part) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): local topology, shared source and ingress; [Accepted — 2026-10-11](#p02d-7-decision-package-2026-10-10): shared CI lifecycle/topology; ADR-0056 measurement Accepted on the same date; Step 3 local proof passes; Step 4 owns real CI receipts | | G34 | How does the pre-classification anonymous limiter treat a request arriving over the authenticated trusted hop? Every server-rendered call reaches the API from the renderer's peer, so every visitor of both tenants shares one partition, and one client sending random `Host` values through the renderer can starve both sites. The partition key, the budget and how the renderer derives any visitor identity it states — while unknown-host floods stay bounded before database work, and a direct peer is still limited per peer | The reviews differ: a visitor address stated over the hop, in a dedicated single-valued header or through `X-Forwarded-For` with the peer captured first, as ADR-0036 anticipates; a separate hop budget with limiting in the renderer; or an explicitly sized shared quota. A per-host ceiling as the only backstop multiplies under a random-`Host` flood | Contract: a dated ADR-0036 amendment if the hop changes the key or the budget, stating the new input's trust rule and whether it may be logged or audited; otherwise a phase-doc statement. Detail: API Standards § Request and Response Limits, [Security Standards § Rate Limiting](../standards/11-security.md#rate-limiting), the catalogue's per-peer rule. `P02b-0` re-verifies Phase 02b's G14 against the answer | P02d-5 | [Accepted — 2026-10-08](#p02d-5-accepted-answers): authenticated visitor and peer budgets | | G35 | The server SDK transport. Its options — visitor host, locale, an optional assertion, never a tenant id as selector; where the host comes from; how the API origin is configured; the server-only guard, timeouts and cancellation; and whether it forwards W3C `traceparent`. With it: which parts of [Observability Standards § Frontend Observability](../standards/10-observability.md#frontend-observability) — Next.js error capture, web vitals — ship here, and which phase owns the rest, since no phase names them | Host and locale plus an optional assertion; hop headers and origin from server configuration, never from request input; a `server-only` guard; Problem Details mapped to the `AppError` union [Error Handling Standards](../standards/09-error-handling.md) already fixes; `traceparent` forwarded; Next.js error capture and web vitals assigned to Phase 11, whose § Observability lists error tracking | Detail: Frontend Architecture Standards § SDK and the Frontend Architecture SDK sketch; a pin and licence verdict if a guard package is added; an exclusion row naming frontend observability's owner, with an Observability Standards sentence | P02d-5 (the transport's headers and configuration read); the ownership half closes by exit, because a deferral names its phase | [Accepted — 2026-10-08](#p02d-5-accepted-answers): configured caller, deadlines and observability owners | | G36 | The edge middleware and entry behaviour. Does the middleware resolve anything (with G25)? What does it carry inward, and under which header name — the Frontend Architecture sketch reuses `x-learnstack-host`, the hop header's own name? Which inbound internal headers are removed or overwritten, including `x-organization-id` when resolution has none — a deny-strip or an allowlist rebuild? What does the matcher exclude? What do `/` and a locale-less path answer, with which status, target and default-locale source; what do a disabled, malformed or non-canonical locale segment (G6 c), a platform host and an unknown host answer; does this run in middleware or the route tree, and may an i18n library own the middleware? Does this phase build the locale-less redirect [Localization Standards § URL Strategy](../standards/08-localization.md#url-strategy) requires, or keep the standards index's i18n-runtime carve-out while Phase 06 claims redirect handling? | Normalise the host; strip every client-supplied `x-tenant-id`, `x-organization-id`, `x-locale` and `x-learnstack-*`; drop the scaffold's `503` guard and TODOs; `/` redirects to the tenant's default locale; a disabled locale is a `404` before any content call; a platform or unknown host gets a `404` with no platform text; the redirect built minimally here, with Phase 06's rows reworded to "deepens" | Detail: a phase-doc statement; the Standards 07 § Tenant Resolution flowchart and the Frontend Architecture middleware sketch; Phase 06's rows in the same diff; if less is built, a dated narrowing of the standards index row for Localization Standards naming the owning phase | P02d-5 (the middleware replacement rewrites the scaffold's locale fallback, so every placement answer changes it first) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): membership-first entry and redirects | | G37 | How do tenant-varying `(public)` routes render, and which Next.js caches may hold tenant data — the full-route cache, the fetch data cache, `unstable_cache`, `generateStaticParams` — so one host's page is never served on the other? A public URL carries no tenant, and both tenants send the same request line over the hop, so a path-keyed cache leaks. What freshness does a page have after a customization or content write? | All three reviews: dynamic rendering with uncached SDK fetches — no `revalidate`, no `generateStaticParams`, no `unstable_cache` — relying on the API's generation-keyed cache; no ISR here | Detail: [Frontend Architecture Standards § Public Site Renderer](../standards/07-frontend-architecture.md#public-site-renderer), which prescribes `revalidate` today, and [Frontend Architecture § Rendering Strategies](../architecture/14-frontend-architecture.md#rendering-strategies), rewritten with the `add-frontend-route` skill; [Performance Standards § Caching](../standards/15-performance.md#caching) if the answer caches; an ADR if the pass judges the Standards 07 change non-trivial | P02d-5 (one mechanism: a host-bearing rewrite target is middleware code and fetch cache options are transport code, both written before the renderer) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): dynamic no-store renderer policy | -| G38 | The frontend test set. (a) Which predicates of the middleware and the server SDK does Vitest cover, and in which packages — `pnpm -r test` runs only packages with a test script, which `packages/sdk` lacks? (b) How are async Server Component pages and field components covered below the browser, given vendor guidance that Vitest does not render async Server Components? (c) What automated evidence, if any, re-proves the page-level two-host claim after exit — an HTTP smoke against `next start`, one narrow Playwright smoke pulled forward from Phase 06, or a dated manual record? (d) By what mechanism does the `frontend` job refuse skipped and todo cases, which it does not today, since `No_Architecture_Test_Is_Skippable`'s runner leg reads only the backend `.trx` files? | (a) host normalization and header stripping, locale parsing and entry answers, hop headers with no tenant selector, `not_found` mapping — each with an inversion companion; (b) async pages covered through their synchronous children; (c) the reviews split three ways; (d) a reporter-output check or a lint ban on disabled tests, failing also on a package with tests and no script, proven with a planted skip | Detail: a phase-doc statement; the test files; the Standards 21 entry `No_Architecture_Test_Is_Skippable` extended rather than a second name; `ci.yml`. Contract for (c) only if a browser smoke moves: a Testing Standards § End-to-End Tests edit citing this row, with its carriers | P02d-5 (a; d at the latest), P02d-6 (b, c), P02d-7 (c's job) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): (a,d) tests and non-skippability; [Accepted — 2026-10-09](#p02d-6-accepted-answers): (b,c) synchronous tests and required production HTML/RSC product proof; P7 owns the browser/demo job; [Accepted — 2026-10-11](#p02d-7-decision-package-2026-10-10): narrow browser-job scope; ADR-0056 measurement Accepted on the same date; implementation pending | +| G38 | The frontend test set. (a) Which predicates of the middleware and the server SDK does Vitest cover, and in which packages — `pnpm -r test` runs only packages with a test script, which `packages/sdk` lacks? (b) How are async Server Component pages and field components covered below the browser, given vendor guidance that Vitest does not render async Server Components? (c) What automated evidence, if any, re-proves the page-level two-host claim after exit — an HTTP smoke against `next start`, one narrow Playwright smoke pulled forward from Phase 06, or a dated manual record? (d) By what mechanism does the `frontend` job refuse skipped and todo cases, which it does not today, since `No_Architecture_Test_Is_Skippable`'s runner leg reads only the backend `.trx` files? | (a) host normalization and header stripping, locale parsing and entry answers, hop headers with no tenant selector, `not_found` mapping — each with an inversion companion; (b) async pages covered through their synchronous children; (c) the reviews split three ways; (d) a reporter-output check or a lint ban on disabled tests, failing also on a package with tests and no script, proven with a planted skip | Detail: a phase-doc statement; the test files; the Standards 21 entry `No_Architecture_Test_Is_Skippable` extended rather than a second name; `ci.yml`. Contract for (c) only if a browser smoke moves: a Testing Standards § End-to-End Tests edit citing this row, with its carriers | P02d-5 (a; d at the latest), P02d-6 (b, c), P02d-7 (c's job) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): (a,d) tests and non-skippability; [Accepted — 2026-10-09](#p02d-6-accepted-answers): (b,c) synchronous tests and required production HTML/RSC product proof; P7 owns the browser/demo job; [Accepted — 2026-10-11](#p02d-7-decision-package-2026-10-10): narrow browser-job scope; ADR-0056 measurement Accepted on the same date; browser proof delivered in Step 3; CI receipts owned by Step 4 | | G39 | Is [ADR-0027](../decisions/0027-frontend-i18n.md), the frontend i18n library, Accepted in this phase rather than Phase 04, or do this phase's pages meet a library-neutral message contract under the standards index's carve-out? Where does the one UI string catalogue live — the carriers name three paths? | The reviews differ: Accept at first use (`next-intl` composed with the tenant middleware, with its pin and licence verdict), or move only the minimum slice — catalogue loading, lookup, layout locale, `lang`. A third option, no platform-authored text, is hard for a skip link or a not-found page | Contract: ADR-0027 Accepted, with the decisions index row, Phase 04's ADR-0027 lines and the standards index row in the same diff — which, under [the decisions index SLA](../decisions/README.md#open-adr-drafts), makes it an exit blocker here — or a narrowed carve-out plus a phase-doc statement. Detail: [Localization Standards § Strings in Code](../standards/08-localization.md#strings-in-code), [Localization § UI String Catalogue](../architecture/12-localization.md#ui-string-catalogue), the `add-i18n-key` and `add-frontend-route` skills | P02d-6 (the first platform string, message loading and catalogue files) | [Accepted — 2026-10-09](#p02d-6-accepted-answers): ADR-0027, exact pin and one checked UI catalogue home | | G40 | Route files, page states and site chrome. What happens to `(public)/page.tsx`'s platform placeholder, and to `/studio` and `/portal` on tenant hosts; is the `courses` segment fixed, and which phase owns localized section names? Does this phase ship `(public)` loading, error and not-found files — [Frontend Architecture Standards § Routing](../standards/07-frontend-architecture.md#routing) requires `loading.tsx` and `error.tsx` per route group, and a not-found page is this phase's own choice; how do SDK `not_found`, a cursor `validation_failed`, unavailable and `429` map to page states; what do an empty catalog and a course with no eligible lesson show; does the catalog render a next-page link? Does a minimal chrome ship? Are `hreflang`, canonical and `og:locale`, which [Localization Standards § SEO](../standards/08-localization.md#seo) requires on translated public pages, built here or carved out? | The placeholder leaves the public tree; a fixed `courses` segment with the section-name owner named; minimal state files in tenant tokens; `not_found` → an HTTP `404` page; unavailable or `429` → the route group's error page without disclosure; an explicit empty state; a next-page link over enough seeded courses; in-page links rather than chrome, keeping Phase 06's navigation rows true | Detail: a phase-doc statement; Phase 06's § What Phase 02d already shipped rows reworded; a dated carve-out in the standards index row for Frontend Architecture Standards or Localization Standards, naming the owning phase, for whatever this phase builds less of | P02d-6 | [Accepted — 2026-10-09](#p02d-6-accepted-answers): product routes, approved status/URL chain, page states and metadata | | G41 | How does the lesson page draw what the subset does not implement — an out-of-subset `x-renderer`, a missing optional field, an array of objects, a stored value whose type differs from its declaration, an `x-taxonomy` value and its missing band? And where do composite and primitive components live — Frontend Architecture Standards names `packages/blocks`, Frontend Architecture names `components/blocks/`, and the registry sits in `apps/web/src/lib/customization/`? | A safe placeholder, never an exception and never raw JSON; a missing optional field renders nothing; `integer`, `boolean` and enums as text; an `x-taxonomy` value as the band's display name in the requested locale. No review addresses the component home | Detail: Tenant Customization Model § 2 (the implemented subset, not a second list) and § 8.1; Frontend Architecture Standards § Public Site Renderer and the Frontend Architecture tree. A new primitive would be an ADR-0018 release, which this row must not assume, since Phase 04 owns the field-type set | P02d-6 | [Accepted — 2026-10-09](#p02d-6-accepted-answers): ordered plain-string components and bounded fallbacks | | G42 | How do validated branding tokens reach the server-rendered HTML — a `style` attribute on the root element, which needs `unsafe-inline` or `unsafe-hashes`; a nonce-compatible `<style>` element built from validated values; or a per-tenant stylesheet route — without constraining [Security Standards § HTTP Headers](../standards/11-security.md#http-headers)' nonce-based target before Phase 11 documents it per surface? | A `<style>` element built only from registry-validated values, emitting only the `--ls-*` vocabulary, never a `style` attribute; a nonce would force dynamic rendering (G37) | Detail: Frontend Architecture Standards § Tenant Branding for the mechanism; Frontend Architecture § Theming | P02d-6 (the layout's token injection; closes with G37's answer and G16's grammar) | [Accepted — 2026-10-09](#p02d-6-accepted-answers): atomic four-token style-element injection | | G43 | Which accessibility checks on this phase's pages fail a build — route tests asserting `lang`, one `<main>`, the heading outline, a skip link and a descriptive title; `jsx-a11y` at error severity, where most of the shipped config's rules warn; or jsdom axe, which Testing Standards puts through Playwright in Phase 06? Is catalog → lesson a critical flow that needs [Accessibility Standards § Testing](../standards/16-accessibility.md#testing)' screen-reader smoke test? | Route tests in the `frontend` job for the checkable semantics; keyboard, focus and 320 CSS px reflow in the manual record; failing `jsx-a11y` with a planted companion. No review addresses the screen-reader question | Detail: a phase-doc statement; [Accessibility Standards § Tooling](../standards/16-accessibility.md#tooling) if lint severity or component axe becomes a rule; the lint configuration. Whether failing lint enforces the standard couples with G44; its index row changes only in the enforcing pull request | P02d-6 (page components and their tests) | [Accepted — 2026-10-09](#p02d-6-accepted-answers): failing lint/semantics and mandatory manual assistive-technology proof | -| G44 | The Lighthouse job. Does it activate in this phase, and on what full-stack harness — a migrated stack, a seed written as `learnstack_app`, the API as a process over the hop with a per-run secret, `next start` on a production build, both seed hosts reachable from CI's browser, a readiness and tenant-marker check before the audit — or does activation move to the phase that brings a browser harness? What does it assert: the URL set and which [Performance Standards](../standards/15-performance.md) row each page answers to (its LCP row names a landing page this phase does not ship); which rows, under which throttling preset; the 200 KB budget or the 250 KB forbidden line; hard or warning, run count and aggregation; categories, including the accessibility audit [Accessibility Standards § Tooling](../standards/16-accessibility.md#tooling) requires; the runtime ceiling, tool install and report destination; and what the standards index rows for Performance and Accessibility say afterwards? | Activate here, reusing the `make demo` entrypoint; catalog, course and lesson on both hosts plus the bilingual tenant's second locale; hard assertions on deterministic audits (script transfer size, CLS, the accessibility category or contrast over both palettes) and median-of-N timings as warnings, with TBT rather than a lab INP; tooling from the lockfile; reports to workflow artifacts only; Accessibility promoted if asserted hard, Performance kept Adopted as a pre-baseline check unless a hard budget makes it Active for what ships. The budget authority is settled: [Frontend Architecture Standards § Performance](../standards/07-frontend-architecture.md#performance) names Performance Standards | Contract: a phase-doc statement plus a committed Lighthouse configuration. Detail: `ci.yml`, CONTRIBUTING's activation edits, the `run-tests-locally` skill; Performance Standards only if a number or lab profile changes; the standards index rows and status headers in the enforcing pull request. Moving activation edits `ci.yml`, CONTRIBUTING and the skills, and leaves Phase 01's and 02a's records as written | P02d-5 (whether it activates, as an input to G32: the hosts must work in CI's browser), P02d-7 (the harness and assertions) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): whether: activate in P7; harness details stay P7; [Approved — 2026-10-11](#p02d-7-approval-and-exit-boundary): bounded seventh-check activation after real success; [Accepted — 2026-10-11](#p02d-7-accepted-answers): ADR-0056 measurements and serial feasibility gate; enforcement pending | -| G45 | What does `make demo` start and guarantee on a clean checkout? The process model — a foreground supervisor over detached compose, or detached processes with a stop target; the web app's mode; how environment reaches host processes, given `dotnet run` reads no `.env` and nothing creates `apps/web/.env.local`; readiness waits before Phase 11's `/readyz`; stale-`.env` detection; re-run and stop behaviour; whether its seed step keeps `make seed`'s wait on every default-profile service and both Keycloak realms; and what it prints, including the bilingual tenant's second-locale URLs | The reviews differ on attached versus detached processes; both reject a destructive reset, wait on both processes, keep re-runs idempotent and have CI reuse the entrypoint | Detail: the `Makefile` targets with help lines and a dated phase-doc statement; README § Quickstart, `scripts/seed.sh`'s closing output and the `local-dev-setup` and `seed-tenant` skills in the same packet; Infrastructure Standards § Healthchecks if the seed's gate narrows. No ADR | P02d-7 (with G44, whose job invokes the same entrypoint; if G44's harness moves earlier, this row moves with it) | [Accepted — 2026-10-11](#p02d-7-demo-lifecycle): shared foreground lifecycle; implementation pending | +| G44 | The Lighthouse job. Does it activate in this phase, and on what full-stack harness — a migrated stack, a seed written as `learnstack_app`, the API as a process over the hop with a per-run secret, `next start` on a production build, both seed hosts reachable from CI's browser, a readiness and tenant-marker check before the audit — or does activation move to the phase that brings a browser harness? What does it assert: the URL set and which [Performance Standards](../standards/15-performance.md) row each page answers to (its LCP row names a landing page this phase does not ship); which rows, under which throttling preset; the 200 KB budget or the 250 KB forbidden line; hard or warning, run count and aggregation; categories, including the accessibility audit [Accessibility Standards § Tooling](../standards/16-accessibility.md#tooling) requires; the runtime ceiling, tool install and report destination; and what the standards index rows for Performance and Accessibility say afterwards? | Activate here, reusing the `make demo` entrypoint; catalog, course and lesson on both hosts plus the bilingual tenant's second locale; hard assertions on deterministic audits (script transfer size, CLS, the accessibility category or contrast over both palettes) and median-of-N timings as warnings, with TBT rather than a lab INP; tooling from the lockfile; reports to workflow artifacts only; Accessibility promoted if asserted hard, Performance kept Adopted as a pre-baseline check unless a hard budget makes it Active for what ships. The budget authority is settled: [Frontend Architecture Standards § Performance](../standards/07-frontend-architecture.md#performance) names Performance Standards | Contract: a phase-doc statement plus a committed Lighthouse configuration. Detail: `ci.yml`, CONTRIBUTING's activation edits, the `run-tests-locally` skill; Performance Standards only if a number or lab profile changes; the standards index rows and status headers in the enforcing pull request. Moving activation edits `ci.yml`, CONTRIBUTING and the skills, and leaves Phase 01's and 02a's records as written | P02d-5 (whether it activates, as an input to G32: the hosts must work in CI's browser), P02d-7 (the harness and assertions) | [Accepted — 2026-10-08](#p02d-5-accepted-answers): whether: activate in P7; harness details stay P7; [Approved — 2026-10-11](#p02d-7-approval-and-exit-boundary): bounded seventh-check activation after real success; [Accepted — 2026-10-11](#p02d-7-accepted-answers): ADR-0056 measurements and serial feasibility gate; local enforcement passes; live CI/protection receipts owned by Step 4 | +| G45 | What does `make demo` start and guarantee on a clean checkout? The process model — a foreground supervisor over detached compose, or detached processes with a stop target; the web app's mode; how environment reaches host processes, given `dotnet run` reads no `.env` and nothing creates `apps/web/.env.local`; readiness waits before Phase 11's `/readyz`; stale-`.env` detection; re-run and stop behaviour; whether its seed step keeps `make seed`'s wait on every default-profile service and both Keycloak realms; and what it prints, including the bilingual tenant's second-locale URLs | The reviews differ on attached versus detached processes; both reject a destructive reset, wait on both processes, keep re-runs idempotent and have CI reuse the entrypoint | Detail: the `Makefile` targets with help lines and a dated phase-doc statement; README § Quickstart, `scripts/seed.sh`'s closing output and the `local-dev-setup` and `seed-tenant` skills in the same packet; Infrastructure Standards § Healthchecks if the seed's gate narrows. No ADR | P02d-7 (with G44, whose job invokes the same entrypoint; if G44's harness moves earlier, this row moves with it) | [Accepted — 2026-10-11](#p02d-7-demo-lifecycle): shared foreground lifecycle; implemented with both review rounds complete in Step 1 | Gates that define one mechanism are answered against each other. Where their parts shape different packets' code, the mechanism is split as @@ -6023,7 +6023,7 @@ protection receipts; historical delivery records retain their original limits. ### P02d-7 Step 3 — browser and audit proof (2026-10-11) -**Implementation in progress; both independent review rounds remain pending.** +**Complete — both independent review rounds and verified fixes pass.** The shared CI lifecycle invokes `verify-public-demo.mjs` over the same seeded production API/native renderer. `DemoManifest` also derives hidden lesson titles and field values, excluding values shared with eligible public content. The @@ -6170,6 +6170,58 @@ The subsequent shared-bound change has focused verification above and must also run in final CI. Both independent review rounds and fresh fix verification are complete. Step 4 owns CI enforcement and phase exit; neither is claimed here. +### P02d-7 Step 4 — CI enforcement and phase exit (2026-10-11) + +**Implementation in progress; both independent review rounds pending.** +The always-running `public demo + lighthouse` job replaces the disabled +placeholder. It installs the exact locked browser tools and managed Chromium, +then invokes `make demo DEMO_MODE=ci` over the shared seven-service lifecycle. +The 20-minute job includes setup, the 12-minute serial proof, separate bounded +cleanup and artifact handling. An unconditional bounded workflow receipt records +failure even when setup prevents a product receipt. Uploads allow only public +JSON/HTML reports, screenshots and sanitized workflow/proof receipts. + +The [individual exit evidence matrix](phase-02d-exit-evidence.md) maps all +36 Deliverables, 79 Completion Criteria, 39 exclusions and nine exit obligations. +It preserves prior human/PR evidence and names outstanding final CI receipts; +implementation alone does not constitute phase exit. + +**Criterion reconciliation.** Published roots cannot receive new translations +under ADR-0050. The third-locale proof therefore creates and publishes new +French-only roots through supported commands, preserving the existing EN/TR +public responses and all five migration histories. Organization branding writers +remain unrouted. The branding criterion now separates API-root command refusal +from mapped-host reads and distinguishes a successful business audit from the +required standalone denied-attempt audit. This corrects the mutable criterion's +no-audit overclaim; ADR-0033/0044 and production auditing are unchanged. + +**Education preservation handoff.** Phase 05 inherits separate Course/Lesson +roots and their contained Pattern A translations. Its migration preserves stable +IDs and published localized URLs, `(sort,id)` lesson order, tenant/organization +scope, translated bodies, exact content-type/taxonomy revision pins and course +access policy. `SeedData.All` supplies both tenant curricula: eight courses, +ten lessons and 27 translations at their declared scopes, including draft and +restricted controls. Carry those persisted fixtures through the migration; +reseeding is not a migration strategy. + +**P02b-0 re-verification handoff.** Re-read the four `/api/v1/public` GET/HEAD +pairs and contract; retained `*.learnstack.local` seed hosts over native HTTPS, +manual local hosts/CA setup and private paired hop configuration; coordinated +60/min visitor and 600/min physical-peer accounting; tenant-wide English versus +organization-scoped Yoga seed context; one live bootstrap with two calls per +normal product document and three for a followed missing-content chain; and the +uncached settings reader plus `learnstack.tenancy.settings` eager-invalidation +event owned by Phase 02b. These delivered premises do not Accept future +session/BFF/authenticated-rate-limit decisions. + +**Validation boundary.** Both third-locale/branding combined cases pass locally +with zero skips. Release build has zero warnings/errors; 1,705 unit, 203 architecture, +four contract and 180 Docker-free integration cases pass, as do all 1,500 guarded +frontend cases. Typecheck, lint, whitespace and 2,042 relative links (666 fragments) +pass. The complete Docker suite is running. Two fresh review rounds, a real +successful PR job and the authorized seventh-context activation/read-back remain. +No PR, live check activation or phase exit is claimed yet. + ### P02d-1 decision pass (2026-09-14) **Accepted — 2026-09-14, verified against `6c58343`.** The maintainer approved @@ -7101,11 +7153,13 @@ otherwise string containing `</style>` — never reaches a rendered document, and a refused write commits neither a `tenant_settings` row nor an audit row. A key outside the contract, and a failing contrast pair, behave as G16 records — never a silent save. -- A branding key written as an organization-scoped `tenant_settings` row behaves as - **G16** (e) records, checked request-level through a host mapped to the organization: - refused at write, committing neither a `tenant_settings` row nor an audit row; stored - while the page served on that host is unchanged; or, if G16 (e) applies it, shown on - that host's page and on no other host's. +- Under **G16** (e), the unrouted branding command dispatched through the API + composition root in organization scope refuses the write. It changes no + `tenant_settings` row and commits no successful setting-write audit; the denied + attempt remains auditable under ADR-0033/0044. A real GET on the mapped + organization host returns the same tenant palette before and after refusal. + This combines the application-writer boundary with the shipped HTTP reader; + it does not introduce an HTTP authoring endpoint. - If **G19** includes a write-time rule, a lesson write holding a disallowed URL is refused with details naming the JSON pointer, and nothing is written. - Whatever **G18** refuses at save — which may include a presentation entry naming a @@ -7437,8 +7491,8 @@ otherwise handler's response type and neither has a handler. The mechanical control is accepted in **G28**: mandatory marked dispatch and structural guards complement the physical read-only barrier. P02d-4 Step 1 delivers the physical read-only barrier and host admission. - Endpoint dispatch/dependency guards remain with Step 2; the barrier covers only - enlisted transactions. + Steps 2–4 deliver endpoint dispatch/dependency and eligibility proofs; + the physical barrier covers only enlisted transactions. - **A missing marker looks like a resolver bug.** A host-only request to a type without `[PublicSurface]` answers the unknown-host `404` by design, so a public read shipped without its marker reads as a resolution or Row Level Security defect. The tempting diff --git a/docs/roadmap/phase-04-cms-media-pages.md b/docs/roadmap/phase-04-cms-media-pages.md index ce8e8184..e83c46fb 100644 --- a/docs/roadmap/phase-04-cms-media-pages.md +++ b/docs/roadmap/phase-04-cms-media-pages.md @@ -8,7 +8,9 @@ catalog pages, campaign pages, and tenant-defined page blocks. [Phase 02d](phase-02d-walking-skeleton.md) delivers the anonymous read API and trusted server transport through P02d-5. Catalog, course-detail/outline and lesson product -pages are delivered by P02d-6; the two-host browser/demo proof remains P02d-7. +pages are delivered by P02d-6; P02d-7 implements the two-host demo and narrow +browser/Lighthouse proof. Its [delivery record](phase-02d-walking-skeleton.md) +owns current CI enforcement and phase-exit evidence. Its bounded renderer uses fixed section names and ADR-0051's ordered plain-text profile. This phase adds an authored, versioned, localized content system that a tenant admin drives from Admin Studio, including the richer primitive field set. @@ -87,6 +89,15 @@ Also in scope: - `TenantContentType` JSON Schema editor in Admin Studio; the schema is validated as a schema on save, not merely stored. +- Authored field ordering and per-locale field-label editing under + [ADR-0051](../decisions/0051-ordered-text-card-presentation.md), preserving the + ordered `x-fields` contract and localized visible labels when extending the + plain-text profile to richer primitives. +- Customization deprecate and revise commands with their Studio lifecycle controls; + per-band taxonomy editing is delivered with [Phase 05](phase-05-education-learning-content.md#admin-studio-education-screens) + and consolidated by [Phase 06](phase-06-renderer-admin-studio.md#admin-studio--screen-ownership). + Existing exact revision pins remain readable; the revision workflow decision + below precedes any new mutation contract. - Built-in primitive field types composed by the JSON Schema: text, rich text, number, boolean, date/time, media reference, entry reference, select / multi-select, JSON / object. The set is closed and changes only with a LearnStack release. @@ -283,6 +294,10 @@ Storage and asset management: emit no protected bearer URL; issuance and retrieval require effective access. It does not claim an authenticated evaluator exists before Phase 07. The first active URL/markup sink also needs the shared safety contract named in ADR-0051. + This phase owns the tenant media-origin allow-policy: approved origin provenance, + permitted schemes/hosts and enforcement at authored URL validation and the first + active media sink. Its decision pass settles the policy before introducing that + sink; Phase 02d's inert plain-text fields authorize no media URL or markup. **This phase owns the media processing pipeline.** No phase currently does: [Media Pipeline](../architecture/16-media-pipeline.md) describes `IVideoTranscoder`, @@ -399,7 +414,10 @@ describes. a `LimitKey`. - `ITenantSearch` / `IPlatformSearch` with a PostgreSQL full-text implementation over content entries and pages, tenant-filtered inside the port. -- Admin Studio CMS screens per the list above. +- Admin Studio CMS screens per the list above, including field-order/localized-label + authoring and customization deprecate/revise controls. +- The tenant media-origin allow-policy and its authoring/runtime enforcement at + active media sinks. - Public read APIs for the renderer, versioned per [ADR-0024](../decisions/0024-api-versioning-policy.md). - CMS/Studio UI messages extend the ADR-0027 foundation owned by P02d-6, with @@ -445,6 +463,10 @@ describes. page block; a video asset produces an HLS master playlist, a poster and a thumbnail strip through the ffmpeg worker. - An SVG containing a `<script>` element is stored sanitised and served without it. +- Disallowed tenant media origins are refused at authoring and cannot load through + an active sink; allowed origins render under the same tenant's policy. +- Studio preserves authored field order and displays translated labels in each + supported locale; deprecating/revising a definition preserves existing exact pins. - Draft and published versions are separated, published pages never show draft content, and the preview flow works for admin users. - The same Studio editor and rendering pipeline serve both diff --git a/docs/roadmap/phase-05-education-learning-content.md b/docs/roadmap/phase-05-education-learning-content.md index 34c23230..f4c99d1b 100644 --- a/docs/roadmap/phase-05-education-learning-content.md +++ b/docs/roadmap/phase-05-education-learning-content.md @@ -58,21 +58,22 @@ content-access policy through version/module migration, decides its versioned ow and any policy-edit/reparent/preview behavior before those writers, and never infers public access from a new version or listing. This note claims no shipped column. -**Current delivery — 2026-10-09.** P02d-2 delivered the policy column, restricted +**Current delivery — 2026-10-11.** P02d-2 delivered the policy column, restricted backfill and writers; P02d-4 delivered eligible public reads. Preserve those contracts through this phase's version/module migration. P02d-6 delivers the -bounded renderer and product/manual proofs; P02d-7 still owns the browser/demo -harness. The [packet closeout](phase-02d-walking-skeleton.md#p02d-6-packet-closeout-2026-10-10) -records current implementation evidence. +bounded renderer and product/manual proofs; P02d-7 implements the demo and narrow +browser/Lighthouse proof. The [Phase 02d delivery record](phase-02d-walking-skeleton.md) +owns current implementation, CI enforcement and phase-exit evidence. Phase 05 does not re-create these. Phase 02d's [delivery status](phase-02d-walking-skeleton.md#delivery-record-p02d-1) distinguishes accepted design from shipped implementation. This phase's decision pass designs the move from independent lessons referencing courses to course versions and modules, and from translated inline bodies to lesson items. It must preserve course and -lesson ids, published localized URLs, lesson order, organization scope, translated -bodies and exact content-type and taxonomy revision bindings. The migration and its -tests must carry existing rows forward; re-seeding is not a migration strategy. +lesson ids, published localized URLs, lesson order, tenant/organization scope, +translated bodies, exact content-type and taxonomy revision bindings and effective +content-access policy. Migration tests must carry existing rows forward; +re-seeding is not a migration strategy. Each change follows [Database Standards § Migrations](../standards/05-database.md#migrations). | Phase 02d baseline | Phase 05 adds | @@ -134,12 +135,13 @@ scoring and does not re-decide it. for the yoga studio, tracks for a coding bootcamp). A taxonomy key and an item key are lowercase under [ADR-0018's key rule](../decisions/0018-tenant-driven-customization-model.md#2026-09-04--customization-keys-and-item-keys-are-lowercase), - and a band's name is its `display_name`. Which key the yoga taxonomy uses is G14 in - [Phase 02d's decision register](phase-02d-walking-skeleton.md#the-decision-register), - and the decision pass that closes it writes the key here. The taxonomy is data, not - code. The `Level` projection must preserve the exact revision and band referenced - by an existing course; a new Active taxonomy cannot silently relabel or remove that - stored binding. This phase's decision pass defines how the revision-aware projection + and a band's name is its `display_name`. The shipped Yoga seed uses + `yoga-difficulty` revision 1, with `foundation`, `developing` and `advanced` bands; + [SeedData](../../backend/src/LearnStack.Tools.Seeder/SeedData.cs) owns that + inventory. The taxonomy is tenant data. The `Level` projection preserves the exact + revision and band referenced by an existing course; a new Active taxonomy cannot + silently relabel or remove that stored binding. This phase's decision pass defines + how the revision-aware projection composes with the target `Level` identity. - Tag. - Instructor profile reference, with tenant-defined custom fields via @@ -163,6 +165,18 @@ scoring and does not re-decide it. Required capabilities: draft version, published version, version clone, change summary, publish validation. +### Post-seed authoring and lifecycle + +This phase owns the authenticated Course/Lesson authoring API and Studio surface, +including commands to edit content after seeding, reorder lessons, unpublish and +delete. Its decision pass settles allowed states, versioned owners, concurrency, +access-policy edits, reparenting and published-URL behavior before those writers. +The current ADR-0050 baseline permits draft-only insertions and independent +`draft → published` transitions; it supplies no published edit, reorder, unpublish +or delete operation. New lifecycle behavior must preserve the migration obligations +[above](#what-phase-02d-already-shipped), rather than treating a seed rerun as an edit +or migration. This handoff records future ownership without selecting that contract. + ### Learning structure - Module. @@ -367,8 +381,10 @@ cross-phase screen ownership table lives in **one** place — - Lesson editor. - Lesson item editor (schema-driven for both built-in and tenant-defined item types). - `TenantLessonItemType` editor (schema + player key). -- `TenantLevelTaxonomy` editor (items + metadata; the tenant admin declares CEFR / - difficulty / track / kyu-dan). +- `TenantLevelTaxonomy` editor with per-band editing of keys, ordering, localized + labels and metadata; the tenant admin declares CEFR / difficulty / track / + kyu-dan. It consumes [Phase 04](phase-04-cms-media-pages.md)'s customization + deprecate/revise lifecycle and preserves existing exact revision/band pins. - `TenantCompletionRule` editor — sandboxed DSL editor with live validation against the ADR-0025 engine. - Course publish flow. @@ -387,6 +403,9 @@ cross-phase screen ownership table lives in **one** place — - Education catalog API — programs, courses, versions, categories, levels, tags, SEO. - Versioned course structure with draft / publish / clone. - Lesson content management with lesson items across both registry tiers. +- Authenticated post-seed Course/Lesson edit, reorder, unpublish and delete commands + and Studio controls under the lifecycle contract settled in this phase. +- Per-band taxonomy editing over the versioned customization lifecycle. - Public catalog rendering data, extending the read endpoints [Phase 02d](phase-02d-walking-skeleton.md) shipped. - The customization runtime cost model implemented and **measured**: validation on the @@ -407,6 +426,11 @@ cross-phase screen ownership table lives in **one** place — complete, no scoring band is assigned, and the failure is audited. - An admin creates a course, adds modules and lessons, edits it as a draft, and publishes it; the published course detail is readable by the public site. +- Post-seed edit/reorder/unpublish/delete cases prove the allowed state transitions, + concurrency and refusal behavior chosen by the lifecycle decision; seed reruns + cannot substitute for those commands. +- Migration tests preserve the existing seed rows' stable IDs, localized URLs, + scopes, lesson order, translated bodies, exact definition pins and access policy. - `CourseVersion` behaviour is covered by integration tests, including that an existing enrollment reference stays pinned to its version when a new version publishes. - Both seed tenants from [Phase 02a Packet 7](phase-02a-kernel-tenancy.md) — the English diff --git a/docs/roadmap/phase-06-renderer-admin-studio.md b/docs/roadmap/phase-06-renderer-admin-studio.md index 2ac7c9d1..8def8216 100644 --- a/docs/roadmap/phase-06-renderer-admin-studio.md +++ b/docs/roadmap/phase-06-renderer-admin-studio.md @@ -9,8 +9,8 @@ learner-facing and instructor-facing screen after this phase is built into. [Phase 02d](phase-02d-walking-skeleton.md) delivers the public read API and trusted server transport through P02d-5. P02d-6 owns catalog, course-detail/outline and lesson pages, now implemented with product proofs and passing manual accessibility -smoke. P02d-7 owns the unbuilt browser/demo harness. This phase deepens -that bounded path with authored navigation, +smoke. P02d-7 implements the demo, narrow Playwright library browser proof and +Lighthouse audits. This phase deepens that bounded path with authored navigation, tenant error pages, complete block composition and editing surfaces. After this phase, LearnStack publishes a simple but real education website for a tenant, @@ -24,7 +24,10 @@ and a non-developer tenant admin can maintain it. Rows identify P02d-6 scope merged through PR #27; its [merge closeout](phase-02d-walking-skeleton.md#p02d-6-merge-and-closeout-2026-10-10) -records final verification. Planned P02d-7 work is not current behavior. +records final verification. P02d-7's +[delivery record](phase-02d-walking-skeleton.md#p02d-7-step-3--browser-and-audit-proof-2026-10-11) +records the narrow browser/audit proof; the canonical Phase 02d closeout records +its CI enforcement and phase-exit state. | Phase 02d foundation | Phase 06 adds | |---|---| @@ -32,7 +35,7 @@ records final verification. Planned P02d-7 work is not current behavior. | Anonymous `(public)` catalog/course Server Component pages delivered P02d-6 Step 2; lesson page delivered Step 3 in [Phase 02d § Public renderer](phase-02d-walking-skeleton.md#public-renderer) | Navigation, SEO metadata beyond G40, tenant-authored error pages, redirect handling, full page composition | | ADR-0051 ordered plain-text lesson presentation, API projection delivered P02d-4 and bounded renderer delivered P02d-6 Step 3 | The complete two-tier block registry with safe-render placeholders | | Four-color public theme projection delivered P02d-4; safe document injection delivered P02d-6 Step 1 | The branding configuration surface, additional tokens and organization override | -| The `apps/web` Vitest suite [Phase 02d](phase-02d-walking-skeleton.md) extends | The browser-level end-to-end suite | +| The `apps/web` Vitest suite and P02d-7's pinned Playwright library/Lighthouse proof over nine seed-derived product URLs | The full Playwright Test project and direct axe suite across public, Studio and portal flows | **P02d-6 inheritance — Accepted 2026-10-09; Steps 1–4 implemented.** [ADR-0027](../decisions/0027-frontend-i18n.md) selects exact `next-intl` 4.14.9, @@ -46,9 +49,12 @@ uses plain same-host anchors, opaque signed-target pagination, safe four-color injection and local 307→404 navigation to `/{locale}/status/not-found`. The URL changes; known content-call failures are translated HTTP 200 noindex states. Tenant-authored errors, menus, media, expanded renderer composition and -organization overrides remain here. P02d-7 owns the initial browser/demo and -Lighthouse activation; this phase owns the full Playwright/axe suite and Phase 11 -owns web-vitals telemetry. Acceptance does not claim these consumers are shipped. +organization overrides remain here. P02d-7's Playwright 1.64.0 library proof and +Lighthouse 13.5.0 audits exercise the seeded production public pages; Lighthouse's +transitive axe audit is part of that bounded proof. This phase owns the full +`@playwright/test` project and direct axe suite, including authenticated Studio and +portal flows. [Phase 11](phase-11-production-hardening.md#observability) owns +web-vitals telemetry. These future consumers are not Phase 02d delivery. ### Public site renderer @@ -234,8 +240,9 @@ live class. **Phase 06 owns it.** ### End-to-end test stack — a carried dependency -P02d-7 owns the initial browser/demo harness; Phase 06 expands it into the full -browser/axe suite and depends on the ephemeral end-to-end stack working. +P02d-7 delivers a narrow Playwright library browser and Lighthouse harness through +the shared demo lifecycle. Phase 06 adds the full Playwright Test/axe suite and +retains the ephemeral end-to-end stack dependency. `infra/compose/e2e.yml` overlays the development stack with `volumes: !reset []`, which discards more than the named volumes: it also discards the **PostgreSQL init script** and the **SeaweedFS S3 identity file**. @@ -262,7 +269,8 @@ browser suite against a mis-provisioned stack is worse evidence than no suite. information-architecture pass. - The `(portal)` route-group shell and the instructor portal's first screens. - Shared UI package and the typed SDK over the full API surface. -- A browser-level end-to-end suite running against the fixed ephemeral stack. +- The full Playwright Test/axe end-to-end suite running against the fixed ephemeral + stack, extending the narrow P02d-7 public browser/audit proof. ## Completion Criteria diff --git a/docs/roadmap/phase-11-production-hardening.md b/docs/roadmap/phase-11-production-hardening.md index 1085bad5..96a290d7 100644 --- a/docs/roadmap/phase-11-production-hardening.md +++ b/docs/roadmap/phase-11-production-hardening.md @@ -401,7 +401,11 @@ bounds request *cost* once a request is inside. Neither substitutes for the othe - Database indexes. - Query review. -- Cache strategy. +- Cache strategy, including gateway/CDN response caching for public API responses + and rendered pages. This phase settles host/tenant/organization/locale and + eligibility partitioning, cache keys, validators and invalidation before enabling + it. The Phase 02d API and renderer retain `no-store`; the generation-keyed + definition cache does not authorize response or page caching. - CDN strategy for media and public assets. - Pagination enforcement. - Search indexing optimization. @@ -532,6 +536,8 @@ same `ILiveClassProvider`. - Backup and restore process with a completed drill. - Performance baseline against the budgets in [15-performance.md](../standards/15-performance.md). +- Gateway/CDN response-cache policy and isolation/freshness proofs before activation, + preserving the existing uncached public contract until that decision ships. - Live classroom operations checklist. - Release checklist and operational runbooks under `docs/runbooks/`. - ADR-0026 Accepted, and diff --git a/docs/standards/06-testing.md b/docs/standards/06-testing.md index f747a94f..66b4734f 100644 --- a/docs/standards/06-testing.md +++ b/docs/standards/06-testing.md @@ -84,10 +84,12 @@ belongs to is decided by what it needs, not by what it is about: a Testcontainers PostgreSQL. **Packet 7** introduces the population, because it is the only shape in which the real middleware chain, the real EF query filters and the real RLS policies run against one another in one request, connected as - `learnstack_app`. It drives no production endpoint — Packet 7 ships none — but a - test-only controller the fixture registers, which is what `IdempotencyFixture` - already does for `/api/v1/sideeffectprobe`. These live under `Database/` with the - rest of the Docker-bound suite and carry the same trait. + `learnstack_app`. Packet 7 originally drives test-only controllers because it + ships no production endpoint. P02d-4 adds actual public Education GET/HEAD cases + in `PublicEducationHttpTests`, including mapped-host scope and uniform hidden + resources. Test-only probes remain separate from the production endpoint set. + These live under `Database/` with the rest of the Docker-bound suite and carry + the same trait. **Where a Docker-bound test lives, and what it takes, is what routes it.** `Every_Database_Test_Carries_The_Docker_Trait` scans the whole of @@ -140,8 +142,10 @@ P02d-7 Step 3 implements the narrow seeded catalog → course → lesson browser proof over the running production API/native renderer. Its [delivery record](../roadmap/phase-02d-walking-skeleton.md#p02d-7-step-3--browser-and-audit-proof-2026-10-11) records the passing local nine-page walkthrough and 27 Lighthouse audits; -independent reviews and required CI activation remain pending. The proof uses -Playwright's library and managed Chromium, not a separate Playwright Test project. +both independent Step 3 reviews are complete. The packet's Step 4 record owns +real CI receipts and required-check activation; local proof alone does not establish +activation. The proof uses Playwright's library and managed Chromium, without a +separate Playwright Test project. It supplements G33's human walkthrough and preserves P6's recorded manual smoke; it does not replace either with automated accessibility scores. @@ -152,6 +156,31 @@ separate from browser evidence. P02d-7's proof adds actual linked navigation, computed themes, ordered fields, TLS refusal controls and bounded audits over unchanged seeded product routes. +Run the shared proof from a fresh checkout without root `.env`, web `.env.local` +or `artifacts/public-demo`, with Docker and the documented toolchain available: + +```bash +(cd frontend && pnpm install --frozen-lockfile) +(cd frontend && pnpm exec playwright install --with-deps chromium) +make demo DEMO_MODE=ci +``` + +The lifecycle provisions a unique tmpfs-backed Compose project, generates private +disposable TLS/configuration, seeds through normal commands and stops its Keycloak +before browser navigation. Fixed application/Compose ports must be free. Review +the sanitized `artifacts/public-demo/receipt.json`, all 27 JSON/HTML report pairs +and browser screenshots; proof and owned cleanup must both pass. Existing artifacts +must be moved aside before a repeat run. Private environments, certificates, keys, +browser profiles and raw process logs are excluded from artifacts. Human foreground +`make demo` retains manual hosts/CA/leaf setup and persistent local data. The +[local test workflow](../../.claude/skills/run-tests-locally/SKILL.md#public-demo-managed-browser-and-lighthouse) +owns the complete setup and artifact instructions. + +The frontend workspace pins Playwright and Lighthouse as development tools. +Lighthouse's transitive development `axe-core@4.14.0` does not supply a standalone +application axe dependency or the full Phase 06 axe suite. There is no +`pnpm test:e2e`, `pnpm test:a11y` or `@playwright/test` project. + ### Public renderer fixture ownership P02d-5 remediation Step 3 implements test-owned process/tree cleanup, positive @@ -234,29 +263,33 @@ offenders. Canonical names/statuses live in the not mark them Implemented. Manual keyboard, focus, 320 CSS px reflow/zoom, long strings, contrast and real screen-reader smoke evidence must name commit, environment, both hosts/locales and assistive technology. If pending, P6 completion -is not claimed. Full Playwright/axe remains Phase 06; demo/browser/Lighthouse remains -P02d-7. G38(a)'s transport proofs and G38(d)'s guarded runner are already delivered. +is not claimed. Full Playwright Test/axe remains Phase 06; the narrow seeded +demo/browser/Lighthouse proof is delivered by P02d-7. G38(a)'s transport proofs and +G38(d)'s guarded runner are already delivered. ## Tenant Isolation Tests **Mandatory** for every PR touching tenant-owned data: -```csharp -public sealed class CourseTenantIsolationTests : IntegrationTestBase -{ - [Fact] - public async Task User_in_tenant_A_cannot_see_courses_in_tenant_B() - { - var (tenantA, tenantB) = await SeedTwoTenantsAsync(); - var courseInB = await CreateCourseAsync(tenantB); - - var response = await Client.As(tenantA.AdminUser) - .GetAsync($"/api/v1/courses/{courseInB.Id}"); - - response.StatusCode.Should().Be(HttpStatusCode.NotFound); - } -} -``` +Use the shipped examples: + +- [PublicEducationHttpTests](../../backend/tests/LearnStack.Tests.Integration/Database/PublicEducationHttpTests.cs) + resolves actual mapped hosts and asserts exact-locale public catalog/detail + behavior, foreign/draft/restricted hiding and sibling-organization refusal. + `Course_draft_branch_foreign_and_unknown_are_uniformly_hidden` and + `Organization_host_never_serves_a_sibling_organization` exercise the production + public GET/HEAD contract. +- [EducationIsolationTests](../../backend/tests/LearnStack.Tests.Integration/Database/EducationIsolationTests.cs) + independently tests raw app-role RLS and EF-filter behavior on all four Education + tables, including unresolved scope, insert scope, reporting reads versus writes, + immutable organizations and parent constraints. + +Fixtures apply every chain through +[MigrationChains](../../backend/tests/LearnStack.Tests.Integration/Database/MigrationChains.cs), +which owns current chain/history discovery. The current schema has five chains, +21 data tables and five history tables; tests must not copy a fixed partial chain +list. Follow [add-integration-test](../../.claude/skills/add-integration-test/SKILL.md) +for fixture selection and transaction-scoped context. Rules: - Every module owning tenant-scoped data has at least one such test. @@ -333,8 +366,12 @@ Real LiveKit is **not** required in CI; a fake provider satisfies the contract. `backend` job. 4. The Docker-bound integration tests — the `backend-integration` job. 5. Frontend unit and component tests — the `frontend` job. -6. E2E tests — from [Phase 06](../roadmap/phase-06-renderer-admin-studio.md), per - § End-to-End Tests; allowed to retry on infra flake, with logged justification. +6. Narrow seeded browser/Lighthouse proof — the `public demo + lighthouse` job + invokes the shared `make demo DEMO_MODE=ci` lifecycle, per § End-to-End Tests. + It retains real admission budgets and never retries a 429 or audits a refusal + page. The packet's Step 4 record owns the real PR receipt and seventh required + check activation. Phase 06 owns the broader Playwright Test/axe golden flows; + any infrastructure-flake retry there requires logged justification. 7. Coverage report — none yet, per § Coverage Targets. A failure in any step that runs fails the pull request. Which checks block a merge is a diff --git a/docs/standards/15-performance.md b/docs/standards/15-performance.md index ba134417..ec90ffa9 100644 --- a/docs/standards/15-performance.md +++ b/docs/standards/15-performance.md @@ -1,6 +1,6 @@ # 15 — Performance Standards -**Status:** Adopted +**Status:** Active **Derives from:** [ADR 0002 — Initial Architecture](../decisions/0002-initial-architecture.md) (initial budgets in [04-technical-architecture.md § Performance Budgets](../architecture/04-technical-architecture.md)), [ADR 0005 — Live Classroom Media Stack](../decisions/0005-live-classroom-media-stack.md) (classroom join + bandwidth budgets). Public-read additions derive from [ADR-0052](../decisions/0052-anonymous-public-read-boundary.md); P02d-5's bounded @@ -17,9 +17,13 @@ cold navigation through collection completion, including initial async/lazy loads and original-document inline executable bodies. It excludes inert data, evaluation-generated code and scripts requested after that window or by later interaction. This can be stricter than entry-chunk/build-time accounting; it is -not merely a unit clarification. P7 Step 3's local browser/audit feasibility passes; -independent reviews and CI activation remain pending. This standard stays Adopted -until Step 4 lands required enforcement. +not merely a unit clarification. P7 delivers the always-running +`public demo + lighthouse` job and its fail-closed browser/report/source controls. +The hard gzip/CLS/automated-accessibility checks make this standard Active for +that delivered scope. Timing medians remain advisory; production baselines, +field telemetry and load tests remain Phase 11. The +[Step 4 record](../roadmap/phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) +owns real CI receipts and bounded required-check activation. ## Initial Budgets diff --git a/docs/standards/16-accessibility.md b/docs/standards/16-accessibility.md index f60ebfa0..38b2e0e6 100644 --- a/docs/standards/16-accessibility.md +++ b/docs/standards/16-accessibility.md @@ -98,8 +98,11 @@ LearnStack is an education platform; learners with disabilities are a first-clas - `eslint-plugin-jsx-a11y` in the frontend lint config. - Phase 06 integrates `axe-core` with Playwright for public-renderer and portal critical flows. -- P02d-7 owns Lighthouse activation and the accessibility assertions for public - routes; the CI placeholder remains disabled. +- P02d-7 delivers the narrow managed-browser walkthrough and hard Lighthouse + automated accessibility score for nine seeded pages under + [ADR-0056](../decisions/0056-public-demo-browser-and-lighthouse-enforcement.md). + The [Step 4 record](../roadmap/phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) + owns CI and required-check receipts; this supplements the scoped P6 human record. - Manual keyboard walkthroughs for new screens in the PR review. **P02d-6 G43 enforcement — Step 3, 2026-10-10.** All 31 active recommended diff --git a/docs/standards/21-architecture-tests-catalogue.md b/docs/standards/21-architecture-tests-catalogue.md index ac3d9e57..65906fdf 100644 --- a/docs/standards/21-architecture-tests-catalogue.md +++ b/docs/standards/21-architecture-tests-catalogue.md @@ -10,7 +10,7 @@ [ADR-0055 Public Renderer Bootstrap Failures](../decisions/0055-public-renderer-bootstrap-failures.md) (replacement admission proofs implemented; both review rounds complete), [ADR-0056 Public Demo Browser and Lighthouse Enforcement](../decisions/0056-public-demo-browser-and-lighthouse-enforcement.md) -(accepted 2026-10-11; browser/audit rules Registered). The +(accepted 2026-10-11; browser/audit replacement proofs implemented). The catalogue grows as subsequent ADRs and phases land their tests; per-test ownership stays with the originating ADR / standard. @@ -134,8 +134,8 @@ two fifths of its subject is the defect this section is about. It also refuses a test class that exists nowhere, because otherwise a renamed or deleted file drops its entries out of the subject instead of failing. -**171 rules in this catalogue are Implemented, and 108 of them are in that assembly.** -The other 63 are no less binding, and most could not live there. The table says where +**175 rules in this catalogue are Implemented, and 108 of them are in that assembly.** +The other 67 are no less binding, and most could not live there. The table says where and why, and deliberately carries no per-row count: those are the numbers nothing recomputes, and the first version of this table claimed "three rules" for a suite that holds ten. @@ -656,7 +656,8 @@ otherwise). [P7 package](../roadmap/phase-02d-walking-skeleton.md#p02d-7-genericity-enforcement), approved on 2026-10-11; Step 2 implements the exact-literal/reference fences. ADR-0056's separate - browser/Lighthouse measurement decision is Accepted; its rules remain Registered. + browser/Lighthouse measurement decision and its implemented controls complement + this source fence; neither proves all dynamically assembled tenant comparisons. - **Type:** Roslyn C#/embedded-JSON scan, TypeScript AST/JSON scan, compiled and restore-resolved project references, with planted offenders and clean controls. **Kind:** structural. @@ -4489,12 +4490,15 @@ test-only instrumentation stays in the disposable copied app. ## P02d-7 public demo and Lighthouse controls -These behavioral rules remain Registered under Accepted ADR-0056 while P7 Step 3 -independent reviews and Step 4 CI enforcement remain pending. The first complete -local browser/audit feasibility run passes. The Node proof -entrypoint is `frontend/apps/web/scripts/verify-public-demo.mjs`, invoked through -the shared demo lifecycle. Step 4 adds the `public demo + lighthouse` CI job. -Registration claims neither a passing complete audit nor delivered CI enforcement. +These behavioral rules are Implemented under Accepted ADR-0056 by +`frontend/apps/web/scripts/verify-public-demo.mjs`, its contract/gatherer/worker +and the always-running `public demo + lighthouse` job through `make demo`. +`src/test/public-demo.test.ts` and `src/test/demo-lifecycle.test.ts` execute +planted failing and clean controls in the required frontend job. Actual browser +mutants, TLS refusals and a real Lighthouse timeout also run in the full proof. +The [Step 4 record](../roadmap/phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) +owns exact CI and protection receipts. These are Node behavioral rules, not +C# architecture-test methods or a full WCAG/production-performance claim. ### `Public_Demo_Uses_Seeded_Production_Pages` @@ -4505,8 +4509,8 @@ Registration claims neither a passing complete audit nor delivered CI enforcemen - **Scope:** nine delivered pages; full Playwright/axe remains Phase 06. - **Type:** Node browser proof with wrong-page/error-page controls. **Kind:** behavioural. -- **Status:** **Registered** — planned Node proof entrypoint and CI job above; - implemented only after named enforcing controls and the actual proof pass. +- **Status:** **Implemented** — `verify-public-demo.mjs` browser mode and + `public-demo.test.ts` actual-page controls, executed by the jobs above. - **Phase:** 02d (P02d-7 Step 3). ### `Public_Lighthouse_Reports_Enforce_Budgets` @@ -4518,7 +4522,7 @@ Registration claims neither a passing complete audit nor delivered CI enforcemen - **Scope:** pinned Lighthouse/Chromium; every seed lane/URL/run. - **Type:** Node report validation and real audits, with stale/missing/error and budget-offender controls. **Kind:** behavioural. -- **Status:** **Registered** — planned Node proof entrypoint and CI job above. +- **Status:** **Implemented** — named Node proof and planted controls above. - **Phase:** 02d (P02d-7 Step 3). ### `Public_Initial_JavaScript_Gzip_Budget_Is_Measured` @@ -4529,7 +4533,7 @@ Registration claims neither a passing complete audit nor delivered CI enforcemen - **Scope:** the ADR's collection window, origin coverage and exclusions. - **Type:** Node source accounting, with omitted/empty/malformed/over-budget and clean-source controls. **Kind:** behavioural. -- **Status:** **Registered** — planned Node proof entrypoint and CI job above. +- **Status:** **Implemented** — named Node proof and planted controls above. - **Phase:** 02d (P02d-7 Step 3). ### `Public_Demo_Preserves_Admission_And_Cleanup` @@ -4540,7 +4544,7 @@ Registration claims neither a passing complete audit nor delivered CI enforcemen - **Scope:** the shared demo lifecycle and full-stack CI job. - **Type:** Node lifecycle/proof controls and real production navigation. **Kind:** behavioural. -- **Status:** **Registered** — planned Node proof entrypoint and CI job above. +- **Status:** **Implemented** — named Node proof and planted controls above. - **Phase:** 02d (P02d-7 Steps 1, 3 and 4). ## References diff --git a/docs/standards/README.md b/docs/standards/README.md index 21a9ae12..72fe952c 100644 --- a/docs/standards/README.md +++ b/docs/standards/README.md @@ -67,7 +67,7 @@ bookkeeping pass. ### Honest status today -The table below describes the implementation as of 2026-10-10: +The table below describes the implementation as of 2026-10-11: [Phase 02a](../roadmap/phase-02a-kernel-tenancy.md) and P02d-1–6 are complete and merged. P02d-5's ingress, configured server caller, dynamic entry and frontend guards are delivered through PR #26; the @@ -89,8 +89,10 @@ independent review rounds. The owns completed Step 3 reviews, verified fixes and delivery evidence; its five rules are Implemented. P6's [merge closeout](../roadmap/phase-02d-walking-skeleton.md#p02d-6-merge-and-closeout-2026-10-10) -records PR #27's merge and final verification; P7 has not started. Acceptance -alone promotes no standard or test status. +records PR #27's merge and final verification. P7 delivers the shared demo, +G20 fences and seeded browser/Lighthouse enforcement. Its +[Step 4 record](../roadmap/phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) +owns review, real CI and protection receipts. Acceptance alone promotes no status. **The documents and this table say the same thing, and a test holds them to it.** [Phase 02a Packet 10](../roadmap/phase-02a-kernel-tenancy.md) reconciled the twenty-two @@ -116,8 +118,8 @@ included. | 12 | [Infrastructure](12-infrastructure.md) | **Active** | Compose stack, `Makefile`, CI workflow, pre-commit hooks and secret scanning all live since Phase 01. | | 13 | [Documentation](13-documentation.md) | **Active** | Governs this corpus; the CI link audit walks changed Markdown. | | 14 | [Git Workflow](14-git-workflow.md) | **Active** | Conventional Commits, hooks and required checks are live. Two branch-protection settings — `Require approvals` and `Do not allow bypassing` — are **deferred by maintainer decision (2026-08-10)** while the repository has one active contributor; the trigger and what activating them involves are recorded in [CONTRIBUTING § Branch protection](../../.github/CONTRIBUTING.md). P02d-1 repaired and re-read the live required-check list on 2026-09-14: all five active jobs, including the current meta name and Docker integration, are required with GitHub Actions attribution and strict up-to-date checking. P02d-4 activates the sixth `openapi diff` context after a successful real job and verifies every other setting unchanged. [CONTRIBUTING § Branch protection](../../.github/CONTRIBUTING.md#branch-protection-settings-on-main) owns the current list; the [P02d-4 delivery record](../roadmap/phase-02d-walking-skeleton.md#p02d-4-step-4-contract-sdk-and-ci) records activation verification. | -| 15 | [Performance](15-performance.md) | **Adopted** | No budget is measured and no load test exists. Enforcement lands in [Phase 11](../roadmap/phase-11-production-hardening.md). Accepted P02d-5 G44 assigns Lighthouse activation to P02d-7 after P6 pages; P7 selects the harness and assertions. The job remains disabled. [Phase 02d's decision register](../roadmap/phase-02d-walking-skeleton.md#the-decision-register) owns the decision; any status promotion lands with its enforcement. | -| 16 | [Accessibility](16-accessibility.md) | **Active** | P6 delivers catalog/course/lesson and controlled-state semantics, all 31 active recommended jsx-a11y rules at error severity with per-rule actual-config dirty/clean controls, and real product HTML/Flight proofs. The [packet closeout](../roadmap/phase-02d-walking-skeleton.md#p02d-6-packet-closeout-2026-10-10) records keyboard/focus/reflow/contrast observations and the maintainer's passing VoiceOver smoke. This is enforcement for delivered public-page scope, not a full WCAG audit. Full Playwright/axe remains [Phase 06](../roadmap/phase-06-renderer-admin-studio.md); Accepted G44 assigns Lighthouse to P02d-7 after P6. | +| 15 | [Performance](15-performance.md) | **Active** | P02d-7 delivers the always-running `public demo + lighthouse` job under ADR-0056: nine seeded pages, 27 audits, actual-page/source/census controls and hard normalized gzip/CLS/automated-accessibility checks. Timing medians are advisory. The [Step 4 record](../roadmap/phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) owns real CI and required-check receipts. Production p95/field telemetry/load tests remain [Phase 11](../roadmap/phase-11-production-hardening.md). | +| 16 | [Accessibility](16-accessibility.md) | **Active** | P6 delivers catalog/course/lesson and controlled-state semantics, all 31 active recommended jsx-a11y rules at error severity with per-rule actual-config dirty/clean controls, and real product HTML/Flight proofs. The [packet closeout](../roadmap/phase-02d-walking-skeleton.md#p02d-6-packet-closeout-2026-10-10) records keyboard/focus/reflow/contrast observations and the maintainer's passing VoiceOver smoke. This is enforcement for delivered public-page scope, not a full WCAG audit. P02d-7 adds hard Lighthouse automated accessibility and a narrow library browser walkthrough; full Playwright Test/axe remains [Phase 06](../roadmap/phase-06-renderer-admin-studio.md). | | 17 | [Code Review](17-code-review.md) | **Active** | Applied to every pull request merged so far; the zero-tolerance blocker list is in live use. | | 18 | [Audit Coverage](18-audit-coverage.md) | **Active** | Packet 9 lit the write path under [ADR-0033](../decisions/0033-audit-durability-model.md) and [ADR-0044](../decisions/0044-audit-write-path.md): classification at step 3, MUST rows on the business transaction before `COMMIT`, `audit_log` / `audit_config` with their append-only layers, and the catalogue ↔ matrix join enforced in both directions and per request type by `AuditCoverageTests`. Retention and partitioning are [Phase 11](../roadmap/phase-11-production-hardening.md)'s. | | 19 | [Permissions](19-permissions.md) | **Adopted** | No permission key, policy or role exists. Lands in [Phase 03](../roadmap/phase-03-identity-admin.md). | @@ -134,12 +136,13 @@ Step 3 adds Education eligibility, scoped seek pages and bounded content/label projections with HTTP/database proof. Step 4 adds served/snapshot equality, recursive DTO guards, generated SDK/drift and breaking-policy CI controls. -Twenty `Active`, two `Adopted`. Packet 10 moved five: the frontend rules, the one-app -rule, the locale invariants, the out-of-band setters and the port bans are all mechanical -now, and a standard whose rules a test enforces is `Active` by this document's own -definition. P02d-6 promotes Accessibility with blocking lint/semantic controls and -recorded manual evidence. Performance and Permissions remain Adopted: no budget is -enforced and no permission key exists. Each names the phase that will promote it. +Twenty-one `Active`, one `Adopted`. Packet 10 moved five: the frontend rules, the one- +app rule, the locale invariants, the out-of-band setters and the port bans are all +mechanical now, and a standard whose rules a test enforces is `Active` by this +document's own definition. P02d-6 promotes Accessibility with blocking lint/semantic +controls and recorded manual evidence. P02d-7 promotes Performance with the hard checks +above; this does not make advisory or future production measurements enforced. +Permissions remains Adopted until Phase 03 ships permission keys and enforcement. ## Relationship to ADRs diff --git a/frontend/README.md b/frontend/README.md index c6045710..bb9263ae 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -27,7 +27,7 @@ There is **no `extensions/` folder** — ADR-0018 model is data, not code. ## Common Commands ```bash -pnpm install # install workspace deps +pnpm install --frozen-lockfile # install workspace deps pnpm --filter @learnstack/web dev # native HTTPS ingress; prepare TLS first pnpm lint # eslint across the workspace pnpm typecheck # tsc --noEmit across the workspace @@ -40,5 +40,32 @@ remain explicit developer steps. Start `make public-api` in another terminal. The native ingress serves the configured tenant hosts over HTTPS on port 3000. Direct stock `next dev/start` is unsupported. P6 implements localized public catalog/course/lesson pages; its [closeout](../docs/roadmap/phase-02d-walking-skeleton.md#p02d-6-step-4-product-proof-and-accessibility-closeout) -records completed reviews and passing manual accessibility. P7 owns the browser/demo -harness; P6 awaits maintainer PR review and merge. +records completed reviews and passing manual accessibility. P6 is complete and +merged through PR #27 on 2026-10-10. P7 delivers the shared demo and narrow +Playwright library/Lighthouse proof; Phase 06 owns the broader Playwright Test/axe +suite. Automated scores retain P6's separately attributed manual evidence. + +## Seeded browser and Lighthouse proof + +From a fresh checkout without root `.env`, web `.env.local` or +`artifacts/public-demo`, run: + +```bash +# from frontend/, after the locked dependency install above +pnpm exec playwright install --with-deps chromium +cd .. +make demo DEMO_MODE=ci +``` + +The shared lifecycle builds the production API/native renderer, seeds an isolated +tmpfs-backed Compose project, stops its Keycloak and runs nine linked product +pages plus 27 cold audits. Docker, .NET, Node, pnpm, OpenSSL and make are required; +fixed application/Compose ports must be free. It uses disposable private TLS and +certificate-specific browser trust without system hosts/trust changes. Review +`artifacts/public-demo/receipt.json`, all 27 JSON/HTML report pairs and browser +screenshots; proof and owned cleanup must both pass. Follow +[Running tests locally](../.claude/skills/run-tests-locally/SKILL.md#public-demo-managed-browser-and-lighthouse) +for the complete workflow. The packet's Step 4 record and +[branch protection](../.github/CONTRIBUTING.md#branch-protection-settings-on-main) +own real CI receipts and required-check activation; local success alone does not +establish activation. Human foreground `make demo` retains the manual HTTPS setup. diff --git a/frontend/apps/web/README.md b/frontend/apps/web/README.md index db22d27e..1df84221 100644 --- a/frontend/apps/web/README.md +++ b/frontend/apps/web/README.md @@ -31,8 +31,12 @@ records completed verification, reviews and scoped browser/VoiceOver observation P6 is complete and merged through PR #27 on 2026-10-10; its [merge closeout](../../../docs/roadmap/phase-02d-walking-skeleton.md#p02d-6-merge-and-closeout-2026-10-10) owns final verification. P7's shared demo/browser package was approved on -2026-10-11, together with ADR-0056. Step 1 implements the foreground lifecycle; -the browser/audit proof remains Step 3. +2026-10-11, together with ADR-0056. The shared local/CI lifecycle and narrow +Playwright library proof are delivered: nine seeded pages and 27 Lighthouse audits. +The [Step 3 record](../../../docs/roadmap/phase-02d-walking-skeleton.md#p02d-7-step-3--browser-and-audit-proof-2026-10-11) +owns local execution and reviews; the packet's Step 4 record and CONTRIBUTING own +real CI receipts and required-check activation. Phase 06 retains the broader +Playwright Test/axe suite. There is **no `extensions/` folder for vertical-provided components** — per [ADR-0018](../../../docs/decisions/0018-tenant-driven-customization-model.md), @@ -62,3 +66,22 @@ IPv4 loopback port 3000 and serves configured hosts over HTTPS. `/api/healthz` i the exact web health path. The paired API origin comes from private local configuration, never from the visitor's URL. Direct stock `next dev/start` does not establish trusted provenance and is unsupported. + +For the isolated browser/Lighthouse proof, use a fresh checkout without root +`.env`, web `.env.local` or `artifacts/public-demo`: + +```bash +(cd frontend && pnpm install --frozen-lockfile) +(cd frontend && pnpm exec playwright install --with-deps chromium) +make demo DEMO_MODE=ci +``` + +Run these commands from the repository root with Docker and the documented +toolchain available and fixed application/Compose ports free. CI mode generates +private disposable TLS/configuration, uses certificate-specific browser trust and +stops its Keycloak before the product proof. Review the sanitized +`artifacts/public-demo/receipt.json`, 27 JSON/HTML report pairs and browser +screenshots; proof and owned cleanup must both pass. See +[Running tests locally](../../../.claude/skills/run-tests-locally/SKILL.md#public-demo-managed-browser-and-lighthouse) +for artifact freshness and cleanup rules. Local success alone does not establish +required-check activation or a new manual accessibility pass. diff --git a/infra/compose/README.md b/infra/compose/README.md index 09be2650..aa4b18dd 100644 --- a/infra/compose/README.md +++ b/infra/compose/README.md @@ -181,8 +181,28 @@ COMPOSE_PROFILES=gated docker compose --env-file .env -f infra/compose/dev.yml - ``` P02d-7's isolated demo lifecycle uses this overlay with a unique project and -private configuration. Its browser/Lighthouse driver remains Step 3 work. -The full Playwright/axe suite remains Phase 06. Explicit Compose selection ignores +private configuration. The delivered Playwright library walkthrough covers nine +seeded product pages, followed by 27 Lighthouse audits over the same production +API/build/database with its Keycloak stopped. From a fresh checkout without root +`.env`, web `.env.local` or `artifacts/public-demo`: + +```bash +(cd frontend && pnpm install --frozen-lockfile) +(cd frontend && pnpm exec playwright install --with-deps chromium) +make demo DEMO_MODE=ci +``` + +Fixed ports must be free. The lifecycle owns disposable TLS/configuration, +certificate-specific browser trust and cleanup, without modifying system hosts or +trust. Review the sanitized `artifacts/public-demo/receipt.json`, all 27 JSON/HTML +report pairs and browser screenshots; proof and cleanup must both pass. See +[Running tests locally](../../.claude/skills/run-tests-locally/SKILL.md#public-demo-managed-browser-and-lighthouse) +for the complete workflow and +[branch protection](../../.github/CONTRIBUTING.md#branch-protection-settings-on-main) +for actual required-check activation. Local success alone does not establish it. +Human `make demo` retains manual hosts/CA/leaf setup and persistent local data. + +The full Playwright Test/axe suite remains Phase 06. Explicit Compose selection ignores ambient `COMPOSE_*` overrides; use an explicit `--profile gated` for that opt-in. Host ports remain fixed, so a foreign stack/listener is refused rather than stopped. From 100b02217d0babdc0bc1989c93d235a94eff6171 Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 05:46:12 +0300 Subject: [PATCH 17/35] fix(ci): complete P7 exit proofs and reserve owned cleanup Pair host, locale and organization HTTP outcomes with raw translation reads on each request connection. Reserve cleanup inside the CI budget and prepare sandbox-enabled managed Chromium on hosted Linux only. Reconcile mutable exit and review guidance with delivered contracts. ADR: 0036, 0040, 0052, 0056 Module: Education, Tenancy --- .claude/skills/run-tests-locally/SKILL.md | 16 + .claude/skills/standards-check/SKILL.md | 18 +- .github/workflows/ci.yml | 37 ++- .../PublicLocaleEvolutionHttpTests.cs | 275 +++++++++++++++++- docs/roadmap/phase-02b-events-auth.md | 15 +- docs/roadmap/phase-02d-exit-evidence.md | 14 +- docs/roadmap/phase-02d-walking-skeleton.md | 102 +++++-- docs/standards/17-code-review.md | 22 +- .../apps/web/src/test/public-demo-ci.test.ts | 91 ++++++ scripts/ci-public-chromium.mjs | 237 +++++++++++++++ scripts/ci-public-chromium.test.mjs | 246 ++++++++++++++++ 11 files changed, 1003 insertions(+), 70 deletions(-) create mode 100644 frontend/apps/web/src/test/public-demo-ci.test.ts create mode 100644 scripts/ci-public-chromium.mjs create mode 100644 scripts/ci-public-chromium.test.mjs diff --git a/.claude/skills/run-tests-locally/SKILL.md b/.claude/skills/run-tests-locally/SKILL.md index 3e32bda4..8ea2ee4e 100644 --- a/.claude/skills/run-tests-locally/SKILL.md +++ b/.claude/skills/run-tests-locally/SKILL.md @@ -219,6 +219,22 @@ It runs nine linked product pages and 27 cold Lighthouse audits over one unchang API/build/database, with real admission pacing and certificate-specific trust. Missing browser installation fails the proof rather than skipping it. +On GitHub-hosted Linux runners, run `node scripts/ci-public-chromium.mjs prepare` +after installation and before the lifecycle, then run +`node scripts/ci-public-chromium.mjs cleanup` in an always-running cleanup step. +The helper discovers Playwright's exact executable and performs a sandbox-enabled +20-second launch smoke with a disposable browser profile. If Ubuntu's AppArmor +user-namespace restriction is enabled, it loads one invocation-owned profile +allowing `userns` only for that exact executable; the source and ownership marker +stay under `RUNNER_TEMP`, and cleanup unloads only that profile. It preserves the +kernel restriction and foreign policies/files. This follows +[Chromium's AppArmor guidance](https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md) +with a literal attachment path. The helper refuses local/self-hosted execution; +it does not change workstation policy. Run its isolated controls with +`node --test scripts/ci-public-chromium.test.mjs`; these use fake commands and +an executable fixture without mutating host AppArmor. A passing Linux job remains +required evidence of the actual runner prerequisite and complete demo/audit flow. + Review `artifacts/public-demo/receipt.json`, the 27 JSON/HTML report pairs and browser screenshots. Proof and owned cleanup must both pass. Archive only this sanitized artifact directory; private configuration, certificates, keys, profiles and raw diff --git a/.claude/skills/standards-check/SKILL.md b/.claude/skills/standards-check/SKILL.md index ef3e44b3..347b60f6 100644 --- a/.claude/skills/standards-check/SKILL.md +++ b/.claude/skills/standards-check/SKILL.md @@ -315,18 +315,20 @@ domain the diff doesn't touch. - [ ] Public-route budgets in [15-performance.md § Initial Budgets](../../../docs/standards/15-performance.md#initial-budgets) and [§ Bundle Size](../../../docs/standards/15-performance.md#bundle-size) respected. - **Not mechanically checkable yet** — `ci.yml`'s `lighthouse-budget` job is a - placeholder. Accepted P02d-5 G44 assigns activation to P02d-7/G44/G45 after - P6 pages. Judge by reading until that harness ships; do not report an unrun - audit as a measured pass or failure. + P02d-7's `make demo DEMO_MODE=ci` proof enforces the ADR-0056 normalized + gzip/CLS/automated-accessibility checks on nine seeded pages; timing medians + remain advisory. Follow + [run-tests-locally](../run-tests-locally/SKILL.md#public-demo-managed-browser-and-lighthouse) + for prerequisites and inspect actual receipts rather than claiming an unrun pass. - [ ] Backend latency budget per module respected. #### `16-accessibility.md` - [ ] WCAG 2.2 AA target. -- [ ] `axe-core` clean on changed components. **Not mechanically checkable yet** — - no `axe` dependency exists in `frontend/`; [Phase 06](../../../docs/roadmap/phase-06-renderer-admin-studio.md) - wires the automated checks, per - [Standards index row 16](../../../docs/standards/README.md). Judge by reading. +- [ ] Applicable blocking jsx-a11y rules, component semantics and P7's automated + Lighthouse accessibility checks pass. Lighthouse's transitive development axe + audit is bounded to its nine pages; the full Playwright Test/direct axe suite + remains [Phase 06](../../../docs/roadmap/phase-06-renderer-admin-studio.md). + Automated scores do not replace the recorded manual checks below. - [ ] Keyboard navigation + focus order reviewed. - [ ] Color contrast verified per brand token. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 739a4e9e..b1095b58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -380,28 +380,38 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 20 steps: + # Start before checkout. Reserve four minutes for the shared 30-second + # teardown, owned sandbox-policy cleanup and bounded receipt/artifact steps. + - name: Reserve demo cleanup and artifact time + run: echo "PUBLIC_DEMO_DEADLINE=$(( $(date +%s) + 16 * 60 ))" >> "$GITHUB_ENV" + - name: Checkout + timeout-minutes: 2 uses: actions/checkout@v4 with: persist-credentials: false - name: Set up .NET SDK + timeout-minutes: 3 uses: actions/setup-dotnet@v4 with: global-json-file: backend/global.json - name: Set up Node.js + timeout-minutes: 2 uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} - name: Set up pnpm + timeout-minutes: 1 uses: pnpm/action-setup@v4 with: version: ${{ env.PNPM_VERSION }} run_install: false - name: Cache NuGet packages + timeout-minutes: 1 uses: actions/cache@v4 with: path: ~/.nuget/packages @@ -410,20 +420,42 @@ jobs: nuget-${{ runner.os }}- - name: Install pinned browser tools + timeout-minutes: 5 working-directory: frontend run: | pnpm install --frozen-lockfile pnpm exec playwright install --with-deps chromium + - name: Prepare sandbox-enabled managed Chromium + timeout-minutes: 1 + run: | + node --test scripts/ci-public-chromium.test.mjs + node scripts/ci-public-chromium.mjs prepare + # The same entrypoint owns restoration, seven-service readiness, migrations, # contextual seeding, native TLS, production builds and confirmed cleanup. - # Its 12-minute proof deadline is separate from setup and 30-second cleanup. + # Its internal 12-minute proof bound remains; this earlier absolute job + # deadline also bounds cumulative setup/build before owned teardown. - name: Prove the seeded production sites and budgets id: demo - run: make demo DEMO_MODE=ci + run: | + remaining=$(( PUBLIC_DEMO_DEADLINE - $(date +%s) )) + if [ "$remaining" -le 0 ]; then + echo 'Demo setup exhausted the reserved job budget.' >&2 + exit 1 + fi + # SIGINT enters the shared owner teardown; forced termination is a + # failed run, never passing or partial proof evidence. + timeout --signal=INT --kill-after=35s "${remaining}s" make demo DEMO_MODE=ci + + - name: Remove only the owned Chromium sandbox profile + if: always() + timeout-minutes: 1 + run: node scripts/ci-public-chromium.mjs cleanup - name: Record bounded workflow outcome if: always() + timeout-minutes: 1 env: DEMO_OUTCOME: ${{ steps.demo.outcome }} CHECKOUT_SHA: ${{ github.sha }} @@ -442,6 +474,7 @@ jobs: - name: Upload public reports and sanitized receipts only if: always() + timeout-minutes: 1 uses: actions/upload-artifact@v4 with: name: public-demo-lighthouse diff --git a/backend/tests/LearnStack.Tests.Integration/Database/PublicLocaleEvolutionHttpTests.cs b/backend/tests/LearnStack.Tests.Integration/Database/PublicLocaleEvolutionHttpTests.cs index 2f773815..4f85383d 100644 --- a/backend/tests/LearnStack.Tests.Integration/Database/PublicLocaleEvolutionHttpTests.cs +++ b/backend/tests/LearnStack.Tests.Integration/Database/PublicLocaleEvolutionHttpTests.cs @@ -10,12 +10,16 @@ using LearnStack.Modules.Tenancy.Application.Contracts.Locales; using LearnStack.Modules.Tenancy.Application.Contracts.PublicReads; using LearnStack.Modules.Tenancy.Application.Contracts.Seeding; +using LearnStack.Modules.Tenancy.Application.Contracts.Tenant; using LearnStack.Modules.Tenancy.Infrastructure.Persistence; +using LearnStack.SharedKernel.Identifiers; +using LearnStack.SharedKernel.Persistence; using LearnStack.SharedKernel.Results; using LearnStack.SharedKernel.Tenancy; using LearnStack.Tools.Seeder; using MediatR; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; @@ -92,6 +96,10 @@ public async Task Third_locale_authored_through_api_commands_serves_exact_new_ur course.Status.Should().Be("Published"); course.ContentAccess.Should().Be("public"); + var englishContext = new SeedTenantContext(SeedData.English.TenantId, null); + var englishBefore = (await SendAsync(host, englishContext, new GetTenantSeedStateQuery())).State!; + await SendAsync(host, englishContext, new AddTenantLocaleCommand(englishBefore.Version, "fr", true, false, 1)); + var auditsAfterAuthoring = await CountsAsync(database.AppConnectionString, organizationContext); var catalog = await JsonAsync(client, Root + "?locale=fr"); var detail = await JsonAsync(client, $"{Root}/{FrenchCourseSlug}?locale=fr"); @@ -108,10 +116,14 @@ public async Task Third_locale_authored_through_api_commands_serves_exact_new_ur } foreach (var path in new[] { "/foundation", "/studyo-temelleri", "/foundation/lessons/tree-pose", "/studyo-temelleri/lessons/agac-durusu" }) await NotFoundAsync(client, Root + path + "?locale=fr"); - // English's enabled locale admits the request, then tenant isolation hides - // the new Yoga course and lesson independently of locale admission. - await NotFoundAsync(client, $"http://{SeedData.English.Host}{Root}/{FrenchCourseSlug}?locale=en"); - await NotFoundAsync(client, $"http://{SeedData.English.Host}{Root}/{FrenchCourseSlug}/lessons/{FrenchLessonSlug}?locale=en"); + // Both hosts now admit French, and these exact URLs succeeded on Yoga. + // The foreign refusal therefore discriminates tenant isolation from an + // unsupported locale or a translation missing on the owning tenant. + var englishFrench = await JsonAsync(client, $"http://{SeedData.English.Host}{Root}?locale=fr"); + englishFrench["locale"]!.GetValue<string>().Should().Be("fr"); + englishFrench["items"]!.AsArray().Should().BeEmpty(); + await NotFoundAsync(client, $"http://{SeedData.English.Host}{Root}/{FrenchCourseSlug}?locale=fr"); + await NotFoundAsync(client, $"http://{SeedData.English.Host}{Root}/{FrenchCourseSlug}/lessons/{FrenchLessonSlug}?locale=fr"); await NotFoundAsync(client, $"{Root}/foundation/lessons/{FrenchLessonSlug}?locale=fr"); var siteAfter = await JsonAsync(client, Site); @@ -182,6 +194,89 @@ public async Task Organization_branding_writer_is_refused_with_denied_audit_and_ observation.Reads.Should().BeGreaterThan(0); } + [Fact] + public async Task Public_host_locale_and_organization_contracts_hold_together_with_exact_request_connection_translation_scope() + { + await using var database = await SeededDatabaseAsync(); + var observation = new PublicReadObservation(); + var scopes = new TranslationScopeObservation(); + await using var host = ApiHost(database, observation, scopes); + using var client = Client(host, Yoga.Host); + var context = new SeedTenantContext(Yoga.TenantId, null); + const string tenantHost = "yoga-tenant-scope.example.test"; + var mapping = await SendAsync(host, context, new MapHostToTenantCommand(tenantHost, null, true, true)); + mapping.TenantId.Should().Be(Yoga.TenantId); + mapping.OrganizationId.Should().BeNull(); + var tenant = (await SendAsync(host, context, new GetTenantSeedStateQuery())).State!; + await SendAsync(host, context, new AddTenantLocaleCommand(tenant.Version, "fr", true, false, 2)); + var probe = await AuthorLocaleProbeAsync(host, context); + scopes.Expect(SeedData.English.Host, SeedData.English, null, null); + scopes.Expect(Yoga.Host, Yoga, Yoga.DefaultOrganization.OrganizationId, probe); + scopes.Expect(tenantHost, Yoga, null, probe); + var requests = 0; + + // The same supported route and locale positively resolve B's unique + // course, then conceal it on A's already live host. + var yogaOnly = Yoga.Curriculum!.Courses.Single(course => course.SlugKey == "shared-practice"); + var yogaOnlySlug = yogaOnly.Translations.Single(row => row.Locale == "en").Slug; + JsonNode.DeepEquals(await Read(Yoga.Host, $"/{yogaOnlySlug}?locale=en"), + ExpectedSeedCourse(Yoga, yogaOnly.Id, "en")).Should().BeTrue(); + await Hidden(SeedData.English.Host, $"/{yogaOnlySlug}?locale=en"); + + // Stable source identities select the full expected public payloads; + // neither accepted public DTO exposes its source ID. + var englishShared = SeedData.English.Curriculum!.Courses.Single(course => course.SlugKey == "foundations"); + var yogaShared = Yoga.Curriculum.Courses.Single(course => course.SlugKey == "studio-foundations"); + var englishDetail = await Read(SeedData.English.Host, "/foundation?locale=en"); + var yogaDetail = await Read(Yoga.Host, "/foundation?locale=en"); + JsonNode.DeepEquals(englishDetail, ExpectedSeedCourse(SeedData.English, englishShared.Id, "en")).Should().BeTrue(); + JsonNode.DeepEquals(yogaDetail, ExpectedSeedCourse(Yoga, yogaShared.Id, "en")).Should().BeTrue(); + JsonNode.DeepEquals(englishDetail, yogaDetail).Should().BeFalse(); + + var englishProbe = await Read(Yoga.Host, "/locale-probe?locale=en"); + englishProbe["course"]!["title"]!.GetValue<string>().Should().Be("Locale probe"); + Slugs(englishProbe["lessons"]!["items"]!).Should().Equal("english-lesson"); + var turkishProbe = await Read(Yoga.Host, "/yerel-prova?locale=tr-TR"); + Slugs(turkishProbe["lessons"]!["items"]!).Should().Equal("yalniz-turkce"); + var translatedLesson = await Read(Yoga.Host, "/locale-probe/lessons/english-lesson?locale=en"); + translatedLesson["lesson"]!["title"]!.GetValue<string>().Should().Be("English lesson"); + var otherLocaleLesson = await Read(Yoga.Host, "/yerel-prova/lessons/yalniz-turkce?locale=tr-TR"); + otherLocaleLesson["lesson"]!["title"]!.GetValue<string>().Should().Be("Yalnız Türkçe"); + await Hidden(Yoga.Host, "/locale-probe/lessons/yalniz-turkce?locale=en"); + await Hidden(Yoga.Host, "/locale-probe?locale=fr"); + var frenchCatalog = await Read(Yoga.Host, "?locale=fr"); + frenchCatalog["locale"]!.GetValue<string>().Should().Be("fr"); + Slugs(frenchCatalog["items"]!).Should().BeEmpty("French is enabled but none of these published courses has a French translation"); + + var organizationCatalog = await Read(Yoga.Host, "?locale=en"); + Slugs(organizationCatalog["items"]!).Should().Equal( + SeedCatalogSlugs(Yoga, Yoga.DefaultOrganization.OrganizationId, "en").Append("locale-probe")); + Slugs((await Read(Yoga.Host, "?locale=tr-TR"))["items"]!).Should().Contain("yerel-prova"); + var sibling = Yoga.Curriculum.Courses.Single(course => course.OrganizationId == Yoga.SecondOrganization.OrganizationId); + await Hidden(Yoga.Host, "/" + sibling.Translations.Single(row => row.Locale == "en").Slug + "?locale=en"); + var tenantCatalog = await Read(tenantHost, "?locale=en"); + Slugs(tenantCatalog["items"]!).Should().Equal(SeedCatalogSlugs(Yoga, null, "en").Append("locale-probe")); + await Hidden(tenantHost, "/foundation?locale=en"); + JsonNode.DeepEquals(await Read(tenantHost, $"/{yogaOnlySlug}?locale=en"), + ExpectedSeedCourse(Yoga, yogaOnly.Id, "en")).Should().BeTrue(); + + // Each successful/hidden HTTP request passes the raw satellite observer + // exactly once on its own physically read-only application transaction. + scopes.Reads.Should().Be(requests); + observation.Reads.Should().Be(requests); + + async Task<JsonNode> Read(string hostname, string path) + { + requests++; + return await JsonAsync(client, $"http://{hostname}{Root}{path}"); + } + async Task Hidden(string hostname, string path) + { + requests++; + await NotFoundAsync(client, $"http://{hostname}{Root}{path}"); + } + } + private async Task<DisposableSchemaDatabase> SeededDatabaseAsync() { var database = await DisposableSchemaDatabase.CreateAsync(schema.Postgres); @@ -199,7 +294,8 @@ private async Task<DisposableSchemaDatabase> SeededDatabaseAsync() } } - private WebApplicationFactory<Program> ApiHost(DisposableSchemaDatabase database, PublicReadObservation observation) => + private WebApplicationFactory<Program> ApiHost(DisposableSchemaDatabase database, PublicReadObservation observation, + TranslationScopeObservation? scopes = null) => factory.WithWebHostBuilder(builder => builder .UseEnvironment(Environments.Development) .UseSetting("ConnectionStrings:Default", database.AppConnectionString) @@ -207,10 +303,16 @@ private WebApplicationFactory<Program> ApiHost(DisposableSchemaDatabase database .ConfigureTestServices(services => { services.AddSingleton(observation); + services.AddHttpContextAccessor(); services.AddScoped<PublicTenantConfigurationReader>(); // This existing observer checks the actual enlisted transaction's // READ ONLY, current_user, superuser and BYPASSRLS flags. - services.AddScoped<IPublicTenantConfigurationReader, ObservedPublicConfigurationReader>(); + services.AddScoped<ObservedPublicConfigurationReader>(); + services.AddScoped<IPublicTenantConfigurationReader>(provider => scopes is null + ? provider.GetRequiredService<ObservedPublicConfigurationReader>() + : new RequestTranslationScopeReader(provider.GetRequiredService<ObservedPublicConfigurationReader>(), + provider.GetRequiredService<IUnitOfWork>(), provider.GetRequiredService<ITenantContext>(), + provider.GetRequiredService<IHttpContextAccessor>(), scopes)); })); private static HttpClient Client(WebApplicationFactory<Program> host, string hostname) => @@ -231,6 +333,76 @@ private static async Task<T> SendAsync<T>(WebApplicationFactory<Program> host, I finally { accessor.Current = previous; } } + private static async Task<LocaleProbe> AuthorLocaleProbeAsync(WebApplicationFactory<Program> host, SeedTenantContext context) + { + var course = await SendAsync(host, context, new CreateCourseCommand(Guid.CreateVersion7(), "locale-probe", "public")); + course = await SendAsync(host, context, new AddCourseTranslationCommand(course.Id, course.Version, + "en", "Locale probe", null, "locale-probe")); + course = await SendAsync(host, context, new AddCourseTranslationCommand(course.Id, course.Version, + "tr-TR", "Yerel prova", null, "yerel-prova")); + var contentType = Yoga.Curriculum!.ContentType; + const string body = """{"pose":"Probe pose","instruction":"Hold steadily.","breathing":"Breathe slowly."}"""; + var turkish = await SendAsync(host, context, new CreateLessonCommand(Guid.CreateVersion7(), course.Id, 0, + contentType.Key, contentType.SchemaVersion)); + turkish = await SendAsync(host, context, new AddLessonTranslationCommand(turkish.Id, turkish.Version, + "tr-TR", "Yalnız Türkçe", "yalniz-turkce", body)); + await SendAsync(host, context, new PublishLessonCommand(turkish.Id, turkish.Version)); + var english = await SendAsync(host, context, new CreateLessonCommand(Guid.CreateVersion7(), course.Id, 1, + contentType.Key, contentType.SchemaVersion)); + english = await SendAsync(host, context, new AddLessonTranslationCommand(english.Id, english.Version, + "en", "English lesson", "english-lesson", body)); + await SendAsync(host, context, new PublishLessonCommand(english.Id, english.Version)); + await SendAsync(host, context, new PublishCourseCommand(course.Id, course.Version)); + return new LocaleProbe(context.TenantId, course.Id, turkish.Id, english.Id); + } + + private static JsonNode ExpectedSeedCourse(SeedTenant tenant, Guid sourceId, string locale) + { + var curriculum = tenant.Curriculum!; + var course = curriculum.Courses.Single(row => row.Id == sourceId); + var translation = course.Translations.Single(row => row.Locale == locale); + curriculum.Taxonomy.Key.Should().Be(course.LevelTaxonomyKey); + curriculum.Taxonomy.SchemaVersion.Should().Be(course.LevelTaxonomySchemaVersion); + var band = curriculum.Taxonomy.Bands.Single(row => row.Key == course.LevelBandKey); + var alternates = curriculum.Locales.Where(row => row.IsEnabled && row.Locale != locale) + .OrderBy(row => row.Sort).ThenBy(row => row.Locale, StringComparer.Ordinal) + .Select(row => course.Translations.SingleOrDefault(item => item.Locale == row.Locale)) + .Where(row => row is not null).Select(row => new { locale = row!.Locale, slug = row.Slug }).ToArray(); + object? outline = course.ContentAccess == "public" ? new + { + items = course.Lessons.Where(row => row.Status == "Published" && row.Translations.Any(item => item.Locale == locale)) + .OrderBy(row => row.Sort).ThenBy(row => row.Id).Select(row => new + { + slug = row.Translations.Single(item => item.Locale == locale).Slug, + title = row.Translations.Single(item => item.Locale == locale).Title, + sort = row.Sort, + }).ToArray(), + pageInfo = new { nextCursor = (string?)null, previousCursor = (string?)null, hasNext = false, hasPrevious = false }, + } : null; + return JsonSerializer.SerializeToNode(new + { + locale, + course = new + { + slug = translation.Slug, + title = translation.Title, + summary = translation.Summary, + contentAccess = course.ContentAccess, + level = new { state = "ready", label = new { value = band.DisplayName[locale], locale } }, + }, + alternates, + lessons = outline, + })!; + } + + private static string[] SeedCatalogSlugs(SeedTenant tenant, OrganizationId? organization, string locale) => + tenant.Curriculum!.Courses.Where(row => row.Status == "Published" + && (row.OrganizationId is null || row.OrganizationId == organization)) + .Select(row => row.Translations.SingleOrDefault(item => item.Locale == locale)) + .Where(row => row is not null).Select(row => row!.Slug).ToArray(); + + private static string[] Slugs(JsonNode items) => items.AsArray().Select(item => item!["slug"]!.GetValue<string>()).ToArray(); + private static void AssertFrenchResponses(JsonNode catalog, JsonNode course, JsonNode lesson) { var summary = JsonSerializer.SerializeToNode(new { slug = FrenchCourseSlug, title = FrenchCourseTitle, summary = FrenchSummary, contentAccess = "public", level = (object?)null }); @@ -266,7 +438,7 @@ private static async Task<JsonNode> JsonAsync(HttpClient client, string path) { using var response = await client.GetAsync(path); response.StatusCode.Should().Be(HttpStatusCode.OK, await response.Content.ReadAsStringAsync()); - response.Headers.CacheControl?.NoStore.Should().BeTrue(); + (response.Headers.CacheControl?.NoStore).Should().BeTrue(); return (await response.Content.ReadFromJsonAsync<JsonNode>())!; } @@ -274,7 +446,7 @@ private static async Task NotFoundAsync(HttpClient client, string path) { using var response = await client.GetAsync(path); response.StatusCode.Should().Be(HttpStatusCode.NotFound, await response.Content.ReadAsStringAsync()); - response.Headers.CacheControl?.NoStore.Should().BeTrue(); + (response.Headers.CacheControl?.NoStore).Should().BeTrue(); response.Content.Headers.ContentType!.MediaType.Should().Be("application/problem+json"); var problem = (await response.Content.ReadFromJsonAsync<JsonNode>())!; problem["code"]!.GetValue<string>().Should().Be("not_found"); @@ -342,4 +514,91 @@ SELECT count(*) FROM audit_log private sealed record HistoryRow(string MigrationId, string ProductVersion); private sealed record WriteCounts(long Settings, long Audits, long SuccessfulBrandingAudits); + private sealed record LocaleProbe(TenantId TenantId, Guid CourseId, Guid TurkishLessonId, Guid EnglishLessonId); + private sealed record TranslationRow(Guid TenantId, Guid? OrganizationId, Guid RootId, string Locale, string Slug); + private sealed record TranslationScope(TenantId TenantId, OrganizationId? OrganizationId, + TranslationRow[] Courses, TranslationRow[] Lessons); + + private sealed class TranslationScopeObservation + { + private readonly Dictionary<string, TranslationScope> _expected = new(StringComparer.Ordinal); + private int _reads; + public int Reads => Volatile.Read(ref _reads); + + public void Expect(string hostname, SeedTenant tenant, OrganizationId? organization, LocaleProbe? probe) + { + // Raw scope deliberately includes every seeded translation regardless + // of publication/access/locale; these are RLS assertions, not the + // narrower public-eligibility projection. + var courses = tenant.Curriculum!.Courses + .Where(row => row.OrganizationId is null || row.OrganizationId == organization).ToArray(); + var courseRows = courses.SelectMany(course => course.Translations.Select(row => + new TranslationRow(tenant.TenantId.Value, course.OrganizationId?.Value, course.Id, row.Locale, row.Slug))).ToList(); + var lessonRows = courses.SelectMany(course => course.Lessons.SelectMany(lesson => lesson.Translations.Select(row => + new TranslationRow(tenant.TenantId.Value, course.OrganizationId?.Value, lesson.Id, row.Locale, row.Slug)))).ToList(); + if (probe is not null) + { + probe.TenantId.Should().Be(tenant.TenantId); + courseRows.AddRange([ + new TranslationRow(probe.TenantId.Value, null, probe.CourseId, "en", "locale-probe"), + new TranslationRow(probe.TenantId.Value, null, probe.CourseId, "tr-TR", "yerel-prova"), + ]); + lessonRows.AddRange([ + new TranslationRow(probe.TenantId.Value, null, probe.TurkishLessonId, "tr-TR", "yalniz-turkce"), + new TranslationRow(probe.TenantId.Value, null, probe.EnglishLessonId, "en", "english-lesson"), + ]); + } + courseRows.Should().NotBeEmpty(); + lessonRows.Should().NotBeEmpty(); + _expected.Add(hostname, new TranslationScope(tenant.TenantId, organization, courseRows.ToArray(), lessonRows.ToArray())); + } + + public async Task AssertAsync(string hostname, ITenantContext context, IUnitOfWork unit, CancellationToken cancellationToken) + { + var expected = _expected[hostname]; + context.TenantId.Should().Be(expected.TenantId); + context.OrganizationId.Should().Be(expected.OrganizationId); + context.HostScope.Should().NotBeNull(); + context.HostScope!.TenantId.Should().Be(expected.TenantId); + context.HostScope.OrganizationId.Should().Be(expected.OrganizationId); + unit.Mode.Should().Be(TransactionMode.ReadOnly); + unit.HasActiveTransaction.Should().BeTrue(); + unit.IsTenantContextIssuedOn(unit.Transaction).Should().BeTrue(); + await SchemaQueries.AssertApplicationRoleAsync(unit.Connection); + // No WHERE clause, EF query filter, replacement connection, or scope + // announcement: only the request's already enlisted RLS frame filters + // these two complete satellite-table reads. + var courses = await ReadRowsAsync(unit, + "SELECT tenant_id, organization_id, course_id, locale, slug FROM course_translations", cancellationToken); + var lessons = await ReadRowsAsync(unit, + "SELECT tenant_id, organization_id, lesson_id, locale, slug FROM lesson_translations", cancellationToken); + courses.Should().NotBeEmpty(); + lessons.Should().NotBeEmpty(); + courses.Should().BeEquivalentTo(expected.Courses, "raw course translations must match the exact scope of host {0}", hostname); + lessons.Should().BeEquivalentTo(expected.Lessons, "raw lesson translations must match the exact scope of host {0}", hostname); + Interlocked.Increment(ref _reads); + } + + private static async Task<List<TranslationRow>> ReadRowsAsync(IUnitOfWork unit, string sql, CancellationToken cancellationToken) + { + await using var command = new NpgsqlCommand(sql, (NpgsqlConnection)unit.Connection, (NpgsqlTransaction?)unit.Transaction); + await using var reader = await command.ExecuteReaderAsync(cancellationToken); + var rows = new List<TranslationRow>(); + while (await reader.ReadAsync(cancellationToken)) + rows.Add(new TranslationRow(reader.GetGuid(0), reader.IsDBNull(1) ? null : reader.GetGuid(1), + reader.GetGuid(2), reader.GetString(3), reader.GetString(4))); + return rows; + } + } + + private sealed class RequestTranslationScopeReader(ObservedPublicConfigurationReader reader, IUnitOfWork unit, + ITenantContext context, IHttpContextAccessor http, TranslationScopeObservation observation) : IPublicTenantConfigurationReader + { + public async Task<Result<PublicTenantConfiguration>> ReadAsync(CancellationToken cancellationToken) + { + var result = await reader.ReadAsync(cancellationToken); + await observation.AssertAsync(http.HttpContext!.Request.Host.Host, context, unit, cancellationToken); + return result; + } + } } diff --git a/docs/roadmap/phase-02b-events-auth.md b/docs/roadmap/phase-02b-events-auth.md index a2239036..0c2e64c9 100644 --- a/docs/roadmap/phase-02b-events-auth.md +++ b/docs/roadmap/phase-02b-events-auth.md @@ -1270,13 +1270,14 @@ shape depends on an open gate say so, and are written when that gate is Accepted amendment written after the code it governs is a record nobody can disagree with — the lesson Packet 9 recorded for its own readings. The mitigation is the decision pass each packet opens with: its decisions are its first commit, and its code follows them. -- **A gate is answered before the ground it stands on exists.** Several premises the - register cites are code [Phase 02d](phase-02d-walking-skeleton.md) has not yet - written: the first `/api/v1/*` endpoints, which **G14** and **G20** bound; the local - hosts **G12**'s transport serves; and the socket-peer limiter G14 describes, which - Phase 02d's server-rendered pages reach through one peer. Earlier packets move later - premises the same way: the dispatcher's keyed data source can change the connection - allow-list before **G9** decides the job storage's entry in it. The mitigation is +- **A gate relies on a premise that an earlier packet has moved.** + [Phase 02d](phase-02d-walking-skeleton.md) delivered public GET/HEAD endpoints, + retained native HTTPS tenant hosts and coordinated canonical visitor/physical-peer + admission. **G14**, **G20** and **G12** must use those delivered contracts, including + single-bootstrap rendering and exact peer accounting, rather than the former + socket-peer-only assumption. Earlier packets move later premises the same way: + the dispatcher's keyed data source can change the connection allow-list before + **G9** decides the job storage's entry in it. The mitigation is [Roadmap § Decision Timing](README.md#decision-timing): `P02b-0` re-verifies the register once Phase 02d exits, and each gate closes in the decision pass of the first packet it shapes. diff --git a/docs/roadmap/phase-02d-exit-evidence.md b/docs/roadmap/phase-02d-exit-evidence.md index ed796514..4d297c33 100644 --- a/docs/roadmap/phase-02d-exit-evidence.md +++ b/docs/roadmap/phase-02d-exit-evidence.md @@ -92,9 +92,9 @@ checks supplement that record; they do not manufacture new human evidence. | D30 | The required `frontend` job refusing a Vitest run that reports a skipped or todo case in every workspace package that carries tests, proven with … | Guarded workspace runner and planted skip/todo/empty/omitted-workspace controls; No_Architecture_Test_Is_Skippable. | B, F | | D31 | The accessibility review Accessibility Standards requires of every new screen, recorded in the renderer pull request's description: a manual keyboard walkthrough of each public … | PR27 description preserves attributed prior manual smoke and links Original manual evidence to P6 Step4; P6 manual/VoiceOver closeout. | H | | D32 | The tenant-branching check **G20** selects, Registered in the first pass that uses it and Implemented with its companion before exit. | Step2 DomainGenericityTests.DemoIdentities.cs, demo-genericity.test.ts, Production_Projects_Do_Not_Reference_The_Seeder, schema-replacement fixture. | B, I, F, M | -| D33 | `make demo` and its stop behaviour per **G45**, with README § Quickstart, the closing output of `scripts/seed.sh` and the `local-dev-setup` and `seed-tenant` skills updated … | Step1 demo-lifecycle controls/shared supervisor; README/seed/local-dev/seed skills partly updated. | J, M | +| D33 | `make demo` and its stop behaviour per **G45**, with README § Quickstart, the closing output of `scripts/seed.sh` and the `local-dev-setup` and `seed-tenant` skills updated … | Step1 demo-lifecycle controls/shared supervisor; README, seed output and local-dev/seed/test skills updated to the delivered shared lifecycle. | J, M | | D34 | The full-stack Lighthouse job and its committed configuration, if **G44** activates it here. | Step3 pinned browser/Lighthouse configuration, gatherer/report/gzip/admission controls and local 27-report feasibility. | J | -| D35 | The standards index rows this phase makes stale — the notes on Frontend Coding, Frontend Architecture and Accessibility Standards, the table count on Database … | Database counts updated previously; Accessibility already Active. Performance still Adopted and four P7 rules still Registered. Performance is Active for the implemented hard P7 checks; Permissions remains Adopted. | B, F, J, M | +| D35 | The standards index rows this phase makes stale — the notes on Frontend Coding, Frontend Architecture and Accessibility Standards, the table count on Database … | Database counts updated previously; Accessibility already Active. Performance is Active for implemented hard P7 checks; all four behavioral P7 rules are Implemented. Permissions remains Adopted. | B, F, J, M | | D36 | The delivery record at exit names the Education model shipped, the preservation obligations G2 recorded, the seed fixtures Phase 05's migration must carry, and … | Phase05 inherited baseline already preserves rows/IDs/URLs/order/scope/body/pins/policy. | M | ## Completion criteria @@ -128,7 +128,7 @@ checks supplement that record; they do not manufacture new human evidence. | C25 | A duplicate slug written through the command **G11** names returns `Result.Fail(business_rule_violation)` and does not throw. A slug outside the shape **G9** settles is refused … | EducationWriterTests, EducationWriterValidationTests, EducationConstraintTests. | B, I | | C26 | A publication-state transition **G3** forbids answers `Result.Fail(business_rule_violation)` from the command, does not throw, and writes nothing (`backend integration`, plus a command or aggregate unit … | EducationAggregateTests/EducationWriterTests forbidden lifecycle and no mutation. | B, I | | C27 | A branding value outside **G16**'s grammar — `red;}body{background:url(//x)}`, a string containing `</style>` — never reaches a rendered document, and a refused write commits neither … | TenancyWriterTests branding refusal/atomicity, BrandingThemeTests, product theme defenses. | B, I, F | -| C28 | A branding key written as an organization-scoped `tenant_settings` row behaves as **G16** (e) records, checked request-level through a host mapped to the organization: refused … | PublicLocaleEvolutionHttpTests.Organization_branding_writer_is_refused_with_denied_audit_and_mapped_host_keeps_tenant_palette; local focused case passed; one expected Denied audit, no successful setting mutation; final I pending. | I, M | +| C28 | An organization-scoped branding command is refused without setting mutation; its Denied audit is retained, and the live organization host keeps the tenant palette. | PublicLocaleEvolutionHttpTests.Organization_branding_writer_is_refused_with_denied_audit_and_mapped_host_keeps_tenant_palette; local focused case passed; one expected Denied audit, no successful setting mutation; final I pending. | I, M | | C29 | If **G19** includes a write-time rule, a lesson write holding a disallowed URL is refused with details naming the JSON pointer, and nothing is … | G19 Accepted text profile introduces no active URL sink or scheme write-time rule. | N | | C30 | Whatever **G18** refuses at save — which may include a presentation entry naming a property absent from `properties`, a malformed label map or a … | TextCardPresentationTests, customization command/schema validation tests. | B | | C31 | A course write naming a taxonomy revision or band key the tenant does not declare, including one only the other tenant declares, returns `validation_failed` … | EducationWriterTests and EducationWriterValidationTests taxonomy/band binding validation. | B, I | @@ -140,9 +140,9 @@ checks supplement that record; they do not manufacture new human evidence. | C37 | Every cache family this phase adds appears in the cheat sheet, the Observability Standards family list and the `cache.name` mapping, and none of its … | InMemoryCacheServiceTests and three named cache-family carrier lists. | B, M | | C38 | For a request in an enabled `tr-TR`, a label authored only under `tr` resolves as the chain **G24** records, and a value missing in … | PublicEducationDisplayTests and locale-resolution/projection tests; P3/P4 fallback records. | B, I | | C39 | The out-of-band setter guard stays green: either the setter table is unchanged, or the ADR-0040 amendment and Security Standards row land with the loader. | Out-of-band setter guards and P2/P3 approved setter decisions. | B, M | -| C40 | In one test, a course slug that exists only in tenant B returns `200` with that course on tenant B's host and `404` on … | PublicEducationHttpTests and TenantIsolationHttpTests paired positive/negative host cases. | I, M | -| C41 | In the same test, a course returns `200` at its slug in a locale it is translated into and `404` for that slug under … | PublicEducationHttpTests.Course_and_lesson_use_exact_translations_and_real_alternate_url_pairs and Missing_exact_translation_never_uses_default_content_or_advertises_disabled_alternates. | I | -| C42 | On the organization host, a sibling organization's course is absent from the catalog and its slug returns `404`, while a tenant-wide course and its … | PublicEducationHttpTests.Organization_host_never_serves_a_sibling_organization and isolation suite raw satellite cases. | I | +| C40 | In one test, a course slug that exists only in tenant B returns `200` with that course on tenant B's host and `404` on … | PublicLocaleEvolutionHttpTests.Public_host_locale_and_organization_contracts_hold_together_with_exact_request_connection_translation_scope pairs foreign-only/shared slugs with full seed-derived payloads. | I | +| C41 | In the same test, a course returns `200` at its slug in a locale it is translated into and `404` for that slug under … | The same PublicLocaleEvolutionHttpTests case pairs enabled/untranslated French with translated EN/TR course and lesson lists. | I | +| C42 | On the organization host, a sibling organization's course is absent from the catalog and its slug returns `404`, while a tenant-wide course and its … | The same PublicLocaleEvolutionHttpTests case proves three host scopes and exact raw satellite row sets on each of its 17 HTTP requests' own enlisted connection. | I | | C43 | A draft course is absent from the catalog, and its detail slug and every lesson requested under it answer per **G29**; a lesson of … | PublicEducationHttpTests.Course_draft_branch_foreign_and_unknown_are_uniformly_hidden and Lesson_masks_draft_parent_draft_restricted_scope_wrong_parent_and_foreign_rows. | I | | C44 | Each of the reads without `locale` returns `400` `validation_failed` naming `locale`, never a `500` or a defaulted locale; sending a different `X-Locale` or `Accept-Language` … | PublicEducationHttpTests query/detail/unsupported-locale cases including Well_formed_unsupported_locale_is_400_and_headers_do_not_replace_explicit_locale. | I | | C45 | A cursor value the catalog list cannot read — malformed or truncated — returns `400` `validation_failed` naming `cursor`, never `500`. Walking `nextCursor` with a … | PublicEducationHttpTests query-shape/cursor/seek cases, PublicReadProtocolTests and OpenAPI exact parameter controls. | B, I, O | @@ -178,7 +178,7 @@ checks supplement that record; they do not manufacture new human evidence. | C75 | No Education type, member, column, key or DTO name carries a forbidden domain term, and Education references Customization only through its `Application.Contracts` assembly (`backend`). | DomainGenericityTests and module-dependency guards. | B | | C76 | If **G44** activates it in this phase, the Lighthouse job runs real steps under a name without "(deferred to Phase 02d)", audits the URL … | Step3 complete local nineURL x threeRun feasibility, report/gzip/admission/offender controls and zero429 positive observer. | J | | C77 | Every register row is closed in the form **G1** chose; every Deliverable is observed by at least one criterion; no catalogue row whose Phase … | Four P7 behavioral entries are Implemented with Node owners, planted controls and the always-running public-demo job; CorpusConsistencyTests enforces status/count alignment. | B, I, F, J, M | -| C78 | Every row in § Explicitly not in this phase names a phase whose own document carries that capability in its scope, its deliverables or … | Owner audit X01-X39 below; current output/seed-host carriers partly stale. | M | +| C78 | Every row in § Explicitly not in this phase names a phase whose own document carries that capability in its scope, its deliverables or … | Owner audit X01–X39 below and synchronized current output/retained seed-host carriers. | M | | C79 | The documentation Deliverables are in the tree at exit: the Education spec's `README.md` and `permissions.md` beside `audit.md`, with its state diagram and the eligibility … | Existing Education/Customization/Testing/schema/skill files and Phase05 preservation baseline. | M | C07 is conditional: G32 retains `*.learnstack.local`, so no seed-host migration diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index 043ca445..34d87b2e 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -6172,7 +6172,7 @@ complete. Step 4 owns CI enforcement and phase exit; neither is claimed here. ### P02d-7 Step 4 — CI enforcement and phase exit (2026-10-11) -**Implementation in progress; both independent review rounds pending.** +**Implementation delivered; round 1 fixes complete, round 2 pending.** The always-running `public demo + lighthouse` job replaces the disabled placeholder. It installs the exact locked browser tools and managed Chromium, then invokes `make demo DEMO_MODE=ci` over the shared seven-service lifecycle. @@ -6218,10 +6218,46 @@ session/BFF/authenticated-rate-limit decisions. with zero skips. Release build has zero warnings/errors; 1,705 unit, 203 architecture, four contract and 180 Docker-free integration cases pass, as do all 1,500 guarded frontend cases. Typecheck, lint, whitespace and 2,042 relative links (666 fragments) -pass. The complete Docker suite is running. Two fresh review rounds, a real +pass. All 871 Docker integration cases pass with zero skips; execution guards pass. +Two fresh review rounds, a real successful PR job and the authorized seventh-context activation/read-back remain. No PR, live check activation or phase exit is claimed yet. +#### Step 4 review round 1 (2026-10-11) + +Fresh GPT-6-astra (xhigh) and GPT-6.1-sol (xhigh) agents reviewed +`06d46ad..bf5bc9c` for runtime/CI ownership and corpus/exit evidence. Their +confirmed findings concern proof completeness and CI prerequisites, not a +production contract defect. C40–C42 now share one HTTP test: 17 requests pair +foreign-only/shared slugs, exact-locale omissions and organization/tenant host +controls with exact raw translation sets on each request's own enlisted +application connection. The third-locale case now enables French on the foreign +host and proves its positive catalog before checking the same French detail +URLs are hidden. Missing Cache-Control can no longer bypass its assertions. + +The CI job starts an absolute deadline before checkout, bounds setup steps and +interrupts the shared lifecycle by minute 16, reserving four minutes inside the +unchanged 20-minute ceiling for owned cleanup, policy cleanup and artifacts. +Four controls execute the actual workflow shell: first-step reservation, +remaining-budget arguments and two exhausted-budget refusals. An actual GNU +timeout → make → shared Node-owner experiment exits 124 only after child cleanup. +The internal 12-minute serial proof deadline remains unchanged. + +The GitHub-hosted Linux prerequisite loads only an invocation-owned AppArmor +userns profile for the exact managed Chromium when the kernel restriction needs +it, then performs a sandbox-enabled launch smoke. Fifteen isolated controls +exercise ownership, literal paths, failed load/removal and cleanup without +changing workstation policy. A real Linux job remains required; the initial +runner risk was source-supported inference, not a reproduced hosted failure. +The exit matrix, stale review guidance, Phase 02b risk premises and mutable +renderer/writer scope descriptions now match delivered contracts. + +All three focused locale/branding Docker cases pass with zero skips and the +execution guard. The guarded frontend rerun passes 1,504 cases (1,444 web + 60 +SDK), zero failures/skips/todos; typecheck, lint, scoped backend formatting and +whitespace pass. The initial full backend totals above precede the added combined +case. Final complete PR CI, round 2 and protection read-back remain required. + ### P02d-1 decision pass (2026-09-14) **Accepted — 2026-09-14, verified against `6c58343`.** The maintainer approved @@ -6366,10 +6402,11 @@ scope, with explicit data-preservation obligations. The distinguish this shape from Phase 05's target hierarchy. - `Course` — tenant-owned, optionally organization-scoped, with independent - `draft` / `published` state under [ADR-0048](../decisions/0048-walking-skeleton-publication.md). + `draft` / `published` state and explicit content-access policy under + [ADR-0050](../decisions/0050-publication-and-course-content-access.md). Its title, summary and per-locale slug live in `course_translations`; its optional - level reference pins an exact taxonomy revision and band. G5's write validation and - unresolved-band presentation remain with their later packets. No versioning, + level reference pins an exact taxonomy revision and band. P02d-2/4 delivered + G5's write validation and bounded unresolved-band presentation. No versioning, programs or cohorts. - `Lesson` — ordered within a course; its title and per-locale slug likewise live in `lesson_translations`. Its body is drawn the way @@ -6550,11 +6587,10 @@ module's audit catalogue and registered in both composition roots. [Audit Coverage Standards](../standards/18-audit-coverage.md). The command set and re-run behaviour are **G11**; the Customization contract the lesson writer calls, and which revisions it may bind, are **G12**. -- **Tenancy commands** raise `tenancy.locale.write` (SHOULD) and `tenancy.setting.write` - (MUST), both `(planned)` today. The setting command lands only once **G17** is - answered, because no command writing `tenant_settings` precedes the `[PiiSensitive]` - decision ([Phase 03](phase-03-identity-admin.md)); its keys and value checks follow - **G16**, and it performs the contrast check +- **Tenancy commands**, delivered in P02d-2, raise `tenancy.locale.write` (SHOULD) + and `tenancy.setting.write` (MUST). Accepted **G17** supplies whole-value + `[PiiSensitive]` redaction before setting writes; keys and value checks follow + Accepted **G16**, including the contrast check [Accessibility Standards § Color and Contrast](../standards/16-accessibility.md#color-and-contrast) requires before a theme token is saved, with the outcome G16 records. - **The Education module spec**, `docs/modules/education/` (`README.md`, `audit.md`, @@ -6573,8 +6609,8 @@ module's audit catalogue and registered in both composition roots. announced context, never from a command field ([Security Standards § Forbidden](../standards/11-security.md#forbidden)), and a tenant-wide row can be updated only from a context that announces no organization. The - seeder announces its context today by calling `IUnitOfWork.SetTenantContextAsync` - itself, which ADR-0040's closed setter set does not list: **G15**. + seeder uses the accepted **G15** contextual composition and registered caller + fence; it does not directly call a tenant-context setter. Each tenant's **own** customization data — the table in § Genericity proof — is authored through the Customization module's commands, as Phase 02a's seed is, and presented as @@ -6618,8 +6654,8 @@ Obligations already imposed: P02d-3 delivered **G12**'s cache contract, the loader/correctness contract (**G22**) and internal display fallback (**G24**) under the -[accepted gate answers](#accepted-gate-answers). P02d-4 delivers public response -parts; page-state behavior remains P02d-6. +[accepted gate answers](#accepted-gate-answers). P02d-4 delivered public response +parts; P02d-6 delivered page-state behavior. **The typed settings accessor** over `tenant_settings`, which Phase 02a left to its first reader, is delivered in P02d-3. Under Row Level Security a `tenant_settings` @@ -6732,27 +6768,31 @@ The full path from [Phase 02a Packet 7](phase-02a-kernel-tenancy.md#delivery-record-packet-7), exercised for real — on the path a Server Component takes: -1. The browser's `Host` reaches Next.js. Both pages are Server Components, so the API - call is made by the Next.js server, and the `Host` the API sees is not the visitor's. -2. The server SDK states the visitor's host to the API over the trusted hop - ([ADR-0036 § Effective host and the trusted hop](../decisions/0036-tenant-resolution-trusted-inputs.md#effective-host-and-the-trusted-hop)), - whose § Consequences names `frontend/packages/sdk/src/server.ts` as the only frontend - place that sets the hop headers. +1. Native HTTPS ingress validates the browser's host, physical peer and request + target, strips authority carriers and signs the request-local provenance envelope. + Middleware verifies it before making the one live site bootstrap call. +2. The configured server caller in + `frontend/apps/web/src/server/configured-public-client.ts` states the verified + host/visitor to the API over the closed trusted hop under + [ADR-0053](../decisions/0053-trusted-public-server-rendering.md) and + [ADR-0054](../decisions/0054-bounded-public-renderer-admission.md). + The injected SDK remains transport-policy agnostic. 3. The API resolves that effective host through `platform_host_to_tenant` to a `(tenant_id, organization_id?)` pair, the singleton `ITenantContextAccessor` is written and the transient `ITenantContext` resolves from it on every access, the transaction sets `app.tenant_id` / `app.organization_id` with `SET LOCAL`, and Row Level Security filters every read. -4. Whatever the edge resolves is for rendering only, and any `X-Tenant-Id` is an - assertion +4. RSC consumes the verified immutable bootstrap snapshot for that request under + [ADR-0055](../decisions/0055-public-renderer-bootstrap-failures.md). Rendering + contributes no tenant authority; the API owns resolution and admission ([Frontend Architecture Standards § Tenant Resolution](../standards/07-frontend-architecture.md#tenant-resolution)). -5. In this phase's default topology the loopback bind, not the secret, is the boundary - (ADR-0036 § Consequences). +5. The private loopback hop and authenticated internal envelope preserve the + accepted local trust boundary; a stock Next process cannot mint admission. -None of that path is wired from the renderer's side yet — § What this phase inherits -lists the scaffolds this phase replaces. The topology and its evidence are **G33**, the -limiter in front of it **G34**, the SDK transport **G31** and **G35**, the middleware -and entry behaviour **G36**, and the rendering mode **G37**. +P02d-5/6 delivered this path and its real production HTML/RSC isolation proofs. +**G33**, **G34**, **G31**, **G35**, **G36** and **G37** are Accepted and implemented; +their packet records retain the decisions and test receipts. P02d-7 adds the +shared foreground lifecycle and real browser/audit enforcement. Two hosts are registered in local development, one per seed tenant: [Phase 02a Packet 7](phase-02a-kernel-tenancy.md#delivery-record-packet-7) wrote one @@ -7207,8 +7247,10 @@ otherwise - In one test, a course slug that exists only in tenant B returns `200` with that course on tenant B's host and `404` on tenant A's host, and a `(locale, slug)` held by one - course in each tenant returns each host's own course, compared by id. A status alone - proves nothing here: a route miss and an unknown host also answer `404` with the same + course in each tenant returns each host's own course, compared against its exact + seed-derived public payload. Stable source-side IDs select the expected course; + accepted public DTOs expose no ID. A status alone proves nothing here: a route miss + and an unknown host also answer `404` with the same `not_found` code, and the same route's `200` is what rules them out. - In the same test, a course returns `200` at its slug in a locale it is translated into and `404` for that slug under an enabled locale it has no translation for; a lesson diff --git a/docs/standards/17-code-review.md b/docs/standards/17-code-review.md index 9ff8a4f0..d2c1fd1c 100644 --- a/docs/standards/17-code-review.md +++ b/docs/standards/17-code-review.md @@ -2,6 +2,9 @@ **Status:** Active **Derives from:** [ADR 0003 — Tenant Isolation Defense in Depth](../decisions/0003-tenant-isolation-defense-in-depth.md), [ADR 0010 — Cross-Module Communication](../decisions/0010-cross-module-communication.md), [ADR 0041 — Correcting False Statements in Accepted ADRs](../decisions/0041-correcting-false-statements-in-accepted-adrs.md) (every zero-tolerance blocker maps back to one of these three). +Public accessibility enforcement additionally derives from +[ADR-0027](../decisions/0027-frontend-i18n.md) and +[ADR-0056](../decisions/0056-public-demo-browser-and-lighthouse-enforcement.md). How LearnStack reviews pull requests. The goal is faster, safer ship — not gatekeeping. @@ -65,16 +68,19 @@ Before requesting reviews, run the relevant checklist on your own diff: ([Security Standards § Multi-Tenant + Organization Isolation Review Checklist](11-security.md#multi-tenant--organization-isolation-review-checklist)). - [ ] New forms use React Hook Form + Zod and render errors at the field level. - [ ] New routes have `error.tsx` and `loading.tsx` where appropriate. -- [ ] Accessibility: every interactive element keyboard-reachable; labels associated; color contrast checked; axe-core tests pass where a suite runs them — none does yet (see the note below). +- [ ] Accessibility: keyboard reachability, labels and contrast reviewed; blocking + JSX accessibility checks and the public browser/Lighthouse proof pass where + applicable. Preserve the scoped manual evidence described below. - [ ] Bundle size delta acceptable on public routes (< 200 KB gzipped per route). -> **Open in Phase 02d.** No axe-core suite exists in `frontend/` today, and -> [Testing Standards § End-to-End Tests](06-testing.md#end-to-end-tests) assigns the -> Playwright axe run to [Phase 06](../roadmap/phase-06-renderer-admin-studio.md). Which -> accessibility checks fail a build on Phase 02d's public pages — route tests, -> `jsx-a11y` at error severity or component axe — is G43 in -> [Phase 02d's decision register](../roadmap/phase-02d-walking-skeleton.md#the-decision-register), -> and the pass that closes it edits the accessibility box with its answer. +> **Accepted G43 enforcement is delivered.** P02d-6 supplies blocking `jsx-a11y` +> rules with planted controls. P02d-7's shared browser/Lighthouse proof enforces +> automated accessibility score 100 through Lighthouse's transitive axe audits; +> it does not provide the full Playwright Test/axe suite owned by +> [Phase 06](../roadmap/phase-06-renderer-admin-studio.md). +> [Testing Standards § End-to-End Tests](06-testing.md#end-to-end-tests) separates +> these automated checks from the preserved keyboard, focus, reflow, calculated +> contrast and maintainer VoiceOver smoke evidence. Neither is a full WCAG audit. If a checkbox doesn't apply to your diff, omit it. If you cannot tick a checkbox, fix the gap before requesting review. diff --git a/frontend/apps/web/src/test/public-demo-ci.test.ts b/frontend/apps/web/src/test/public-demo-ci.test.ts new file mode 100644 index 00000000..0229ea1f --- /dev/null +++ b/frontend/apps/web/src/test/public-demo-ci.test.ts @@ -0,0 +1,91 @@ +// @vitest-environment node +import { spawnSync } from 'node:child_process'; +import { chmodSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; + +import { afterEach, expect, it } from 'vitest'; + +const job = readFileSync( + new URL('../../../../../.github/workflows/ci.yml', import.meta.url), + 'utf8', +) + .split(' public-demo:\n')[1] + ?.split('\n meta:')[0]; +const roots: string[] = []; +afterEach(() => { + for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); +}); + +function fixture() { + const root = mkdtempSync(join(tmpdir(), 'learnstack-ci-budget-')); + roots.push(root); + const environment = join(root, 'environment'); + const invocation = join(root, 'invocation'); + for (const [name, body] of [ + ['date', 'printf "1000\\n"'], + ['timeout', 'printf "%s\\n" "$@" > "$INVOCATION"'], + ] as const) { + writeFileSync(join(root, name), '#!/bin/sh\n' + body + '\n'); + chmodSync(join(root, name), 0o700); + } + const env = { + PATH: root, + NODE_ENV: 'test' as const, + GITHUB_ENV: environment, + INVOCATION: invocation, + }; + return { root, environment, invocation, env }; +} + +function proofScript() { + expect(job).toBeDefined(); + const script = job?.match(/ {8}id: demo\n {8}run: \|\n((?: {10}.*\n|\n)+)/)?.[1]; + expect(script).toBeDefined(); + if (!script) throw new Error('Missing real workflow proof command'); + return script; +} + +it('starts the absolute budget before checkout and reserves four minutes of the job ceiling', () => { + const files = fixture(); + const first = job?.match( + /steps:\n(?: {6}#.*\n)* {6}- name: Reserve demo cleanup and artifact time\n {8}run: (.+)\n/, + ); + expect(first).not.toBeNull(); + expect(job).toContain('timeout-minutes: 20'); + if (!first?.[1]) throw new Error('Missing first-step budget reservation'); + const result = spawnSync('/bin/bash', ['-eu', '-c', first[1]], { env: files.env }); + expect(result.status).toBe(0); + expect(readFileSync(files.environment, 'utf8')).toBe('PUBLIC_DEMO_DEADLINE=1960\n'); +}); + +it('bounds the real workflow command by the remaining budget and requests owned SIGINT cleanup', () => { + const files = fixture(); + const result = spawnSync('/bin/bash', ['-eu', '-c', proofScript()], { + env: { ...files.env, PUBLIC_DEMO_DEADLINE: '1123' }, + }); + expect(result.status).toBe(0); + expect(readFileSync(files.invocation, 'utf8').split('\n')).toEqual([ + '--signal=INT', + '--kill-after=35s', + '123s', + 'make', + 'demo', + 'DEMO_MODE=ci', + '', + ]); +}); + +it.each(['1000', '999'])( + 'refuses an exhausted absolute budget before starting owned resources: %s', + (deadline) => { + const files = fixture(); + const result = spawnSync('/bin/bash', ['-eu', '-c', proofScript()], { + env: { ...files.env, PUBLIC_DEMO_DEADLINE: deadline }, + encoding: 'utf8', + }); + expect(result.status).toBe(1); + expect(result.stderr).toContain('Demo setup exhausted'); + expect(() => readFileSync(files.invocation)).toThrow(); + }, +); diff --git a/scripts/ci-public-chromium.mjs b/scripts/ci-public-chromium.mjs new file mode 100644 index 00000000..c4a38d79 --- /dev/null +++ b/scripts/ci-public-chromium.mjs @@ -0,0 +1,237 @@ +import assert from 'node:assert/strict'; +import { randomBytes } from 'node:crypto'; +import { + accessSync, + constants, + lstatSync, + mkdirSync, + readFileSync, + readdirSync, + realpathSync, + renameSync, + rmdirSync, + rmSync, + unlinkSync, + writeFileSync, +} from 'node:fs'; +import { join, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { DemoProcesses, installDemoCancellation } from './demo-process.mjs'; + +const root = fileURLToPath(new URL('../', import.meta.url)); +const restrictionPath = '/proc/sys/kernel/apparmor_restrict_unprivileged_userns'; + +async function runCommand(command, args, options) { + const controller = new AbortController(); + const removeCancellation = installDemoCancellation(() => controller.abort()); + const processes = new DemoProcesses(controller.signal); + try { + return await processes.run(command, args, { + ...options, + capture: true, + observe: (chunk, stream) => { + if (stream === 'stderr') process.stderr.write(chunk); + }, + }); + } finally { + try { + await processes.dispose(); + } finally { + removeCancellation(); + } + } +} + +/** AppArmor attachment syntax is a pattern language: accept literal paths only. */ +export function chromiumProfile(name, executable) { + assert.match(name, /^learnstack-public-chromium-[a-f0-9]{32}$/); + assert.match(executable, /^\/[a-zA-Z0-9_./-]+\/chrome$/); + assert.equal(resolve(executable), executable); + // Chromium's documented userns exception, narrowed to this executable. + // https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md + return `abi <abi/4.0>,\ninclude <tunables/global>\nprofile ${name} "${executable}" flags=(unconfined) {\n userns,\n}\n`; +} + +function statOrMissing(path) { + try { + return lstatSync(path); + } catch (error) { + if (error.code === 'ENOENT') return undefined; + throw error; + } +} + +/** Injections are for tests only; the CLI always uses fixed host paths/commands. */ +export function chromiumPrerequisite({ + env = process.env, + platform = process.platform, + run = runCommand, + restriction = restrictionPath, +} = {}) { + assert.equal(platform, 'linux', 'Chromium prerequisite requires Linux'); + assert.equal(env.GITHUB_ACTIONS, 'true', 'Chromium prerequisite requires GitHub Actions'); + assert.equal(env.RUNNER_ENVIRONMENT, 'github-hosted', 'Requires an ephemeral hosted runner'); + assert.match(env.GITHUB_RUN_ID ?? '', /^\d+$/); + assert.match(env.GITHUB_RUN_ATTEMPT ?? '', /^\d+$/); + assert.match(env.GITHUB_JOB ?? '', /^[a-zA-Z0-9_-]+$/); + assert.ok(env.RUNNER_TEMP && resolve(env.RUNNER_TEMP) === realpathSync(env.RUNNER_TEMP)); + const runner = `${env.GITHUB_RUN_ID}-${env.GITHUB_RUN_ATTEMPT}-${env.GITHUB_JOB}`; + const directory = join(env.RUNNER_TEMP, `learnstack-public-chromium-${runner}`); + const marker = join(directory, 'owner.json'); + const profile = join(directory, 'profile'); + const phase = join(directory, 'phase'); + const uid = process.getuid(); + const policy = (action) => + run('sudo', ['-n', 'apparmor_parser', '--skip-cache', action, profile], { + cwd: root, + timeout: 10000, + label: `Owned Chromium AppArmor ${action}`, + }); + const updatePhase = (value) => { + writeFileSync(join(directory, 'phase-next'), value, { + flag: 'wx', + mode: 0o600, + }); + renameSync(join(directory, 'phase-next'), phase); + }; + function ownedState() { + const dir = lstatSync(directory); + assert.ok(dir.isDirectory() && dir.uid === uid && (dir.mode & 0o777) === 0o700); + assert.deepEqual(readdirSync(directory).sort(), ['owner.json', 'phase', 'profile']); + for (const file of [marker, profile, phase]) { + const stat = lstatSync(file); + assert.ok(stat.isFile() && stat.uid === uid && stat.nlink === 1); + assert.equal(stat.mode & 0o777, 0o600); + } + const state = JSON.parse(readFileSync(marker, 'utf8')); + assert.deepEqual(Object.keys(state).sort(), [ + 'executable', + 'name', + 'required', + 'runner', + 'schema', + ]); + assert.equal(state.schema, 1); + assert.equal(state.runner, runner); + assert.equal(typeof state.required, 'boolean'); + assert.equal(readFileSync(profile, 'utf8'), chromiumProfile(state.name, state.executable)); + const status = readFileSync(phase, 'utf8'); + assert.ok(['pending', 'loaded', 'unloaded', 'unneeded'].includes(status)); + assert.ok(state.required ? status !== 'unneeded' : status === 'unneeded'); + return { state, status }; + } + async function cleanup() { + if (!statOrMissing(directory)) return; + const { status } = ownedState(); + // An interrupted load is not proof of ownership. Retain evidence and fail. + assert.notEqual(status, 'pending', 'Chromium AppArmor load was not confirmed'); + if (status === 'loaded') { + await policy('--remove'); + updatePhase('unloaded'); + } + ownedState(); + for (const file of [profile, phase, marker]) unlinkSync(file); + rmdirSync(directory); + } + async function prepare() { + assert.ok(!statOrMissing(directory), 'Chromium prerequisite marker must be fresh'); + const discovered = ( + await run( + 'pnpm', + [ + 'exec', + 'node', + '--input-type=module', + '-e', + "import { chromium } from 'playwright'; process.stdout.write(chromium.executablePath());", + ], + { + cwd: join(root, 'frontend'), + timeout: 10000, + label: 'Managed Chromium executable', + }, + ) + ).trim(); + const executable = realpathSync(discovered); + accessSync(executable, constants.X_OK); + assert.ok(lstatSync(executable).isFile(), 'Managed Chromium must be a regular executable'); + const name = `learnstack-public-chromium-${randomBytes(16).toString('hex')}`; + const source = chromiumProfile(name, executable); + let required = false; + try { + const setting = readFileSync(restriction, 'utf8').trim(); + assert.ok(['0', '1'].includes(setting), 'Unknown AppArmor userns restriction'); + required = setting === '1'; + } catch (error) { + if (error.code !== 'ENOENT') throw error; + } + mkdirSync(directory, { mode: 0o700 }); + writeFileSync(marker, JSON.stringify({ schema: 1, runner, name, executable, required }), { + flag: 'wx', + mode: 0o600, + }); + writeFileSync(profile, source, { flag: 'wx', mode: 0o600 }); + writeFileSync(phase, required ? 'pending' : 'unneeded', { + flag: 'wx', + mode: 0o600, + }); + try { + if (required) { + // --add never replaces another definition. If it fails or is interrupted, + // retain pending state: neither ownership nor absence has been proven. + await policy('--add'); + updatePhase('loaded'); + } + const smoke = join(directory, 'smoke'); + mkdirSync(smoke, { mode: 0o700 }); + try { + const document = await run( + executable, + [ + '--headless=new', + `--user-data-dir=${smoke}`, + '--no-first-run', + '--no-default-browser-check', + '--disable-background-networking', + '--disable-component-update', + '--disable-sync', + '--no-proxy-server', + '--dump-dom', + 'about:blank', + ], + { + cwd: root, + timeout: 20000, + label: 'Sandbox-enabled managed Chromium smoke', + }, + ); + assert.match(document, /<html[\s>]/i, 'Chromium smoke must render a document'); + } finally { + rmSync(smoke, { recursive: true }); + } + } catch (error) { + try { + await cleanup(); + } catch (cleanupError) { + throw new AggregateError([error, cleanupError], 'Chromium prerequisite and cleanup failed'); + } + throw error; + } + return { executable, apparmor: required }; + } + return { prepare, cleanup }; +} + +if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + try { + const [action, ...extra] = process.argv.slice(2); + assert.ok(['prepare', 'cleanup'].includes(action) && extra.length === 0); + const result = await chromiumPrerequisite()[action](); + console.log( + `Chromium prerequisite ${action} passed${result ? ` (AppArmor: ${result.apparmor})` : ''}`, + ); + } catch (error) { + console.error(error.message); + process.exitCode = 1; + } +} diff --git a/scripts/ci-public-chromium.test.mjs b/scripts/ci-public-chromium.test.mjs new file mode 100644 index 00000000..ad47e744 --- /dev/null +++ b/scripts/ci-public-chromium.test.mjs @@ -0,0 +1,246 @@ +import assert from 'node:assert/strict'; +import { execFile } from 'node:child_process'; +import { + existsSync, + mkdirSync, + mkdtempSync, + readFileSync, + realpathSync, + rmSync, + symlinkSync, + writeFileSync, +} from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import test from 'node:test'; +import { promisify } from 'node:util'; +import { chromiumPrerequisite, chromiumProfile } from './ci-public-chromium.mjs'; + +const execute = promisify(execFile); + +function fixture(t, { setting = '1', loadFails = false, smokeFails = false } = {}) { + const temp = mkdtempSync(join(realpathSync(tmpdir()), 'ci-public-chromium-test-')); + t.after(() => rmSync(temp, { recursive: true, force: true })); + const executable = join(temp, 'managed/chrome'); + mkdirSync(join(temp, 'managed')); + writeFileSync(executable, '#!/bin/sh\nprintf "<html><head></head><body></body></html>\\n"\n', { + mode: 0o700, + }); + const restriction = join(temp, 'userns'); + if (setting !== null) writeFileSync(restriction, setting); + const env = { + GITHUB_ACTIONS: 'true', + RUNNER_ENVIRONMENT: 'github-hosted', + GITHUB_RUN_ID: '123', + GITHUB_RUN_ATTEMPT: '2', + GITHUB_JOB: 'public-demo', + RUNNER_TEMP: temp, + }; + const directory = join(temp, 'learnstack-public-chromium-123-2-public-demo'); + const calls = []; + const loaded = new Set(['foreign-profile']); + const control = { removeFails: false }; + async function run(command, args, options) { + calls.push({ command, args, options }); + if (command === 'pnpm') { + assert.deepEqual(args.slice(0, 4), ['exec', 'node', '--input-type=module', '-e']); + assert.match(args[4], /chromium\.executablePath\(\)/); + assert.ok(options.cwd.endsWith('/frontend')); + return executable; + } + if (command === 'sudo') { + assert.deepEqual(args.slice(0, 3), ['-n', 'apparmor_parser', '--skip-cache']); + const source = readFileSync(args[4], 'utf8'); + const name = source.match(/profile (\S+) /)[1]; + if (args[3] === '--add') { + // Model --add refusing a foreign definition with this same name. + if (loadFails) { + loaded.add(name); + throw new Error('Definition already exists'); + } + assert.ok(!loaded.has(name)); + loaded.add(name); + } else { + assert.equal(args[3], '--remove'); + if (control.removeFails) throw new Error('Removal failed'); + assert.ok(loaded.delete(name)); + } + return ''; + } + assert.equal(command, executable); + assert.equal(options.timeout, 20000); + assert.ok(args.includes('--headless=new') && args.includes('--dump-dom')); + assert.equal(args.at(-1), 'about:blank'); + assert.ok(!args.some((arg) => /no-sandbox|disable.*sandbox|ignore-certificate/.test(arg))); + assert.equal( + args.find((arg) => arg.startsWith('--user-data-dir=')), + `--user-data-dir=${directory}/smoke`, + ); + assert.ok(existsSync(join(directory, 'smoke'))); + if (smokeFails) throw new Error('Sandbox launch refused'); + return (await execute(command, args, { timeout: options.timeout })).stdout; + } + const prerequisite = chromiumPrerequisite({ + env, + platform: 'linux', + run, + restriction, + }); + return { + prerequisite, + directory, + executable, + env, + restriction, + calls, + loaded, + control, + temp, + }; +} + +test('AppArmor source attaches only a literal executable path', () => { + const name = `learnstack-public-chromium-${'a'.repeat(32)}`; + const profile = chromiumProfile( + name, + '/home/runner/.cache/ms-playwright/chromium-1248/chrome-linux64/chrome', + ); + assert.match(profile, /^abi <abi\/4\.0>,\ninclude <tunables\/global>\n/); + assert.match(profile, /flags=\(unconfined\) \{\n userns,\n\}\n$/); + for (const path of [ + '/tmp/**/chrome', + '/tmp/[ab]/chrome', + '/tmp/../bin/chrome', + '/tmp/"/chrome', + '/tmp/\n/chrome', + ]) + assert.throws(() => chromiumProfile(name, path)); +}); + +test('prepare loads one exact profile, renders sandbox-enabled smoke and cleans only its policy', async (t) => { + const f = fixture(t); + const foreign = join(f.temp, 'foreign-profile-file'); + writeFileSync(foreign, 'untouched'); + assert.deepEqual(await f.prerequisite.prepare(), { + executable: f.executable, + apparmor: true, + }); + assert.equal(f.loaded.size, 2); + const source = readFileSync(join(f.directory, 'profile'), 'utf8'); + assert.ok(source.includes(`"${f.executable}" flags=(unconfined)`)); + assert.ok(!existsSync(join(f.directory, 'smoke'))); + await f.prerequisite.cleanup(); + await f.prerequisite.cleanup(); + assert.deepEqual([...f.loaded], ['foreign-profile']); + assert.equal(readFileSync(foreign, 'utf8'), 'untouched'); + assert.ok(!existsSync(f.directory)); + assert.deepEqual( + f.calls.filter((call) => call.command === 'sudo').map((call) => call.args[3]), + ['--add', '--remove'], + ); +}); + +for (const setting of ['0', null]) { + test(`restriction ${setting ?? 'absent'} needs no policy but still requires browser smoke`, async (t) => { + const f = fixture(t, { setting }); + assert.equal((await f.prerequisite.prepare()).apparmor, false); + await f.prerequisite.cleanup(); + assert.ok(f.calls.some((call) => call.command === f.executable)); + assert.ok(!f.calls.some((call) => call.command === 'sudo')); + }); +} + +test('--add failure never removes the existing foreign definition', async (t) => { + const f = fixture(t, { loadFails: true }); + await assert.rejects(f.prerequisite.prepare(), (error) => { + assert.ok(error instanceof AggregateError); + assert.match(error.errors[0].message, /Definition already exists/); + assert.match(error.errors[1].message, /load was not confirmed/); + return true; + }); + assert.equal(f.loaded.size, 2); + assert.deepEqual( + f.calls.filter((call) => call.command === 'sudo').map((call) => call.args[3]), + ['--add'], + ); + assert.equal(readFileSync(join(f.directory, 'phase'), 'utf8'), 'pending'); + await assert.rejects(f.prerequisite.cleanup(), /load was not confirmed/); + assert.equal(f.loaded.size, 2); +}); + +test('smoke failure unloads its successfully created policy and removes its profile', async (t) => { + const f = fixture(t, { smokeFails: true }); + await assert.rejects(f.prerequisite.prepare(), /Sandbox launch refused/); + assert.deepEqual([...f.loaded], ['foreign-profile']); + assert.ok(!existsSync(f.directory)); +}); + +test('duplicate prepare refuses the existing marker without loading again', async (t) => { + const f = fixture(t); + await f.prerequisite.prepare(); + await assert.rejects(f.prerequisite.prepare(), /marker must be fresh/); + assert.equal(f.calls.filter((call) => call.command === 'sudo').length, 1); + await f.prerequisite.cleanup(); +}); + +for (const mutation of ['runner', 'profile', 'extra-file', 'symlink', 'pending']) { + test(`cleanup refuses ${mutation} ownership mismatch before any policy command`, async (t) => { + const f = fixture(t); + await f.prerequisite.prepare(); + const commands = f.calls.length; + if (mutation === 'runner') { + const marker = join(f.directory, 'owner.json'); + const state = JSON.parse(readFileSync(marker, 'utf8')); + state.runner = '456-1-other-job'; + writeFileSync(marker, JSON.stringify(state)); + } else if (mutation === 'profile') { + writeFileSync(join(f.directory, 'profile'), 'profile foreign-profile { }'); + } else if (mutation === 'extra-file') { + writeFileSync(join(f.directory, 'foreign'), 'untouched'); + } else if (mutation === 'symlink') { + const marker = join(f.directory, 'owner.json'); + const foreign = join(f.temp, 'foreign-marker'); + writeFileSync(foreign, readFileSync(marker)); + rmSync(marker); + symlinkSync(foreign, marker); + } else { + writeFileSync(join(f.directory, 'phase'), 'pending'); + } + await assert.rejects(f.prerequisite.cleanup()); + assert.equal(f.calls.length, commands); + assert.equal(f.loaded.size, 2); + assert.ok(existsSync(f.directory)); + }); +} + +test('failed unload retains owned marker and allows a successful cleanup retry', async (t) => { + const f = fixture(t); + await f.prerequisite.prepare(); + f.control.removeFails = true; + await assert.rejects(f.prerequisite.cleanup(), /Removal failed/); + assert.equal(readFileSync(join(f.directory, 'phase'), 'utf8'), 'loaded'); + f.control.removeFails = false; + await f.prerequisite.cleanup(); + assert.deepEqual([...f.loaded], ['foreign-profile']); + assert.ok(!existsSync(f.directory)); +}); + +test('unknown kernel setting and missing executable fail before creating owned state', async (t) => { + const f = fixture(t, { setting: 'unexpected' }); + await assert.rejects(f.prerequisite.prepare(), /Unknown AppArmor/); + assert.ok(!existsSync(f.directory)); + rmSync(f.executable); + await assert.rejects(f.prerequisite.prepare(), /ENOENT/); + assert.ok(!existsSync(f.directory)); + assert.ok(!f.calls.some((call) => call.command === 'sudo')); +}); + +test('host policy operations refuse a local or self-hosted environment', (t) => { + const f = fixture(t); + for (const change of [ + { GITHUB_ACTIONS: 'false' }, + { RUNNER_ENVIRONMENT: 'self-hosted' }, + { GITHUB_RUN_ID: '../other' }, + ]) + assert.throws(() => chromiumPrerequisite({ env: { ...f.env, ...change }, platform: 'linux' })); +}); From 8605fc94f7ba343d5cd7cc15d28001d99349735b Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 05:51:01 +0300 Subject: [PATCH 18/35] docs(roadmap): close both P7 phase-exit review rounds Record independent runtime and corpus approval, focused proof results and verified navigation fixes. Keep real Linux CI, full receipts and seventh-check activation explicitly pending before phase exit. ADR: 0056 --- .github/CONTRIBUTING.md | 2 +- docs/roadmap/phase-02d-exit-evidence.md | 6 ++-- docs/roadmap/phase-02d-walking-skeleton.md | 32 +++++++++++++++++-- .../21-architecture-tests-catalogue.md | 3 ++ 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 96200101..f4a1122e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -78,7 +78,7 @@ Configure these in **GitHub → Settings → Branches → Branch protection rule public-key trust. Its Flight-to-document navigation and fresh HMR admission scope does not deliver P7's browser demo, full Playwright/axe or Lighthouse. The [Step 3 record](../docs/roadmap/phase-02d-walking-skeleton.md#adr-0055-step-3--production-admission-proof-and-closeout) - owns actual execution and remaining reviews. + owns completed implementation, reviews and execution evidence. - P02d-7 replaces the disabled Lighthouse placeholder with the always-running `public demo + lighthouse` job under ADR-0056. It installs the locked browser tools and Playwright-managed Chromium, then runs `make demo DEMO_MODE=ci` over diff --git a/docs/roadmap/phase-02d-exit-evidence.md b/docs/roadmap/phase-02d-exit-evidence.md index 4d297c33..890a151d 100644 --- a/docs/roadmap/phase-02d-exit-evidence.md +++ b/docs/roadmap/phase-02d-exit-evidence.md @@ -187,13 +187,13 @@ Phase 04/05/06 retain the named future contracts. C36 is conditional: G23 select uncached settings, so no settings-cache eviction rule is claimed. Other named rows retain their full canonical conditions even when a locator is abbreviated. -The two new `PublicLocaleEvolutionHttpTests` cases passed locally with zero skips. +The three `PublicLocaleEvolutionHttpTests` cases passed locally with zero skips. They use the normal API-root pipeline and actual mapped-host HTTP, under `learnstack_app`, physical READ ONLY and non-BYPASSRLS. French-only new roots are authored while Draft; published seeded roots are not edited to create the proof. All five migration histories and complete pre-existing EN/TR DTOs remain equal. The organization writer refusal commits exactly its expected Denied audit; -public reads remain audit Off. Final receipt I must include both cases. +public reads remain audit Off. Final receipt I must include all three cases. ## Exclusions and future owners @@ -247,7 +247,7 @@ by listing its phase here. | ID | Obligation | Required evidence | |---|---|---| -| E01 | Every Completion Criterion holds with named/manual evidence | All C01-C79 rows, the two new combined HTTP/pipeline cases; actual B/I/F/O/J/H receipts linked at exact final head where applicable. | +| E01 | Every Completion Criterion holds with named/manual evidence | All C01-C79 rows, the three locale/branding/combined-scope HTTP/pipeline cases; actual B/I/F/O/J/H receipts linked at exact final head where applicable. | | E02 | Every register row closed through G1 vehicle and carriers, including G32 development transport | Dated closure/link census; Accepted ADRs retained, implementation receipts distinct from decisions; Phase02b native HTTPS carriers reconciled. | | E03 | Phase02a and Education schema/request isolation green as app role, zero skips, required | Exact final backend/backend-integration TRX/rollup, role/isolation evidence and skip guard. | | E04 | OpenAPI/SDK/Lighthouse required and shown able to fail; live list/date; no deferred job names | O/J offender controls, successful final real PR rollup, dated seven-context strict protection read-back, all other settings preserved. | diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index 34d87b2e..8397896c 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -6138,7 +6138,8 @@ verified proof gaps remain; the existing 50 proof controls passed independently. child with deliberately deferred stdout demonstrated a 429 arriving after a prematurely passing final census. Cleanup now joins `close` with a separate shared five-second stop/output-drain bound before observer finalization. The - regression holds and releases the real pipe, proves cleanup waits, then refuses the 429. + regression holds and releases the real pipe, proves cleanup waits, then refuses + the 429. - Clip/filter/mask and offscreen/overflow styles could hide laid-out markers. The bounded seeded-page predicate now refuses these ancestor styles and horizontally unreachable/negative-area markers. Each lesson navigation checks @@ -6172,7 +6173,7 @@ complete. Step 4 owns CI enforcement and phase exit; neither is claimed here. ### P02d-7 Step 4 — CI enforcement and phase exit (2026-10-11) -**Implementation delivered; round 1 fixes complete, round 2 pending.** +**Implementation and both independent review rounds complete; real CI pending.** The always-running `public demo + lighthouse` job replaces the disabled placeholder. It installs the exact locked browser tools and managed Chromium, then invokes `make demo DEMO_MODE=ci` over the shared seven-service lifecycle. @@ -6214,7 +6215,7 @@ uncached settings reader plus `learnstack.tenancy.settings` eager-invalidation event owned by Phase 02b. These delivered premises do not Accept future session/BFF/authenticated-rate-limit decisions. -**Validation boundary.** Both third-locale/branding combined cases pass locally +**Initial validation at `bf5bc9c`.** Both third-locale/branding cases pass locally with zero skips. Release build has zero warnings/errors; 1,705 unit, 203 architecture, four contract and 180 Docker-free integration cases pass, as do all 1,500 guarded frontend cases. Typecheck, lint, whitespace and 2,042 relative links (666 fragments) @@ -6258,6 +6259,31 @@ SDK), zero failures/skips/todos; typecheck, lint, scoped backend formatting and whitespace pass. The initial full backend totals above precede the added combined case. Final complete PR CI, round 2 and protection read-back remain required. +#### Step 4 review round 2 (2026-10-11) + +Fresh GPT-6-astra (xhigh) and GPT-6.1-sol (xhigh) agents reviewed +`06d46ad..100b022` across runtime/CI ownership, security, correctness, +maintainability, test quality and the complete changed corpus/exit matrix. +Both approve with no remaining Blocker or Major. The corpus reviewer confirmed +two Minor navigation/census remnants: the matrix still called the expanded +three-case class two cases, and CONTRIBUTING still described completed +ADR-0055 reviews as remaining. Both are corrected; the reviewer independently +checked the bounded follow-up. One overlong P7 prose line is wrapped without +changing its content, and catalogue navigation names the new deadline/sandbox +controls. Earlier P1–P6 delivery records remain unchanged. + +The runtime reviewer independently passes all 15 Chromium-prerequisite controls, +four actual-workflow deadline controls and all three focused Docker HTTP cases, +with zero skips, plus whitespace. The corpus reviewer verifies all 36/79/39/9 +inventory counts, complete named evidence, 175 Implemented rules, 21 Active/one +Adopted standards and future-owner scope. Root checks pass seven ADR lifecycle +and 14 OpenAPI-CI controls. The complete PR's 33 unique Markdown files resolve +2,188 relative links and 686 fragments with no errors before these closing +navigation additions. Fenced and inline examples are excluded from link counts. +Both review rounds and verified fixes are complete. Actual successful Linux PR +CI, complete artifact receipts and authorized protection activation/read-back +remain required before a positive phase-exit verdict. + ### P02d-1 decision pass (2026-09-14) **Accepted — 2026-09-14, verified against `6c58343`.** The maintainer approved diff --git a/docs/standards/21-architecture-tests-catalogue.md b/docs/standards/21-architecture-tests-catalogue.md index 65906fdf..0fb033a4 100644 --- a/docs/standards/21-architecture-tests-catalogue.md +++ b/docs/standards/21-architecture-tests-catalogue.md @@ -4496,6 +4496,9 @@ and the always-running `public demo + lighthouse` job through `make demo`. `src/test/public-demo.test.ts` and `src/test/demo-lifecycle.test.ts` execute planted failing and clean controls in the required frontend job. Actual browser mutants, TLS refusals and a real Lighthouse timeout also run in the full proof. +`src/test/public-demo-ci.test.ts` executes the actual workflow deadline shell; +`scripts/ci-public-chromium.test.mjs` tests owned Linux sandbox preparation and +cleanup before the job runs the real managed-browser launch smoke. The [Step 4 record](../roadmap/phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) owns exact CI and protection receipts. These are Node behavioral rules, not C# architecture-test methods or a full WCAG/production-performance claim. From 36cd6e0fa96f696e666c3ea52dd37090142dc2e5 Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 06:11:28 +0300 Subject: [PATCH 19/35] docs: record P02d-7 CI and phase-exit verification Tie completion to the passing real PR reports and bounded required-check activation so acceptance and local feasibility cannot stand in for exit evidence. Preserve earlier delivery history and maintainer merge review. ADR: 0056 --- .github/CONTRIBUTING.md | 16 +++- CLAUDE.md | 13 +++- README.md | 12 ++- ...demo-browser-and-lighthouse-enforcement.md | 23 ++++++ docs/decisions/README.md | 2 +- docs/roadmap/README.md | 12 ++- docs/roadmap/phase-02d-exit-evidence.md | 35 +++++---- docs/roadmap/phase-02d-walking-skeleton.md | 78 ++++++++++++++++++- docs/standards/README.md | 2 +- 9 files changed, 156 insertions(+), 37 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f4a1122e..9fdb78f9 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -61,6 +61,14 @@ Configure these in **GitHub → Settings → Branches → Branch protection rule every other protection setting unchanged. The [packet delivery record](../docs/roadmap/phase-02d-walking-skeleton.md#p02d-4-step-4-contract-sdk-and-ci) records the successful job and activation proof. + - `public demo + lighthouse` — **required since P02d-7, 2026-10-11.** The + first complete [real PR run](https://github.com/HodeTech/LearnStack/actions/runs/38106505383) + passes before activation. Downloaded artifacts confirm all nine pages, + 27 audits and owned cleanup. Full API read-back confirms seven GitHub + Actions contexts, strict up-to-date checking, all six previous contexts + retained and every unrelated protection setting unchanged. The + [CI and exit closeout](../docs/roadmap/phase-02d-walking-skeleton.md#p02d-7-ci-and-phase-exit-closeout-2026-10-11) + records execution, artifact validation and activation proof. - P02d-5 keeps the existing check names. The frontend job uses the guarded workspace test runner and native production/cleanup controls. Backend integration also builds a disposable Next app against the real API/PostgreSQL; @@ -86,13 +94,13 @@ Configure these in **GitHub → Settings → Branches → Branch protection rule normalized gzip/CLS/automated-accessibility checks, real quota observation and confirmed cleanup are mandatory. Only public reports/screenshots and sanitized receipts are uploaded; raw logs, profiles and private TLS/env files - are excluded. The maintainer authorized adding it as the seventh required - context only after a complete successful real PR run. The + are excluded. The authorized seventh-context activation followed the complete + successful real PR run on 2026-10-11. The [Step 4 record](../docs/roadmap/phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) - owns the actual run and activation/read-back status. + owns the actual run and verified activation/read-back. GitHub matches required checks **by name**. The - [packet record](../docs/roadmap/phase-02d-walking-skeleton.md#p02d-4-step-4-contract-sdk-and-ci) + [current CI and exit record](../docs/roadmap/phase-02d-walking-skeleton.md#p02d-7-ci-and-phase-exit-closeout-2026-10-11) owns execution and dated API read-back; a workflow edit alone is not a protection-setting change. - **Require conversation resolution before merging**: on. diff --git a/CLAUDE.md b/CLAUDE.md index b6073e23..9dbc7f19 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -64,7 +64,8 @@ so a status header, a catalogue entry, a published count or a planted `Skip` fails the build rather than a reader. The whole .NET suite runs with **zero skips**, which the runner now refuses to let change. -**[Phase 02d](docs/roadmap/phase-02d-walking-skeleton.md) is in progress**: its kickoff +**[Phase 02d](docs/roadmap/phase-02d-walking-skeleton.md) implementation and exit +verification are complete; PR #28 review and merge remain pending**. Its kickoff shipped the packet table and the decision register, and every later packet opens with its decision pass. **P02d-1 is complete and merged** through [PR #22](https://github.com/HodeTech/LearnStack/pull/22) on 2026-09-14. Education's @@ -155,9 +156,13 @@ independent review rounds; the owns browser/audit implementation, passing complete local reruns and both completed Step 3 review rounds. The [Step 4 record](docs/roadmap/phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) -owns CI enforcement, individual exit reconciliation and the outstanding real PR/ -protection receipts. Step 4 implementation and reviews are in progress. -Phase 02d remains in progress; Phase 06 retains the full renderer/Studio expansion. +owns CI enforcement, completed reviews and individual exit reconciliation. Its +[CI and exit closeout](docs/roadmap/phase-02d-walking-skeleton.md#p02d-7-ci-and-phase-exit-closeout-2026-10-11) +verifies all seven real PR jobs, complete artifacts and live seventh-check +activation with all other protection settings preserved. All four steps completed +both review rounds. [PR #28](https://github.com/HodeTech/LearnStack/pull/28) awaits +maintainer review and merge. P02b-0 re-verification/decision pass is next afterward; +Phase 06 retains the full renderer/Studio expansion. **Phase 01** shipped the .NET 10 solution scaffold under `backend/` (core + 7 modules × 4 projects + 4 test projects including the diff --git a/README.md b/README.md index 218dfece..46f59592 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,8 @@ items, rules, custom fields and notification templates; their delivery is tracke ## Where it is today -**Phase 01 and Phase 02a are complete. Phase 02d is in progress.** +**Phase 01 and Phase 02a are complete. Phase 02d implementation and exit +verification are complete; PR #28 awaits maintainer review and merge.** [P02d-1](docs/roadmap/phase-02d-walking-skeleton.md#merge-and-closeout-2026-09-14) is **complete and merged**: Education domain, schema and isolation proofs. **P02d-2's decision package and ADR-0050/0051 are Accepted** as of 2026-10-02, @@ -107,10 +108,13 @@ on 2026-10-10; its [merge closeout](docs/roadmap/phase-02d-walking-skeleton.md#p02d-6-merge-and-closeout-2026-10-10) records final verification. P02d-7's demo, Lighthouse and phase-exit [decision package](docs/roadmap/phase-02d-walking-skeleton.md#p02d-7-decision-package-2026-10-10) -and ADR-0056 were approved on 2026-10-11. Steps 1–3 deliver the shared demo, -genericity fences and seeded browser/Lighthouse proof; the +and ADR-0056 were approved on 2026-10-11. All four steps completed both independent +review rounds. The shared demo, genericity fences and seeded browser/Lighthouse +proof pass real CI; the seventh required context is active. The [Step 4 record](docs/roadmap/phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) -owns CI enforcement, reviews and phase-exit status. The +owns CI enforcement, reviews and the positive phase-exit verdict. +[PR #28](https://github.com/HodeTech/LearnStack/pull/28) awaits maintainer review +and merge; P02b-0 re-verification is next afterward. The [P02d-4 decision package](docs/roadmap/phase-02d-walking-skeleton.md#p02d-4-decision-package-2026-10-03) is Accepted — 2026-10-03. All four implementation steps and their review loops are complete. P02d-5 supplies trusted server rendering; P02d-6 supplies public diff --git a/docs/decisions/0056-public-demo-browser-and-lighthouse-enforcement.md b/docs/decisions/0056-public-demo-browser-and-lighthouse-enforcement.md index 231d01e8..992154d6 100644 --- a/docs/decisions/0056-public-demo-browser-and-lighthouse-enforcement.md +++ b/docs/decisions/0056-public-demo-browser-and-lighthouse-enforcement.md @@ -2,6 +2,10 @@ ## Status +> **Delivery navigation — 2026-10-11:** [Amendment 1](#amendment-1--p02d-7-enforcement-delivery-2026-10-11) +> records implemented proofs, passing real PR CI and required-check activation. +> Pending statements below describe the acceptance baseline. + Accepted No implementation, passing audit or gate acceptance is claimed. @@ -295,6 +299,25 @@ Acceptance registers proof obligations, not passing tests or delivered enforceme These are registered behavioral obligations for that Node/CI proof owner, not existing scripts or C# test methods. +## Amendments + +### Amendment 1 — P02d-7 enforcement delivery (2026-10-11) + +The four-step implementation and both independent review rounds per step are +complete. All four behavioral rules above are Implemented with named executable +owners. The shared demo lifecycle supplies the actual linked nine-page browser +proof and 27 serial cold Lighthouse audits, bounded report/source admission, +hard gzip/CLS/automated-accessibility checks, real quota accounting and confirmed +owned cleanup. Per-URL timing medians remain advisory. + +The first real [PR run](https://github.com/HodeTech/LearnStack/actions/runs/38106505383) +passes all seven jobs. Its complete sanitized artifacts and the subsequent +authorized seventh-context activation/full protection read-back are verified in +the [CI and exit closeout](../roadmap/phase-02d-walking-skeleton.md#p02d-7-ci-and-phase-exit-closeout-2026-10-11). +PR #28 remains subject to maintainer review and merge. This is delivery navigation; +the acceptance metadata, decision and feasibility obligations remain unchanged. +Existing P6 human/VoiceOver evidence and Phase 06/11 scope retain their limits. + ## References - [P02d-7 package](../roadmap/phase-02d-walking-skeleton.md#p02d-7-decision-package-2026-10-10). diff --git a/docs/decisions/README.md b/docs/decisions/README.md index 769cfc3a..edc108fa 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -71,7 +71,7 @@ an amendment is not a lifecycle status change. | 0053 | [Trusted Public Server Rendering](0053-trusted-public-server-rendering.md) | Accepted 2026-10-08: P02d-5 delivers native ingress, configured transport, dynamic entry and source/runtime proofs. [ADR-0054](0054-bounded-public-renderer-admission.md) replaces bounded accounting/native/query contracts. P02d-5 is complete and merged through PR #26 on 2026-10-09; the [merge closeout](../roadmap/phase-02d-walking-skeleton.md#p02d-5-merge-and-closeout-2026-10-09) owns final verification ([Amendment 8](0053-trusted-public-server-rendering.md#amendment-8--merge-closeout-2026-10-09)); P6/P7 remain separate | | 0054 | [Bounded Public Renderer Admission](0054-bounded-public-renderer-admission.md) | Accepted 2026-10-09: coordinated anonymous accounting, native GET/HEAD/production-upgrade admission and equivalent redirect-query encoding are delivered. All five remediation steps are complete and merged through PR #26; the [merge closeout](../roadmap/phase-02d-walking-skeleton.md#p02d-5-merge-and-closeout-2026-10-09) owns final verification ([Amendment 6](0054-bounded-public-renderer-admission.md#amendment-6--merge-closeout-2026-10-09)) | | 0055 | [Handle Public Renderer Bootstrap Failures in Middleware](0055-public-renderer-bootstrap-failures.md) | Accepted 2026-10-10: one live middleware bootstrap and an immutable native same-request snapshot; exact bootstrap 404/429/503, bounded renderer Retry-After and two/one/three-call accounting implemented. Production replacement proofs pass; all three steps completed both review rounds and focused fix verification. [Step 3](../roadmap/phase-02d-walking-skeleton.md#adr-0055-step-3--production-admission-proof-and-closeout) owns delivery evidence, completed reviews and verified fixes; five new catalogue rules are Implemented | -| 0056 | [Public Demo Browser and Lighthouse Enforcement](0056-public-demo-browser-and-lighthouse-enforcement.md) | Accepted 2026-10-11: pinned Lighthouse/Playwright Chromium, seed-derived nine-page browser proof, 27 serial audits, actual-page admission, normalized gzip/CLS/accessibility hard checks, advisory timings and bounded seventh-check activation; proof rules Registered, implementation pending | +| 0056 | [Public Demo Browser and Lighthouse Enforcement](0056-public-demo-browser-and-lighthouse-enforcement.md) | Accepted 2026-10-11: pinned Lighthouse/Playwright Chromium, seed-derived nine-page browser proof, 27 serial audits, actual-page admission, normalized gzip/CLS/accessibility hard checks and advisory timings delivered; four proof rules Implemented, real PR CI/artifacts pass and seventh required context activated ([Amendment 1](0056-public-demo-browser-and-lighthouse-enforcement.md#amendment-1--p02d-7-enforcement-delivery-2026-10-11)); PR #28 review/merge pending | ## Proposed ADRs diff --git a/docs/roadmap/README.md b/docs/roadmap/README.md index 98466216..1a1c4937 100644 --- a/docs/roadmap/README.md +++ b/docs/roadmap/README.md @@ -45,7 +45,8 @@ not deferred to the showcase phase. - [Phase 01: Repository, Tooling, and Local Infrastructure](phase-01-repository-tooling.md) — **complete** - [Phase 02a: Platform Kernel, Multi-Tenancy, Organization, and Foundation Sockets](phase-02a-kernel-tenancy.md) — **complete** (packets 0–3, 3b and 4–10 shipped) - [Phase 02d: Two-Tenant Walking Skeleton](phase-02d-walking-skeleton.md) — - **in progress**; P02d-1 and P02d-2 complete and merged; the + **implementation and exit verification complete; PR #28 review/merge pending**. + P02d-1 and P02d-2 complete and merged; the [P02d-2 closeout](phase-02d-walking-skeleton.md#p02d-2-merge-and-closeout-2026-10-02) records final verification. P02d-3 read internals are implemented; the [decision package](phase-02d-walking-skeleton.md#p02d-3-decision-package-2026-10-02) @@ -83,10 +84,13 @@ not deferred to the showcase phase. [merge closeout](phase-02d-walking-skeleton.md#p02d-6-merge-and-closeout-2026-10-10) records final verification. P02d-7's demo, Lighthouse and phase-exit [decision package](phase-02d-walking-skeleton.md#p02d-7-decision-package-2026-10-10) - and ADR-0056 were approved on 2026-10-11. Steps 1–3 deliver the shared demo, - genericity fences and seeded browser/Lighthouse proof. The + and ADR-0056 were approved on 2026-10-11. All four steps completed both independent + review rounds. The shared demo, genericity fences and seeded browser/Lighthouse + proof pass real CI; the seventh required context is active. The [Step 4 record](phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) - owns CI enforcement, reviews and phase-exit status. Phase 02d remains in progress. + owns CI enforcement, reviews and the positive phase-exit verdict. + [PR #28](https://github.com/HodeTech/LearnStack/pull/28) awaits maintainer review + and merge. P02b-0 re-verification and decision pass are next afterward. - [Phase 02b: Events, Background Jobs, Identity, and Session](phase-02b-events-auth.md) - [Phase 03: Identity Domain, Authorization, and Admin Foundation](phase-03-identity-admin.md) - [Phase 04: Headless CMS, Page Builder, and Media Library](phase-04-cms-media-pages.md) diff --git a/docs/roadmap/phase-02d-exit-evidence.md b/docs/roadmap/phase-02d-exit-evidence.md index 890a151d..f99a7e08 100644 --- a/docs/roadmap/phase-02d-exit-evidence.md +++ b/docs/roadmap/phase-02d-exit-evidence.md @@ -1,11 +1,11 @@ # Phase 02d — individual exit evidence -**Reconciliation in progress — 2026-10-11.** P7 Steps 1–3 completed both -independent review rounds. Step 4 implementation, its two review rounds, the -real PR check receipts and seventh-check activation are recorded in the -[Step 4 record](phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11). +**Reconciliation complete — 2026-10-11.** All four P7 steps completed both +independent review rounds. The real PR check receipts, verified artifacts, +seventh-check activation and positive exit verdict are recorded in the +[CI and exit closeout](phase-02d-walking-skeleton.md#p02d-7-ci-and-phase-exit-closeout-2026-10-11). This document is an evidence index, not a new architecture decision or a merge -approval. Its pending receipts are not passing results. +approval. PR #28 awaits maintainer review and merge. The rows enumerate all 36 [deliverables](phase-02d-walking-skeleton.md#deliverables), 79 [completion criteria](phase-02d-walking-skeleton.md#completion-criteria), @@ -18,12 +18,12 @@ phase document owns the complete contract and every subordinate condition. | Code | Required receipt and present boundary | |---|---| -| B | Final PR `backend` success: Release build/format, unit, architecture, contract and Docker-free integration; zero skipped tests and execution guards. Pending. | -| I | Final PR `backend integration (Testcontainers)` success, including physical app-role/RLS/read-only production proofs. Pending. | -| F | Final PR guarded `frontend` success: complete workspace reports, zero skipped/todo, lint, typecheck, builds and controls. Pending. | -| O | Final PR `openapi diff` and generated SDK drift success with retained planted incompatibility controls. Pending. | -| J | Final PR `public demo + lighthouse` success, sanitized nine-page/27-audit receipt and confirmed cleanup; then authorized seventh-context activation and complete protection read-back. Pending. | -| M | Named source/document inspection and explicit future-owner reconciliation in Step 4. Requires both fresh review rounds. | +| B | Real PR `backend` passes: Release build/format, 1,705 unit, 203 architecture, four contract and 180 Docker-free integration; zero failures/skips and execution guards. | +| I | Real PR `backend integration (Testcontainers)` passes all 872 cases, including the three locale/branding/combined-scope cases and physical app-role/RLS/read-only production proofs; zero failures/skips. | +| F | Real PR guarded `frontend` passes 1,444 web + 60 SDK cases, zero failures/skips/todos, plus lint, typecheck, builds and controls. | +| O | Real PR `openapi diff` and generated SDK drift pass with retained planted incompatibility controls. | +| J | Real PR `public demo + lighthouse` passes with verified nine-page/27-audit artifacts and confirmed cleanup; authorized seventh-context activation and complete protection read-back pass. | +| M | Named source/document inspection and explicit future-owner reconciliation in Step 4; both fresh review rounds and verified fixes complete. | | H | Attributed carried-forward P6 manual evidence below; no new final-head human/WCAG claim. | | N | Conditional branch made inapplicable by its Accepted decision, as named below. | @@ -31,7 +31,11 @@ Named backend classes live under `backend/tests/`; frontend tests live under `frontend/apps/web/src/` or `frontend/scripts/`. Partial-class filenames are identified separately where needed. P1–P6 refer to the merged packet records in [Phase 02d](phase-02d-walking-skeleton.md); Step 1–3 refer to P7's records. -The final PR rollup and workflow artifacts, not a historic count, supply B/I/F/O/J. +[Run 38106505383](https://github.com/HodeTech/LearnStack/actions/runs/38106505383) +supplies B/I/F/O/J for source `8605fc9`, tested merge `15109c3`; the closeout +records full identities and artifact validation. The +[PR rollup](https://github.com/HodeTech/LearnStack/pull/28/checks) must also pass +on subsequent documentation heads before merge; historic counts do not replace it. ## Local and manual evidence boundaries @@ -193,7 +197,7 @@ They use the normal API-root pipeline and actual mapped-host HTTP, under authored while Draft; published seeded roots are not edited to create the proof. All five migration histories and complete pre-existing EN/TR DTOs remain equal. The organization writer refusal commits exactly its expected Denied audit; -public reads remain audit Off. Final receipt I must include all three cases. +public reads remain audit Off. Downloaded receipt I includes all three Passed cases. ## Exclusions and future owners @@ -263,5 +267,6 @@ and future settings-event ownership. Phase 05 migrates the existing records; it does not treat reseeding as migration. Course Marketplace ADR-0049 and Phase 09a remain Proposed and are outside this exit. -A positive phase-exit verdict requires the final receipts and both Step 4 review -rounds above. Maintainer PR review and merge are separate actions. +All E01–E09 obligations pass against the receipts and named evidence above, as +recorded in the positive CI/exit closeout. Maintainer PR review and merge are +separate actions; subsequent PR heads retain the seven required checks. diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index 8397896c..009c573e 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -1,6 +1,9 @@ # Phase 02d: Two-Tenant Walking Skeleton -> **Status (2026-10-11).** Phase 02d **in progress**. The kickoff, `P02d-0`, ships this +> **Status (2026-10-11).** Phase 02d implementation and exit verification are +> **complete**; [PR #28](https://github.com/HodeTech/LearnStack/pull/28) awaits +> maintainer review and merge. The [CI and exit closeout](#p02d-7-ci-and-phase-exit-closeout-2026-10-11) +> records the evidence and live protection read-back. The kickoff, `P02d-0`, ships this > plan — the inherited baseline, the packet table, the decision register, criteria that > name their evidence, and the corrections to the documents that contradicted the phase > — and no code. Every later packet opens with its decision pass and updates its own @@ -15,7 +18,7 @@ > | P02d-4 | Public read API and contract checks | ✅ complete and merged — 2026-10-08; [merge closeout](#p02d-4-merge-and-closeout-2026-10-08) | > | P02d-5 | Server-rendering path | ✅ complete and merged — 2026-10-09; [merge closeout](#p02d-5-merge-and-closeout-2026-10-09) | > | P02d-6 | Public renderer | ✅ complete and merged — 2026-10-10; [merge closeout](#p02d-6-merge-and-closeout-2026-10-10) | -> | P02d-7 | Demo, full-stack CI and exit | decision pass Accepted — 2026-10-11; [decision package](#p02d-7-decision-package-2026-10-10); Steps 1–3 complete; [Step 4](#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) in progress | +> | P02d-7 | Demo, full-stack CI and exit | ✅ implementation and exit verification complete — 2026-10-11; all four steps completed both independent review rounds; [CI and exit closeout](#p02d-7-ci-and-phase-exit-closeout-2026-10-11); PR #28 review/merge pending | **Acceptance update — 2026-10-02.** P02d-1 remains merged. The maintainer accepted ADR-0050/0051 and the [P02d-2 package](#p02d-2-decision-package-2026-10-02), including @@ -6173,7 +6176,9 @@ complete. Step 4 owns CI enforcement and phase exit; neither is claimed here. ### P02d-7 Step 4 — CI enforcement and phase exit (2026-10-11) -**Implementation and both independent review rounds complete; real CI pending.** +**Implementation, both independent review rounds and real CI complete.** The +[CI and exit closeout](#p02d-7-ci-and-phase-exit-closeout-2026-10-11) records +successful artifacts and the activated seventh required context. The always-running `public demo + lighthouse` job replaces the disabled placeholder. It installs the exact locked browser tools and managed Chromium, then invokes `make demo DEMO_MODE=ci` over the shared seven-service lifecycle. @@ -6184,7 +6189,7 @@ JSON/HTML reports, screenshots and sanitized workflow/proof receipts. The [individual exit evidence matrix](phase-02d-exit-evidence.md) maps all 36 Deliverables, 79 Completion Criteria, 39 exclusions and nine exit obligations. -It preserves prior human/PR evidence and names outstanding final CI receipts; +It preserves prior human/PR evidence and names the verified CI receipts; implementation alone does not constitute phase exit. **Criterion reconciliation.** Published roots cannot receive new translations @@ -6284,6 +6289,71 @@ Both review rounds and verified fixes are complete. Actual successful Linux PR CI, complete artifact receipts and authorized protection activation/read-back remain required before a positive phase-exit verdict. +#### P02d-7 CI and phase-exit closeout (2026-10-11) + +**Verdict: implementation and Phase 02d exit verification complete.** All four +P7 steps completed both fresh independent review rounds; verified findings are +fixed and committed. [PR #28](https://github.com/HodeTech/LearnStack/pull/28) +remains open for maintainer review and merge. No merge is claimed. + +All seven jobs passed in the first real +[PR run](https://github.com/HodeTech/LearnStack/actions/runs/38106505383) for source +head `8605fc94f7ba343d5cd7cc15d28001d99349735b`. GitHub tested synthetic merge +`15109c3a80a41ee7b6d6f9832880c7b2b13877f5`, whose parents are that source and +main `378346126949c90bb286b5217c24513fc2044f06`. The sanitized workflow receipt +records both identities. Downloaded TRX files confirm 1,705 unit, 203 architecture, +four contract, 180 Docker-free integration and 872 Docker integration passes: +2,964 backend tests, zero failures/skips. All three locale/branding/combined-scope +cases are present and Passed. Frontend job output confirms 1,444 web + 60 SDK +passes, zero failures/skips/todos; typecheck, lint, builds and SDK drift pass. +Meta, secret scan and OpenAPI compatibility pass too. + +The `public-demo-lighthouse` artifact contains exactly 27 JSON/HTML report pairs, +nine screenshots and two sanitized receipts; no private logs, profiles, env files +or keys are included. Report digests, nine URL/three-run census, configuration, +invocation, build and synthetic checkout identities match. The invocation is +`aab02c37c71c02569f71ef8829a96c09`; build is `yTmMjFs6JVE2ea_W-jFzX`. +Node 22.23.1, Lighthouse 13.5.0, Playwright 1.64.0 and Chromium revision 1248 / +156.0.8078.4 run on the four-CPU Ubuntu 24 hosted runner. Its sandbox-enabled +launch passes with the exact-executable temporary AppArmor prerequisite; +the owned policy removal passes afterward. + +All nine linked navigations and 24 planted visibility refusals pass. Every audit +has normalized initial JS gzip 106,359–106,553 bytes, CLS 0 and automated +accessibility 1. Per-URL timing medians remain advisory, not production p95. +All 134 API observations are 200, with zero 429, malformed or pending records: +six startup + two observer-control + 18 linked-browser + 3 × 36 audit calls. +Both TLS refusal controls and the actual audit-timeout control pass. Keycloak is +stopped before anonymous navigation. Setup/proof/cleanup take +228,127 / 650,154 / 11,041 ms; the proof stays inside 12 minutes and cleanup +inside 30 seconds. The complete job takes 15 minutes 51 seconds, within its +20-minute ceiling and absolute setup/proof deadline. + +After that successful run, the authorized API update adds only +`public demo + lighthouse` to main's required contexts. A fresh full read-back +confirms seven GitHub Actions contexts (`app_id: 15368`), strict up-to-date +checking, all six prior contexts retained and every unrelated protection setting +identical to the immediately preceding API response. The current list lives in +[CONTRIBUTING](../../.github/CONTRIBUTING.md#branch-protection-settings-on-main). + +The [individual evidence matrix](phase-02d-exit-evidence.md) reconciles all +36 deliverables, 79 criteria, 39 explicit exclusions and E01–E09. All 45 register +rows have dated Accepted closure links; no Phase 02d-owned Registered/Awaiting +catalogue rule remains. All four ADR-0056 rules are Implemented; corpus checks +confirm 175 Implemented catalogue entries and 21 Active/one Adopted standards. +The existing P6 human/VoiceOver evidence retains its original attribution and +limits; this closeout claims no new final-head manual WCAG or zoom audit. +Phase 05 preservation and P02b-0 premises are handed off above and in their +owning documents; no future-phase decision is accepted by this exit. +Closing-document checks pass all five CorpusConsistencyTests with zero skips; +the 33 changed/new Markdown files resolve 2,197 relative links and 694 fragments +with no errors. Added prose respects 88 columns; ADR-0056 changes are insertion-only. + +Closing documentation commits must also pass the seven required jobs before +merge; the [PR check rollup](https://github.com/HodeTech/LearnStack/pull/28/checks) +owns that moving-head result. Next after maintainer review and merge is +**P02b-0 re-verification and decision pass**, before Phase 02b implementation. + ### P02d-1 decision pass (2026-09-14) **Accepted — 2026-09-14, verified against `6c58343`.** The maintainer approved diff --git a/docs/standards/README.md b/docs/standards/README.md index 72fe952c..a65a96da 100644 --- a/docs/standards/README.md +++ b/docs/standards/README.md @@ -117,7 +117,7 @@ included. | 11 | [Security](11-security.md) | **Active** | No authentication yet, and the isolation half of this document is live and mechanical. Row Level Security with the four roles and the isolation suite that runs as `learnstack_app`; the tenancy edge, the trusted-hop predicate and the anonymous rate limiter from Packet 4; and, since Packet 10, § The out-of-band setters is mechanical — every announcer of a session variable is one the table names and each reader opens its transaction read-only, with `App_Role_Cannot_Enumerate_Tenants`, `App_Role_Cannot_Enumerate_Host_Map` and `Tenant_A_Cannot_Repoint_Tenant_B_Host` proving the role cannot read or repoint what the policies bar. Authentication and authorisation land in [Phase 02b](../roadmap/phase-02b-events-auth.md) and [Phase 03](../roadmap/phase-03-identity-admin.md). Three sections are **not** enforced by anything today and are the document's own carve-out: § Transport, § HTTP Headers and § CORS — nothing sets HSTS, `nosniff`, a CSP or an origin policy, at the edge or in either app. [Phase 11 § Secure headers](../roadmap/phase-11-production-hardening.md) owns them, at APISIX and in the ASP.NET layer beside it. | | 12 | [Infrastructure](12-infrastructure.md) | **Active** | Compose stack, `Makefile`, CI workflow, pre-commit hooks and secret scanning all live since Phase 01. | | 13 | [Documentation](13-documentation.md) | **Active** | Governs this corpus; the CI link audit walks changed Markdown. | -| 14 | [Git Workflow](14-git-workflow.md) | **Active** | Conventional Commits, hooks and required checks are live. Two branch-protection settings — `Require approvals` and `Do not allow bypassing` — are **deferred by maintainer decision (2026-08-10)** while the repository has one active contributor; the trigger and what activating them involves are recorded in [CONTRIBUTING § Branch protection](../../.github/CONTRIBUTING.md). P02d-1 repaired and re-read the live required-check list on 2026-09-14: all five active jobs, including the current meta name and Docker integration, are required with GitHub Actions attribution and strict up-to-date checking. P02d-4 activates the sixth `openapi diff` context after a successful real job and verifies every other setting unchanged. [CONTRIBUTING § Branch protection](../../.github/CONTRIBUTING.md#branch-protection-settings-on-main) owns the current list; the [P02d-4 delivery record](../roadmap/phase-02d-walking-skeleton.md#p02d-4-step-4-contract-sdk-and-ci) records activation verification. | +| 14 | [Git Workflow](14-git-workflow.md) | **Active** | Conventional Commits, hooks and required checks are live. Two branch-protection settings — `Require approvals` and `Do not allow bypassing` — are **deferred by maintainer decision (2026-08-10)** while the repository has one active contributor; the trigger and what activating them involves are recorded in [CONTRIBUTING § Branch protection](../../.github/CONTRIBUTING.md). P02d-1 repaired and re-read the live required-check list on 2026-09-14: all five active jobs, including the current meta name and Docker integration, are required with GitHub Actions attribution and strict up-to-date checking. P02d-4 activates the sixth `openapi diff` context after a successful real job and verifies every other setting unchanged. P02d-7 activates the seventh `public demo + lighthouse` context after complete real PR success and verifies all six prior contexts, strict mode and every unrelated setting preserved; its [CI and exit closeout](../roadmap/phase-02d-walking-skeleton.md#p02d-7-ci-and-phase-exit-closeout-2026-10-11) records the receipts. [CONTRIBUTING § Branch protection](../../.github/CONTRIBUTING.md#branch-protection-settings-on-main) owns the current list; the [P02d-4 delivery record](../roadmap/phase-02d-walking-skeleton.md#p02d-4-step-4-contract-sdk-and-ci) records activation verification. | | 15 | [Performance](15-performance.md) | **Active** | P02d-7 delivers the always-running `public demo + lighthouse` job under ADR-0056: nine seeded pages, 27 audits, actual-page/source/census controls and hard normalized gzip/CLS/automated-accessibility checks. Timing medians are advisory. The [Step 4 record](../roadmap/phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) owns real CI and required-check receipts. Production p95/field telemetry/load tests remain [Phase 11](../roadmap/phase-11-production-hardening.md). | | 16 | [Accessibility](16-accessibility.md) | **Active** | P6 delivers catalog/course/lesson and controlled-state semantics, all 31 active recommended jsx-a11y rules at error severity with per-rule actual-config dirty/clean controls, and real product HTML/Flight proofs. The [packet closeout](../roadmap/phase-02d-walking-skeleton.md#p02d-6-packet-closeout-2026-10-10) records keyboard/focus/reflow/contrast observations and the maintainer's passing VoiceOver smoke. This is enforcement for delivered public-page scope, not a full WCAG audit. P02d-7 adds hard Lighthouse automated accessibility and a narrow library browser walkthrough; full Playwright Test/axe remains [Phase 06](../roadmap/phase-06-renderer-admin-studio.md). | | 17 | [Code Review](17-code-review.md) | **Active** | Applied to every pull request merged so far; the zero-tolerance blocker list is in live use. | From e00395ade66ff95cfc5e440c14dd35dcdf57606e Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 06:13:58 +0300 Subject: [PATCH 20/35] docs(roadmap): align locale exit rows with verified CI Remove two stale pending suffixes after independently confirming both named cases Passed in the downloaded real PR integration receipt. ADR: 0056 --- docs/roadmap/phase-02d-exit-evidence.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/roadmap/phase-02d-exit-evidence.md b/docs/roadmap/phase-02d-exit-evidence.md index f99a7e08..8f04e3ea 100644 --- a/docs/roadmap/phase-02d-exit-evidence.md +++ b/docs/roadmap/phase-02d-exit-evidence.md @@ -126,13 +126,13 @@ checks supplement that record; they do not manufacture new human evidence. | C19 | No Tenancy or Education matrix row whose command ships still carries `(planned)`, and `Every_Shipped_Request_Is_Registered` and `CompositionRootCatalogueTests` pass for both roots. | AuditCoverageTests, CompositionRootCatalogueTests and Tenancy/Education matrices. | B, I, M | | C20 | A second seed run exits 0 and changes no Education, `tenant_locales` or `tenant_settings` row; each seeded row carries the `organization_id` **G14** names; each seed … | SeederTests.Running_the_seed_twice_changes_nothing_and_still_succeeds, exact inventory/process-repeat cases; Step1 audit-neutral repeat. | I, J | | C21 | The Phase 02a request-level suite (`TenantIsolationHttpTests`) still names the exact rows it expects: its customization cases assert `BeEquivalentTo` an enumerated per-tenant set that includes … | TenantIsolationHttpTests enumerated exact seed sets; SeederTests exact generations/counts; P2 writer derivation record. | I, M | -| C22 | With migration history unchanged, a request-level test adds a third locale — a `tenant_locales` row through the Tenancy locale command plus translation rows through … | PublicLocaleEvolutionHttpTests.Third_locale_authored_through_api_commands_serves_exact_new_urls_without_changing_existing_responses_or_migrations; local focused case passed; final I pending. | I, M | +| C22 | With migration history unchanged, a request-level test adds a third locale — a `tenant_locales` row through the Tenancy locale command plus translation rows through … | PublicLocaleEvolutionHttpTests.Third_locale_authored_through_api_commands_serves_exact_new_urls_without_changing_existing_responses_or_migrations; local focused case passed; downloaded real PR receipt I passed. | I, M | | C23 | An Education translation write for a locale absent from, or disabled in, the tenant's `tenant_locales` behaves as **G13** records, and a refused write commits … | EducationWriterTests.Locale_slug_lifecycle_and_stale_refusals_preserve_the_root_and_reserve_slugs_on_insert; Seeder exact canonical inventory. | I | | C24 | A lesson write whose body fails its bound revision returns `validation_failed` with details keyed by JSON pointer and persists no lesson or translation row; … | EducationWriterTests.Exact_active_bindings_and_existing_deprecated_pins_use_their_own_schema; EducationWriterValidationTests; Seeder exact non-card bindings. | B, I | | C25 | A duplicate slug written through the command **G11** names returns `Result.Fail(business_rule_violation)` and does not throw. A slug outside the shape **G9** settles is refused … | EducationWriterTests, EducationWriterValidationTests, EducationConstraintTests. | B, I | | C26 | A publication-state transition **G3** forbids answers `Result.Fail(business_rule_violation)` from the command, does not throw, and writes nothing (`backend integration`, plus a command or aggregate unit … | EducationAggregateTests/EducationWriterTests forbidden lifecycle and no mutation. | B, I | | C27 | A branding value outside **G16**'s grammar — `red;}body{background:url(//x)}`, a string containing `</style>` — never reaches a rendered document, and a refused write commits neither … | TenancyWriterTests branding refusal/atomicity, BrandingThemeTests, product theme defenses. | B, I, F | -| C28 | An organization-scoped branding command is refused without setting mutation; its Denied audit is retained, and the live organization host keeps the tenant palette. | PublicLocaleEvolutionHttpTests.Organization_branding_writer_is_refused_with_denied_audit_and_mapped_host_keeps_tenant_palette; local focused case passed; one expected Denied audit, no successful setting mutation; final I pending. | I, M | +| C28 | An organization-scoped branding command is refused without setting mutation; its Denied audit is retained, and the live organization host keeps the tenant palette. | PublicLocaleEvolutionHttpTests.Organization_branding_writer_is_refused_with_denied_audit_and_mapped_host_keeps_tenant_palette; local focused case passed; one expected Denied audit, no successful setting mutation; downloaded real PR receipt I passed. | I, M | | C29 | If **G19** includes a write-time rule, a lesson write holding a disallowed URL is refused with details naming the JSON pointer, and nothing is … | G19 Accepted text profile introduces no active URL sink or scheme write-time rule. | N | | C30 | Whatever **G18** refuses at save — which may include a presentation entry naming a property absent from `properties`, a malformed label map or a … | TextCardPresentationTests, customization command/schema validation tests. | B | | C31 | A course write naming a taxonomy revision or band key the tenant does not declare, including one only the other tenant declares, returns `validation_failed` … | EducationWriterTests and EducationWriterValidationTests taxonomy/band binding validation. | B, I | From d47ef17c8473e17e0950361dc35e419ba6c0825c Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 06:26:43 +0300 Subject: [PATCH 21/35] test(architecture): handle optional demo curricula consistently Keep the identity census aligned with the producer's nullable curriculum contract while preserving every tenant and present-curriculum assertion. The required demo inventory remains enforced separately. ADR: 0018, 0056 --- .../DomainGenericityTests.DemoIdentities.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs index ca773413..4ad97a35 100644 --- a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs +++ b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs @@ -76,7 +76,7 @@ public void Demo_Identity_Projection_Is_Complete_And_The_Frontend_Snapshot_Match values.Should().Contain(new DemoIdentity("band-label", label)); } } - var curriculum = tenant.Curriculum!; + if (tenant.Curriculum is not { } curriculum) continue; values.Should().Contain(new DemoIdentity("id", curriculum.Theme.Id.ToString("D"))); foreach (var course in curriculum.Courses) { From dca3a7b9a88acd7f013eb3b48fd84a3c30d6cc70 Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 09:49:21 +0300 Subject: [PATCH 22/35] fix(dev): align demo tool versions and review evidence Keep installed tool metadata and receipt versions in one path while retaining independent pinned drift checks. Distinguish reviewed-head CI receipts from activation history and acceptance-time ADR wording. ADR: 0056 --- .github/CONTRIBUTING.md | 3 ++ ...demo-browser-and-lighthouse-enforcement.md | 14 +++++ docs/roadmap/phase-02d-exit-evidence.md | 10 ++-- docs/roadmap/phase-02d-walking-skeleton.md | 35 ++++++++++++ .../apps/web/scripts/public-demo-census.json | 6 +++ .../apps/web/scripts/public-demo-contract.mjs | 2 +- .../apps/web/scripts/public-demo-gatherer.mjs | 2 + .../web/scripts/public-demo-toolchain.d.mts | 16 ++++++ .../web/scripts/public-demo-toolchain.mjs | 39 ++++++++++++++ .../apps/web/scripts/public-demo-worker.mjs | 12 +++-- .../apps/web/scripts/verify-public-demo.mjs | 21 ++++---- .../apps/web/src/test/public-demo.test.ts | 54 ++++++++++++++++++- scripts/public-runtime.mjs | 6 +-- 13 files changed, 196 insertions(+), 24 deletions(-) create mode 100644 frontend/apps/web/scripts/public-demo-toolchain.d.mts create mode 100644 frontend/apps/web/scripts/public-demo-toolchain.mjs diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 9fdb78f9..255ab840 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -69,6 +69,9 @@ Configure these in **GitHub → Settings → Branches → Branch protection rule retained and every unrelated protection setting unchanged. The [CI and exit closeout](../docs/roadmap/phase-02d-walking-skeleton.md#p02d-7-ci-and-phase-exit-closeout-2026-10-11) records execution, artifact validation and activation proof. + The separate [reviewed-head verification](../docs/roadmap/phase-02d-walking-skeleton.md#reviewed-implementation-head-verification-2026-10-11) + identifies the exact implementation head inspected after activation; + subsequent heads still require all seven passing checks. - P02d-5 keeps the existing check names. The frontend job uses the guarded workspace test runner and native production/cleanup controls. Backend integration also builds a disposable Next app against the real API/PostgreSQL; diff --git a/docs/decisions/0056-public-demo-browser-and-lighthouse-enforcement.md b/docs/decisions/0056-public-demo-browser-and-lighthouse-enforcement.md index 992154d6..79098314 100644 --- a/docs/decisions/0056-public-demo-browser-and-lighthouse-enforcement.md +++ b/docs/decisions/0056-public-demo-browser-and-lighthouse-enforcement.md @@ -10,6 +10,11 @@ Accepted No implementation, passing audit or gate acceptance is claimed. +> **Acceptance-baseline clarification — 2026-10-11:** The preceding sentence +> records the state at acceptance, not current delivery status. +> [Amendment 2](#amendment-2--acceptance-and-reviewed-head-navigation-2026-10-11) +> distinguishes that baseline, activation history and reviewed-head evidence. + **Date:** 2026-10-11 **Deciders:** @cemil @@ -318,6 +323,15 @@ PR #28 remains subject to maintainer review and merge. This is delivery navigati the acceptance metadata, decision and feasibility obligations remain unchanged. Existing P6 human/VoiceOver evidence and Phase 06/11 scope retain their limits. +### Amendment 2 — Acceptance and reviewed-head navigation (2026-10-11) + +The original no-implementation sentence describes acceptance-time state. +Amendment 1 describes later delivery and the first real run used for activation. +The [reviewed-head verification](../roadmap/phase-02d-walking-skeleton.md#reviewed-implementation-head-verification-2026-10-11) +separately records source `d47ef17` and its downloaded successful CI artifacts. +Subsequent heads remain subject to all seven required checks. This clarification +changes no decision, tool version, budget or original acceptance metadata. + ## References - [P02d-7 package](../roadmap/phase-02d-walking-skeleton.md#p02d-7-decision-package-2026-10-10). diff --git a/docs/roadmap/phase-02d-exit-evidence.md b/docs/roadmap/phase-02d-exit-evidence.md index 8f04e3ea..54a9c1c3 100644 --- a/docs/roadmap/phase-02d-exit-evidence.md +++ b/docs/roadmap/phase-02d-exit-evidence.md @@ -31,11 +31,13 @@ Named backend classes live under `backend/tests/`; frontend tests live under `frontend/apps/web/src/` or `frontend/scripts/`. Partial-class filenames are identified separately where needed. P1–P6 refer to the merged packet records in [Phase 02d](phase-02d-walking-skeleton.md); Step 1–3 refer to P7's records. -[Run 38106505383](https://github.com/HodeTech/LearnStack/actions/runs/38106505383) -supplies B/I/F/O/J for source `8605fc9`, tested merge `15109c3`; the closeout -records full identities and artifact validation. The +[Run 38108622191](https://github.com/HodeTech/LearnStack/actions/runs/38108622191) +supplies B/I/F/O/J for reviewed implementation source `d47ef17`, tested merge +`ba44563`; the [exact-head verification](phase-02d-walking-skeleton.md#reviewed-implementation-head-verification-2026-10-11) +records full identities and artifact validation. The earlier run owns +seventh-check activation history. The [PR rollup](https://github.com/HodeTech/LearnStack/pull/28/checks) must also pass -on subsequent documentation heads before merge; historic counts do not replace it. +on subsequent heads before merge; historic counts do not replace it. ## Local and manual evidence boundaries diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index 009c573e..6a160f5e 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -6349,6 +6349,41 @@ Closing-document checks pass all five CorpusConsistencyTests with zero skips; the 33 changed/new Markdown files resolve 2,197 relative links and 694 fragments with no errors. Added prose respects 88 columns; ADR-0056 changes are insertion-only. +##### Reviewed implementation head verification (2026-10-11) + +The first run above owns activation history. The separately downloaded +[reviewed-head run](https://github.com/HodeTech/LearnStack/actions/runs/38108622191) +passes all seven jobs for source `d47ef17c8473e17e0950361dc35e419ba6c0825c`, +tested merge `ba44563af66fbd7744b6625673e61286a8e77fa4` with the same main parent. +Its invocation is `170c02e7741fbc6c79895ce718cecd89`; build is +`rlL6ubYmcf7_VQaPBN-fA`. TRX/frontend receipts confirm the same 2,964 backend +and 1,504 frontend passes, zero failures/skips/todos. + +All 27 report pairs, nine screenshots, nine navigations and 24 visibility +refusals pass. Report digests and source/build/invocation/configuration identities +match. Normalized gzip is 106,358–106,551 bytes, CLS 0 and automated +accessibility 1 throughout. Both TLS refusals, the audit-timeout control and all +134 API observations (200 only, no malformed/pending records) pass. +Setup/proof/cleanup take 214,616 / 644,207 / 12,962 ms; all cleanup flags pass. +Sandbox-enabled Chromium and owned AppArmor cleanup pass. These numbers belong +to the exact implementation head reviewed externally, not to later commits. + +##### External review follow-up (2026-10-11) + +The maintainer's review of `3783461..d47ef17` reported no Blocker/Major and +four bounded documentation/maintenance findings. All four are verified and +addressed: the reviewed-head receipt above supplements activation history; +runtime imports move to the file header; installed tool/browser metadata feeds +the shared census and remains checked against independent committed pins; and +ADR-0056 gains dated acceptance-baseline navigation without changing history. +Tool versions, budgets, admission and cleanup behavior are unchanged. + +Local validation passes 1,454 web + 60 SDK tests, zero failures/skips/todos, +typecheck, lint and all 203 architecture tests. Ten added cases cover installed +metadata/pin mismatch, malformed or missing browser metadata, stale census and +wrong-version report refusal, each retaining a clean passing control. Two fresh +independent remediation review rounds and full seven-job CI are pending. + Closing documentation commits must also pass the seven required jobs before merge; the [PR check rollup](https://github.com/HodeTech/LearnStack/pull/28/checks) owns that moving-head result. Next after maintainer review and merge is diff --git a/frontend/apps/web/scripts/public-demo-census.json b/frontend/apps/web/scripts/public-demo-census.json index 372adfbd..9e3944d8 100644 --- a/frontend/apps/web/scripts/public-demo-census.json +++ b/frontend/apps/web/scripts/public-demo-census.json @@ -1,4 +1,10 @@ { + "versions": { + "lighthouse": "13.5.0", + "playwright": "1.64.0", + "chromiumRevision": "1248", + "browserVersion": "156.0.8078.4" + }, "artifacts": [ { "id": "Accessibility" diff --git a/frontend/apps/web/scripts/public-demo-contract.mjs b/frontend/apps/web/scripts/public-demo-contract.mjs index 03b61dfe..073dc621 100644 --- a/frontend/apps/web/scripts/public-demo-contract.mjs +++ b/frontend/apps/web/scripts/public-demo-contract.mjs @@ -220,7 +220,7 @@ export function assertConfiguration(actual, expected) { } export function validateReport(lhr, expected, census) { - assert.equal(lhr.lighthouseVersion, '13.5.0'); + assert.equal(lhr.lighthouseVersion, census.versions.lighthouse); assert.equal(lhr.runtimeError, undefined, 'Runtime errors refuse the report'); assert.deepEqual(lhr.runWarnings, [], 'Incomplete/warning audit reports are refused'); for (const key of ['requestedUrl', 'mainDocumentUrl', 'finalDisplayedUrl']) diff --git a/frontend/apps/web/scripts/public-demo-gatherer.mjs b/frontend/apps/web/scripts/public-demo-gatherer.mjs index 725fd044..55d8d893 100644 --- a/frontend/apps/web/scripts/public-demo-gatherer.mjs +++ b/frontend/apps/web/scripts/public-demo-gatherer.mjs @@ -7,6 +7,7 @@ import { normalizedJavaScript, productDomSnapshot, } from './public-demo-contract.mjs'; +import { readDemoToolchain } from './public-demo-toolchain.mjs'; /** Observe the initial audited target; never refetch a body or navigate a second time. */ export class PublicDemoDocument extends BaseGatherer { @@ -184,6 +185,7 @@ export function configurationCensus(config) { // must not differ merely because Lighthouse represents them as undefined. return JSON.parse( JSON.stringify({ + versions: readDemoToolchain(), artifacts: config.artifacts .map((row) => ({ id: row.id, dependencies: row.dependencies })) .sort((a, b) => a.id.localeCompare(b.id)), diff --git a/frontend/apps/web/scripts/public-demo-toolchain.d.mts b/frontend/apps/web/scripts/public-demo-toolchain.d.mts new file mode 100644 index 00000000..8ab57a21 --- /dev/null +++ b/frontend/apps/web/scripts/public-demo-toolchain.d.mts @@ -0,0 +1,16 @@ +export interface DemoToolchain { + lighthouse: string; + playwright: string; + chromiumRevision: string; + browserVersion: string; +} +export function readDemoToolchain(): Readonly<DemoToolchain>; +export function toolchainVersions( + pins: { lighthouse: string; playwright: string }, + installed: { + lighthouse: string; + playwright: string; + core: string; + browsers: Array<{ name: string; revision: string; browserVersion?: string }>; + }, +): Readonly<DemoToolchain>; diff --git a/frontend/apps/web/scripts/public-demo-toolchain.mjs b/frontend/apps/web/scripts/public-demo-toolchain.mjs new file mode 100644 index 00000000..9816d25a --- /dev/null +++ b/frontend/apps/web/scripts/public-demo-toolchain.mjs @@ -0,0 +1,39 @@ +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import { createRequire } from 'node:module'; +import { dirname, join } from 'node:path'; + +/** Match installed metadata to exact workspace pins before admitting audit tools. */ +export function toolchainVersions(pins, installed) { + for (const name of ['lighthouse', 'playwright']) { + assert.match(pins[name], /^\d+\.\d+\.\d+$/, 'Exact workspace tool pin'); + assert.equal(installed[name], pins[name], 'Installed ' + name + ' matches workspace pin'); + } + assert.equal(installed.core, installed.playwright, 'Playwright core matches its library'); + const chromium = installed.browsers.filter((browser) => browser.name === 'chromium'); + assert.equal(chromium.length, 1, 'One managed full Chromium declaration'); + assert.match(chromium[0].revision, /^\d+$/, 'Managed Chromium revision'); + assert.match(chromium[0].browserVersion, /^\d+\.\d+\.\d+\.\d+$/, 'Managed Chromium version'); + return Object.freeze({ + lighthouse: installed.lighthouse, + playwright: installed.playwright, + chromiumRevision: chromium[0].revision, + browserVersion: chromium[0].browserVersion, + }); +} + +export function readDemoToolchain() { + const require = createRequire(import.meta.url); + const playwrightManifest = require.resolve('playwright/package.json'); + const coreManifest = createRequire(playwrightManifest).resolve('playwright-core/package.json'); + const json = (path) => JSON.parse(readFileSync(path, 'utf8')); + return toolchainVersions( + json(new URL('../../../package.json', import.meta.url)).devDependencies, + { + lighthouse: require('lighthouse/package.json').version, + playwright: json(playwrightManifest).version, + core: json(coreManifest).version, + browsers: json(join(dirname(coreManifest), 'browsers.json')).browsers, + }, + ); +} diff --git a/frontend/apps/web/scripts/public-demo-worker.mjs b/frontend/apps/web/scripts/public-demo-worker.mjs index 7388488d..ae65056b 100644 --- a/frontend/apps/web/scripts/public-demo-worker.mjs +++ b/frontend/apps/web/scripts/public-demo-worker.mjs @@ -1,7 +1,6 @@ import assert from 'node:assert/strict'; import { readFileSync, writeFileSync } from 'node:fs'; import { createServer } from 'node:http'; -import { createRequire } from 'node:module'; import { join } from 'node:path'; import lighthouse, { generateReport } from 'lighthouse'; @@ -15,8 +14,8 @@ import { validateReport, } from './public-demo-contract.mjs'; import { resolvedDemoCensus, demoLighthouseConfiguration } from './public-demo-gatherer.mjs'; +import { readDemoToolchain } from './public-demo-toolchain.mjs'; -const require = createRequire(import.meta.url); const expectedCensus = JSON.parse( readFileSync(new URL('./public-demo-census.json', import.meta.url), 'utf8'), ); @@ -159,15 +158,18 @@ async function timeoutControl(port) { } async function main(input) { - assert.equal(require('playwright/package.json').version, '1.64.0'); - assert.equal(require('lighthouse/package.json').version, '13.5.0'); + assert.deepEqual(readDemoToolchain(), expectedCensus.versions, 'Pinned tool/browser census'); const browser = await chromium.connectOverCDP(`http://127.0.0.1:${input.port}`, { timeout: 10000, }); let browserVersion; try { browserVersion = browser.version(); - assert.equal(browserVersion, '156.0.8078.4', 'Pinned managed full Chromium version'); + assert.equal( + browserVersion, + expectedCensus.versions.browserVersion, + 'Pinned managed full Chromium version', + ); // The native browser starts with no product target. Retire its blank target. for (const context of browser.contexts()) for (const page of context.pages()) await page.close(); diff --git a/frontend/apps/web/scripts/verify-public-demo.mjs b/frontend/apps/web/scripts/verify-public-demo.mjs index 2a290563..8064524f 100644 --- a/frontend/apps/web/scripts/verify-public-demo.mjs +++ b/frontend/apps/web/scripts/verify-public-demo.mjs @@ -16,6 +16,9 @@ import { completionDelta, finalCompletionCensus } from '../../../../scripts/demo const root = fileURLToPath(new URL('../../../../', import.meta.url)); const worker = fileURLToPath(new URL('./public-demo-worker.mjs', import.meta.url)); const snapshot = (state) => JSON.parse(JSON.stringify(state)); +const census = JSON.parse( + readFileSync(new URL('./public-demo-census.json', import.meta.url), 'utf8'), +); /** Four paced batches over one unchanged production API/build/database. */ export async function verifyPublicDemo(runtime) { @@ -59,12 +62,12 @@ export async function verifyPublicDemo(runtime) { os: platform() + ' ' + release(), cpus: cpus().length, runnerImage: process.env.ImageOS ?? null, - versions: { lighthouse: '13.5.0', playwright: '1.64.0', chromiumRevision: '1248' }, - configDigest: digest( - JSON.stringify( - JSON.parse(readFileSync(new URL('./public-demo-census.json', import.meta.url), 'utf8')), - ), - ), + versions: { + lighthouse: census.versions.lighthouse, + playwright: census.versions.playwright, + chromiumRevision: census.versions.chromiumRevision, + }, + configDigest: digest(JSON.stringify(census)), setupMilliseconds: runtime.setupMilliseconds, batches: [], reports: [], @@ -72,9 +75,7 @@ export async function verifyPublicDemo(runtime) { proofMilliseconds: null, passed: false, }; - receipt.configuration = JSON.parse( - readFileSync(new URL('./public-demo-census.json', import.meta.url), 'utf8'), - ); + receipt.configuration = census; const expected = runtime.manifest.flatMap((lane) => ['catalog', 'course', 'lesson'].flatMap((kind) => [1, 2, 3].map((run) => ({ @@ -82,7 +83,7 @@ export async function verifyPublicDemo(runtime) { url: lane[kind + 'Url'], run, configDigest: receipt.configDigest, - browserVersion: '156.0.8078.4', + browserVersion: census.versions.browserVersion, })), ), ); diff --git a/frontend/apps/web/src/test/public-demo.test.ts b/frontend/apps/web/src/test/public-demo.test.ts index 73cccdd1..17e971d5 100644 --- a/frontend/apps/web/src/test/public-demo.test.ts +++ b/frontend/apps/web/src/test/public-demo.test.ts @@ -19,10 +19,16 @@ import { validateReport, } from '../../scripts/public-demo-contract.mjs'; import { PublicDemoDocument, resolvedDemoCensus } from '../../scripts/public-demo-gatherer.mjs'; +import { + readDemoToolchain, + toolchainVersions, + type DemoToolchain, +} from '../../scripts/public-demo-toolchain.mjs'; const census = JSON.parse( readFileSync(new URL('../../scripts/public-demo-census.json', import.meta.url), 'utf8'), ) as { + versions: DemoToolchain; audits: string[]; categories: Record<string, Array<{ id: string; weight: number }>>; }; @@ -237,7 +243,7 @@ function cleanReport() { ]) audits[id]!.numericValue = 0; return { - lighthouseVersion: '13.5.0', + lighthouseVersion: census.versions.lighthouse, runWarnings: [] as string[], requestedUrl: lane.lessonUrl, mainDocumentUrl: lane.lessonUrl, @@ -262,6 +268,50 @@ describe('Public_Lighthouse_Reports_Enforce_Budgets', () => { census, ); }); + it('derives the installed tool/browser versions and refuses an independently stale census', () => { + expect(readDemoToolchain()).toEqual(census.versions); + expect(() => + assertConfiguration( + { ...census, versions: { ...census.versions, chromiumRevision: 'stale' } }, + census, + ), + ).toThrow(); + expect(() => assertConfiguration(census, census)).not.toThrow(); + }); + it.each([ + 'lighthouse', + 'playwright', + 'core', + 'unpinned', + 'missing', + 'duplicate', + 'revision', + 'browser-version', + ])('refuses %s tool metadata without weakening clean admission', (kind) => { + const pins = { lighthouse: census.versions.lighthouse, playwright: census.versions.playwright }; + const clean = { + lighthouse: pins.lighthouse, + playwright: pins.playwright, + core: pins.playwright, + browsers: [ + { + name: 'chromium', + revision: census.versions.chromiumRevision, + browserVersion: census.versions.browserVersion, + }, + ], + }; + const installed = structuredClone(clean); + if (kind === 'lighthouse' || kind === 'playwright' || kind === 'core') + installed[kind] = '0.0.0'; + if (kind === 'unpinned') pins.playwright = '^' + pins.playwright; + if (kind === 'missing') installed.browsers = []; + if (kind === 'duplicate') installed.browsers.push({ ...installed.browsers[0]! }); + if (kind === 'revision') installed.browsers[0]!.revision = ''; + if (kind === 'browser-version') installed.browsers[0]!.browserVersion = 'unknown'; + expect(() => toolchainVersions(pins, installed)).toThrow(); + expect(toolchainVersions(census.versions, clean)).toEqual(census.versions); + }); it.each([ 'missing', 'runtime', @@ -273,6 +323,7 @@ describe('Public_Lighthouse_Reports_Enforce_Budgets', () => { 'accessibility', 'weights', 'redirect', + 'version', ])('refuses a planted %s report', (kind) => { const value = structuredClone(cleanReport()); if (kind === 'missing') delete value.audits[census.audits[0]!]; @@ -285,6 +336,7 @@ describe('Public_Lighthouse_Reports_Enforce_Budgets', () => { if (kind === 'accessibility') value.categories.accessibility!.score = 0.99; if (kind === 'weights') value.categories.accessibility!.auditRefs[0]!.weight = 999; if (kind === 'redirect') value.finalDisplayedUrl = lane.catalogUrl; + if (kind === 'version') value.lighthouseVersion = '0.0.0'; expect(() => validateReport(value, { url: lane.lessonUrl }, census)).toThrow(); expect(() => validateReport(cleanReport(), { url: lane.lessonUrl }, census)).not.toThrow(); }); diff --git a/scripts/public-runtime.mjs b/scripts/public-runtime.mjs index 33499264..69fc7a53 100644 --- a/scripts/public-runtime.mjs +++ b/scripts/public-runtime.mjs @@ -1,3 +1,6 @@ +import { realpathSync } from 'node:fs'; +import { join } from 'node:path'; + /** Keep privileged setup/worker credentials and arbitrary configuration out of runtime. */ export function publicApiEnvironment(values, configuration, base = process.env) { const environment = {}; @@ -15,9 +18,6 @@ export function publicApiEnvironment(values, configuration, base = process.env) Tenancy__TrustedHop__Secrets__0: configuration.secret, }; } -import { realpathSync } from 'node:fs'; -import { join } from 'node:path'; - /** Development configuration must not consult the workstation's user secrets. */ export function publicDemoApiEnvironment(values, configuration, privateRoot, base = process.env) { const profile = realpathSync(privateRoot); From aebefeeb1eeefd6a32acbfd6008e2516e51c84bf Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 09:55:39 +0300 Subject: [PATCH 23/35] docs(roadmap): record P7 review remediation verification Record both fresh independent approvals and local proof results while keeping later-head seven-job CI acceptance with the PR check rollup. ADR: 0056 --- docs/roadmap/phase-02d-walking-skeleton.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index 6a160f5e..187e79d1 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -6381,8 +6381,13 @@ Tool versions, budgets, admission and cleanup behavior are unchanged. Local validation passes 1,454 web + 60 SDK tests, zero failures/skips/todos, typecheck, lint and all 203 architecture tests. Ten added cases cover installed metadata/pin mismatch, malformed or missing browser metadata, stale census and -wrong-version report refusal, each retaining a clean passing control. Two fresh -independent remediation review rounds and full seven-job CI are pending. +wrong-version report refusal, each retaining a clean passing control. Both fresh +independent remediation rounds reviewed `d47ef17..dca3a7b` and approved without +findings. Each independently checked installed dependency resolution, fail-closed +metadata/census comparison and the downloaded historical receipts. All five +corpus tests pass; the complete PR's 33 changed/new Markdown files resolve +2,201 relative links and 698 fragments without errors. The new remediation head +must still pass full seven-job CI through the PR rollup before merge. Closing documentation commits must also pass the seven required jobs before merge; the [PR check rollup](https://github.com/HodeTech/LearnStack/pull/28/checks) From cd6affdd990b8c9d6cfc1ac7e398905d7906b397 Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 10:59:18 +0300 Subject: [PATCH 24/35] fix(dev): preserve independent demo cleanup and seed launch Keep the documented seed launcher argument-free. Attempt owned Compose teardown even when process cleanup or output observation fails, and retain private state until every cleanup stage succeeds. Preserve private error causes internally while keeping foreground diagnostics fixed. ADR: 0056 --- .gitignore | 3 + .../apps/web/src/test/demo-lifecycle.test.ts | 162 +++++++++++++++++- scripts/demo-http.mjs | 11 +- scripts/demo-process.d.mts | 2 +- scripts/demo-process.mjs | 40 +++-- scripts/demo.d.mts | 51 ++++++ scripts/demo.mjs | 104 ++++++----- scripts/seed.sh | 2 +- scripts/wait-compose.d.mts | 7 + 9 files changed, 326 insertions(+), 56 deletions(-) diff --git a/.gitignore b/.gitignore index bcd9a715..cdd5aa09 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,9 @@ dist/ build/ coverage/ +# Local test and browser proof artifacts +/artifacts/ + # Environment — track only the explicitly-listed *.example templates, # never real envs. `!*.example` would un-ignore every future `foo.example` # file in the tree (e.g. `infra/foo.conf.example`); the explicit allowlist diff --git a/frontend/apps/web/src/test/demo-lifecycle.test.ts b/frontend/apps/web/src/test/demo-lifecycle.test.ts index 12fe6034..b7e68af7 100644 --- a/frontend/apps/web/src/test/demo-lifecycle.test.ts +++ b/frontend/apps/web/src/test/demo-lifecycle.test.ts @@ -16,7 +16,11 @@ import { finalCompletionCensus, } from '../../../../../scripts/demo-observation.mjs'; import { DemoProcesses } from '../../../../../scripts/demo-process.mjs'; -import { isApiListenerEvent, validateCertificate } from '../../../../../scripts/demo.mjs'; +import { + disposeDemoResources, + isApiListenerEvent, + validateCertificate, +} from '../../../../../scripts/demo.mjs'; import { publicApiEnvironment, publicDemoApiEnvironment, @@ -88,6 +92,50 @@ describe('shared explicit demo stack selection', () => { expect(result.stderr).not.toContain('foreign'); } }); + it('launches the argument-free Seeder from the documented shell path', () => { + const root = temporary(); + for (const directory of ['scripts', 'backend', 'bin']) mkdirSync(join(root, directory)); + for (const file of ['seed.sh', 'connection-string.awk']) + writeFileSync( + join(root, 'scripts', file), + readFileSync(new URL(`../../../../../scripts/${file}`, import.meta.url)), + ); + writeFileSync( + join(root, '.env'), + 'ConnectionStrings__Migration=Username=learnstack_migration\nConnectionStrings__Default=Username=learnstack_app\n', + ); + for (const [name, body] of Object.entries({ + docker: '[ "$*" = "compose version" ]', + node: '[ "$*" = "scripts/wait-compose.mjs" ]', + dotnet: + '[ "$#" = 3 ] && [ "$1" = run ] && [ "$2" = --project ] && [ "$3" = src/LearnStack.Tools.Seeder ] && [ "$PWD" = "$TEST_ROOT/backend" ] && [ "$ConnectionStrings__Default" = Username=learnstack_app ] && printf launched > "$TEST_ROOT/launched"', + })) + writeFileSync(join(root, 'bin', name), `#!/bin/sh\n${body}\n`, { mode: 0o700 }); + const launch = () => + spawnSync('bash', [join(root, 'scripts/seed.sh')], { + cwd: root, + env: { + PATH: `${join(root, 'bin')}:${process.env.PATH}`, + TEST_ROOT: root, + NODE_ENV: 'test', + }, + encoding: 'utf8', + timeout: 5000, + }); + expect(launch().status).toBe(0); + expect(readFileSync(join(root, 'launched'), 'utf8')).toBe('launched'); + const script = join(root, 'scripts/seed.sh'); + writeFileSync( + script, + readFileSync(script, 'utf8').replace( + 'dotnet run --project src/LearnStack.Tools.Seeder', + 'dotnet run --project src/LearnStack.Tools.Seeder --nologo', + ), + ); + const refused = launch(); + expect(refused.status).not.toBe(0); + expect(refused.stderr).toContain('tenant seeding failed'); + }); it('reads the selected migration env file and refuses its runtime role before any database act', () => { const root = temporary(); writeFileSync( @@ -585,3 +633,115 @@ describe('owned real process lifecycle', () => { expect(() => processes.assertActive()).toThrow('daemon exited'); }); }); + +describe('independent owned cleanup attempts', () => { + it.each(['processes', 'observer', 'compose'])( + 'retains private state and failure after %s fails, without skipping other teardown', + async (stage) => { + const actions: string[] = []; + const cause = new Error('private diagnostic sentinel'); + const attempt = (name: string) => () => { + actions.push(name); + if (stage === name) throw cause; + }; + const error = await disposeDemoResources({ + processes: { dispose: async () => attempt('processes')() }, + finish: attempt('observer'), + teardown: attempt('compose'), + removePrivate: attempt('private'), + }).catch((error: unknown) => error); + expect(actions).toEqual(['processes', 'observer', 'compose']); + expect(error).toBeInstanceOf(AggregateError); + expect((error as AggregateError).errors).toEqual([cause]); + expect((error as Error).message).not.toContain(cause.message); + }, + ); + it.each([false, true])( + 'removes private state only after every applicable stage confirms cleanup (CI=%s)', + async (ci) => { + const actions: string[] = []; + await disposeDemoResources({ + processes: { + dispose: async () => { + actions.push('processes'); + }, + }, + finish: () => { + actions.push('observer'); + }, + teardown: ci + ? async () => { + actions.push('compose'); + } + : undefined, + removePrivate: () => { + actions.push('private'); + }, + }); + expect(actions).toEqual( + ci ? ['processes', 'observer', 'compose', 'private'] : ['processes', 'observer', 'private'], + ); + }, + ); + it('retains observer causes internally without printing private output', async () => { + const cause = new Error('private observer sentinel'); + const processes = new DemoProcesses(new AbortController().signal); + const error = await processes + .run(process.execPath, ['-e', 'process.stdout.write("output")'], { + label: 'Fixed observer stage', + observe: () => { + throw cause; + }, + }) + .catch((error: unknown) => error); + expect(error).toBeInstanceOf(Error); + expect((error as Error).message).toBe('demo: Fixed observer stage failed'); + expect(((error as Error).cause as Error).cause).toBe(cause); + await processes.dispose(); + }); +}); + +describe('listener bind diagnostics', () => { + it.each(['EADDRINUSE', 'EACCES'])( + 'keeps %s distinct without exposing socket diagnostics', + (code) => { + const result = spawnSync( + process.execPath, + [ + '--input-type=module', + '-e', + ` + import net from 'node:net'; + import { EventEmitter } from 'node:events'; + import { syncBuiltinESMExports } from 'node:module'; + const cause = Object.assign(new Error('private bind diagnostic'), { code: process.argv[1] }); + net.createServer = () => { + const server = new EventEmitter(); + server.listen = () => queueMicrotask(() => server.emit('error', cause)); + return server; + }; + syncBuiltinESMExports(); + const { vacant } = await import(process.argv[2]); + try { await vacant(3000); process.exitCode = 2; } + catch (error) { console.log(JSON.stringify({ message: error.message, code: error.cause?.code })); } + `, + code, + new URL('../../../../../scripts/demo-http.mjs', import.meta.url).href, + ], + { + encoding: 'utf8', + timeout: 5000, + }, + ); + expect(result.status).toBe(0); + expect(result.stderr).toBe(''); + expect(JSON.parse(result.stdout)).toEqual({ + message: + code === 'EADDRINUSE' + ? 'Port 3000 is occupied; stop its owner before make demo' + : 'Demo listener bind check failed', + code, + }); + }, + ); +}); diff --git a/scripts/demo-http.mjs b/scripts/demo-http.mjs index 647f8614..9b930fd3 100644 --- a/scripts/demo-http.mjs +++ b/scripts/demo-http.mjs @@ -24,8 +24,15 @@ export async function boundedBody(response, maximum) { export function vacant(port) { return new Promise((resolve, reject) => { const server = createServer(); - server.once('error', () => - reject(new Error(`Port ${port} is occupied; stop its owner before make demo`)), + server.once('error', (cause) => + reject( + new Error( + cause.code === 'EADDRINUSE' + ? `Port ${port} is occupied; stop its owner before make demo` + : 'Demo listener bind check failed', + { cause }, + ), + ), ); server.listen(port, '127.0.0.1', () => server.close((error) => (error ? reject(error) : resolve())), diff --git a/scripts/demo-process.d.mts b/scripts/demo-process.d.mts index 6f1fbe68..96a9a11f 100644 --- a/scripts/demo-process.d.mts +++ b/scripts/demo-process.d.mts @@ -1,7 +1,7 @@ import type { ChildProcess } from 'node:child_process'; export function installDemoCancellation(cancel: () => void): () => void; export class DemoCommandError extends Error { - constructor(label: string); + constructor(label: string, cause?: unknown); } interface Options { cwd?: string; diff --git a/scripts/demo-process.mjs b/scripts/demo-process.mjs index ec6de503..f42b9827 100644 --- a/scripts/demo-process.mjs +++ b/scripts/demo-process.mjs @@ -3,8 +3,8 @@ import { stopTestChild } from '../frontend/apps/web/scripts/stop-test-child.mjs' /** Only fixed caller-owned stage labels reach the foreground CLI. */ export class DemoCommandError extends Error { - constructor(label) { - super(`demo: ${label} failed`); + constructor(label, cause) { + super(`demo: ${label} failed`, { cause }); } } @@ -60,8 +60,8 @@ export class DemoProcesses { let outputBytes = 0; let failed; for (const stream of [child.stdout, child.stderr]) { - stream.once('error', () => { - failed = new Error(`${label} output refused`); + stream.once('error', (cause) => { + failed ??= new Error(`${label} output refused`, { cause }); void stopTestChild(child); }); stream.on('data', (chunk) => { @@ -72,8 +72,8 @@ export class DemoProcesses { if (outputBytes > 2 * 1024 * 1024) throw new Error('Command output exceeds bound'); output.push(chunk); } - } catch { - failed = new Error(`${label} output refused`); + } catch (cause) { + failed ??= new Error(`${label} output refused`, { cause }); void stopTestChild(child); } }); @@ -85,16 +85,23 @@ export class DemoProcesses { const running = { child, exit, - result: () => ({ output: Buffer.concat(output).toString('utf8'), failed }), + result: () => ({ + output: Buffer.concat(output).toString('utf8'), + failed, + }), }; - this.#children.set(child, { closed, result: running.result, daemon: false }); + this.#children.set(child, { + closed, + result: running.result, + daemon: false, + }); return running; } daemon(command, args, options) { const running = this.start(command, args, options); this.#children.get(running.child).daemon = true; void running.exit.then(() => { - this.#failed = new DemoCommandError(`${options.label} exited`); + this.#failed = new DemoCommandError(`${options.label} exited`, running.result().failed); this.#failure(this.#failed); }); return running; @@ -116,7 +123,10 @@ export class DemoProcesses { this.failure.then(() => ({ code: 1 })), ]); if (result.code !== 0 || running.result().failed) - throw new DemoCommandError(options.label ?? command); + throw new DemoCommandError( + options.label ?? command, + running.result().failed ?? this.#failed, + ); this.assertActive(); return running.result().output; } finally { @@ -147,10 +157,16 @@ export class DemoProcesses { } finally { clearTimeout(timer); } - if (daemon && result().failed) throw new Error('Owned output was refused'); + if (daemon && result().failed) + throw new Error('Owned output was refused', { + cause: result().failed, + }); }), ); if (results.some((row) => row.status === 'rejected')) - throw new Error('Owned process cleanup failed; private files retained'); + throw new AggregateError( + results.filter((row) => row.status === 'rejected').map((row) => row.reason), + 'Owned process cleanup failed; private files retained', + ); } } diff --git a/scripts/demo.d.mts b/scripts/demo.d.mts index 920f28e3..1ffc8e2b 100644 --- a/scripts/demo.d.mts +++ b/scripts/demo.d.mts @@ -5,3 +5,54 @@ export function validateCertificate( hosts: string[], now?: number, ): import('node:crypto').X509Certificate; + +export function disposeDemoResources(options: { + processes: Pick<import('./demo-process.mjs').DemoProcesses, 'dispose'>; + finish?: () => void | Promise<void>; + teardown?: () => void | Promise<void>; + removePrivate: () => void | Promise<void>; +}): Promise<void>; +export function startDemo(mode: 'local' | 'ci'): Promise<{ + mode: 'local' | 'ci'; + manifest: DemoLane[]; + configuration: import('../frontend/apps/web/src/server/ingress').PublicServerConfiguration; + ca: string[] | Buffer; + leaf: import('node:crypto').X509Certificate; + privateRoot: string; + observation: { + apiReady: boolean; + webReady: boolean; + counts: Map<string, number>; + malformed: boolean; + }; + completions: import('./demo-observation.mjs').CompletionState; + processes: import('./demo-process.mjs').DemoProcesses; + signal: AbortSignal; + dispose(): Promise<{ + passed: true; + milliseconds: number; + processesStopped: true; + composeEmpty: boolean; + privateFilesRemoved: boolean; + environmentRemoved: boolean; + lockRemoved: boolean; + }>; + compose(args: string[], options?: { timeout?: number; capture?: boolean }): Promise<string>; + signalRequested(): boolean; + setupMilliseconds: number; +}>; + +interface DemoLane { + host: string; + locale: string; + displayName: string; + courseTitle: string; + lessonTitle: string; + catalogUrl: string; + courseUrl: string; + lessonUrl: string; + fields: { name: string; label: string; value: string }[]; + theme: Record<string, string>; + excludedTitles: string[]; + excludedContent: string[]; +} diff --git a/scripts/demo.mjs b/scripts/demo.mjs index 827a237c..3b59ae2b 100644 --- a/scripts/demo.mjs +++ b/scripts/demo.mjs @@ -52,6 +52,25 @@ export function validateCertificate(certificate, privateKey, hosts, now = Date.n return leaf; } +/** Attempt every owned teardown stage; private files survive any unconfirmed stage. */ +export async function disposeDemoResources({ processes, finish, teardown, removePrivate }) { + const failures = []; + for (const attempt of [() => processes.dispose(), finish, teardown]) { + if (!attempt) continue; + try { + await attempt(); + } catch (error) { + failures.push(error); + } + } + if (failures.length) + throw new AggregateError( + failures, + 'Owned cleanup could not be confirmed; private files retained', + ); + await removePrivate(); +} + /** Start the same seeded, production-built topology for foreground use and CI proof. */ export async function startDemo(mode) { if (!['local', 'ci'].includes(mode)) throw new Error('Use make demo DEMO_MODE=local or ci'); @@ -98,45 +117,52 @@ export async function startDemo(mode) { }; controller.abort(); try { - await processes.dispose(); - completions?.finish(); - // Cleanup has a separate signal: cancellation must not cancel teardown. - if (mode === 'ci' && startedStack) { - const cleanup = new DemoProcesses(new AbortController().signal); - try { - await cleanup.run( - 'docker', - [...selected.args, '--profile', '*', 'down', '--volumes', '--remove-orphans'], - { - cwd: selected.cwd, - env: selected.env, - label: 'Owned Compose teardown', - timeout: cleanupTimeout(20000), - }, - ); - const remaining = await cleanup.run( - 'docker', - [...selected.args, '--profile', '*', 'ps', '-a', '-q'], - { - cwd: selected.cwd, - env: selected.env, - label: 'Owned Compose teardown verification', - capture: true, - timeout: cleanupTimeout(5000), - }, - ); - if (remaining.trim()) throw new Error('Owned Compose cleanup incomplete'); - } finally { - await cleanup.dispose(); - } - } - if (ownedEnvironment !== undefined) { - if (readFileSync(rootEnv, 'utf8') !== ownedEnvironment) - throw new Error('CI environment changed; private files retained'); - unlinkSync(rootEnv); - } - if (privateRoot) rmSync(privateRoot, { recursive: true }); - if (locked) rmSync(lock, { recursive: true }); + await disposeDemoResources({ + processes, + finish: () => completions?.finish(), + // Cleanup has a separate signal: cancellation must not cancel teardown. + teardown: + mode === 'ci' && startedStack + ? async () => { + const cleanup = new DemoProcesses(new AbortController().signal); + try { + await cleanup.run( + 'docker', + [...selected.args, '--profile', '*', 'down', '--volumes', '--remove-orphans'], + { + cwd: selected.cwd, + env: selected.env, + label: 'Owned Compose teardown', + timeout: cleanupTimeout(20000), + }, + ); + const remaining = await cleanup.run( + 'docker', + [...selected.args, '--profile', '*', 'ps', '-a', '-q'], + { + cwd: selected.cwd, + env: selected.env, + label: 'Owned Compose teardown verification', + capture: true, + timeout: cleanupTimeout(5000), + }, + ); + if (remaining.trim()) throw new Error('Owned Compose cleanup incomplete'); + } finally { + await cleanup.dispose(); + } + } + : undefined, + removePrivate: () => { + if (ownedEnvironment !== undefined) { + if (readFileSync(rootEnv, 'utf8') !== ownedEnvironment) + throw new Error('CI environment changed; private files retained'); + unlinkSync(rootEnv); + } + if (privateRoot) rmSync(privateRoot, { recursive: true }); + if (locked) rmSync(lock, { recursive: true }); + }, + }); const milliseconds = Date.now() - started; if (mode === 'ci' && milliseconds > 30000) throw new Error('Owned cleanup deadline'); return { diff --git a/scripts/seed.sh b/scripts/seed.sh index 1787d318..60b892fd 100755 --- a/scripts/seed.sh +++ b/scripts/seed.sh @@ -127,7 +127,7 @@ fi # repository root no global.json applies and whichever SDK is newest answers, which is # not the one CI and `make migrate` use. if ! (cd backend && ConnectionStrings__Default="$seed_cs" \ - dotnet run --project src/LearnStack.Tools.Seeder --nologo); then + dotnet run --project src/LearnStack.Tools.Seeder); then red "seed: tenant seeding failed." red " Has the schema been applied? → make migrate" exit 1 diff --git a/scripts/wait-compose.d.mts b/scripts/wait-compose.d.mts index 0bb9bc20..a673e2f4 100644 --- a/scripts/wait-compose.d.mts +++ b/scripts/wait-compose.d.mts @@ -8,3 +8,10 @@ export function healthyServices( rows: { Service: string; State: string; Health?: string }[], postgresOnly?: boolean, ): boolean; + +export function waitCompose( + selected: ReturnType<typeof import('./compose.mjs').composeSelection>, + processes: import('./demo-process.mjs').DemoProcesses, + signal: AbortSignal, + postgresOnly?: boolean, +): Promise<void>; From db6bcdf3ab6604860e330c3a5c9fde0dabb8462f Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 11:11:01 +0300 Subject: [PATCH 25/35] test(architecture): close demo source census admission gaps Resolve supported local aliases and workspace exports transitively, refuse unclassified roots/formats and missing imports, and distinguish actual dependency/output roots from nested authored source. Cross-check backend sources against evaluated Compile inputs and refuse unmodeled build shapes. ADR: 0018, 0035 --- .../DomainGenericityTests.DemoIdentities.cs | 25 +- .../DomainGenericityTests.SourceCensus.cs | 90 +++++ .../21-architecture-tests-catalogue.md | 15 +- .../web/src/test/demo-genericity-sources.ts | 336 +++++++++++++++--- .../apps/web/src/test/demo-genericity.test.ts | 166 ++++++++- 5 files changed, 573 insertions(+), 59 deletions(-) create mode 100644 backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs diff --git a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs index 4ad97a35..3cdad383 100644 --- a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs +++ b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs @@ -16,9 +16,8 @@ public void Production_Code_Does_Not_Branch_On_Demo_Tenant_Literals() { var vocabulary = DemoIdentities.Create(); vocabulary.Values.Should().NotBeEmpty(); - var files = ProductionSourceRoots.SelectMany(root => Directory.EnumerateFiles(root, "*", SearchOption.AllDirectories)) - .Where(path => !path.Split(Path.DirectorySeparatorChar).Any(part => part is "bin" or "obj")) - .Where(path => Path.GetExtension(path) is ".cs" or ".json") + var allFiles = DemoProductionSourceCensus(); + var files = allFiles // Sole authoritative tenant declaration, never the whole Seeder project. .Where(path => Path.GetRelativePath(RepositoryPaths.BackendSrc(), path).Replace('\\', '/') != "LearnStack.Tools.Seeder/SeedData.cs").Order(StringComparer.Ordinal).ToArray(); @@ -112,6 +111,26 @@ public void Demo_Literal_Fence_Detects_Decoded_Identities_And_Admits_Platform_Da foreach (var value in new[] { identity, key, Guid.Parse(id).ToString("B").ToUpperInvariant(), Guid.Parse(id).ToString("N") }) DemoLiteralViolations("Probe.cs", $"class Probe {{ string Value = {JsonSerializer.Serialize(value)}; }}", vocabulary) .Should().ContainSingle("each backend identity/customization/alternate UUID spelling must be seen"); + var project = Path.GetFullPath("/repo/backend/src/Probe"); + var generated = new[] { Path.Combine(project, "bin"), Path.Combine(project, "obj") }; + foreach (var directory in new[] { "bin", "obj" }) + { + BackendDemoSourceKind(Path.Combine(project, "Features", directory, "Probe.cs"), generated) + .Should().Be(1, "only actual project outputs are excluded"); + BackendDemoSourceKind(Path.Combine(project, directory, "Generated.cs"), generated).Should().Be(0); + } + Action unknownFormat = () => _ = BackendDemoSourceKind(Path.Combine(project, "Probe.resx"), generated); + unknownFormat.Should().Throw<InvalidOperationException>(); + Action linkedInput = () => RequireCompileCoverage([Path.Combine(project, "Probe.cs")], ["/repo/shared/Linked.cs"]); + linkedInput.Should().Throw<InvalidOperationException>(); + RequireCompileCoverage([Path.Combine(project, "Probe.cs")], [Path.Combine(project, "Probe.cs")]); + Action dynamicCompile = () => RefuseExecutionTimeCompile("<Project><Target Name=\"Add\"><ItemGroup><Compile Include=\"../shared/Probe.cs\" /></ItemGroup></Target></Project>"); + dynamicCompile.Should().Throw<InvalidOperationException>(); + RefuseExecutionTimeCompile("<Project><ItemGroup><Compile Include=\"Probe.cs\" /></ItemGroup></Project>"); + Action importedTarget = () => RefuseExecutionTimeCompile("<Project><Import Project=\"../shared.targets\" /></Project>"); + importedTarget.Should().Throw<InvalidOperationException>(); + Action customSdk = () => RefuseExecutionTimeCompile("<Project Sdk=\"Custom.Sdk\" />"); + customSdk.Should().Throw<InvalidOperationException>(); var escaped = $"\\u{(int)identity[0]:x4}{identity[1..]}"; DemoLiteralViolations("Probe.cs", "class Probe { string Value = \"" + escaped + "\"; }", vocabulary) .Should().ContainSingle("Roslyn decodes escaped strings"); diff --git a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs new file mode 100644 index 00000000..35911d8d --- /dev/null +++ b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs @@ -0,0 +1,90 @@ +using System.Diagnostics; +using System.Text.Json; +using System.Xml.Linq; + +namespace LearnStack.Tests.Architecture; + +public sealed partial class DomainGenericityTests +{ + private static readonly string[] DemoOutputProperties = ["BaseOutputPath", "BaseIntermediateOutputPath"]; + + private static string[] DemoProductionSourceCensus() + { + var projects = ProductionSourceRoots.SelectMany(root => Directory.EnumerateFiles(root, "*.csproj", SearchOption.AllDirectories)) + .Order(StringComparer.Ordinal).ToArray(); + var evaluated = projects.Select(EvaluatedDemoCompile).ToArray(); + var outputs = evaluated.SelectMany(row => row.Outputs).Distinct(StringComparer.Ordinal).ToArray(); + var files = ProductionSourceRoots.SelectMany(root => Directory.EnumerateFiles(root, "*", SearchOption.AllDirectories)) + .Where(path => BackendDemoSourceKind(path, outputs) == 1).ToArray(); + // Evaluation includes explicit/linked Compile items as well as the SDK's default glob. + // A compiler input outside the supported census must refuse, never disappear. + RequireCompileCoverage(files, evaluated.SelectMany(row => row.Sources)); + foreach (var file in ProductionSourceRoots.SelectMany(root => Directory.EnumerateFiles(root, "*", SearchOption.AllDirectories)) + .Where(path => BackendDemoSourceKind(path, outputs) == 2) + .Concat([Path.Combine(RepositoryPaths.RepoRoot(), "backend/Directory.Build.props"), + Path.Combine(RepositoryPaths.RepoRoot(), "backend/Directory.Packages.props")]) + .Where(path => Path.GetExtension(path) is ".csproj" or ".props" or ".targets")) + RefuseExecutionTimeCompile(File.ReadAllText(file)); + return files; + } + + private static int BackendDemoSourceKind(string path, IEnumerable<string> outputs) + { + path = Path.GetFullPath(path); + if (outputs.Any(root => path.StartsWith(Path.TrimEndingDirectorySeparator(root) + Path.DirectorySeparatorChar, StringComparison.Ordinal))) + return 0; + if (Path.GetExtension(path) is ".cs" or ".json") return 1; + if (Path.GetExtension(path) is ".csproj" or ".props" or ".targets" or ".md" || Path.GetFileName(path) == ".editorconfig") return 2; + throw new InvalidOperationException($"Unclassified backend production source: {path}; Fix: review its census ownership."); + } + + private static void RequireCompileCoverage(IEnumerable<string> files, IEnumerable<string> compiled) + { + var admitted = files.Select(Path.GetFullPath).ToHashSet(StringComparer.Ordinal); + if (compiled.Any(path => !admitted.Contains(Path.GetFullPath(path)))) + throw new InvalidOperationException("Unclassified Compile input; Fix: include the linked source in the supported production census."); + } + + private static void RefuseExecutionTimeCompile(string source) + { + var document = XDocument.Parse(source); + const string modulesImport = "$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))"; + if (document.Descendants().Any(node => node.Name.LocalName is "Target" or "Sdk" + || node.Name.LocalName == "Import" && (string?)node.Attribute("Project") != modulesImport) + || document.Root?.Attribute("Sdk") is { } sdk && sdk.Value is not ("Microsoft.NET.Sdk" or "Microsoft.NET.Sdk.Web")) + throw new InvalidOperationException("Execution-time Compile/import shapes are unmodeled; Fix: review compiler-input admission before introducing a custom target or import."); + } + + private static (string[] Sources, string[] Outputs) EvaluatedDemoCompile(string project) + { + using var child = new Process + { + StartInfo = new ProcessStartInfo("dotnet") + { + ArgumentList = { "msbuild", project, "-getItem:Compile", "-getProperty:BaseOutputPath,BaseIntermediateOutputPath", "-p:Configuration=Release", "-nologo" }, + RedirectStandardOutput = true, + RedirectStandardError = true, + WorkingDirectory = Path.GetDirectoryName(project)!, + } + }; + child.Start(); + var output = child.StandardOutput.ReadToEndAsync(); + var error = child.StandardError.ReadToEndAsync(); + if (!child.WaitForExit(120_000)) + { + child.Kill(entireProcessTree: true); + child.WaitForExit(); + throw new InvalidOperationException("MSBuild Compile census deadline."); + } + Task.WaitAll(output, error); + if (child.ExitCode != 0) throw new InvalidOperationException("MSBuild Compile census failed."); + using var document = JsonDocument.Parse(output.Result); + var sources = document.RootElement.GetProperty("Items").GetProperty("Compile").EnumerateArray() + .Select(row => Path.GetFullPath(row.GetProperty("FullPath").GetString()!)).ToArray(); + var properties = document.RootElement.GetProperty("Properties"); + var outputs = DemoOutputProperties + .Select(name => properties.GetProperty(name).GetString()!) + .Select(path => Path.GetFullPath(path.Replace('\\', Path.DirectorySeparatorChar), Path.GetDirectoryName(project)!)).ToArray(); + return (sources, outputs); + } +} diff --git a/docs/standards/21-architecture-tests-catalogue.md b/docs/standards/21-architecture-tests-catalogue.md index 0fb033a4..a24b817d 100644 --- a/docs/standards/21-architecture-tests-catalogue.md +++ b/docs/standards/21-architecture-tests-catalogue.md @@ -675,8 +675,19 @@ otherwise). text/attribute values are included. Frontend runtime imports cannot hide helpers behind test filenames or directories; exact standalone proof/development entries retain their bounded exemptions. - Generated-output roots are exact paths; local module URL suffixes resolve and - computed runtime imports fail rather than omit a helper. + Generated/dependency roots are exact paths. Local module URL suffixes, + supported tsconfig aliases, workspace exports, re-exports, import-equals and + literal `require.resolve` edges enter the closure. Missing/unsupported local + edges and unclassified repository roots/source formats fail. Installed external + packages are resolved under the known dependency roots; local/link targets + enter the census or refuse. Native `.server` edges require the actual pinned + TypeScript output mapping; the known stylesheet is an explicit inert asset. + Backend `DomainGenericityTests.SourceCensus.cs` cross-checks the source set with + Release MSBuild-evaluated `Compile` inputs and actual output/intermediate roots. + Nested `bin`/`obj` remain authored source. Linked inputs outside the census and + unmodeled custom targets/imports/SDKs refuse rather than silently omit code. + Dirty/clean controls cover these admission boundaries. Computed runtime imports + fail rather than omit a helper. The rule does not claim to prove dynamically assembled identities. `Production_Projects_Do_Not_Reference_The_Seeder` diff --git a/frontend/apps/web/src/test/demo-genericity-sources.ts b/frontend/apps/web/src/test/demo-genericity-sources.ts index 2c9542ba..f00d5458 100644 --- a/frontend/apps/web/src/test/demo-genericity-sources.ts +++ b/frontend/apps/web/src/test/demo-genericity-sources.ts @@ -1,3 +1,4 @@ +import { isBuiltin } from 'node:module'; import { posix } from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -29,24 +30,256 @@ const generatedOutputs = new Set([ /** Only actual generated roots are omitted; nested source directories stay visible. */ export function omitDemoSourceDirectory(path: string): boolean { - return path.split('/').at(-1) === 'node_modules' || generatedOutputs.has(path); + return dependencyRoots.has(path) || generatedOutputs.has(path); } +const dependencyRoots = new Set([ + 'frontend/node_modules', + 'frontend/apps/web/node_modules', + 'frontend/packages/config/node_modules', + 'frontend/packages/sdk/node_modules', + 'frontend/packages/ui/node_modules', +]); +const sourceExtension = /\.(?:[cm]?[jt]sx?|json)$/; +const declaration = /\.d\.[cm]?[jt]sx?$/; +const nonRuntimeFiles = new Set([ + 'frontend/.gitignore', + 'frontend/.npmrc', + 'frontend/.nvmrc', + 'frontend/.prettierignore', + 'frontend/README.md', + 'frontend/apps/web/README.md', + 'frontend/apps/web/.env.local.example', + 'frontend/apps/web/src/app/globals.css', + 'frontend/apps/web/src/components/.gitkeep', + 'frontend/apps/web/tsconfig.tsbuildinfo', + 'frontend/packages/sdk/tsconfig.tsbuildinfo', + 'frontend/packages/ui/tsconfig.tsbuildinfo', + 'frontend/pnpm-lock.yaml', + 'frontend/pnpm-workspace.yaml', + 'scripts/adr-status.py', + 'scripts/assert-tests-ran.py', + 'scripts/connection-string.awk', + 'scripts/install-oasdiff.py', + 'scripts/openapi-ci.py', + 'scripts/openapi-policy.py', + 'scripts/seed.sh', + 'scripts/test-adr-status.py', + 'scripts/test-openapi-ci.py', +]); +const nonRuntimeRoots = new Set([ + '.claude', + '.config', + '.githooks', + '.github', + '.vscode', + 'docs', + 'infra', +]); +const rootFiles = new Set([ + '.env.example', + '.gitattributes', + '.gitignore', + '.leakwatch.yaml', + '.leakwatchignore', + '.prettierignore', + 'AGENTS.md', + 'CLAUDE.md', + 'Makefile', + 'README.md', +]); + +/** Refuse new roots/formats until their production or non-runtime ownership is explicit. */ +export function demoSourceClassification(path: string): 'runtime' | 'other' { + if (!path || path.startsWith('/') || path.split('/').some((part) => part === '..')) + throw new Error(`Unclassified repository source: ${path}`); + const root = path.split('/')[0]!; + if (nonRuntimeRoots.has(root) || rootFiles.has(path)) return 'other'; + // Backend source admission and evaluated Compile coverage are owned by its architecture test. + if (root === 'backend') { + if ( + /^backend\/(?:src|analyzers|tests|openapi)\//.test(path) || + /^backend\/(?:\.editorconfig|Directory\.(?:Build|Packages)\.props|LearnStack\.slnx|README\.md|global\.json)$/.test( + path, + ) + ) + return 'other'; + throw new Error(`Unclassified repository source: ${path}`); + } + if (root !== 'frontend' && root !== 'scripts') + throw new Error(`Unclassified repository source: ${path}`); + if (nonRuntimeFiles.has(path) || declaration.test(path)) return 'other'; + if ( + !sourceExtension.test(path) || + [...dependencyRoots, ...generatedOutputs].some((dir) => path.startsWith(dir + '/')) + ) + throw new Error(`Unclassified repository source: ${path}`); + return 'runtime'; +} + +export type ExternalModuleResolver = (from: string, specifier: string, anchors: string[]) => string; + function testSource(path: string): boolean { return ( path.startsWith('frontend/apps/web/src/test/') || /\.(?:test|spec)\.[cm]?[jt]sx?$/.test(path) ); } -/** A test name/directory cannot hide a helper imported by runtime code. */ -export function productionDemoSources(all: ReadonlyMap<string, string>): Map<string, string> { +/** A standalone exemption cannot hide a statically imported runtime helper. */ +export function productionDemoSources( + all: ReadonlyMap<string, string>, + external?: ExternalModuleResolver, +): Map<string, string> { + const refused = (path: string): never => { + throw new Error(`Unmodeled runtime import: ${path}`); + }; + const packages = [...all] + .filter(([path]) => path.endsWith('/package.json')) + .map(([path, source]) => ({ + root: posix.dirname(path), + manifest: JSON.parse(source), + })); + const generated = new Map<string, string>(); + const serverConfig = all.get('frontend/apps/web/tsconfig.server.json'); + if (serverConfig) { + const config = JSON.parse(serverConfig); + const expected = ['src/server/ingress.ts', 'src/server/public-admission-runtime.ts']; + if ( + config.compilerOptions?.rootDir !== 'src/server' || + config.compilerOptions?.outDir !== '.server' || + JSON.stringify([...config.include].sort()) !== JSON.stringify(expected) + ) + refused('tsconfig.server.json'); + for (const input of expected) + generated.set( + `frontend/apps/web/.server/${posix.basename(input, '.ts')}.js`, + `frontend/apps/web/${input}`, + ); + } + const candidates = (base: string) => [ + base, + ...['.ts', '.tsx', '.js', '.jsx', '.mts', '.cts', '.mjs', '.cjs', '.json'].flatMap((ext) => [ + base + ext, + posix.join(base, 'index' + ext), + ]), + ...(/\.[cm]?jsx?$/.test(base) + ? [base.replace(/\.[cm]?jsx?$/, '.ts'), base.replace(/\.[cm]?jsx?$/, '.tsx')] + : []), + ]; + const local = (base: string, from: string): string[] => { + if (base === 'frontend/apps/web/src/app/globals.css') return all.has(base) ? [] : refused(from); + base = generated.get(base) ?? base; + const target = candidates(base).find((path) => all.has(path)); + if (!target || !sourceExtension.test(target) || declaration.test(target)) return refused(from); + return [target]; + }; + const mapped = (value: unknown, root: string, from: string): string[] => { + if (typeof value === 'string' && value.startsWith('./')) + return local(posix.normalize(posix.join(root, value)), from); + if (value && typeof value === 'object' && !Array.isArray(value)) { + const values = Object.values(value); + if (values.length) return values.flatMap((value) => mapped(value, root, from)); + } + return refused(from); + }; + const resolveEdge = (edge: string, path: string, anchors: string[] = []): string[] => { + if (isBuiltin(edge)) return []; + if (/^(?:file:|\/)/.test(edge)) return refused(path); + if (edge.startsWith('.')) { + if (anchors.length) return refused(path); + const filename = fileURLToPath(new URL(edge, `file:///learnstack/${path}`)); + if (!filename.startsWith('/learnstack/')) return refused(path); + return local(filename.slice('/learnstack/'.length), path); + } + // Match actual supported tsconfig paths rather than treating alias spelling as external. + let directory = posix.dirname(path); + while (directory !== '.') { + const source = all.get(posix.join(directory, 'tsconfig.json')); + if (source) { + const config = JSON.parse(source); + if (config.compilerOptions?.baseUrl) return refused(path); + for (const [pattern, replacements] of Object.entries(config.compilerOptions?.paths ?? {})) { + const parts = pattern.split('*'); + if (parts.length > 2 || !Array.isArray(replacements) || replacements.length === 0) + return refused(path); + const match = + parts.length === 1 + ? edge === pattern + : edge.startsWith(parts[0]!) && edge.endsWith(parts[1]!); + if (!match) continue; + const capture = + parts.length === 1 ? '' : edge.slice(parts[0]!.length, edge.length - parts[1]!.length); + return replacements.flatMap((value) => { + if (typeof value !== 'string' || !value.startsWith('./') || value.split('*').length > 2) + return refused(path); + return local(posix.normalize(posix.join(directory, value.replace('*', capture))), path); + }); + } + // Inherited alias maps are not silently ignored. The shipped inherited presets have none. + const checkExtends = (name: unknown, owner: string, seen = new Set<string>()) => { + if (name === undefined) return; + if (typeof name !== 'string' || seen.has(name)) return refused(path); + seen.add(name); + const target = name.startsWith('.') + ? candidates(posix.join(owner, name)).find((key) => all.has(key)) + : packages.flatMap((pkg) => + name.startsWith(pkg.manifest.name + '/') + ? mapped( + pkg.manifest.exports?.['./' + name.slice(pkg.manifest.name.length + 1)], + pkg.root, + path, + ) + : [], + )[0]; + if (!target) return refused(path); + const inherited = JSON.parse(all.get(target)!); + if (inherited.compilerOptions?.paths || inherited.compilerOptions?.baseUrl) + return refused(path); + checkExtends(inherited.extends, posix.dirname(target), seen); + }; + checkExtends(config.extends, directory); + break; + } + directory = posix.dirname(directory); + } + const pkg = packages.find( + (pkg) => edge === pkg.manifest.name || edge.startsWith(pkg.manifest.name + '/'), + ); + if (pkg) { + const key = + edge === pkg.manifest.name ? '.' : './' + edge.slice(pkg.manifest.name.length + 1); + return mapped( + pkg.manifest.exports?.[key] ?? (key === '.' ? pkg.manifest.main : undefined), + pkg.root, + path, + ); + } + // #imports and unmodeled aliases require explicit modeling; bare names are not an exemption. + if (edge.startsWith('#') || !external) return refused(path); + const target = external(path, edge, anchors); + if (all.has(target)) return local(target, path); + if (![...dependencyRoots].some((root) => target.startsWith(root + '/'))) return refused(path); + return []; + }; const result = new Map( - [...all].filter(([path]) => !testSource(path) && !exemptEntries.has(path)), + [...all].filter( + ([path]) => + sourceExtension.test(path) && + !declaration.test(path) && + !testSource(path) && + !exemptEntries.has(path), + ), ); for (const [path, source] of result) { if (path.endsWith('.json')) continue; const file = ts.createSourceFile(path, source, ts.ScriptTarget.Latest, true); - const imports: string[] = []; + const imports: { name: string; anchors?: string[] }[] = []; + const resolveCall = (node: ts.Node): node is ts.CallExpression => + ts.isCallExpression(node) && + ts.isPropertyAccessExpression(node.expression) && + ts.isIdentifier(node.expression.expression) && + node.expression.expression.text === 'require' && + node.expression.name.text === 'resolve'; const visit = (node: ts.Node) => { if ( ((ts.isImportDeclaration(node) && !node.importClause?.isTypeOnly) || @@ -54,60 +287,67 @@ export function productionDemoSources(all: ReadonlyMap<string, string>): Map<str node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier) ) - imports.push(node.moduleSpecifier.text); + imports.push({ name: node.moduleSpecifier.text }); + if ( + ts.isImportEqualsDeclaration(node) && + !node.isTypeOnly && + ts.isExternalModuleReference(node.moduleReference) + ) { + const value = node.moduleReference.expression; + if (!value || !ts.isStringLiteralLike(value)) return refused(path); + imports.push({ name: value.text }); + } if ( ts.isCallExpression(node) && (node.expression.kind === ts.SyntaxKind.ImportKeyword || - (ts.isIdentifier(node.expression) && node.expression.text === 'require')) + (ts.isIdentifier(node.expression) && node.expression.text === 'require') || + resolveCall(node)) ) { - let specifier = node.arguments[0]; - // ESLint resolves an external package before loading it. This remains a - // statically named edge; computed resolver inputs are refused below. - if ( - specifier && - ts.isCallExpression(specifier) && - ts.isPropertyAccessExpression(specifier.expression) && - ts.isIdentifier(specifier.expression.expression) && - specifier.expression.expression.text === 'require' && - specifier.expression.name.text === 'resolve' - ) { + const value = node.arguments[0]; + if (value && resolveCall(value)) { + ts.forEachChild(node, visit); + return; + } + if (!value || !ts.isStringLiteralLike(value)) return refused(path); + const anchors: string[] = []; + if (node.arguments.length > 1) { + const options = node.arguments[1]; if ( - specifier.arguments.length > 1 && - (!specifier.arguments[0] || - !ts.isStringLiteralLike(specifier.arguments[0]) || - specifier.arguments[0].text.startsWith('.')) + !resolveCall(node) || + value.text.startsWith('.') || + !options || + !ts.isObjectLiteralExpression(options) || + options.properties.length !== 1 ) - throw new Error(`Unmodeled runtime import: ${path}`); - specifier = specifier.arguments[0]; + return refused(path); + const property = options.properties[0]; + if ( + !property || + !ts.isPropertyAssignment(property) || + property.name.getText(file) !== 'paths' || + !ts.isArrayLiteralExpression(property.initializer) || + !property.initializer.elements.length + ) + return refused(path); + for (const anchor of property.initializer.elements) { + if ( + !resolveCall(anchor) || + anchor.arguments.length !== 1 || + !anchor.arguments[0] || + !ts.isStringLiteralLike(anchor.arguments[0]) + ) + return refused(path); + anchors.push(anchor.arguments[0].text); + } } - if (!specifier || !ts.isStringLiteralLike(specifier)) - throw new Error(`Unmodeled runtime import: ${path}`); - imports.push(specifier.text); + imports.push({ name: value.text, anchors }); } ts.forEachChild(node, visit); }; visit(file); - for (const edge of imports) { - if (/^(?:file:|\/)/.test(edge)) throw new Error(`Unmodeled runtime import: ${path}`); - if (!edge.startsWith('.')) continue; - // Node ESM resolves query/fragment and percent escapes as a module URL. - const resolved = new URL(edge, `file:///learnstack/${path}`); - const filename = fileURLToPath(resolved); - if (!filename.startsWith('/learnstack/')) - throw new Error(`Unmodeled runtime import: ${path}`); - const base = filename.slice('/learnstack/'.length); - const candidates = [ - base, - ...['.ts', '.tsx', '.js', '.jsx', '.mts', '.cts', '.mjs', '.cjs', '.json'].flatMap( - (extension) => [base + extension, posix.join(base, 'index' + extension)], - ), - ]; - if (/\.[cm]?jsx?$/.test(base)) - candidates.push(base.replace(/\.[cm]?jsx?$/, '.ts'), base.replace(/\.[cm]?jsx?$/, '.tsx')); - const target = candidates.find((candidate) => all.has(candidate)); - // Exemptions apply only to standalone entries, never imported runtime helpers. - if (target) result.set(target, all.get(target)!); - } + for (const edge of imports) + for (const target of resolveEdge(edge.name, path, edge.anchors)) + result.set(target, all.get(target)!); } return result; } diff --git a/frontend/apps/web/src/test/demo-genericity.test.ts b/frontend/apps/web/src/test/demo-genericity.test.ts index 56709c4b..0cb5e2ba 100644 --- a/frontend/apps/web/src/test/demo-genericity.test.ts +++ b/frontend/apps/web/src/test/demo-genericity.test.ts @@ -1,28 +1,52 @@ // @vitest-environment node +import { execFileSync } from 'node:child_process'; import { readdirSync, readFileSync } from 'node:fs'; +import { createRequire } from 'node:module'; import { dirname, join, relative, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; import { describe, expect, it } from 'vitest'; import { demoIdentityFindings } from './demo-genericity-analysis'; -import { omitDemoSourceDirectory, productionDemoSources } from './demo-genericity-sources'; +import { + demoSourceClassification, + omitDemoSourceDirectory, + productionDemoSources, +} from './demo-genericity-sources'; import vocabulary from './fixtures/demo-identities.json'; const root = resolve(dirname(fileURLToPath(import.meta.url)), '../../../../..'); function productionSources(): Map<string, string> { + const inventory = execFileSync( + 'git', + [ + 'ls-files', + '--cached', + '--others', + '--exclude-standard', + '--exclude=.claude/worktrees/', + '-z', + ], + { cwd: root, encoding: 'utf8' }, + ) + .split('\0') + .filter(Boolean); + for (const path of inventory) demoSourceClassification(path); const files = new Map<string, string>(); const visit = (directory: string) => { for (const entry of readdirSync(directory, { withFileTypes: true })) { const path = join(directory, entry.name); const name = relative(root, path).replaceAll('\\', '/'); - if (entry.isSymbolicLink() && entry.name !== 'node_modules') + if (entry.isSymbolicLink() && !omitDemoSourceDirectory(name)) throw new Error(`Unmodeled production symlink: ${name}`); if (entry.isDirectory()) { if (!omitDemoSourceDirectory(name)) visit(path); + } else if (entry.isSymbolicLink()) { + if (!omitDemoSourceDirectory(name)) + throw new Error(`Unmodeled production symlink: ${name}`); } else if ( - /\.(?:[cm]?[jt]sx?|json)$/.test(entry.name) && - !/\.d\.[cm]?[jt]sx?$/.test(entry.name) + demoSourceClassification(name) === 'runtime' || + name === 'frontend/apps/web/src/app/globals.css' ) { files.set(name, readFileSync(path, 'utf8')); } @@ -30,7 +54,11 @@ function productionSources(): Map<string, string> { }; visit(join(root, 'frontend')); visit(join(root, 'scripts')); - return productionDemoSources(files); + return productionDemoSources(files, (from, specifier, anchors) => { + let resolver = createRequire(join(root, from)); + for (const anchor of anchors) resolver = createRequire(resolver.resolve(anchor)); + return relative(root, resolver.resolve(specifier)).replaceAll('\\', '/'); + }); } describe('P02d-7 exact demo identity boundary', () => { @@ -197,7 +225,13 @@ describe('P02d-7 exact demo identity boundary', () => { expect(resolved.has(target)).toBe(true); expect(() => productionDemoSources( - new Map([[entry, "require(require.resolve('eslint-plugin-jsx-a11y', { paths: [] }));"]]), + new Map([ + [ + entry, + "require(require.resolve('eslint-plugin-jsx-a11y', { paths: [require.resolve('eslint-config-next')] }));", + ], + ]), + (_from, name) => `frontend/node_modules/${name}/index.js`, ), ).not.toThrow(); for (const source of [ @@ -222,9 +256,129 @@ describe('P02d-7 exact demo identity boundary', () => { 'frontend/apps/web/src/dist', 'frontend/apps/web/scripts/coverage', 'frontend/apps/web/src/.server', + 'scripts/node_modules', + 'frontend/apps/web/src/node_modules', ]) expect(omitDemoSourceDirectory(path)).toBe(false); }); + it('refuses unclassified production roots and formats while retaining declared non-runtime ownership', () => { + for (const path of [ + 'shared/probe.mjs', + 'frontend/apps/web/src/probe.vue', + 'scripts/probe.runtime', + 'backend/feature/Probe.cs', + ]) + expect(() => demoSourceClassification(path)).toThrow('Unclassified'); + for (const path of [ + 'scripts/demo.mjs', + 'scripts/node_modules/probe/index.js', + 'frontend/apps/web/src/test/probe.test.ts', + ]) + expect(demoSourceClassification(path)).toBe('runtime'); + for (const path of [ + 'README.md', + 'docs/example.md', + 'scripts/seed.sh', + 'frontend/apps/web/src/app/globals.css', + ]) + expect(demoSourceClassification(path)).toBe('other'); + }); + it('follows aliases, workspace exports, import-equals and transitive re-exports into exemptions', () => { + const entry = 'frontend/apps/web/src/server/probe.ts'; + const helper = 'frontend/apps/web/src/test/helper.ts'; + const configHelper = 'frontend/packages/config/helper.test.mjs'; + for (const source of [ + "import '@/test/helper';", + "export * from '@/test/helper';", + "import helper = require('@/test/helper');", + "require.resolve('@/test/helper');", + ]) { + const files = productionDemoSources( + new Map([ + ['frontend/apps/web/tsconfig.json', '{"compilerOptions":{"paths":{"@/*":["./src/*"]}}}'], + [ + 'frontend/packages/config/package.json', + '{"name":"@learnstack/config","exports":{"./helper":"./helper.test.mjs"}}', + ], + [entry, source], + [helper, "export * from '@learnstack/config/helper';"], + [configHelper, `export const branch = ${JSON.stringify(identity)};`], + ]), + ); + expect(files.has(helper)).toBe(true); + expect(files.has(configHelper)).toBe(true); + expect( + [...files].flatMap(([path, source]) => demoIdentityFindings(path, source, vocabulary)), + ).toEqual([identity]); + } + }); + it('refuses missing, unknown-format, inherited-alias and untrusted external edges', () => { + const entry = 'frontend/apps/web/scripts/entry.mjs'; + for (const edge of ['./missing.mjs', './helper.runtime', 'unknown-package', '#local']) + expect(() => + productionDemoSources( + new Map([ + [entry, `require(${JSON.stringify(edge)})`], + ['frontend/apps/web/scripts/helper.runtime', `specialize('${identity}')`], + ]), + ), + ).toThrow('Unmodeled'); + expect(() => + productionDemoSources( + new Map([[entry, "import 'linked-package';"]]), + () => '../foreign/index.js', + ), + ).toThrow('Unmodeled'); + const helper = 'frontend/apps/web/src/test/helper.ts'; + expect( + productionDemoSources( + new Map([ + [entry, "import 'linked-package';"], + [helper, 'export const clean = 1;'], + ]), + () => helper, + ).has(helper), + ).toBe(true); + expect(() => + productionDemoSources( + new Map([ + [entry, "import 'external-package';"], + ['frontend/apps/web/tsconfig.json', '{"extends":"./base.json"}'], + [ + 'frontend/apps/web/base.json', + '{"compilerOptions":{"paths":{"hidden/*":["./src/test/*"]}}}', + ], + ]), + () => 'frontend/node_modules/external-package/index.js', + ), + ).toThrow('Unmodeled'); + }); + it('admits only the validated native generated-output mapping and known stylesheet', () => { + const entry = 'scripts/demo.mjs'; + const source = 'frontend/apps/web/src/server/ingress.ts'; + const config = { + compilerOptions: { rootDir: 'src/server', outDir: '.server' }, + include: ['src/server/ingress.ts', 'src/server/public-admission-runtime.ts'], + }; + const files = new Map([ + [ + entry, + "import '../frontend/apps/web/.server/ingress.js'; import '../frontend/apps/web/src/app/globals.css';", + ], + [source, 'export const clean = true;'], + ['frontend/apps/web/src/app/globals.css', ':root { color: black }'], + ['frontend/apps/web/tsconfig.server.json', JSON.stringify(config)], + ]); + expect(productionDemoSources(files).has(source)).toBe(true); + files.set( + 'frontend/apps/web/tsconfig.server.json', + JSON.stringify({ + ...config, + compilerOptions: { ...config.compilerOptions, outDir: 'unmodeled' }, + }), + ); + expect(() => productionDemoSources(files)).toThrow('Unmodeled'); + }); it('fails loudly on unreadable sources and an empty or malformed vocabulary', () => { expect(() => demoIdentityFindings('probe.ts', 'const = ;', vocabulary)).toThrow('Unreadable'); expect(() => demoIdentityFindings('probe.json', '{', vocabulary)).toThrow(); From 90114f0bbcdc2ef280995aecfc4ad1eb2bb552df Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 11:19:30 +0300 Subject: [PATCH 26/35] test(architecture): refuse ambiguous demo census resolution Include competing alias and JS/TS targets conservatively, and select workspace exports only from owned manifests. Refuse implicit build hooks and project references outside the evaluated production project set. ADR: 0018, 0056 --- .../DomainGenericityTests.DemoIdentities.cs | 6 ++ .../DomainGenericityTests.SourceCensus.cs | 32 ++++++++-- .../21-architecture-tests-catalogue.md | 10 +++- .../web/src/test/demo-genericity-sources.ts | 39 ++++++++---- .../apps/web/src/test/demo-genericity.test.ts | 60 +++++++++++++++++++ 5 files changed, 130 insertions(+), 17 deletions(-) diff --git a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs index 3cdad383..e96b9763 100644 --- a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs +++ b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs @@ -131,6 +131,12 @@ public void Demo_Literal_Fence_Detects_Decoded_Identities_And_Admits_Platform_Da importedTarget.Should().Throw<InvalidOperationException>(); Action customSdk = () => RefuseExecutionTimeCompile("<Project Sdk=\"Custom.Sdk\" />"); customSdk.Should().Throw<InvalidOperationException>(); + Action implicitImport = () => RefuseExecutionTimeCompile("<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><DirectoryBuildTargetsPath>../../tests/CensusInjection.targets</DirectoryBuildTargetsPath></PropertyGroup></Project>"); + implicitImport.Should().Throw<InvalidOperationException>(); + RefuseExecutionTimeCompile("<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><TargetFramework>net10.0</TargetFramework></PropertyGroup></Project>"); + Action externalProject = () => RequireProductionProjectCoverage([Path.Combine(project, "Probe.csproj")], ["/repo/backend/tests/RuntimeHelper/RuntimeHelper.csproj"]); + externalProject.Should().Throw<InvalidOperationException>(); + RequireProductionProjectCoverage([Path.Combine(project, "Probe.csproj")], [Path.Combine(project, "Probe.csproj")]); var escaped = $"\\u{(int)identity[0]:x4}{identity[1..]}"; DemoLiteralViolations("Probe.cs", "class Probe { string Value = \"" + escaped + "\"; }", vocabulary) .Should().ContainSingle("Roslyn decodes escaped strings"); diff --git a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs index 35911d8d..b4c30c32 100644 --- a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs +++ b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs @@ -13,6 +13,7 @@ private static string[] DemoProductionSourceCensus() var projects = ProductionSourceRoots.SelectMany(root => Directory.EnumerateFiles(root, "*.csproj", SearchOption.AllDirectories)) .Order(StringComparer.Ordinal).ToArray(); var evaluated = projects.Select(EvaluatedDemoCompile).ToArray(); + RequireProductionProjectCoverage(projects, evaluated.SelectMany(row => row.References)); var outputs = evaluated.SelectMany(row => row.Outputs).Distinct(StringComparer.Ordinal).ToArray(); var files = ProductionSourceRoots.SelectMany(root => Directory.EnumerateFiles(root, "*", SearchOption.AllDirectories)) .Where(path => BackendDemoSourceKind(path, outputs) == 1).ToArray(); @@ -45,23 +46,44 @@ private static void RequireCompileCoverage(IEnumerable<string> files, IEnumerabl throw new InvalidOperationException("Unclassified Compile input; Fix: include the linked source in the supported production census."); } + private static void RequireProductionProjectCoverage(IEnumerable<string> projects, IEnumerable<string> references) + { + var admitted = projects.Select(Path.GetFullPath).ToHashSet(StringComparer.Ordinal); + if (references.Any(path => !admitted.Contains(Path.GetFullPath(path)))) + throw new InvalidOperationException("Unclassified production ProjectReference; Fix: include its compiler inputs in the supported census."); + } + + // Property-selected SDK hooks can import targets absent from evaluation-only Compile items. + // New build properties must be reviewed rather than silently expanding this bounded model. + private static readonly HashSet<string> DemoBuildProperties = new(StringComparer.Ordinal) + { + "AnalysisLevel", "AnalysisMode", "AssemblyName", "EnforceCodeStyleInBuild", + "EnforceExtendedAnalyzerRules", "GenerateDocumentationFile", "ImplicitUsings", "IsPackable", + "LangVersion", "ManagePackageVersionsCentrally", "NoWarn", "NuGetAuditLevel", "NuGetAuditMode", + "Nullable", "OutputType", "RootNamespace", "TargetFramework", "TreatWarningsAsErrors", + "UserSecretsId", "WarningsNotAsErrors" + }; + private static void RefuseExecutionTimeCompile(string source) { var document = XDocument.Parse(source); const string modulesImport = "$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))"; - if (document.Descendants().Any(node => node.Name.LocalName is "Target" or "Sdk" + if (document.Root?.Elements().Any(node => node.Name.LocalName is not ("PropertyGroup" or "ItemGroup" or "Import")) == true + || document.Descendants().Where(node => node.Name.LocalName == "PropertyGroup") + .SelectMany(node => node.Elements()).Any(node => !DemoBuildProperties.Contains(node.Name.LocalName)) + || document.Descendants().Any(node => node.Name.LocalName is "Target" or "Sdk" || node.Name.LocalName == "Import" && (string?)node.Attribute("Project") != modulesImport) || document.Root?.Attribute("Sdk") is { } sdk && sdk.Value is not ("Microsoft.NET.Sdk" or "Microsoft.NET.Sdk.Web")) throw new InvalidOperationException("Execution-time Compile/import shapes are unmodeled; Fix: review compiler-input admission before introducing a custom target or import."); } - private static (string[] Sources, string[] Outputs) EvaluatedDemoCompile(string project) + private static (string[] Sources, string[] Outputs, string[] References) EvaluatedDemoCompile(string project) { using var child = new Process { StartInfo = new ProcessStartInfo("dotnet") { - ArgumentList = { "msbuild", project, "-getItem:Compile", "-getProperty:BaseOutputPath,BaseIntermediateOutputPath", "-p:Configuration=Release", "-nologo" }, + ArgumentList = { "msbuild", project, "-getItem:Compile,ProjectReference", "-getProperty:BaseOutputPath,BaseIntermediateOutputPath", "-p:Configuration=Release", "-nologo" }, RedirectStandardOutput = true, RedirectStandardError = true, WorkingDirectory = Path.GetDirectoryName(project)!, @@ -81,10 +103,12 @@ private static (string[] Sources, string[] Outputs) EvaluatedDemoCompile(string using var document = JsonDocument.Parse(output.Result); var sources = document.RootElement.GetProperty("Items").GetProperty("Compile").EnumerateArray() .Select(row => Path.GetFullPath(row.GetProperty("FullPath").GetString()!)).ToArray(); + var references = document.RootElement.GetProperty("Items").GetProperty("ProjectReference").EnumerateArray() + .Select(row => Path.GetFullPath(row.GetProperty("FullPath").GetString()!)).ToArray(); var properties = document.RootElement.GetProperty("Properties"); var outputs = DemoOutputProperties .Select(name => properties.GetProperty(name).GetString()!) .Select(path => Path.GetFullPath(path.Replace('\\', Path.DirectorySeparatorChar), Path.GetDirectoryName(project)!)).ToArray(); - return (sources, outputs); + return (sources, outputs, references); } } diff --git a/docs/standards/21-architecture-tests-catalogue.md b/docs/standards/21-architecture-tests-catalogue.md index a24b817d..3a0f9603 100644 --- a/docs/standards/21-architecture-tests-catalogue.md +++ b/docs/standards/21-architecture-tests-catalogue.md @@ -677,15 +677,19 @@ otherwise). exact standalone proof/development entries retain their bounded exemptions. Generated/dependency roots are exact paths. Local module URL suffixes, supported tsconfig aliases, workspace exports, re-exports, import-equals and - literal `require.resolve` edges enter the closure. Missing/unsupported local + literal `require.resolve` edges enter the closure. Ambiguous local JS/TS and alias + targets are conservatively included; only owned workspace manifests select + workspace exports, and duplicate identities refuse. Missing/unsupported local edges and unclassified repository roots/source formats fail. Installed external packages are resolved under the known dependency roots; local/link targets enter the census or refuse. Native `.server` edges require the actual pinned TypeScript output mapping; the known stylesheet is an explicit inert asset. Backend `DomainGenericityTests.SourceCensus.cs` cross-checks the source set with - Release MSBuild-evaluated `Compile` inputs and actual output/intermediate roots. + Release MSBuild-evaluated `Compile` inputs, `ProjectReference` paths and actual + output/intermediate roots. Nested `bin`/`obj` remain authored source. Linked inputs outside the census and - unmodeled custom targets/imports/SDKs refuse rather than silently omit code. + unmodeled build properties, custom targets/imports/SDKs and references outside + the admitted production project set refuse rather than silently omit code. Dirty/clean controls cover these admission boundaries. Computed runtime imports fail rather than omit a helper. The rule does not claim diff --git a/frontend/apps/web/src/test/demo-genericity-sources.ts b/frontend/apps/web/src/test/demo-genericity-sources.ts index f00d5458..6330ab08 100644 --- a/frontend/apps/web/src/test/demo-genericity-sources.ts +++ b/frontend/apps/web/src/test/demo-genericity-sources.ts @@ -134,7 +134,7 @@ export function productionDemoSources( throw new Error(`Unmodeled runtime import: ${path}`); }; const packages = [...all] - .filter(([path]) => path.endsWith('/package.json')) + .filter(([path]) => /^frontend\/(?:apps|packages)\/[^/]+\/package\.json$/.test(path)) .map(([path, source]) => ({ root: posix.dirname(path), manifest: JSON.parse(source), @@ -169,9 +169,14 @@ export function productionDemoSources( const local = (base: string, from: string): string[] => { if (base === 'frontend/apps/web/src/app/globals.css') return all.has(base) ? [] : refused(from); base = generated.get(base) ?? base; - const target = candidates(base).find((path) => all.has(path)); - if (!target || !sourceExtension.test(target) || declaration.test(target)) return refused(from); - return [target]; + // Conservative union: native Node and TypeScript need not choose the same candidate. + const targets = candidates(base).filter((path) => all.has(path)); + if ( + !targets.length || + targets.some((target) => !sourceExtension.test(target) || declaration.test(target)) + ) + return refused(from); + return targets; }; const mapped = (value: unknown, root: string, from: string): string[] => { if (typeof value === 'string' && value.startsWith('./')) @@ -198,6 +203,7 @@ export function productionDemoSources( if (source) { const config = JSON.parse(source); if (config.compilerOptions?.baseUrl) return refused(path); + const aliases: string[] = []; for (const [pattern, replacements] of Object.entries(config.compilerOptions?.paths ?? {})) { const parts = pattern.split('*'); if (parts.length > 2 || !Array.isArray(replacements) || replacements.length === 0) @@ -209,11 +215,20 @@ export function productionDemoSources( if (!match) continue; const capture = parts.length === 1 ? '' : edge.slice(parts[0]!.length, edge.length - parts[1]!.length); - return replacements.flatMap((value) => { - if (typeof value !== 'string' || !value.startsWith('./') || value.split('*').length > 2) - return refused(path); - return local(posix.normalize(posix.join(directory, value.replace('*', capture))), path); - }); + aliases.push( + ...replacements.flatMap((value) => { + if ( + typeof value !== 'string' || + !value.startsWith('./') || + value.split('*').length > 2 + ) + return refused(path); + return local( + posix.normalize(posix.join(directory, value.replace('*', capture))), + path, + ); + }), + ); } // Inherited alias maps are not silently ignored. The shipped inherited presets have none. const checkExtends = (name: unknown, owner: string, seen = new Set<string>()) => { @@ -238,13 +253,17 @@ export function productionDemoSources( checkExtends(inherited.extends, posix.dirname(target), seen); }; checkExtends(config.extends, directory); + // Include every supported match instead of guessing TypeScript alias precedence. + if (aliases.length) return aliases; break; } directory = posix.dirname(directory); } - const pkg = packages.find( + const matches = packages.filter( (pkg) => edge === pkg.manifest.name || edge.startsWith(pkg.manifest.name + '/'), ); + if (matches.length > 1) return refused(path); + const pkg = matches[0]; if (pkg) { const key = edge === pkg.manifest.name ? '.' : './' + edge.slice(pkg.manifest.name.length + 1); diff --git a/frontend/apps/web/src/test/demo-genericity.test.ts b/frontend/apps/web/src/test/demo-genericity.test.ts index 0cb5e2ba..f19988c4 100644 --- a/frontend/apps/web/src/test/demo-genericity.test.ts +++ b/frontend/apps/web/src/test/demo-genericity.test.ts @@ -312,6 +312,66 @@ describe('P02d-7 exact demo identity boundary', () => { ).toEqual([identity]); } }); + it('includes ambiguous alias and native JS/TS targets and ignores fixture package identities', () => { + const entry = 'frontend/apps/web/src/server/probe.ts'; + const alias = 'frontend/apps/web/src/test/dirty.ts'; + const native = 'frontend/apps/web/src/test/native.js'; + const workspace = 'frontend/packages/sdk/src/runtime.test.ts'; + const files = productionDemoSources( + new Map([ + [ + 'frontend/apps/web/tsconfig.json', + JSON.stringify({ + compilerOptions: { + paths: { + '@/*': ['./src/*'], + '@/special/*': ['./src/test/*'], + }, + }, + }), + ], + [entry, "import '@/special/dirty'; import '@learnstack/sdk/runtime';"], + ['frontend/apps/web/src/special/dirty.ts', 'export const clean = true;'], + [alias, `export const special = ${JSON.stringify(identity)};`], + ['scripts/probe.cjs', "require('../frontend/apps/web/src/test/native');"], + ['frontend/apps/web/src/test/native.ts', 'export const clean = true;'], + [native, `exports.special = ${JSON.stringify(identity)};`], + [ + 'frontend/apps/web/src/test/package-fixture/package.json', + JSON.stringify({ + name: '@learnstack/sdk', + exports: { './runtime': './clean.ts' }, + }), + ], + ['frontend/apps/web/src/test/package-fixture/clean.ts', 'export const clean = true;'], + [ + 'frontend/packages/sdk/package.json', + JSON.stringify({ + name: '@learnstack/sdk', + exports: { './runtime': './src/runtime.test.ts' }, + }), + ], + [workspace, `export const special = ${JSON.stringify(identity)};`], + ]), + ); + for (const path of [alias, native, workspace]) { + expect(files.has(path)).toBe(true); + expect(demoIdentityFindings(path, files.get(path)!, vocabulary)).toEqual([identity]); + } + for (const path of [alias, native, workspace]) files.set(path, 'export const clean = true;'); + expect( + [...files].flatMap(([path, source]) => demoIdentityFindings(path, source, vocabulary)), + ).toEqual([]); + expect(() => + productionDemoSources( + new Map([ + [entry, "import '@learnstack/sdk/runtime';"], + ['frontend/packages/sdk/package.json', '{"name":"@learnstack/sdk"}'], + ['frontend/packages/duplicate/package.json', '{"name":"@learnstack/sdk"}'], + ]), + ), + ).toThrow('Unmodeled'); + }); it('refuses missing, unknown-format, inherited-alias and untrusted external edges', () => { const entry = 'frontend/apps/web/scripts/entry.mjs'; for (const edge of ['./missing.mjs', './helper.runtime', 'unknown-package', '#local']) From c6cd69f1b65955154a1e174b27b36354675031dc Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 11:22:02 +0300 Subject: [PATCH 27/35] test(web): inspect every inherited demo census config candidate Refuse inherited alias maps even when a same-basename source file would previously shadow the actual JSON configuration. ADR: 0018, 0056 --- .../web/src/test/demo-genericity-sources.ts | 22 ++++++++++--------- .../apps/web/src/test/demo-genericity.test.ts | 14 ++++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/frontend/apps/web/src/test/demo-genericity-sources.ts b/frontend/apps/web/src/test/demo-genericity-sources.ts index 6330ab08..741e8dd7 100644 --- a/frontend/apps/web/src/test/demo-genericity-sources.ts +++ b/frontend/apps/web/src/test/demo-genericity-sources.ts @@ -233,10 +233,9 @@ export function productionDemoSources( // Inherited alias maps are not silently ignored. The shipped inherited presets have none. const checkExtends = (name: unknown, owner: string, seen = new Set<string>()) => { if (name === undefined) return; - if (typeof name !== 'string' || seen.has(name)) return refused(path); - seen.add(name); - const target = name.startsWith('.') - ? candidates(posix.join(owner, name)).find((key) => all.has(key)) + if (typeof name !== 'string') return refused(path); + const targets = name.startsWith('.') + ? local(posix.normalize(posix.join(owner, name)), path) : packages.flatMap((pkg) => name.startsWith(pkg.manifest.name + '/') ? mapped( @@ -245,12 +244,15 @@ export function productionDemoSources( path, ) : [], - )[0]; - if (!target) return refused(path); - const inherited = JSON.parse(all.get(target)!); - if (inherited.compilerOptions?.paths || inherited.compilerOptions?.baseUrl) - return refused(path); - checkExtends(inherited.extends, posix.dirname(target), seen); + ); + if (!targets.length) return refused(path); + for (const target of targets) { + if (seen.has(target)) return refused(path); + const inherited = JSON.parse(all.get(target)!); + if (inherited.compilerOptions?.paths || inherited.compilerOptions?.baseUrl) + return refused(path); + checkExtends(inherited.extends, posix.dirname(target), new Set([...seen, target])); + } }; checkExtends(config.extends, directory); // Include every supported match instead of guessing TypeScript alias precedence. diff --git a/frontend/apps/web/src/test/demo-genericity.test.ts b/frontend/apps/web/src/test/demo-genericity.test.ts index f19988c4..407a7d49 100644 --- a/frontend/apps/web/src/test/demo-genericity.test.ts +++ b/frontend/apps/web/src/test/demo-genericity.test.ts @@ -389,6 +389,20 @@ describe('P02d-7 exact demo identity boundary', () => { () => '../foreign/index.js', ), ).toThrow('Unmodeled'); + expect(() => + productionDemoSources( + new Map([ + [entry, "import 'external-package';"], + ['frontend/apps/web/tsconfig.json', '{"extends":"./src/test/base"}'], + ['frontend/apps/web/src/test/base.ts', '{}'], + [ + 'frontend/apps/web/src/test/base.json', + '{"compilerOptions":{"paths":{"hidden/*":["./*"]}}}', + ], + ]), + () => 'frontend/node_modules/external-package/index.js', + ), + ).toThrow('Unmodeled'); const helper = 'frontend/apps/web/src/test/helper.ts'; expect( productionDemoSources( From 9a0d285ec6454ef23c4d8428b2583ddfa7ea30c8 Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 11:25:16 +0300 Subject: [PATCH 28/35] test(dev): verify demo reconciliation and align delivery guidance Exercise independent network overlap and per-route timing aggregation in fast dirty/clean controls. Count completed navigations and restrict uploads to named public artifacts. Record verified review dispositions and align current P7 guidance without rewriting historical ADRs. ADR: 0018, 0056 --- .claude/skills/add-frontend-route/SKILL.md | 12 +-- .github/workflows/ci.yml | 6 +- .../architecture/04-technical-architecture.md | 6 +- docs/roadmap/phase-02d-walking-skeleton.md | 69 ++++++++++++++++ docs/standards/12-infrastructure.md | 7 +- docs/standards/17-code-review.md | 3 +- docs/standards/README.md | 2 +- .../web/scripts/public-demo-contract.d.mts | 14 ++++ .../apps/web/scripts/public-demo-contract.mjs | 40 ++++++++++ .../web/scripts/public-demo-gatherer.d.mts | 15 ++++ .../apps/web/scripts/public-demo-worker.mjs | 26 ++---- .../apps/web/scripts/verify-public-demo.mjs | 20 +---- .../apps/web/src/test/public-demo-ci.test.ts | 20 +++++ .../apps/web/src/test/public-demo.test.ts | 79 +++++++++++++++++++ 14 files changed, 269 insertions(+), 50 deletions(-) diff --git a/.claude/skills/add-frontend-route/SKILL.md b/.claude/skills/add-frontend-route/SKILL.md index f695a9c8..e0101fb5 100644 --- a/.claude/skills/add-frontend-route/SKILL.md +++ b/.claude/skills/add-frontend-route/SKILL.md @@ -315,11 +315,13 @@ records passing production replacement proofs, completed reviews and verified fi hosts/locales. If unavailable, evidence stays pending and completion is not claimed. HTTP/RSC assertions are not browser or assistive-technology proof. P02d-7 owns browser/demo and Lighthouse; Phase 11 owns web-vitals telemetry. -- Lighthouse budget check on representative public routes — CI's `lighthouse budget` - job remains deferred until P02d-7/G44/G45 after P6 pages; judge by reading until - that harness is implemented. Its remaining details are in the - [decision register](../../../docs/roadmap/phase-02d-walking-skeleton.md#the-decision-register); - the pass that closes it rewrites this bullet. +- CI's required `public demo + lighthouse` job exercises the seeded public + catalog/course/lesson routes under + [ADR-0056](../../../docs/decisions/0056-public-demo-browser-and-lighthouse-enforcement.md). + Preserve its production-page admission, hard budgets and owned cleanup. The + [P7 Step 4 record](../../../docs/roadmap/phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) + owns completed G44/G45 enforcement; Phase 06 still owns broader Playwright/axe + coverage. ## Validation diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1095b58..864ac5f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -480,9 +480,9 @@ jobs: name: public-demo-lighthouse path: | artifacts/public-demo/receipt.json - artifacts/public-demo/*.json - artifacts/public-demo/*.html - artifacts/public-demo/*.png + artifacts/public-demo/audit-*.json + artifacts/public-demo/audit-*.html + artifacts/public-demo/browser-*.png artifacts/public-demo-ci/workflow.json if-no-files-found: error retention-days: 7 diff --git a/docs/architecture/04-technical-architecture.md b/docs/architecture/04-technical-architecture.md index 702ee59f..ec3183aa 100644 --- a/docs/architecture/04-technical-architecture.md +++ b/docs/architecture/04-technical-architecture.md @@ -232,8 +232,10 @@ Application projects run **outside** containers during active development for fa P02d-5 delivers G33's paired loopback API and native TLS web ingress, with isolated real-API production-rendering fixtures. The [accepted local setup](../roadmap/phase-02d-walking-skeleton.md#local-setup-and-ingress-details) -owns host, certificate and private configuration preparation. P02d-7 owns G45's -`make demo` lifecycle and browser evidence; that gate remains open. +owns host, certificate and private configuration preparation. P02d-7 delivers +G45's `make demo` lifecycle and browser evidence; the +[Step 4 record](../roadmap/phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) +owns completed reviews, CI enforcement and phase-exit verification. ## Observability diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index 187e79d1..43aa7634 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -6389,6 +6389,75 @@ corpus tests pass; the complete PR's 33 changed/new Markdown files resolve 2,201 relative links and 698 fragments without errors. The new remediation head must still pass full seven-job CI through the PR rollup before merge. +##### Systematic review remediation (2026-10-11) + +The later review examined source `aebefee`. Its findings were re-verified against +current code before changes; this is a separate record from the historical +`d47ef17` review above. No new architecture decision or budget change is needed. +Work remains on `development`; PR #28 is not merged by this record. + +1. **Lifecycle and launcher — complete.** `cd6affd` removes the unsupported + Seeder launcher argument, attempts independent process/observer/Compose + cleanup stages even when a preceding stage fails, and retains failure causes + internally without echoing private diagnostics. Private files are removed + only after confirmed cleanup. Socket errors distinguish occupied ports from + other bind failures; declaration files describe the actual lifecycle API. + `/artifacts/` is ignored. All 34 lifecycle tests, lint and typecheck pass. + Two first-round reviewers and a fresh second-round reviewer approved without + findings. +2. **Genericity census — complete.** `db6bcdf`, `90114f0` and `c6cd69f` close + source-root/format admission and supported static import gaps. Local and + inherited-config candidate ambiguities are conservatively included or + refused; workspace manifests have explicit ownership. Backend evaluation + checks `Compile` and `ProjectReference` coverage, exact output roots and + bounded build shapes/properties. First-round frontend/backend reviewers + identified five verified resolution/build-admission gaps, fixed in + `90114f0`. The fresh second round found inherited-config shadowing, fixed in + `c6cd69f`; its same counterexample now refuses and its clean control passes. + All 18 frontend genericity cases, seven backend genericity cases, all 203 + architecture cases, lint, typecheck and targeted format pass. This remains a + bounded exact-literal/static-import fence, not arbitrary program analysis. +3. **Proof helpers and carriers — implementation in progress.** Actual worker + network-inventory reconciliation and verifier advisory aggregation are shared + with fast dirty/clean controls. Navigation counts come from completed + observations; upload globs admit only named reports/screenshots/receipts. + Current architecture, infrastructure, standards and route-authoring guidance + describe delivered G44/G45 enforcement. Both fresh review rounds and final + seven-job CI are pending for this step. + +**Other finding dispositions.** The gzip adapter equality checks wiring; the +independent Script observer checks source-window coverage, not a second byte +measurement. Existing fast tests already cover report admission, source-byte +normalization, completion accounting and gatherer cleanup; full orchestration, +TLS refusal, real visibility and report-file checks remain real lifecycle/CI +proofs. The added helpers supplement those proofs rather than replacing them. +The review's zero-fast-coverage claim was therefore broader than the actual gap. + +The reported PR-body count/gzip mismatch compared different receipts. Downloaded +[run 38119659152](https://github.com/HodeTech/LearnStack/actions/runs/38119659152) +for source `aebefee`, tested merge `0bb897c`, verifies 2,964 backend and 1,514 +frontend passes, gzip 106,358–106,552 bytes. Historical `d47ef17` numbers above +remain correct for that earlier head; neither substitutes for final remediation +CI. The newer proof took 619,309 ms inside the accepted 720,000 ms deadline; +cleanup took 10,595 ms inside 30,000 ms. No deadline increase is justified. + +Ordinal complete-value matching and strict readable JSON are accepted G20 +behavior, so host case-folding and JSON-comment tolerance are not introduced. +Below-fold laid-out content remains valid full-page evidence; adding a viewport +bottom cutoff would reject legitimate long lessons. Bounded child ownership +records are retained through process-group/EOF confirmation; no sustained leak +was demonstrated. The older `public-local` exit behavior, dormant platform +branches and test-project placement are unchanged maintenance suggestions. +Census regeneration instructions already name the authoritative Seeder command. + +Mutable Action tags are pre-existing throughout CI, with no accepted SHA-pinning +policy. This patch does not introduce a repository-wide dependency policy; +[Security Standards](../standards/11-security.md#dependency-hygiene) already assign +update automation to Phase 11. Accepted ADR-0053/0056 baseline and dated notes +remain historical; their then-pending wording is not rewritten as a correction. +Current carriers link delivered P7 evidence instead. No new human/WCAG evidence +is claimed by these orchestration and proof changes. + Closing documentation commits must also pass the seven required jobs before merge; the [PR check rollup](https://github.com/HodeTech/LearnStack/pull/28/checks) owns that moving-head result. Next after maintainer review and merge is diff --git a/docs/standards/12-infrastructure.md b/docs/standards/12-infrastructure.md index e5e1061a..ffd25ae5 100644 --- a/docs/standards/12-infrastructure.md +++ b/docs/standards/12-infrastructure.md @@ -93,8 +93,11 @@ P02d-5 delivers G33's loopback API/native TLS web ingress and paired private loc configuration under [ADR-0053](../decisions/0053-trusted-public-server-rendering.md). Follow the [local setup](../roadmap/phase-02d-walking-skeleton.md#local-setup-and-ingress-details) for explicit hosts and certificate trust preparation; neither is installed by scripts. -P02d-7 owns G45's `make demo` lifecycle and browser/TLS evidence, plus the remaining -G44 Lighthouse harness/assertions after P6. APISIX remains Phase 11. +P02d-7 delivers G45's `make demo` lifecycle, browser/TLS evidence and G44's +Lighthouse harness/assertions under +[ADR-0056](../decisions/0056-public-demo-browser-and-lighthouse-enforcement.md). +The [Step 4 record](../roadmap/phase-02d-walking-skeleton.md#p02d-7-step-4--ci-enforcement-and-phase-exit-2026-10-11) +owns enforcement and phase-exit verification. APISIX remains Phase 11. ### Healthchecks and the readiness gate diff --git a/docs/standards/17-code-review.md b/docs/standards/17-code-review.md index d2c1fd1c..6b23ba6c 100644 --- a/docs/standards/17-code-review.md +++ b/docs/standards/17-code-review.md @@ -71,7 +71,8 @@ Before requesting reviews, run the relevant checklist on your own diff: - [ ] Accessibility: keyboard reachability, labels and contrast reviewed; blocking JSX accessibility checks and the public browser/Lighthouse proof pass where applicable. Preserve the scoped manual evidence described below. -- [ ] Bundle size delta acceptable on public routes (< 200 KB gzipped per route). +- [ ] Public-route JavaScript meets the normalized gzip budget and measurement + scope in [Performance Standards](15-performance.md#frontend-rules). > **Accepted G43 enforcement is delivered.** P02d-6 supplies blocking `jsx-a11y` > rules with planted controls. P02d-7's shared browser/Lighthouse proof enforces diff --git a/docs/standards/README.md b/docs/standards/README.md index a65a96da..211483d4 100644 --- a/docs/standards/README.md +++ b/docs/standards/README.md @@ -81,7 +81,7 @@ loaders, chrome/states and atomic theme injection. Its owns foundation validation and review evidence. Steps 2–3 implement actual catalog/course/lesson views, pagination/metadata and blocking JSX accessibility controls. Step 4 implements automated product HTML/Flight proofs and completes -manual accessibility, including maintainer-reported VoiceOver. P7 owns +manual accessibility, including maintainer-reported VoiceOver. P7 delivers demo/browser/Lighthouse. ADR-0055 remediation delivers single-bootstrap admission and passing production replacement proofs. All three steps completed both independent review rounds. The diff --git a/frontend/apps/web/scripts/public-demo-contract.d.mts b/frontend/apps/web/scripts/public-demo-contract.d.mts index 6fd69a48..eaa16922 100644 --- a/frontend/apps/web/scripts/public-demo-contract.d.mts +++ b/frontend/apps/web/scripts/public-demo-contract.d.mts @@ -22,3 +22,17 @@ export function validateReport( census: unknown, ): Record<string, number>; export function reportInventory(rows: unknown, expected: unknown): void; + +export function reconcileScriptInventory( + log: Array<{ + method: string; + params: { type: string; requestId: string; response: { url: string } }; + }>, + inventory: Array<{ id: string; url: string }>, +): void; +export function reportAdvisories( + reports: Array<{ url: string; metrics: Record<string, number> }>, +): Array<{ + url: string; + metrics: Record<string, { median: number; threshold: number; warning: boolean }>; +}>; diff --git a/frontend/apps/web/scripts/public-demo-contract.mjs b/frontend/apps/web/scripts/public-demo-contract.mjs index 073dc621..bce0ca63 100644 --- a/frontend/apps/web/scripts/public-demo-contract.mjs +++ b/frontend/apps/web/scripts/public-demo-contract.mjs @@ -282,3 +282,43 @@ export function reportInventory(rows, expected) { assert.equal(row.browserVersion, expected[0].browserVersion, 'Exact audited browser'); } } + +/** Reconcile independent Lighthouse events with the complete source gatherer's window. */ +export function reconcileScriptInventory(log, inventory) { + const logged = log.filter( + (row) => row.method === 'Network.responseReceived' && row.params.type === 'Script', + ); + assert.ok(logged.length > 0, 'Positive independent Script network observer'); + for (const row of logged) + assert.ok( + inventory.some( + (item) => item.id === row.params.requestId && item.url === row.params.response.url, + ), + 'Script inventory overlap', + ); +} + +/** Timing metrics remain warnings; each URL owns exactly three finite samples. */ +export function reportAdvisories(reports) { + return [...new Set(reports.map((row) => row.url))].map((url) => ({ + url, + metrics: Object.fromEntries( + Object.entries({ + 'largest-contentful-paint': 1500, + 'server-response-time': 300, + 'total-blocking-time': 200, + }).map(([key, threshold]) => { + const samples = reports.filter((row) => row.url === url).map((row) => row.metrics[key]); + assert.equal(samples.length, 3, 'Exactly three advisory samples per URL'); + assert.ok( + samples.every( + (value) => typeof value === 'number' && Number.isFinite(value) && value >= 0, + ), + 'Finite advisory samples', + ); + const median = samples.sort((a, b) => a - b)[1]; + return [key, { median, threshold, warning: median >= threshold }]; + }), + ), + })); +} diff --git a/frontend/apps/web/scripts/public-demo-gatherer.d.mts b/frontend/apps/web/scripts/public-demo-gatherer.d.mts index d390de65..dc1beb2b 100644 --- a/frontend/apps/web/scripts/public-demo-gatherer.d.mts +++ b/frontend/apps/web/scripts/public-demo-gatherer.d.mts @@ -5,3 +5,18 @@ export class PublicDemoDocument { export const demoLighthouseConfiguration: unknown; export function configurationCensus(config: unknown): unknown; export function resolvedDemoCensus(flags: unknown): Promise<unknown>; + +export class InitialJavaScriptGzip { + static readonly meta: { + id: string; + title: string; + description: string; + scoreDisplayMode: string; + requiredArtifacts: string[]; + }; + static audit(artifacts: { PublicDemoDocument: { gzip: { total: number } } }): { + score: number; + numericValue: number; + numericUnit: string; + }; +} diff --git a/frontend/apps/web/scripts/public-demo-worker.mjs b/frontend/apps/web/scripts/public-demo-worker.mjs index ae65056b..85bd8d23 100644 --- a/frontend/apps/web/scripts/public-demo-worker.mjs +++ b/frontend/apps/web/scripts/public-demo-worker.mjs @@ -11,6 +11,7 @@ import { assertConfiguration, digest, productDomSnapshot, + reconcileScriptInventory, validateReport, } from './public-demo-contract.mjs'; import { resolvedDemoCensus, demoLighthouseConfiguration } from './public-demo-gatherer.mjs'; @@ -50,6 +51,7 @@ async function observe(page, response, lane, kind) { async function browserPaths(browser, input) { let visibilityControls = 0; + let navigations = 0; for (const [laneIndex, lane] of input.lanes.entries()) { const context = await browser.newContext({ viewport: { width: 412, height: 823 }, @@ -70,6 +72,7 @@ async function browserPaths(browser, input) { ]); } await observe(page, response, lane, kind); + navigations++; await page.screenshot({ path: join(input.output, `browser-${laneIndex}-${kind}.png`), fullPage: true, @@ -106,7 +109,7 @@ async function browserPaths(browser, input) { await context.close(); } } - return visibilityControls; + return { navigations, visibilityControls }; } /** The pinned Lighthouse load deadline is a warning, which admission must refuse. */ @@ -192,11 +195,8 @@ async function main(input) { return; } if (input.mode === 'browser') { - const visibilityControls = await browserPaths(browser, input); - writeFileSync( - input.result, - JSON.stringify({ browserVersion, navigations: 9, visibilityControls }), - ); + const counts = await browserPaths(browser, input); + writeFileSync(input.result, JSON.stringify({ browserVersion, ...counts })); return; } if (input.mode !== 'timeout-control') { @@ -243,18 +243,8 @@ async function main(input) { const metrics = validateReport(result.lhr, input, expectedCensus); assert.equal(metrics['initial-js-gzip-bytes'], result.artifacts.PublicDemoDocument.gzip.total); const source = result.artifacts.PublicDemoDocument; - // Independently reconcile the overlap with Lighthouse's earlier network window. - const logged = result.artifacts.DevtoolsLog.filter( - (row) => row.method === 'Network.responseReceived' && row.params.type === 'Script', - ); - assert.ok(logged.length > 0, 'Positive independent Script network observer'); - for (const row of logged) - assert.ok( - source.inventory.some( - (item) => item.id === row.params.requestId && item.url === row.params.response.url, - ), - 'Script inventory overlap', - ); + // This is independent network-window coverage, not a second gzip measurement. + reconcileScriptInventory(result.artifacts.DevtoolsLog, source.inventory); const base = join(input.output, `audit-${input.laneIndex}-${input.kind}-${input.run}`); const report = JSON.stringify(result.lhr); writeFileSync(base + '.json', report, { flag: 'wx' }); diff --git a/frontend/apps/web/scripts/verify-public-demo.mjs b/frontend/apps/web/scripts/verify-public-demo.mjs index 8064524f..813682cc 100644 --- a/frontend/apps/web/scripts/verify-public-demo.mjs +++ b/frontend/apps/web/scripts/verify-public-demo.mjs @@ -8,7 +8,7 @@ import { fileURLToPath } from 'node:url'; import { chromium } from 'playwright'; -import { digest, reportInventory } from './public-demo-contract.mjs'; +import { digest, reportAdvisories, reportInventory } from './public-demo-contract.mjs'; import { stopTestChild } from './stop-test-child.mjs'; import { demoRequest } from '../../../../scripts/demo-http.mjs'; import { completionDelta, finalCompletionCensus } from '../../../../scripts/demo-observation.mjs'; @@ -246,23 +246,7 @@ export async function verifyPublicDemo(runtime) { 'Complete HTML report', ); } - receipt.advisories = [...new Set(receipt.reports.map((row) => row.url))].map((url) => ({ - url, - metrics: Object.fromEntries( - Object.entries({ - 'largest-contentful-paint': 1500, - 'server-response-time': 300, - 'total-blocking-time': 200, - }).map(([key, threshold]) => { - const samples = receipt.reports - .filter((row) => row.url === url) - .map((row) => row.metrics[key]) - .sort((a, b) => a - b); - const median = samples[1]; - return [key, { median, threshold, warning: median >= threshold }]; - }), - ), - })); + receipt.advisories = reportAdvisories(receipt.reports); remaining(1); receipt.proofMilliseconds = Date.now() - started; receipt.passed = true; diff --git a/frontend/apps/web/src/test/public-demo-ci.test.ts b/frontend/apps/web/src/test/public-demo-ci.test.ts index 0229ea1f..472060be 100644 --- a/frontend/apps/web/src/test/public-demo-ci.test.ts +++ b/frontend/apps/web/src/test/public-demo-ci.test.ts @@ -89,3 +89,23 @@ it.each(['1000', '999'])( expect(() => readFileSync(files.invocation)).toThrow(); }, ); + +it('uploads only named public reports, screenshots and sanitized receipts', () => { + const paths = (source: string) => { + const block = source.match(/ {10}path: \|\n((?: {12}.+\n)+)/)?.[1]; + if (!block) throw new Error('Missing actual workflow artifact allowlist'); + return block + .trim() + .split('\n') + .map((path) => path.trim()); + }; + const expected = [ + 'artifacts/public-demo/receipt.json', + 'artifacts/public-demo/audit-*.json', + 'artifacts/public-demo/audit-*.html', + 'artifacts/public-demo/browser-*.png', + 'artifacts/public-demo-ci/workflow.json', + ]; + expect(paths(job!)).toEqual(expected); + expect(paths(job!.replace('audit-*.json', '*.json'))).not.toEqual(expected); +}); diff --git a/frontend/apps/web/src/test/public-demo.test.ts b/frontend/apps/web/src/test/public-demo.test.ts index 17e971d5..13ab87ab 100644 --- a/frontend/apps/web/src/test/public-demo.test.ts +++ b/frontend/apps/web/src/test/public-demo.test.ts @@ -15,6 +15,8 @@ import { assertConfiguration, decodedSource, normalizedJavaScript, + reconcileScriptInventory, + reportAdvisories, reportInventory, validateReport, } from '../../scripts/public-demo-contract.mjs'; @@ -506,3 +508,80 @@ describe('actual initial source gatherer completeness controls', () => { }, ); }); + +describe('public proof independent reconciliation helpers', () => { + const script = { + method: 'Network.responseReceived', + params: { + type: 'Script', + requestId: 'request-one', + response: { url: 'https://public.example/chunk.js' }, + }, + }; + const matching = { id: script.params.requestId, url: script.params.response.url }; + it.each(['empty', 'missing-id', 'wrong-url', 'non-script'])( + 'refuses %s network overlap with a clean control', + (kind) => { + const log = + kind === 'empty' + ? [] + : kind === 'non-script' + ? [{ ...script, params: { ...script.params, type: 'Document' } }] + : [script]; + const rows = + kind === 'missing-id' + ? [{ ...matching, id: 'other' }] + : kind === 'wrong-url' + ? [{ ...matching, url: 'https://public.example/other.js' }] + : [matching]; + expect(() => reconcileScriptInventory(log, rows)).toThrow(); + expect(() => reconcileScriptInventory([script], [matching])).not.toThrow(); + }, + ); + const timing = (url: string, value: number) => ({ + url, + metrics: { + 'largest-contentful-paint': value * 1500, + 'server-response-time': value * 300, + 'total-blocking-time': value * 200, + }, + }); + it('sorts each URL independently and warns at the exact thresholds', () => { + const rows = [ + timing('one', 2), + timing('two', 0.8), + timing('one', 0.5), + timing('two', 0.2), + timing('one', 1), + timing('two', 0.4), + ]; + const result = reportAdvisories(rows); + expect(result).toEqual([ + { + url: 'one', + metrics: { + 'largest-contentful-paint': { median: 1500, threshold: 1500, warning: true }, + 'server-response-time': { median: 300, threshold: 300, warning: true }, + 'total-blocking-time': { median: 200, threshold: 200, warning: true }, + }, + }, + { + url: 'two', + metrics: { + 'largest-contentful-paint': { median: 600, threshold: 1500, warning: false }, + 'server-response-time': { median: 120, threshold: 300, warning: false }, + 'total-blocking-time': { median: 80, threshold: 200, warning: false }, + }, + }, + ]); + expect(rows[0]?.metrics['largest-contentful-paint']).toBe(3000); + }); + it.each(['missing', 'extra', 'nonfinite'])('refuses %s advisory samples', (kind) => { + const rows = [timing('one', 0.2), timing('one', 0.4), timing('one', 0.8)]; + expect(() => reportAdvisories(rows)).not.toThrow(); + if (kind === 'missing') rows.pop(); + if (kind === 'extra') rows.push(timing('one', 1)); + if (kind === 'nonfinite') rows[0]!.metrics['server-response-time'] = Number.NaN; + expect(() => reportAdvisories(rows)).toThrow(); + }); +}); From e3a32d2cfecd62e43a3f81a8674f8355775245e7 Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 11:29:50 +0300 Subject: [PATCH 29/35] docs(roadmap): close systematic P7 remediation review rounds Record all three steps, verified fixes, both independent review rounds and completed local validation. Require final seven-job PR CI without attributing historical evidence to the new source head. ADR: 0018, 0056 --- docs/roadmap/phase-02d-walking-skeleton.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index 43aa7634..abec701b 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -6417,13 +6417,22 @@ Work remains on `development`; PR #28 is not merged by this record. All 18 frontend genericity cases, seven backend genericity cases, all 203 architecture cases, lint, typecheck and targeted format pass. This remains a bounded exact-literal/static-import fence, not arbitrary program analysis. -3. **Proof helpers and carriers — implementation in progress.** Actual worker +3. **Proof helpers and carriers — complete.** `9a0d285` shares actual worker network-inventory reconciliation and verifier advisory aggregation are shared with fast dirty/clean controls. Navigation counts come from completed observations; upload globs admit only named reports/screenshots/receipts. Current architecture, infrastructure, standards and route-authoring guidance - describe delivered G44/G45 enforcement. Both fresh review rounds and final - seven-job CI are pending for this step. + describe delivered G44/G45 enforcement. Two first-round reviewers and a fresh + second-round reviewer approved without findings. The second round also + reproduced all historical advisory medians from the downloaded receipt. + All 128 focused tests, 1,537 frontend cases (1,477 web + 60 SDK) and 2,092 + Docker-free backend cases (1,705 unit + 203 architecture + four contract + + 180 integration) pass with zero failures/skips/todos. Release build, format, + lint, typecheck and production frontend builds pass; 15 sandbox-policy and + seven ADR-status controls pass. The complete PR's 36 Markdown files resolve + 2,289 relative links and 719 fragments; added prose respects 88 columns. + The final PR rollup must still pass all seven required jobs, including the + real Docker and 27-audit lifecycle proof, before merge. **Other finding dispositions.** The gzip adapter equality checks wiring; the independent Script observer checks source-window coverage, not a second byte From 4541d631f6e1ae96247307b93b9ca661f0991620 Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 11:30:17 +0300 Subject: [PATCH 30/35] docs(roadmap): clarify proof helper closeout wording --- docs/roadmap/phase-02d-walking-skeleton.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index abec701b..a0355b10 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -6417,9 +6417,9 @@ Work remains on `development`; PR #28 is not merged by this record. All 18 frontend genericity cases, seven backend genericity cases, all 203 architecture cases, lint, typecheck and targeted format pass. This remains a bounded exact-literal/static-import fence, not arbitrary program analysis. -3. **Proof helpers and carriers — complete.** `9a0d285` shares actual worker - network-inventory reconciliation and verifier advisory aggregation are shared - with fast dirty/clean controls. Navigation counts come from completed +3. **Proof helpers and carriers — complete.** `9a0d285` extracts actual worker + network-inventory reconciliation and verifier advisory aggregation for fast + dirty/clean controls. Navigation counts come from completed observations; upload globs admit only named reports/screenshots/receipts. Current architecture, infrastructure, standards and route-authoring guidance describe delivered G44/G45 enforcement. Two first-round reviewers and a fresh From d16d2d72287f4703c2900c11040d0340debbb4d4 Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 11:50:33 +0300 Subject: [PATCH 31/35] test(architecture): admit ignored local machine artifacts Keep documented environment and OS/editor/log files out of raw census classification only when Git ignores them. Preserve source/unknown format admission and evaluated compiler coverage. ADR: 0018, 0056 --- .../DomainGenericityTests.DemoIdentities.cs | 8 ++++ .../DomainGenericityTests.SourceCensus.cs | 41 +++++++++++++++++-- docs/roadmap/phase-02d-walking-skeleton.md | 8 ++++ .../21-architecture-tests-catalogue.md | 4 +- .../web/src/test/demo-genericity-sources.ts | 25 +++++++++++ .../apps/web/src/test/demo-genericity.test.ts | 31 +++++++++++++- 6 files changed, 112 insertions(+), 5 deletions(-) diff --git a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs index e96b9763..ecd1b440 100644 --- a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs +++ b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs @@ -119,6 +119,14 @@ public void Demo_Literal_Fence_Detects_Decoded_Identities_And_Admits_Platform_Da .Should().Be(1, "only actual project outputs are excluded"); BackendDemoSourceKind(Path.Combine(project, directory, "Generated.cs"), generated).Should().Be(0); } + foreach (var name in new[] { ".env.local", ".DS_Store", "Thumbs.db", "editor.swp", "runtime.log" }) + { + var local = Path.Combine(RepositoryPaths.BackendSrc(), "LearnStack.Api", name); + IsDemoLocalArtifact(local).Should().BeTrue(); + OmitIgnoredDemoLocalFile(local).Should().BeTrue("the actual Git rules omit known machine files"); + } + foreach (var name in new[] { ".env.hidden.cs", ".env.hidden.json", "hidden.resx" }) + IsDemoLocalArtifact(Path.Combine(project, name)).Should().BeFalse("ignored source/unknown formats are not machine-file exemptions"); Action unknownFormat = () => _ = BackendDemoSourceKind(Path.Combine(project, "Probe.resx"), generated); unknownFormat.Should().Throw<InvalidOperationException>(); Action linkedInput = () => RequireCompileCoverage([Path.Combine(project, "Probe.cs")], ["/repo/shared/Linked.cs"]); diff --git a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs index b4c30c32..181d18c7 100644 --- a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs +++ b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs @@ -15,12 +15,13 @@ private static string[] DemoProductionSourceCensus() var evaluated = projects.Select(EvaluatedDemoCompile).ToArray(); RequireProductionProjectCoverage(projects, evaluated.SelectMany(row => row.References)); var outputs = evaluated.SelectMany(row => row.Outputs).Distinct(StringComparer.Ordinal).ToArray(); - var files = ProductionSourceRoots.SelectMany(root => Directory.EnumerateFiles(root, "*", SearchOption.AllDirectories)) - .Where(path => BackendDemoSourceKind(path, outputs) == 1).ToArray(); + var census = ProductionSourceRoots.SelectMany(root => Directory.EnumerateFiles(root, "*", SearchOption.AllDirectories)) + .Where(path => !OmitIgnoredDemoLocalFile(path)).ToArray(); + var files = census.Where(path => BackendDemoSourceKind(path, outputs) == 1).ToArray(); // Evaluation includes explicit/linked Compile items as well as the SDK's default glob. // A compiler input outside the supported census must refuse, never disappear. RequireCompileCoverage(files, evaluated.SelectMany(row => row.Sources)); - foreach (var file in ProductionSourceRoots.SelectMany(root => Directory.EnumerateFiles(root, "*", SearchOption.AllDirectories)) + foreach (var file in census .Where(path => BackendDemoSourceKind(path, outputs) == 2) .Concat([Path.Combine(RepositoryPaths.RepoRoot(), "backend/Directory.Build.props"), Path.Combine(RepositoryPaths.RepoRoot(), "backend/Directory.Packages.props")]) @@ -29,6 +30,40 @@ private static string[] DemoProductionSourceCensus() return files; } + private static bool IsDemoLocalArtifact(string path) => Path.GetFileName(path) is + ".env" or ".env.local" or ".env.development" or ".env.test" or ".env.production" + or ".env.development.local" or ".env.test.local" or ".env.production.local" or ".DS_Store" or "Thumbs.db" + || Path.GetExtension(path) is ".swp" or ".log" or ".user" or ".suo" or ".rsuser"; + + private static bool OmitIgnoredDemoLocalFile(string path) + { + if (!IsDemoLocalArtifact(path)) return false; + using var child = new Process + { + StartInfo = new ProcessStartInfo("git") + { + ArgumentList = { "check-ignore", "--quiet", "--", path }, + WorkingDirectory = RepositoryPaths.RepoRoot(), + RedirectStandardError = true, + } + }; + child.Start(); + var error = child.StandardError.ReadToEndAsync(); + if (!child.WaitForExit(10_000)) + { + child.Kill(entireProcessTree: true); + child.WaitForExit(); + throw new InvalidOperationException("Git ignored-local-file admission deadline."); + } + error.GetAwaiter().GetResult(); + return child.ExitCode switch + { + 0 => true, + 1 => false, + _ => throw new InvalidOperationException("Git ignored-local-file admission failed.") + }; + } + private static int BackendDemoSourceKind(string path, IEnumerable<string> outputs) { path = Path.GetFullPath(path); diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index a0355b10..e230856d 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -6434,6 +6434,14 @@ Work remains on `development`; PR #28 is not merged by this record. The final PR rollup must still pass all seven required jobs, including the real Docker and 27-audit lifecycle proof, before merge. +**Late automatic-review follow-up.** Run 38125035732 passes all seven jobs for +source `4541d63`, including 2,964 backend and 1,537 frontend cases, the real +27-audit proof and cleanup. A later CodeRabbit comment exposed a local-DX gap: +ignored `.env.local` and OS/editor files reached raw filesystem classification. +The follow-up admits only explicitly known machine filenames that Git also +ignores. Ignored source files, unknown formats and compiler coverage retain +fail-closed behavior. Focused reviews and replacement final-head CI are pending. + **Other finding dispositions.** The gzip adapter equality checks wiring; the independent Script observer checks source-window coverage, not a second byte measurement. Existing fast tests already cover report admission, source-byte diff --git a/docs/standards/21-architecture-tests-catalogue.md b/docs/standards/21-architecture-tests-catalogue.md index 3a0f9603..2c03a25b 100644 --- a/docs/standards/21-architecture-tests-catalogue.md +++ b/docs/standards/21-architecture-tests-catalogue.md @@ -675,7 +675,9 @@ otherwise). text/attribute values are included. Frontend runtime imports cannot hide helpers behind test filenames or directories; exact standalone proof/development entries retain their bounded exemptions. - Generated/dependency roots are exact paths. Local module URL suffixes, + Generated/dependency roots are exact paths. Known environment/OS/editor/log + files are omitted only when Git also ignores them; source and unknown formats + retain fail-closed admission. Local module URL suffixes, supported tsconfig aliases, workspace exports, re-exports, import-equals and literal `require.resolve` edges enter the closure. Ambiguous local JS/TS and alias targets are conservatively included; only owned workspace manifests select diff --git a/frontend/apps/web/src/test/demo-genericity-sources.ts b/frontend/apps/web/src/test/demo-genericity-sources.ts index 741e8dd7..de28b62a 100644 --- a/frontend/apps/web/src/test/demo-genericity-sources.ts +++ b/frontend/apps/web/src/test/demo-genericity-sources.ts @@ -117,6 +117,31 @@ export function demoSourceClassification(path: string): 'runtime' | 'other' { return 'runtime'; } +// A narrow machine-file exception, never a blanket exemption for ignored formats. +export function omitIgnoredDemoLocalFile( + path: string, + ignored: (path: string) => boolean, +): boolean { + const name = posix.basename(path); + const environment = new Set([ + '.env', + '.env.local', + '.env.development', + '.env.test', + '.env.production', + '.env.development.local', + '.env.test.local', + '.env.production.local', + ]); + return ( + (environment.has(name) || + name === '.DS_Store' || + name === 'Thumbs.db' || + /\.(?:swp|log|user|suo|rsuser)$/.test(name)) && + ignored(path) + ); +} + export type ExternalModuleResolver = (from: string, specifier: string, anchors: string[]) => string; function testSource(path: string): boolean { diff --git a/frontend/apps/web/src/test/demo-genericity.test.ts b/frontend/apps/web/src/test/demo-genericity.test.ts index 407a7d49..1d3f9b17 100644 --- a/frontend/apps/web/src/test/demo-genericity.test.ts +++ b/frontend/apps/web/src/test/demo-genericity.test.ts @@ -1,5 +1,5 @@ // @vitest-environment node -import { execFileSync } from 'node:child_process'; +import { execFileSync, spawnSync } from 'node:child_process'; import { readdirSync, readFileSync } from 'node:fs'; import { createRequire } from 'node:module'; import { dirname, join, relative, resolve } from 'node:path'; @@ -11,6 +11,7 @@ import { demoIdentityFindings } from './demo-genericity-analysis'; import { demoSourceClassification, omitDemoSourceDirectory, + omitIgnoredDemoLocalFile, productionDemoSources, } from './demo-genericity-sources'; import vocabulary from './fixtures/demo-identities.json'; @@ -37,6 +38,19 @@ function productionSources(): Map<string, string> { for (const entry of readdirSync(directory, { withFileTypes: true })) { const path = join(directory, entry.name); const name = relative(root, path).replaceAll('\\', '/'); + if ( + entry.isFile() && + omitIgnoredDemoLocalFile(name, (candidate) => { + const result = spawnSync('git', ['check-ignore', '--quiet', '--', candidate], { + cwd: root, + stdio: 'ignore', + }); + if (result.status !== 0 && result.status !== 1) + throw new Error('Git ignored-local-file admission failed'); + return result.status === 0; + }) + ) + continue; if (entry.isSymbolicLink() && !omitDemoSourceDirectory(name)) throw new Error(`Unmodeled production symlink: ${name}`); if (entry.isDirectory()) { @@ -261,6 +275,21 @@ describe('P02d-7 exact demo identity boundary', () => { ]) expect(omitDemoSourceDirectory(path)).toBe(false); }); + it('omits only ignored known machine files and retains ignored source and unknown formats', () => { + for (const name of ['.env.local', '.DS_Store', 'Thumbs.db', 'editor.swp', 'runtime.log']) { + const path = `frontend/apps/web/${name}`; + expect(omitIgnoredDemoLocalFile(path, () => true)).toBe(true); + expect(omitIgnoredDemoLocalFile(path, () => false)).toBe(false); + const result = spawnSync('git', ['check-ignore', '--quiet', '--', path], { + cwd: root, + stdio: 'ignore', + }); + expect(result.status).toBe(0); + } + for (const name of ['.env.hidden.ts', '.env.hidden.json', 'hidden.vue', 'hidden.resx']) + expect(omitIgnoredDemoLocalFile(`frontend/apps/web/${name}`, () => true)).toBe(false); + expect(() => demoSourceClassification('frontend/apps/web/hidden.vue')).toThrow('Unclassified'); + }); it('refuses unclassified production roots and formats while retaining declared non-runtime ownership', () => { for (const path of [ 'shared/probe.mjs', From 9343e99d7b11e76dbc36eb829f13c570f678fea2 Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 11:58:00 +0300 Subject: [PATCH 32/35] test(architecture): refuse ignored MSBuild user hooks Do not treat .user files as inert machine artifacts: the SDK can import .csproj.user targets after the evaluation-only source census. Keep those formats refused and plant ignored-file negative controls. Record the second independent review counterexample without changing production behavior or expanding supported build shapes. --- .../DomainGenericityTests.DemoIdentities.cs | 7 ++++++- .../DomainGenericityTests.SourceCensus.cs | 2 +- docs/roadmap/phase-02d-walking-skeleton.md | 6 +++++- .../apps/web/src/test/demo-genericity-sources.ts | 2 +- .../apps/web/src/test/demo-genericity.test.ts | 15 ++++++++++++++- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs index ecd1b440..8d2584fa 100644 --- a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs +++ b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.DemoIdentities.cs @@ -125,8 +125,13 @@ public void Demo_Literal_Fence_Detects_Decoded_Identities_And_Admits_Platform_Da IsDemoLocalArtifact(local).Should().BeTrue(); OmitIgnoredDemoLocalFile(local).Should().BeTrue("the actual Git rules omit known machine files"); } - foreach (var name in new[] { ".env.hidden.cs", ".env.hidden.json", "hidden.resx" }) + foreach (var name in new[] { ".env.hidden.cs", ".env.hidden.json", "hidden.resx", "Probe.csproj.user" }) IsDemoLocalArtifact(Path.Combine(project, name)).Should().BeFalse("ignored source/unknown formats are not machine-file exemptions"); + // MSBuild automatically imports .csproj.user, so ignore rules cannot exempt it. + OmitIgnoredDemoLocalFile(Path.Combine(RepositoryPaths.BackendSrc(), "LearnStack.Api", "Probe.csproj.user")) + .Should().BeFalse(); + Action ignoredBuildHook = () => _ = BackendDemoSourceKind(Path.Combine(project, "Probe.csproj.user"), generated); + ignoredBuildHook.Should().Throw<InvalidOperationException>(); Action unknownFormat = () => _ = BackendDemoSourceKind(Path.Combine(project, "Probe.resx"), generated); unknownFormat.Should().Throw<InvalidOperationException>(); Action linkedInput = () => RequireCompileCoverage([Path.Combine(project, "Probe.cs")], ["/repo/shared/Linked.cs"]); diff --git a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs index 181d18c7..8807cc6d 100644 --- a/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs +++ b/backend/tests/LearnStack.Tests.Architecture/DomainGenericityTests.SourceCensus.cs @@ -33,7 +33,7 @@ private static string[] DemoProductionSourceCensus() private static bool IsDemoLocalArtifact(string path) => Path.GetFileName(path) is ".env" or ".env.local" or ".env.development" or ".env.test" or ".env.production" or ".env.development.local" or ".env.test.local" or ".env.production.local" or ".DS_Store" or "Thumbs.db" - || Path.GetExtension(path) is ".swp" or ".log" or ".user" or ".suo" or ".rsuser"; + || Path.GetExtension(path) is ".swp" or ".log" or ".suo" or ".rsuser"; private static bool OmitIgnoredDemoLocalFile(string path) { diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index e230856d..eaef513d 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -6440,7 +6440,11 @@ source `4541d63`, including 2,964 backend and 1,537 frontend cases, the real ignored `.env.local` and OS/editor files reached raw filesystem classification. The follow-up admits only explicitly known machine filenames that Git also ignores. Ignored source files, unknown formats and compiler coverage retain -fail-closed behavior. Focused reviews and replacement final-head CI are pending. +fail-closed behavior. The first independent round approved `d16d2d7`. The fresh +second round reproduced an automatically imported `.csproj.user` build hook; +`.user` is therefore excluded from the machine-file exemption, with explicit +refusal controls. The same reviewer must verify this fix before closeout. +Replacement final-head CI remains required. **Other finding dispositions.** The gzip adapter equality checks wiring; the independent Script observer checks source-window coverage, not a second byte diff --git a/frontend/apps/web/src/test/demo-genericity-sources.ts b/frontend/apps/web/src/test/demo-genericity-sources.ts index de28b62a..07cb5e82 100644 --- a/frontend/apps/web/src/test/demo-genericity-sources.ts +++ b/frontend/apps/web/src/test/demo-genericity-sources.ts @@ -137,7 +137,7 @@ export function omitIgnoredDemoLocalFile( (environment.has(name) || name === '.DS_Store' || name === 'Thumbs.db' || - /\.(?:swp|log|user|suo|rsuser)$/.test(name)) && + /\.(?:swp|log|suo|rsuser)$/.test(name)) && ignored(path) ); } diff --git a/frontend/apps/web/src/test/demo-genericity.test.ts b/frontend/apps/web/src/test/demo-genericity.test.ts index 1d3f9b17..b1ad1c18 100644 --- a/frontend/apps/web/src/test/demo-genericity.test.ts +++ b/frontend/apps/web/src/test/demo-genericity.test.ts @@ -286,8 +286,21 @@ describe('P02d-7 exact demo identity boundary', () => { }); expect(result.status).toBe(0); } - for (const name of ['.env.hidden.ts', '.env.hidden.json', 'hidden.vue', 'hidden.resx']) + for (const name of [ + '.env.hidden.ts', + '.env.hidden.json', + 'hidden.vue', + 'hidden.resx', + 'Probe.csproj.user', + ]) expect(omitIgnoredDemoLocalFile(`frontend/apps/web/${name}`, () => true)).toBe(false); + // MSBuild automatically imports this ignored format; it is not inert machine data. + expect( + spawnSync('git', ['check-ignore', '--quiet', '--', 'frontend/apps/web/Probe.csproj.user'], { + cwd: root, + stdio: 'ignore', + }).status, + ).toBe(0); expect(() => demoSourceClassification('frontend/apps/web/hidden.vue')).toThrow('Unclassified'); }); it('refuses unclassified production roots and formats while retaining declared non-runtime ownership', () => { From ec86884f95eff93081dbcfeffb6e96f6835c5eb6 Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 11:59:49 +0300 Subject: [PATCH 33/35] docs(roadmap): close ignored-machine-file review follow-up Record both independent reviews, the verified MSBuild counterexample and passing clean and rejection controls. Keep moving-head CI proof with the required PR rollup and preserve earlier dated receipts. --- docs/roadmap/phase-02d-walking-skeleton.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index eaef513d..fcd7a334 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -6442,9 +6442,16 @@ The follow-up admits only explicitly known machine filenames that Git also ignores. Ignored source files, unknown formats and compiler coverage retain fail-closed behavior. The first independent round approved `d16d2d7`. The fresh second round reproduced an automatically imported `.csproj.user` build hook; -`.user` is therefore excluded from the machine-file exemption, with explicit -refusal controls. The same reviewer must verify this fix before closeout. -Replacement final-head CI remains required. +`.user` is therefore excluded from the machine-file exemption in `9343e99`, +with explicit refusal controls. The reviewer independently re-ran the actual +collector: clean ignored files pass and the original build-hook counterexample +refuses. Both review rounds are complete, with no remaining findings. All 19 +frontend and seven backend genericity cases pass; the complete guarded frontend +rerun passes 1,538 cases (1,478 web + 60 SDK), zero failures/skips/todos. +Owned temporary ignored-file controls pass both actual raw collectors and are +removed afterward. Whitespace and the complete PR's link/fragment audit pass. +The final PR rollup below owns replacement final-head CI; all seven jobs remain +required before merge. **Other finding dispositions.** The gzip adapter equality checks wiring; the independent Script observer checks source-window coverage, not a second byte From 32a79515b1b5edf1adaa00b387484a94cf6038d7 Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 12:06:58 +0300 Subject: [PATCH 34/35] test(cache): coordinate the noncooperative factory timeout proof Hold the original factory until its own cache timeout is observed, then release it and verify replacement and late-result behavior. This removes the race between two elapsed timers on loaded CI workers without changing production code, budgets or the asserted contract. Distinguish the test harness timeout and always release the factory. --- .../Caching/InMemoryCacheServiceTests.cs | 41 ++++++++++++------- docs/roadmap/phase-02d-walking-skeleton.md | 11 +++++ 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/backend/tests/LearnStack.Tests.Unit/Infrastructure/Caching/InMemoryCacheServiceTests.cs b/backend/tests/LearnStack.Tests.Unit/Infrastructure/Caching/InMemoryCacheServiceTests.cs index 74b7c67d..03737ae8 100644 --- a/backend/tests/LearnStack.Tests.Unit/Infrastructure/Caching/InMemoryCacheServiceTests.cs +++ b/backend/tests/LearnStack.Tests.Unit/Infrastructure/Caching/InMemoryCacheServiceTests.cs @@ -1105,26 +1105,37 @@ public async Task A_Factory_That_Ignores_Its_Token_Is_Still_Bounded() var cache = new InMemoryCacheService( new FixedClock(Origin), MeterFactory, factoryTimeout: TimeSpan.FromMilliseconds(80)); var runs = 0; + var release = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously); - var overrunning = cache.GetOrSetAsync<string>(Key(), async _ => + var overrunning = cache.GetOrSetAsync(Key(), _ => { Interlocked.Increment(ref runs); - await Task.Delay(TimeSpan.FromMilliseconds(600), CancellationToken.None); - return "late"; + return release.Task; }); - await ((Func<Task>)(() => overrunning)).Should().ThrowAsync<TimeoutException>(); - - // The replacement waits for the overrunning factory rather than starting - // a second one beside it, and is not answered with the first caller's - // timeout for ever. - var replacement = await cache.GetOrSetAsync(Key(), _ => Task.FromResult("fresh")) - .WaitAsync(TestTimeout); - - replacement.Should().Be("fresh"); - runs.Should().Be(1, "no second factory ran alongside the first"); - (await cache.GetAsync<string>(Key())).Should().Be("fresh", - "a result that arrived after its deadline is not cached"); + try + { + // Only the cache's deadline can finish first; two elapsed timers can + // run in reverse order on a busy worker. The outer bound must never + // masquerade as the cache's own timeout if its deadline regresses. + var refusal = await ((Func<Task>)(() => overrunning.WaitAsync(TestTimeout))) + .Should().ThrowAsync<TimeoutException>(); + refusal.WithMessage("The cache factory for '*' did not complete within *s."); + + // A replacement waits for the original factory's real termination. + var replacement = cache.GetOrSetAsync(Key(), _ => Task.FromResult("fresh")); + replacement.IsCompleted.Should().BeFalse("the original factory has not been released"); + release.SetResult("late"); + + (await replacement.WaitAsync(TestTimeout)).Should().Be("fresh"); + runs.Should().Be(1, "no second factory ran alongside the first"); + (await cache.GetAsync<string>(Key())).Should().Be("fresh", + "a result that arrived after its deadline is not cached"); + } + finally + { + release.TrySetResult("late"); + } } [Theory] diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index fcd7a334..09795a8a 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -6453,6 +6453,17 @@ removed afterward. Whitespace and the complete PR's link/fragment audit pass. The final PR rollup below owns replacement final-head CI; all seven jobs remain required before merge. +**CI stability follow-up.** Run 38126790757 reports one unit-test failure in +`A_Factory_That_Ignores_Its_Token_Is_Still_Bounded`; all 203 architecture cases, +including the new admission controls, pass. This pre-existing test races an +80 ms cache deadline against a 600 ms factory delay. It now holds the factory +behind an explicit release signal until the cache's own timeout is observed, +checks that a replacement waits and retains the late-result/cache assertions. +The bounded test wait cannot masquerade as the cache timeout: its message must +identify the cache's own deadline. The release is guaranteed in `finally`. +Production cache behavior and its budget are unchanged. Focused verification +and both independent review rounds remain required before replacement CI. + **Other finding dispositions.** The gzip adapter equality checks wiring; the independent Script observer checks source-window coverage, not a second byte measurement. Existing fast tests already cover report admission, source-byte From 8d9d2195cfadf1d83807613ea22d792b7ce329f4 Mon Sep 17 00:00:00 2001 From: Cemil ILIK <cemililik@outlook.com> Date: Sun, 11 Oct 2026 12:09:50 +0300 Subject: [PATCH 35/35] docs(roadmap): record cache timeout proof reviews Close both independent review rounds and local unit verification for the CI-exposed timing race. Preserve the failed-job disclosure and require replacement final-head CI before merge. --- docs/roadmap/phase-02d-walking-skeleton.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/roadmap/phase-02d-walking-skeleton.md b/docs/roadmap/phase-02d-walking-skeleton.md index 09795a8a..76887cdd 100644 --- a/docs/roadmap/phase-02d-walking-skeleton.md +++ b/docs/roadmap/phase-02d-walking-skeleton.md @@ -6461,8 +6461,12 @@ behind an explicit release signal until the cache's own timeout is observed, checks that a replacement waits and retains the late-result/cache assertions. The bounded test wait cannot masquerade as the cache timeout: its message must identify the cache's own deadline. The release is guaranteed in `finally`. -Production cache behavior and its budget are unchanged. Focused verification -and both independent review rounds remain required before replacement CI. +Production cache behavior and its budget are unchanged. `32a7951` delivers +this test-only fix. Fresh GPT-6.1-sol (high) and GPT-6-astra (high) reviews approve +in two separate rounds with no findings; the second reviewer independently +passes the focused Release case. All 51 cache cases and all 1,705 unit cases +pass with zero skips. Replacement final-head CI remains required by the rollup +below; the initial failed job is not counted as passing evidence. **Other finding dispositions.** The gzip adapter equality checks wiring; the independent Script observer checks source-window coverage, not a second byte