A private project should hide everything under it

Pages of a private project were still showing in links and lists because visibility was only checked on the page itself. Why the project's status should be the one control, derived in queries, and the plan to apply it everywhere.

On /projects/statement-manager the previous button led to GitHub README, a private project. Following that up showed the cause is wider than one button: a page was checked only against its own status, never against its project's. It's now fixed in goatboat and in the site; this page records the cause, the decision and what was built.

What went wrong

Every page has a status (draft, published or private), and so does every project. The public queries decided what to show from the page's status alone. A project's home page is a row in content with its own status, separate from projects.status, and nothing kept the two in step. GitHub README was private as a project and published as a page, so the page counted as live.

A read-only check of the database found 9 published pages belonging to 4 private projects (CPU Ladder, GitHub README, Resume, Skim Milk Hybrid): 4 project home pages and 5 notes pages.

Where it leaked

  • Previous, next and related links. They look at siblings and pages in common, and checked only each page's own status. This is where it showed.
  • The site-wide notes list. listAllNotes filtered on the page's status only.
  • The feeds and tags. The content feed and its count, the home feed and the tag list did the same.
  • Direct URLs and the sitemap. getContentByPath returns a page in any status, because the owner needs that, and the site then checked only the page's own status. The project's status wasn't in the payload, so a notes page of a private project opened for anyone with the link, and the sitemap listed it.
  • The artifacts host. The public artifact endpoint checked only the artifact's own status.

The project's own home page (/projects/<slug>) and notes home already return a 404, because they check the project. That is why the problem hid for so long.

Decision

The project's status is the one control, and a page's visibility is derived from it. A page is public only if it is published, not missing from the code, and its project (if it has one) is published. Marking a project private hides its home page, its notes and everything under it, and nothing has to be updated when the status is flipped. A project home row's own status stops mattering; the project governs it.

Not chosen, and why:

  • A stored "effective visibility" column. It would be a third copy of something that already has two, and SQLite generated columns can't read another table, so triggers or extra code in the write ops would have to keep it current. Drift is the problem we are trying to remove.
  • Setting every page private when its project goes private. It loses each page's own status, so publishing the project again wouldn't bring them back as they were.
  • Fixing the data only. Setting the 5 notes pages to private fixes today's rows, and the next note added to a private project leaks again.

What was built

In goatboat

  • One shared condition. inPublicProject in src/db/queries.ts: the page has no project, or its project is published. It sits next to isLive.
  • Applied to every list that spans projects. Previous and next, related, the content feed and its count, the home feed, the tag list and listAllNotes. The feed applies it only when asked for published content, since looking at drafts is the owner's view.
  • The project's status travels with the page. A page's project now carries its status, and children and tree nodes carry projectStatus, so the site can make the same decision for direct URLs, child lists and the sitemap.
  • The public artifact endpoint also requires the artifact's project to be published.
  • A guard test, tests/private-projects.test.ts: a private project with a post and a note, and a published one for comparison. It checks the feed, its count, the home feed, the tags and the notes list, and that the status comes through on a page, a child and a tree node. A new query that skips the rule fails it.
  • Fixtures. Projects default to draft, so two existing tests that create a project and expect its pages to show now create it as published.

In the site

  • isVisible checks the project too. A published page of a project that isn't published returns a 404, and so do its children and tree nodes. The sitemap leaves them out.
  • Local dev still shows everything. The site's own check still lets drafts and private pages through in development, so they can be previewed. Lists that come from goatboat are filtered in every environment.
  • Deploy order. Deploy goatboat first. If the site goes out first it won't see the project's status yet, and treats a page with no project status as visible, which is how it behaved before.

A deliberate gap

getNotesNav is left unfiltered. It returns the pages of one named project, and the site decides whether that project is visible before it uses the result. Filtering it too would also empty a private project's notes sidebar while previewing it in local dev. If anything ever lists notes navs across projects for the public, it needs the rule.

If it keeps leaking

The strongest guard is a database view, public_content, that holds the rule, with all public code reading only from it so a query can't skip it. It costs a migration and Drizzle view setup, so it waits until a leak shows the shared helper and the guard test aren't enough.