Skip to content

chore: gitsheets 2.7 — retire the stale-sheet workarounds - #200

Merged
themightychris merged 6 commits into
developfrom
chore/gitsheets-2.7
Oct 14, 2026
Merged

themightychris merged 6 commits into
developfrom
chore/gitsheets-2.7

Conversation

@themightychris

Copy link
Copy Markdown
Member

Implements plans/gitsheets-freshness.md (the second half of #150). Stacked on #199 so tests run against production's sheet configs.

Bump: gitsheets ^2.2.0 → ^2.7.0, with core-napi 0.1 → 0.5. As of 2.7, records are read in the native core instead of one git process per record, which helps boot and hot reload.

Bugs fixed:

  • Webhook-vs-write race. No write path took dataRepoLock, and the rebuild ran after the lock was released, so a write landing mid-reload could be overwritten by the swap. Now the ref move, refresh, rebuild and swap all run inside repo.withLock (the mutex transact holds). The fetch runs outside the lock so a slow network never blocks writes.
  • Stale boot after a fast-forward. The store opened its sheets before boot reconcile moved the branch, so a pod could boot serving the old tree. Reconcile now refreshes the store whenever it moves the branch. A new test fails without the fix.
  • Hot reload didn't reload revocations. Fixed; there's a test.
  • Pushes split between two places. Reconcile pushed outside the push daemon. Pushes now go through the daemon (notifyCommit).
  • Webhook could reconcile any branch. A branch other than CFP_DATA_BRANCH now gets a 400.
  • Empty attachments returned 404. Attachments are now served through sheet.getAttachment, with the blob hash as ETag and 304 on revalidation.

Removed: data-repo-lock.ts, Store.swapPublic, stripNullish/asValidator (gitsheets drops null keys itself and takes the Zod schemas without a cast; the map is satisfies ValidatorMap), sheet-indices.ts (25 indexes nothing queried), and the separate writeBlob step.

Spec: storage.md gets a read-freshness section in place of the caching limitation, plus the write-locked hot reload, the served-branch-only webhook, daemon-only pushes and attachment ETags.

Validation: type-check, lint and the full suite pass (497 API tests), including new tests for the race, the boot fast-forward, revocation reload, branch rejection, the push hand-off and ETag/304. Still to do: a sandbox boot and a hot-reload round trip.

🤖 Generated with Claude Code

themightychris and others added 6 commits October 13, 2026 22:26
npm install gitsheets@^2.7.0 -w apps/api

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gitsheets 2.3+ auto-refreshes standing sheets after a transact and
exposes refresh() and withLock(). Specify reads as fresh after our own
writes and after reconcile's refresh; hot reload running its ref move,
rebuild and swap under the transact mutex; a served-branch-only webhook;
reconcile pushes going through the push daemon; and ETag/304 on
attachments. Retires the caching-limitation section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No write path ever took dataRepoLock, so the hot-reload webhook could
race a transact, and the rebuild ran after the lock was released, so a
write landing mid-rebuild could be overwritten by the swap. Reconcile
and the rebuild now run in one repo.withLock (the transact mutex), with
the fetch outside it.

Also: refresh the public store whenever reconcile moves the branch,
which fixes boot serving the pre-fast-forward tree; reload revocations
on hot reload; hand reconcile's pushes to the push daemon; reject a
webhook branch other than CFP_DATA_BRANCH. Deletes data-repo-lock and
Store.swapPublic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replaces the raw git cat-file spawn (a workaround for stale sheet
snapshots) with sheet.getAttachment. The blob hash is the ETag, so a
revalidation is a 304 without reading the blob; an empty blob is now a
200 instead of a 404.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- stripNullish/asValidator: gitsheets drops null keys itself and takes
  Zod schemas as Standard Schema with no cast.
- sheet-indices: 25 defineIndex definitions nothing queried; under
  auto-refresh they'd be rebuilt after every write.
- writeBlob before setAttachments: attachments accept Buffers.
- account-claim test reads slug-history through the sheet, now fresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from fix/slug-history-config to develop October 14, 2026 02:40
@themightychris
themightychris merged commit 159a259 into develop Oct 14, 2026
1 of 2 checks passed
@themightychris
themightychris deleted the chore/gitsheets-2.7 branch October 14, 2026 02:40
@themightychris themightychris mentioned this pull request Oct 14, 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