Repository navigation
Epic #66: Cold-paint perf + cache hygiene for dataset detail - #70
Merged
Merged
Conversation
Comment-analyzer found the rationale block named the wrong cached keys: poisoned entries are responses from /api/dataset/<id>/readme and /api/dataset/<id>/tree (the partial endpoints), not the SSR /dataset/<id> page. Also add "(fixes #53)" next to "PR #54" so a future GitHub search lands on the original bug report.
Phase 1 (#65): bump edge-cache namespace to v2
Extends SummaryReadme with the schema 1.1 fields nemar-cli#616 will emit (content, content_bytes, sha256, truncated; all optional) and inserts a Step 0.5 in /api/dataset/<id>/readme that returns the inlined markdown directly. Eliminates the synchronous GitHub raw fetch on the cold-paint path once the upstream backfill completes. Back-compat: schema 1.0 docs miss the new branch and fall through to the unchanged Step 1-4 resolver. Closes #63 Part of epic #66
Four findings from the parallel sonnet review pass: - pr-test-analyzer: whitespace-only inline content would slip past the length-check, render to empty HTML, and get cached with PUBLISHED_CACHE for the full SWR window. Switch the guard to trim().length === 0; add tests for the whitespace case and for preserving leading whitespace inside otherwise-valid markdown. - type-design-analyzer: declared `content?: string` but the docstring said the generator emits `content: null` on truncation. Align the type to `string | null`. Add a test for the explicit-null case. - comment-analyzer: clarify "leaves content null" in the interface comment now that the type matches; note that nemar-cli#616 is still open so the 256 KB cap is proposed, not enforced. - comment-analyzer: soften the Step 0.5 "abstraction surface tight" rationale and add a forward pointer for the case where a future ReadmeSourceKind needs to distinguish inline vs presigned at render time. 378/378 tests pass (was 375 before this commit).
…rom-summary Phase 2 (#63): consume summary.readme.content from schema 1.1
Splits /api/dataset/<id>/tree?v=<v> into two response modes via the new optional subject= parameter. Without subject= the endpoint emits a skeleton: top-level non-subject entries inline, each sub-XYZ as a collapsed <details data-subject="..."> with a lazy slot. With subject= it returns just that subject's inner subtree. The dataset detail page picks up subtree expansions on the first <details> toggle and drops the fragment into the matching slot. Targets on005505 specifically: 5,409 paths / 136 subjects used to ship 3.3 MB of HTML in one blob and block the file panel for seconds. Skeleton stays under 50 KB; subtree fetches are scoped to one subject at a time and edge-cached per (id, version, subject) for free via the existing URL-keyed cache. Adds isSubjectDir(name) predicate (used both for skeleton row identification and as the param-validation gate on the endpoint), renderBidsSubtree(node, basePath) for the subtree response, and 8 tests covering subject-vs-non-subject rendering plus the traversal-guard cases on the predicate. Closes #64 Part of epic #66
Five sonnet reviewers ran in parallel. Critical and important fixes:
- silent-failure-hunter + code-reviewer: 503 response on the subtree
branch had no Cache-Control. Add FALLBACK_CACHE (no-store) so a
transient upstream failure doesn't pin at the edge, matching the
skeleton's no-manifest treatment.
- silent-failure-hunter + comment-analyzer: the 404 (subject not
found) inline comment promised a "short cache" the code never
set. Add a NOT_FOUND_SUBJECT_CACHE constant (60s s-maxage) so
the wire behavior matches the documented intent.
- code-reviewer: 400 responses (missing v=, invalid subject=)
carried no Cache-Control. Add no-store on both paths so an
intermediate proxy can't pin the error.
- code-reviewer: subject regex was alphanumeric-only; widen to
/^sub-[A-Za-z0-9-]+$/ so BIDS 2.0 + real OpenNeuro datasets
like sub-NDAR-AC904DMU don't silently regress to inline render.
Update isSubjectDir tests; embedded slash still rejected.
- code-reviewer: .tree__error class had no CSS rule. Add a scoped
rule in BidsTree.astro so the subtree-fetch-failure paragraph
reads as a retry prompt, not body text.
- type-design-analyzer: replace inline import("...").TreeNode
with a top-of-file import type so the dependency is legible.
- comment-analyzer: tighten the renderBidsSubtree docstring with
the concrete renderDirChildren(node, basePath, 1) call site,
and add a "keep in sync" warning to the subject-param
validation comment.
- pr-test-analyzer: add four endpoint-validation tests (no v=,
malformed subject, empty subject, underscore label) and two
rendering edge cases (subjects-only tree, nested sub-* doesn't
re-collapse).
393/393 tests (was 386).
Deferred to a follow-up issue: small-subject UX regression (2-3
subjects now require an extra click). Out of #64's stated scope
(100+ subject case).
CF Pages picks up *.test.ts under src/pages/** as a route entry and breaks the build (same class as PR #62 / commit 3cbc89f for the proxy test). Relocate to src/lib/tree-endpoint.test.ts; the file still imports GET from the route source, so the wire-contract coverage is unchanged. 393/393 tests pass; local astro build completes clean.
…s-tree Phase 3 (#64): progressive BIDS tree (skeleton + lazy per-subject)
Cross-phase review surfaced an asymmetry introduced by Phase 3: tree.ts's "Missing id or v=" 400 was hardened with Cache-Control: no-store, but the parallel branch in readme.ts was missed. Add the matching header so both partial endpoints behave consistently at the cache boundary. Pre-existing 404 inconsistencies on the landing not_found path are out of scope (predate this epic).
Deploying nemar-website with
|
| Latest commit: |
a508872
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://216e5e55.nemar-website.pages.dev |
| Branch Preview URL: | https://feature-issue-66-epic-cold-p.nemar-website.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes three independent cold-paint regressions on
/dataset/<id>that compounded into a multi-second blocking experience for users on low-bandwidth connections.Three phases shipped via separate sub-PRs and review passes; this PR bundles them onto
main.nemar-edge-v1→nemar-edge-v2insrc/middleware.ts. Orphans the SWR-poisoned partial fleet that PR fix(api): no-store on tree/readme empty-fallback branches #54 stopped future writes to but couldn't reach (entries written before fix(api): no-store on tree/readme empty-fallback branches #54 lived for up to 24 h per PoP). on005505 was the most visible casualty.summary.readme.content(nemar-cli#616 schema 1.1) into/api/dataset/<id>/readmeas a new Step 0.5 fast path. Eliminates the synchronousraw.githubusercontent.comRTT on every cold render. Back-compat with schema 1.0 (no field present → falls through to the unchanged 4-step resolver). Lights up automatically when the upstream backfill completes; no coupled deploy./api/dataset/<id>/treeinto a skeleton response (top-level non-subject entries + collapsedsub-XYZrows) and a per-subject lazy response (?subject=sub-XYZ). The page already deferred the tree partial viadata-tree-defer; the new client handler picks up the second-stage fetch on first<details>toggle. on005505 specifically: 5,409 paths / 136 subjects went from a 3.3 MB monolithic HTML blob to < 50 KB skeleton + scoped per-subject fetches.readme.ts's "Missing id or v=" 400 now carriesCache-Control: no-storeto match the equivalent branch intree.ts.Closes #66
Closes #65
Closes #63
Closes #64
CLI counterpart
The nemar-cli side (epic nemar-cli#618) ships the schema 1.1 generator (#616) + backfill, plus a separate page-bundle endpoint (#617) that's intentionally out of scope here. The page-bundle consumer will be filed as a follow-up website issue once nemar-cli#617 lands — it collapses the website's cold-load waterfall to one RTT and is the logical next epic.
Phases completed
Test plan
bun run typecheck— 0 errors across all three phasesbun run lint— biome cleanbun run test— full suite green; cumulative diff adds 23 new tests (+8 indata-api.test.ts, +11 in the newrender-tree.test.ts, +4 in the newtree-endpoint.test.ts)bun run build— astro build clean, no Workers-runtime warnings introducedreview(#NN)commits before mergehttps://ww2.nemar.org/dataset/on005505no longer renders the poisoned fallback HTML; cold-isolate response on/api/dataset/on005505/readmeand/treereturns full content;/treeskeleton stays under 50 KBOut of scope (follow-up issues to file post-merge)
landingOut.kind === "not_found"404s on both readme and tree endpoints have never set explicit cache headers. Cross-phase review confirmed this predates this epic; not regressed here. New website issue if we want to harden it.