Skip to content

feat(schema): resolve symlinked schema directories - #1298

Closed
benjymoses wants to merge 2 commits into
Fission-AI:mainfrom
benjymoses:feat/symlinked-schema-dirs
Closed

feat(schema): resolve symlinked schema directories#1298
benjymoses wants to merge 2 commits into
Fission-AI:mainfrom
benjymoses:feat/symlinked-schema-dirs

Conversation

@benjymoses

@benjymoses benjymoses commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

P0 of the performance audit. Vercel Speed Insights showed perf 85 with FCP 2.76s / LCP 3.42s / TTFB 0.85s all amber. Root cause: every public page used the cookie-bound Supabase client, forcing per-request dynamic SSR with no caching — and the existing revalidateTag calls invalidated nothing because no cached read attached tags.

This branch decouples public reads from the auth client and adopts Cache Components (cacheComponents: true) for the public surface.

What changed

  • Cookie-less public client (src/lib/auth/public.ts) for anonymous published-content reads — no cookies(), so routes are no longer forced dynamic.
  • use cache + cacheTag + cacheLife on listPublishedPosts / getPublishedPost / getAllTags / getAllCategories (tagged posts-list + post-${slug}) and public getRef. The existing revalidateTag calls in the post/ref Server Actions now actually invalidate.
  • React cache() wraps the per-slug post read so generateMetadata + body share one query per request.
  • generateStaticParams + ISR on /blog/[slug] (build-time pre-warm, ISR fallback for new slugs — not frozen).
  • Partial Prerendering on the home page — static hero paints immediately, Recent Writing streams behind <Suspense>.
  • Shared Skeleton primitive (src/components/ui/skeleton.tsx) replacing ~9 duplicated inline skeletons.
  • Error strategy: public use cache reads throw DatabaseError — verified against Next docs that throws are not written to cache (no poisoning) and the DbUnavailable fallbacks stay live.
  • Suspense fallbacks reserve header/footer/admin-nav heights to prevent layout shift.
  • ADR 0003 documents the decision; full spec under openspec/changes/public-read-caching-perf/.

Route shape (build output)

  • / ○ static + ISR (15m/1h), Recent Writing streamed
  • /blog/[slug] ◐ PPR + ISR
  • all /admin/* ◐ PPR behind auth guard (unchanged src/proxy.ts)

Verification

  • pnpm build passes, warning-clean (32 pages)
  • ✅ 167/167 tests green
  • ⏳ Post-deploy on this preview: owner-edit → public-refresh round-trip (task 8.2), re-check Speed Insights for perf ≥90 (task 8.4)

See ADR docs/adr/0003-cache-components-public-content-delivery.md.

Summary by CodeRabbit

  • Bug Fixes
    • Schema validation now correctly recognizes schema directories even when they are symlinks.
    • Schema discovery now includes symlinked directories and ignores broken or file-based symlinks.
    • User-provided schemas discovered through symlinks now appear with the expected source and details.

Schema discovery filtered directory entries with `Dirent.isDirectory()`,
which reports the raw entry type and returns false for symlinks — even
those pointing at a real directory. As a result, symlinked schema dirs in
the user/project/package schema locations were silently skipped.

Add a shared `isSchemaDir()` helper that accepts real directories and
dereferences symlinks (via statSync) to admit symlinked directories while
still rejecting symlinks-to-files and broken links. Use it at all six
discovery sites in resolver.ts and in `schema validate` in schema.ts.
Add unit tests for isSchemaDir (real dir, symlink-to-dir, symlink-to-file,
broken symlink, regular file) plus integration tests confirming listSchemas
and listSchemasWithInfo pick up a symlinked user schema dir while ignoring
symlinks whose target is a file.
@benjymoses
benjymoses requested a review from TabishB as a code owner July 3, 2026 16:46
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b2762a60-15ae-4c77-a091-28b112630a39

📥 Commits

Reviewing files that changed from the base of the PR and between 65a7233 and 20458d2.

📒 Files selected for processing (3)
  • src/commands/schema.ts
  • src/core/artifact-graph/resolver.ts
  • test/core/artifact-graph/resolver.test.ts

📝 Walkthrough

Walkthrough

Adds an isSchemaDir helper in resolver.ts that recognizes symlinked directories as valid schema directories (excluding broken symlinks), applies it in listSchemas, listSchemasWithInfo, and the schema validate command, and adds corresponding test coverage.

Changes

Symlink-aware schema directory detection

Layer / File(s) Summary
isSchemaDir helper
src/core/artifact-graph/resolver.ts
Adds exported isSchemaDir(parentDir, entry) that treats real directories and directory-targeting symlinks as schema directories, returning false for broken symlinks.
Schema discovery wiring
src/core/artifact-graph/resolver.ts
listSchemas and listSchemasWithInfo now use isSchemaDir instead of entry.isDirectory() across package built-in, user override, and project-local schema roots.
Schema validate command update
src/commands/schema.ts
Imports isSchemaDir and uses it to filter directory entries when validating all project schemas.
Test coverage
test/core/artifact-graph/resolver.test.ts
Adds tests for isSchemaDir across real directories, directory/file symlinks, and broken symlinks, plus listSchemas/listSchemasWithInfo assertions for symlinked user schemas.

Estimated code review effort: 2 (Simple) | ~12 minutes

Possibly related PRs

Suggested reviewers: TabishB

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Warning

⚠️ This pull request shows signs of AI-generated slop (description_diff_mismatch). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

@benjymoses benjymoses closed this Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant