rvlib-shipkit 2.26.0 → 2.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/package.json +1 -1
- package/src/agent-time/diet.ts +77 -0
- package/src/agent-time/family.ts +72 -0
- package/src/agent-time/hooks.ts +16 -7
- package/src/agent-time/limits.ts +44 -0
- package/src/agent-time/live.ts +12 -8
- package/src/agent-time/mask.ts +96 -18
- package/src/agent-time/refused.ts +45 -0
- package/src/agent-time/registry.ts +289 -0
- package/src/agent-time/render.ts +122 -21
- package/src/agent-time/report-cache.ts +57 -0
- package/src/agent-time/report.ts +314 -40
- package/src/agent-time/shape.ts +50 -3
- package/src/agent-time/store.ts +322 -101
- package/src/agent-time/timeline.ts +140 -21
- package/src/agent-time/turns.ts +18 -8
- package/src/annex/born.ts +2 -2
- package/src/annex/offload.ts +29 -17
- package/src/annex/tidy.ts +70 -10
- package/src/asks/ask-after.ts +44 -0
- package/src/asks/ask-bar-fold.ts +57 -0
- package/src/asks/ask-migrate.ts +280 -0
- package/src/asks/ask-steps-fold.ts +166 -0
- package/src/asks/ask-store.ts +586 -0
- package/src/assets/kit-config.ts +7 -3
- package/src/assets/kits/identity-kit.ts +361 -14
- package/src/assets/kits/poster-thumbnail.ts +282 -0
- package/src/check.ts +3 -1
- package/src/checks/SK003-claude-md-shape.check.ts +92 -25
- package/src/checks/SK004-gitignore-policy.check.ts +20 -9
- package/src/checks/SK013-one-way-in-policy.check.ts +18 -3
- package/src/checks/SK026-asks-autoclose.check.ts +9 -23
- package/src/checks/SK028-readme.check.ts +7 -66
- package/src/checks/SK030-cache-audit.check.ts +6 -1
- package/src/checks/SK031-trace-audit.check.ts +2 -0
- package/src/checks/SK033-global-contribution.check.ts +3 -1
- package/src/checks/SK035-public-clean.check.ts +2 -2
- package/src/checks/SK038-speaks-as.check.ts +3 -3
- package/src/checks/SK042-post-kinds.check.ts +26 -24
- package/src/checks/SK043-scratch-on-the-mac.check.ts +59 -4
- package/src/checks/SK047-login-in-description.check.ts +36 -0
- package/src/checks/SK048-one-local-file.check.ts +36 -0
- package/src/checks/SK049-thread-answers-hook.check.ts +81 -0
- package/src/checks/SK050-retired-commands.check.ts +127 -0
- package/src/cli/cmd_Asks.ts +244 -27
- package/src/cli/cmd_Backup.ts +153 -10
- package/src/cli/cmd_Calls.ts +1 -0
- package/src/cli/cmd_Capacity.ts +2 -2
- package/src/cli/cmd_Commands.ts +140 -34
- package/src/cli/cmd_Contracts.ts +1 -0
- package/src/cli/cmd_CrossRepoActivity.ts +5 -4
- package/src/cli/cmd_Db.ts +253 -0
- package/src/cli/cmd_History.ts +212 -0
- package/src/cli/cmd_Home.ts +31 -3
- package/src/cli/cmd_Hq.ts +516 -0
- package/src/cli/cmd_Keys.ts +1 -0
- package/src/cli/cmd_Lanes.ts +15 -4
- package/src/cli/cmd_Machines.ts +36 -0
- package/src/cli/cmd_Media.ts +38 -6
- package/src/cli/cmd_Messages.ts +152 -1
- package/src/cli/cmd_Needs.ts +1 -0
- package/src/cli/cmd_Reflect.ts +23 -2
- package/src/cli/cmd_Review.ts +1357 -223
- package/src/cli/cmd_Secret.ts +295 -24
- package/src/cli/cmd_Social.ts +113 -28
- package/src/cli/cmd_SocialDrafts.ts +235 -0
- package/src/cli/cmd_Sound.ts +22 -1
- package/src/cli/cmd_Space.ts +324 -0
- package/src/cli/cmd_Start.ts +3 -2
- package/src/cli/cmd_ThreadHolds.ts +34 -0
- package/src/cli/cmd_ThreadKinds.ts +146 -0
- package/src/cli/cmd_ThreadReflect.ts +83 -0
- package/src/cli/cmd_ThreadSyncNeeds.ts +62 -0
- package/src/cli/cmd_Time.ts +76 -5
- package/src/cli/cmd_Tmp.ts +28 -4
- package/src/cli/cmd_Trailer.ts +14 -10
- package/src/cli/cmd_Urls.ts +56 -0
- package/src/cli/cmd_Vault.ts +583 -0
- package/src/cli/cmd_When.ts +1 -0
- package/src/cli/family-help.ts +5 -3
- package/src/cli/family-pages.ts +1 -1
- package/src/cli/kit/builtins.ts +1 -0
- package/src/cli/kit/verb.ts +6 -2
- package/src/cli/registry.ts +44 -4
- package/src/cli.ts +5 -2
- package/src/collections/actions.ts +42 -41
- package/src/collections/collection-types.ts +30 -4
- package/src/collections/md-body.ts +5 -3
- package/src/collections/pings.ts +13 -6
- package/src/collections/providers.ts +147 -61
- package/src/collections/reflections.ts +9 -4
- package/src/collections/review.ts +4 -4
- package/src/contracts/contract-manifests.ts +6 -5
- package/src/contracts/contract-types.ts +6 -4
- package/src/contracts/contracts-engine.ts +11 -0
- package/src/contracts/manifests/chrome-web-store.contract.ts +31 -0
- package/src/core/budget.ts +12 -17
- package/src/core/capacity.ts +27 -18
- package/src/core/check-runner.ts +7 -4
- package/src/core/discover-checks.ts +18 -3
- package/src/core/git.ts +31 -0
- package/src/core/house-layout.ts +17 -0
- package/src/core/layout.ts +13 -5
- package/src/core/locked-write.ts +4 -1
- package/src/core/machine-busy.ts +127 -0
- package/src/core/machine-commit.ts +6 -1
- package/src/core/machine-db.ts +370 -20
- package/src/core/machine-layout.ts +137 -0
- package/src/core/machine-read.ts +81 -0
- package/src/core/migrate-layout.ts +9 -11
- package/src/core/one-way-in-policy.ts +64 -7
- package/src/core/polling-policy.ts +27 -0
- package/src/core/retention.ts +16 -2
- package/src/core/scope.ts +107 -14
- package/src/core/slots.ts +5 -4
- package/src/drill/clean.ts +25 -1
- package/src/drill/run.ts +1 -1
- package/src/drill/seal.ts +27 -4
- package/src/home/activity-shape.ts +2 -0
- package/src/home/activity.ts +59 -3
- package/src/home/app-sign.ts +15 -4
- package/src/home/daemon-jobs.ts +161 -7
- package/src/home/database-projects.ts +111 -0
- package/src/home/database-words.ts +203 -0
- package/src/home/databases.ts +460 -0
- package/src/home/global-units.ts +6 -0
- package/src/home/gui-app/ShipkitGui.swift +122 -1
- package/src/home/gui-app.ts +6 -3
- package/src/home/home-move.ts +514 -0
- package/src/home/home-paths.ts +18 -6
- package/src/home/home-routes.ts +76 -0
- package/src/home/inbox-shape.ts +234 -91
- package/src/home/inbox.ts +26 -71
- package/src/home/machine-fold.ts +815 -0
- package/src/home/machine-host.ts +38 -5
- package/src/home/machine-repair.ts +503 -0
- package/src/home/machine-stores.ts +66 -15
- package/src/home/machine-temp.ts +547 -86
- package/src/home/other-macs.ts +2 -2
- package/src/home/resume.ts +79 -0
- package/src/home/run-daemon.ts +25 -4
- package/src/home/run-pm.ts +18 -5
- package/src/home/serve-daemon.ts +18 -3
- package/src/home/serve-web.ts +179 -10
- package/src/home/space-job.ts +115 -0
- package/src/home/space-page.ts +257 -0
- package/src/home/space-route.ts +167 -0
- package/src/home/space-words.ts +103 -0
- package/src/home/time-page-shape.ts +202 -0
- package/src/home/time-page.ts +64 -0
- package/src/home/vault-page.ts +516 -0
- package/src/home/vault-words.ts +132 -0
- package/src/hooks/leak-guard.ts +40 -13
- package/src/hooks/one-way-in-guard.ts +41 -6
- package/src/hq/cards.ts +581 -0
- package/src/hq/door-route.ts +43 -0
- package/src/hq/door.ts +163 -0
- package/src/hq/files-send.ts +347 -0
- package/src/hq/forgotten-log.ts +35 -0
- package/src/hq/history-check.ts +255 -0
- package/src/hq/history-place.ts +146 -0
- package/src/hq/history-send.ts +487 -0
- package/src/hq/hq-db.ts +102 -0
- package/src/hq/hq-local.ts +502 -0
- package/src/hq/hq-routes.ts +204 -0
- package/src/hq/hq-store.ts +603 -0
- package/src/hq/kinds/ask.ts +147 -0
- package/src/hq/kinds/card-gone.ts +83 -0
- package/src/hq/kinds/card-msg.ts +66 -0
- package/src/hq/kinds/card.ts +99 -0
- package/src/hq/kinds/index.ts +21 -0
- package/src/hq/kinds/kind.ts +126 -0
- package/src/hq/kinds/media.ts +125 -0
- package/src/hq/kinds/prompt.ts +219 -0
- package/src/hq/kinds/reflection.ts +128 -0
- package/src/hq/kinds/report.ts +55 -0
- package/src/hq/kinds/time-day.ts +236 -0
- package/src/hq/ledger.ts +473 -0
- package/src/hq/machine-key.ts +44 -0
- package/src/hq/machine-notes.ts +131 -0
- package/src/hq/outbox.ts +374 -0
- package/src/hq/replica.ts +167 -0
- package/src/hq/repo-id.ts +4 -0
- package/src/hq/report-facts.ts +117 -0
- package/src/hq/report.ts +274 -0
- package/src/hq/switch.ts +151 -0
- package/src/hq/vault-grant.ts +92 -0
- package/src/hq/vault-route.ts +112 -0
- package/src/identities/collection.ts +2 -2
- package/src/identities/identities.ts +24 -11
- package/src/identities/machine-route.ts +8 -3
- package/src/identities/steps.ts +31 -0
- package/src/ledger/db.ts +81 -27
- package/src/ledger/gate-checks.ts +6 -2
- package/src/ledger/run-log.ts +11 -3
- package/src/ledger/store.ts +26 -4
- package/src/media-store/backup/daemon.ts +73 -25
- package/src/media-store/backup/kept.ts +241 -0
- package/src/media-store/backup/keys.ts +1 -1
- package/src/media-store/backup/manifest.ts +20 -2
- package/src/media-store/backup/prune.ts +365 -0
- package/src/media-store/backup/restore.ts +14 -4
- package/src/media-store/backup/retention.ts +122 -0
- package/src/media-store/backup/run.ts +25 -19
- package/src/media-store/backup/secret.ts +6 -4
- package/src/media-store/backup/snapshot.ts +4 -2
- package/src/media-store/backup/sources.ts +83 -31
- package/src/media-store/backup/thread-copy.ts +340 -0
- package/src/media-store/copy/config.ts +76 -0
- package/src/media-store/copy/copy.ts +194 -0
- package/src/media-store/copy/lifecycle.ts +43 -0
- package/src/media-store/copy/night.ts +90 -0
- package/src/media-store/copy/proof.ts +151 -0
- package/src/media-store/copy/snapshot.ts +152 -0
- package/src/media-store/copy/store.ts +62 -0
- package/src/media-store/copy/stream.ts +176 -0
- package/src/media-store/daemon.ts +66 -16
- package/src/media-store/db.ts +24 -13
- package/src/media-store/forget.ts +141 -3
- package/src/media-store/hand.ts +4 -3
- package/src/media-store/hq-find.ts +75 -0
- package/src/media-store/hq-send.ts +277 -0
- package/src/media-store/kind.ts +2 -0
- package/src/media-store/purge.ts +21 -17
- package/src/media-store/put.ts +24 -8
- package/src/media-store/remote.ts +16 -7
- package/src/media-store/space-listing.ts +256 -0
- package/src/media-store/space.ts +46 -26
- package/src/media-store/sync.ts +5 -5
- package/src/media-store/tidy.ts +98 -0
- package/src/media-store/upload.ts +3 -3
- package/src/media-store/webp.ts +66 -0
- package/src/messages/guard.ts +49 -0
- package/src/messages/model.ts +16 -7
- package/src/messages/objects.ts +201 -0
- package/src/messages/routes.ts +14 -4
- package/src/messages/score.ts +3 -3
- package/src/messages/write.ts +285 -0
- package/src/pages/frame-client.ts +191 -4
- package/src/plan/planner.ts +28 -17
- package/src/recordings/media-kind.ts +1 -0
- package/src/recordings/model.ts +1 -1
- package/src/recordings/recorder-app/Capture.swift +9 -7
- package/src/reflect/hq-corpus.ts +56 -0
- package/src/reflect/prompt-corpus.ts +3 -1
- package/src/reflect/transcript.ts +129 -37
- package/src/reflections/reflections-queue.ts +1 -1
- package/src/release/gate-checkout.ts +2 -1
- package/src/release/git-facts.ts +3 -2
- package/src/release/machine-words.ts +67 -0
- package/src/release/public-clean.ts +11 -5
- package/src/releases/from-card.ts +1 -1
- package/src/releases/routes.ts +10 -5
- package/src/releases/store.ts +10 -1
- package/src/repo-config.ts +71 -19
- package/src/review/anim.ts +3 -3
- package/src/review/answer-kinds.ts +131 -0
- package/src/review/auto.ts +2 -2
- package/src/review/band.ts +53 -0
- package/src/review/branch-hold.ts +84 -0
- package/src/review/card-db.ts +254 -0
- package/src/review/card-rows.ts +267 -0
- package/src/review/cells.ts +360 -57
- package/src/review/close.ts +92 -0
- package/src/review/draft-card.ts +33 -0
- package/src/review/draft-model.ts +78 -0
- package/src/review/events.ts +171 -0
- package/src/review/format.ts +152 -19
- package/src/review/glyphs.ts +63 -0
- package/src/review/gone.ts +98 -0
- package/src/review/holds-sync.ts +62 -0
- package/src/review/holds.ts +85 -0
- package/src/review/house-kind-defs.ts +41 -0
- package/src/review/inbox-hook.ts +23 -10
- package/src/review/inbox-read.ts +201 -0
- package/src/review/instructions.ts +199 -0
- package/src/review/kind-apply.ts +61 -0
- package/src/review/kind-catalog.ts +96 -0
- package/src/review/kinds.ts +278 -0
- package/src/review/lane-ask.ts +109 -0
- package/src/review/marks.ts +1 -1
- package/src/review/media-kind.ts +7 -5
- package/src/review/media-read.ts +9 -7
- package/src/review/media.ts +32 -5
- package/src/review/model.ts +582 -109
- package/src/review/move.ts +491 -0
- package/src/review/need-address.ts +15 -0
- package/src/review/need-threads.ts +93 -0
- package/src/review/notes.ts +12 -20
- package/src/review/object-card.ts +48 -0
- package/src/review/object-read.ts +31 -0
- package/src/review/owner-verdict.ts +36 -0
- package/src/review/parties.ts +182 -0
- package/src/review/previews.ts +18 -20
- package/src/review/project.ts +1 -1
- package/src/review/projections.ts +235 -0
- package/src/review/referring.ts +54 -0
- package/src/review/reflection-object.ts +195 -0
- package/src/review/rev.ts +8 -0
- package/src/review/role.ts +1 -1
- package/src/review/routes.ts +194 -38
- package/src/review/secret-route.ts +80 -0
- package/src/review/snooze.ts +38 -0
- package/src/review/stage-card.ts +12 -8
- package/src/review/stage-routes.ts +1 -1
- package/src/review/store.ts +851 -124
- package/src/review/supersede.ts +116 -0
- package/src/review/take-back.ts +52 -0
- package/src/review/thread-fold.ts +64 -0
- package/src/review/threads.ts +349 -14
- package/src/review/traces.ts +218 -0
- package/src/review/trailer-auto-mock.ts +63 -0
- package/src/review/trailer-card.ts +6 -6
- package/src/review/trailer-desk.ts +41 -7
- package/src/review/trailer-media.ts +1 -0
- package/src/review/trailer-model.ts +8 -0
- package/src/review/trailer-notes.ts +1 -1
- package/src/review/trailer-routes.ts +9 -1
- package/src/review/unit.ts +77 -11
- package/src/review/verdict-items.ts +73 -0
- package/src/review/verdict-write.ts +15 -0
- package/src/review/wait.ts +85 -0
- package/src/review/watchers.ts +23 -10
- package/src/rules/untrack-generated.ts +92 -8
- package/src/scaffold/files/claude-settings-local.json +2 -0
- package/src/secrets/archive-mark.ts +52 -0
- package/src/secrets/archive.ts +83 -0
- package/src/secrets/copy.ts +14 -14
- package/src/secrets/held.ts +16 -0
- package/src/secrets/keychain-write.ts +48 -0
- package/src/secrets/keychain.ts +116 -0
- package/src/secrets/lapse-mark.ts +33 -0
- package/src/secrets/lapse.ts +60 -0
- package/src/secrets/list.ts +21 -17
- package/src/secrets/manager.ts +55 -26
- package/src/secrets/read.ts +385 -0
- package/src/secrets/tail.ts +31 -0
- package/src/secrets/who-reads.ts +49 -0
- package/src/serve/door-forward.ts +268 -0
- package/src/serve/door-names.ts +47 -0
- package/src/serve/embed.ts +1 -1
- package/src/serve/hub-app/activity-view.tsx +56 -32
- package/src/serve/hub-app/activity.css +7 -1
- package/src/serve/hub-app/asks-page.tsx +49 -0
- package/src/serve/hub-app/asks-st.ts +25 -0
- package/src/serve/hub-app/auto-text.tsx +14 -6
- package/src/serve/hub-app/benign-errors.ts +15 -1
- package/src/serve/hub-app/card-head.tsx +49 -0
- package/src/serve/hub-app/check-view.tsx +3 -2
- package/src/serve/hub-app/clock-svc.ts +1 -2
- package/src/serve/hub-app/code-copy.ts +35 -0
- package/src/serve/hub-app/col-card.tsx +72 -30
- package/src/serve/hub-app/col-list-page.tsx +125 -0
- package/src/serve/hub-app/col-list-st.ts +103 -0
- package/src/serve/hub-app/col-tables-view.tsx +17 -45
- package/src/serve/hub-app/col-tables.ts +76 -8
- package/src/serve/hub-app/cols-svc.ts +18 -39
- package/src/serve/hub-app/commands/commands-page.tsx +2 -1
- package/src/serve/hub-app/controls.css +83 -0
- package/src/serve/hub-app/database-st.ts +260 -0
- package/src/serve/hub-app/database-view.tsx +289 -0
- package/src/serve/hub-app/database.css +32 -0
- package/src/serve/hub-app/entry-bar.css +14 -0
- package/src/serve/hub-app/entry-bar.tsx +33 -0
- package/src/serve/hub-app/entry-pick.ts +31 -0
- package/src/serve/hub-app/floating.tsx +1 -0
- package/src/serve/hub-app/frames-st.ts +17 -1
- package/src/serve/hub-app/git-view.tsx +3 -2
- package/src/serve/hub-app/hash-route.ts +11 -1
- package/src/serve/hub-app/header-bar.tsx +14 -18
- package/src/serve/hub-app/home-st.ts +142 -11
- package/src/serve/hub-app/home-strip.css +6 -25
- package/src/serve/hub-app/home-strip.tsx +60 -93
- package/src/serve/hub-app/home.html +10 -0
- package/src/serve/hub-app/house-wiki-view.tsx +20 -0
- package/src/serve/hub-app/hub-app.tsx +71 -166
- package/src/serve/hub-app/hub-types.ts +5 -1
- package/src/serve/hub-app/hub.css +146 -71
- package/src/serve/hub-app/icons.tsx +32 -5
- package/src/serve/hub-app/identities-st.ts +56 -6
- package/src/serve/hub-app/identities-view.tsx +104 -61
- package/src/serve/hub-app/identities.css +17 -15
- package/src/serve/hub-app/identity-address.ts +5 -0
- package/src/serve/hub-app/inbox-st.ts +227 -49
- package/src/serve/hub-app/inbox-view.tsx +204 -120
- package/src/serve/hub-app/inbox.css +47 -47
- package/src/serve/hub-app/index.html +10 -0
- package/src/serve/hub-app/instructions.css +30 -0
- package/src/serve/hub-app/kept-cols.tsx +7 -0
- package/src/serve/hub-app/keys.ts +32 -17
- package/src/serve/hub-app/later.tsx +26 -0
- package/src/serve/hub-app/list-filter.tsx +14 -0
- package/src/serve/hub-app/list-walk.ts +72 -3
- package/src/serve/hub-app/machine-st.ts +2 -2
- package/src/serve/hub-app/machines-st.ts +251 -0
- package/src/serve/hub-app/machines-view.tsx +217 -0
- package/src/serve/hub-app/machines.css +67 -0
- package/src/serve/hub-app/markdown.css +51 -0
- package/src/serve/hub-app/md-copy.tsx +57 -0
- package/src/serve/hub-app/md.ts +25 -9
- package/src/serve/hub-app/media-view.tsx +4 -2
- package/src/serve/hub-app/messages/messages-page.tsx +81 -8
- package/src/serve/hub-app/messages/messages-st.ts +99 -3
- package/src/serve/hub-app/messages.css +14 -1
- package/src/serve/hub-app/objects.css +51 -0
- package/src/serve/hub-app/page-keys.ts +175 -0
- package/src/serve/hub-app/pages-frames.tsx +21 -3
- package/src/serve/hub-app/palette-st.ts +58 -11
- package/src/serve/hub-app/palette-view.tsx +3 -1
- package/src/serve/hub-app/pane-boundary.tsx +72 -0
- package/src/serve/hub-app/pane-errors.ts +54 -0
- package/src/serve/hub-app/plan-view.tsx +3 -2
- package/src/serve/hub-app/planned-view.tsx +3 -3
- package/src/serve/hub-app/planned.css +0 -4
- package/src/serve/hub-app/processes-view.tsx +3 -2
- package/src/serve/hub-app/project-list.css +46 -8
- package/src/serve/hub-app/project-list.tsx +125 -59
- package/src/serve/hub-app/projects-svc.ts +83 -8
- package/src/serve/hub-app/reader-chips.tsx +13 -0
- package/src/serve/hub-app/readme-view.tsx +2 -3
- package/src/serve/hub-app/readme.css +22 -6
- package/src/serve/hub-app/reflections-page.tsx +95 -0
- package/src/serve/hub-app/reflections-st.ts +17 -0
- package/src/serve/hub-app/releases/releases-page.tsx +28 -4
- package/src/serve/hub-app/releases/releases-st.ts +1 -1
- package/src/serve/hub-app/releases.css +0 -1
- package/src/serve/hub-app/repo-sections.ts +9 -5
- package/src/serve/hub-app/repo-st.ts +35 -8
- package/src/serve/hub-app/review/code-colors.ts +30 -0
- package/src/serve/hub-app/review/diff-view.tsx +75 -0
- package/src/serve/hub-app/review/dock.tsx +104 -0
- package/src/serve/hub-app/review/draft-card.tsx +163 -0
- package/src/serve/hub-app/review/group-block.tsx +209 -0
- package/src/serve/hub-app/review/instructions-view.tsx +116 -0
- package/src/serve/hub-app/review/item-verdict.tsx +38 -0
- package/src/serve/hub-app/review/kind-states.tsx +193 -0
- package/src/serve/hub-app/review/kind-view.tsx +1 -37
- package/src/serve/hub-app/review/kit.tsx +75 -29
- package/src/serve/hub-app/review/lane-bar.tsx +64 -0
- package/src/serve/hub-app/review/note-place.ts +1 -1
- package/src/serve/hub-app/review/object-card.tsx +62 -0
- package/src/serve/hub-app/review/object-panel.tsx +179 -0
- package/src/serve/hub-app/review/question-views.tsx +385 -0
- package/src/serve/hub-app/review/review-board.tsx +2 -2
- package/src/serve/hub-app/review/review-cells.tsx +148 -87
- package/src/serve/hub-app/review/review-kit.ts +27 -1
- package/src/serve/hub-app/review/review-list.tsx +160 -65
- package/src/serve/hub-app/review/review-page.tsx +12 -12
- package/src/serve/hub-app/review/review-st.ts +174 -47
- package/src/serve/hub-app/review/review-thread.tsx +214 -53
- package/src/serve/hub-app/review/review-views.tsx +494 -159
- package/src/serve/hub-app/review/thread-close.tsx +124 -0
- package/src/serve/hub-app/review/thread-control-st.ts +115 -0
- package/src/serve/hub-app/review/thread-control.tsx +74 -0
- package/src/serve/hub-app/review/thread-st.ts +288 -41
- package/src/serve/hub-app/review/trailer-card.tsx +2 -2
- package/src/serve/hub-app/review/trailer-page.tsx +37 -16
- package/src/serve/hub-app/review/trailer-st.ts +41 -7
- package/src/serve/hub-app/review/trailer-timeline.tsx +2 -2
- package/src/serve/hub-app/review.css +462 -97
- package/src/serve/hub-app/section-head.tsx +51 -0
- package/src/serve/hub-app/side-lists.ts +72 -0
- package/src/serve/hub-app/sidebar.tsx +6 -3
- package/src/serve/hub-app/site/site-part.tsx +2 -8
- package/src/serve/hub-app/site/site-st.ts +4 -4
- package/src/serve/hub-app/social/calendar.tsx +5 -11
- package/src/serve/hub-app/social/comms-page.tsx +43 -15
- package/src/serve/hub-app/social/kit.tsx +32 -13
- package/src/serve/hub-app/social/next-release.tsx +3 -5
- package/src/serve/hub-app/social/post-card.tsx +142 -49
- package/src/serve/hub-app/social/post-page.tsx +80 -0
- package/src/serve/hub-app/social/problems.tsx +5 -9
- package/src/serve/hub-app/social/serial-writes.ts +13 -0
- package/src/serve/hub-app/social/social-model.ts +24 -5
- package/src/serve/hub-app/social/social-page.tsx +95 -36
- package/src/serve/hub-app/social/social-st.ts +162 -41
- package/src/serve/hub-app/social/stage-popup.tsx +1 -1
- package/src/serve/hub-app/social/stage-st.ts +1 -1
- package/src/serve/hub-app/social/step-layout.ts +1 -1
- package/src/serve/hub-app/social.css +10 -17
- package/src/serve/hub-app/space-st.ts +209 -0
- package/src/serve/hub-app/space-view.tsx +196 -0
- package/src/serve/hub-app/space.css +27 -0
- package/src/serve/hub-app/stores/stores-page.tsx +97 -25
- package/src/serve/hub-app/stores/stores-st.ts +44 -19
- package/src/serve/hub-app/stores.css +6 -1
- package/src/serve/hub-app/theme-st.ts +22 -9
- package/src/serve/hub-app/thread-row.tsx +101 -0
- package/src/serve/hub-app/time-ago.tsx +3 -2
- package/src/serve/hub-app/time-charts.tsx +291 -0
- package/src/serve/hub-app/time-pages.tsx +749 -0
- package/src/serve/hub-app/time-st.ts +162 -0
- package/src/serve/hub-app/time-view.tsx +77 -0
- package/src/serve/hub-app/time.css +135 -0
- package/src/serve/hub-app/tree-build.ts +52 -42
- package/src/serve/hub-app/tree-row.tsx +3 -11
- package/src/serve/hub-app/tree-svc.ts +18 -9
- package/src/serve/hub-app/urls-svc.ts +154 -0
- package/src/serve/hub-app/urls-view.tsx +117 -0
- package/src/serve/hub-app/urls.css +30 -0
- package/src/serve/hub-app/vault-st.ts +127 -0
- package/src/serve/hub-app/vault-view.tsx +154 -0
- package/src/serve/hub-app/vault.css +38 -0
- package/src/serve/hub-app/veille/veille-page.tsx +2 -11
- package/src/serve/hub-app/veille/veille-st.ts +12 -10
- package/src/serve/hub-app/veille.css +0 -1
- package/src/serve/hub-app/waiting-svc.ts +29 -0
- package/src/serve/hub-app/when-view.tsx +6 -3
- package/src/serve/hub-app/wiki-st.ts +30 -4
- package/src/serve/hub-app/wikis-view.tsx +6 -5
- package/src/serve/hub-runtime.ts +35 -8
- package/src/serve/project-gutter-route.ts +42 -19
- package/src/serve/project-gutter.ts +16 -50
- package/src/serve/same-origin.ts +13 -0
- package/src/serve/secret-gate.ts +21 -0
- package/src/serve/serve-hub.ts +38 -20
- package/src/serve/tailnet-caller.ts +117 -0
- package/src/shipkit-files.ts +16 -2
- package/src/shipkit.ts +3 -3
- package/src/shot/shooter.ts +616 -420
- package/src/shot/shot-ask.ts +246 -155
- package/src/site/desk.ts +4 -4
- package/src/smoke/run-smoke.ts +6 -6
- package/src/social/brands.ts +4 -0
- package/src/social/card-drafts.ts +11 -19
- package/src/social/cover.ts +202 -0
- package/src/social/desk-index.ts +34 -13
- package/src/social/discord-layout.ts +37 -13
- package/src/social/drafts.ts +7 -4
- package/src/social/import-drafts.ts +244 -0
- package/src/social/kind-pages.ts +3 -3
- package/src/social/kinds.ts +1 -1
- package/src/social/load.ts +111 -65
- package/src/social/media-kind.ts +68 -160
- package/src/social/media-of.ts +5 -4
- package/src/social/open.ts +3 -2
- package/src/social/post-object.ts +120 -0
- package/src/social/post-sources.ts +136 -0
- package/src/social/post-text.ts +103 -0
- package/src/social/posts.ts +378 -0
- package/src/social/presence.ts +7 -5
- package/src/social/publish/discord.ts +5 -2
- package/src/social/publish/index.ts +17 -5
- package/src/social/publish/secret.ts +4 -4
- package/src/social/release-stage.ts +79 -63
- package/src/social/routes.ts +89 -24
- package/src/social/stage.ts +43 -58
- package/src/social/stats.ts +12 -9
- package/src/social/strip.ts +4 -1
- package/src/social/text.ts +4 -3
- package/src/social/thumbnail.ts +347 -0
- package/src/social/tracker.ts +1 -1
- package/src/social/writes.ts +12 -29
- package/src/stores/collection.ts +15 -11
- package/src/stores/desk.ts +246 -47
- package/src/stores/model.ts +72 -6
- package/src/stores/routes.ts +37 -12
- package/src/stores/unit.ts +16 -10
- package/src/suite/judge-suites.ts +41 -11
- package/src/suite/select.ts +45 -3
- package/src/suite/suite-cli.ts +16 -10
- package/src/trailer/bed.ts +1 -1
- package/src/trailer/build.ts +134 -21
- package/src/trailer/ffmpeg.ts +7 -0
- package/src/trailer/fonts.ts +3 -2
- package/src/trailer/grammar.ts +201 -2
- package/src/trailer/graph.ts +42 -5
- package/src/trailer/look.ts +21 -0
- package/src/trailer/mock.ts +154 -0
- package/src/trailer/passage.ts +65 -26
- package/src/trailer/score/heard.ts +89 -0
- package/src/trailer/score/sound.ts +14 -8
- package/src/trailer/sound/eleven.ts +33 -3
- package/src/trailer/sound/run.ts +16 -6
- package/src/trailer/stitch.ts +26 -5
- package/src/trailer/titles.ts +82 -19
- package/src/trailer/versions.ts +1 -3
- package/src/trailer/vertical.ts +3 -1
- package/src/urls/frame.ts +195 -0
- package/src/urls/routes.ts +43 -0
- package/src/urls/rows.ts +171 -0
- package/src/urls/unit.ts +73 -0
- package/src/vault/house-keys.ts +42 -0
- package/src/vault/layout.ts +50 -0
- package/src/vault/policy.ts +165 -0
- package/src/vault/vault-audit.ts +276 -0
- package/src/vault/vault-client.ts +40 -0
- package/src/vault/vault-config.ts +159 -0
- package/src/vault/vault-destroy.ts +78 -0
- package/src/vault/vault-handover.ts +305 -0
- package/src/vault/vault-http.ts +360 -0
- package/src/vault/vault-import.ts +213 -0
- package/src/vault/vault-init.ts +328 -0
- package/src/vault/vault-minter.ts +271 -0
- package/src/vault/vault-restore.ts +333 -0
- package/src/vault/vault-serve.ts +342 -0
- package/src/vault/vault-snapshot.ts +281 -0
- package/src/veille/asks.ts +1 -1
- package/src/veille/desk.ts +2 -2
- package/src/veille/identity.ts +2 -2
- package/src/wiki/graph-pages.ts +13 -1
- package/src/wiki/scan-md.ts +1 -1
- package/src/asks/asks-queue.ts +0 -266
- package/src/social/migrate.ts +0 -123
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// the local copy of the review cards (wiki tools/shipkit/threads-store.md): with the switch cards-in-db on, each card of
|
|
2
|
+
// this machine is rows of the daemon's own file, its head and each message as the json the store writes, filed under
|
|
3
|
+
// its repo's id (the repo's key for the hq, else `path:<its folder>`). Only the review store reads and writes them
|
|
4
|
+
// (store.ts, its primitives `DB`). Every write takes the next number of the copy (`seq`) for its card, so a stamp is a
|
|
5
|
+
// query of a few µs and a reader reads again only the cards whose number moved.
|
|
6
|
+
// The one constraint a reader breaks first: a write made inside a transaction of another connection of this process
|
|
7
|
+
// (the ledger's, as the feed lands) goes through that connection (withCardsDb), never this module's own, which would
|
|
8
|
+
// wait on it until its busy timeout
|
|
9
|
+
import type { Database } from 'bun:sqlite'
|
|
10
|
+
import { cpSync, lstatSync, mkdirSync, realpathSync, renameSync, rmSync } from 'node:fs'
|
|
11
|
+
import { dirname, join, resolve } from 'node:path'
|
|
12
|
+
import { LAYOUT } from '../core/layout.ts'
|
|
13
|
+
|
|
14
|
+
// review_cards a card's head: its json, its rev (the sha of the bytes the store writes), its time, its number
|
|
15
|
+
// review_msgs a message of a card's thread, never rewritten
|
|
16
|
+
// review_gone a card out of the store (a deletion, a tombstone of the feed), whole, for GONE_KEEP_MS: the way back
|
|
17
|
+
// review_replaced the head a landing replaced while this machine's change of it was not in it, the last one
|
|
18
|
+
// review_repos the repo id each store folder's cards were first filed under: a remote renamed later keeps them
|
|
19
|
+
export const CARD_DB_SCHEMA = `
|
|
20
|
+
create table if not exists review_cards (repo text not null, id text not null, seq integer not null, at integer not null, rev text not null, head text not null, primary key (repo, id)) without rowid;
|
|
21
|
+
create index if not exists review_cards_seq on review_cards (repo, seq);
|
|
22
|
+
create table if not exists review_msgs (repo text not null, card text not null, id text not null, rev text not null, body text not null, primary key (repo, card, id)) without rowid;
|
|
23
|
+
create table if not exists review_gone (repo text not null, entry text not null, id text not null, created text not null, seq integer not null, at integer not null, head text not null, thread text not null, primary key (repo, entry)) without rowid;
|
|
24
|
+
create index if not exists review_gone_seq on review_gone (repo, seq);
|
|
25
|
+
create table if not exists review_replaced (repo text not null, id text not null, at integer not null, head text not null, primary key (repo, id)) without rowid;
|
|
26
|
+
create table if not exists review_repos (dir text primary key, repo text not null) without rowid;
|
|
27
|
+
create index if not exists review_msgs_keys on review_msgs (repo, card, id);
|
|
28
|
+
create index if not exists review_replaced_keys on review_replaced (repo, id);
|
|
29
|
+
create index if not exists review_repos_keys on review_repos (dir);
|
|
30
|
+
`
|
|
31
|
+
|
|
32
|
+
/** the connection a write inside another transaction of this process must use */
|
|
33
|
+
let bound: Database | null = null
|
|
34
|
+
/** this process's own connection, a file, with the inode it opened: a file deleted or replaced since is opened again */
|
|
35
|
+
const opened = new Map<string, { db: Database; ino: number }>()
|
|
36
|
+
/** the daemon file's own path as these connections found it: a fold puts a tombstone there, a way back a file, each a
|
|
37
|
+
* new inode; null before the first open */
|
|
38
|
+
let walked: number | null = null
|
|
39
|
+
|
|
40
|
+
/** `fn` with the copy read and written through `db`: the connection whose transaction is open (the feed's landing) */
|
|
41
|
+
export function withCardsDb<T>(db: Database, fn: () => T): T {
|
|
42
|
+
const was = bound
|
|
43
|
+
bound = db
|
|
44
|
+
try {
|
|
45
|
+
return fn()
|
|
46
|
+
} finally {
|
|
47
|
+
bound = was
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** the daemon's file this process reads the copy in; throws when it does not open, never a silent empty store */
|
|
52
|
+
export function cardsDb(): Database {
|
|
53
|
+
if (bound != null) return bound
|
|
54
|
+
// the daemon's file and its migration are the outbox's: loaded only once the switch is on
|
|
55
|
+
const { daemonDbPath, openDaemonDb } = require('../hq/outbox.ts') as typeof import('../hq/outbox.ts')
|
|
56
|
+
// a walk of the daemon file moved the store since these connections opened: each opens again where it is now,
|
|
57
|
+
// through the open that refuses while a walk runs, never a stale file nor tables a fold has not filled yet
|
|
58
|
+
const { forgetStoreHomes, oldStorePath } = require('../core/machine-db.ts') as typeof import('../core/machine-db.ts')
|
|
59
|
+
const ino = lstatSync(oldStorePath('daemon file'), { throwIfNoEntry: false })?.ino ?? 0
|
|
60
|
+
if (walked != null && ino !== walked) {
|
|
61
|
+
closeCardsDb()
|
|
62
|
+
forgetStoreHomes()
|
|
63
|
+
}
|
|
64
|
+
walked = ino
|
|
65
|
+
let path = daemonDbPath()
|
|
66
|
+
const held = opened.get(path)
|
|
67
|
+
if (held != null) {
|
|
68
|
+
if (lstatSync(path, { throwIfNoEntry: false })?.ino === held.ino) return held.db
|
|
69
|
+
try {
|
|
70
|
+
held.db.close()
|
|
71
|
+
} catch {
|
|
72
|
+
// already gone with its file
|
|
73
|
+
}
|
|
74
|
+
opened.delete(path)
|
|
75
|
+
}
|
|
76
|
+
let db = openDaemonDb(path)
|
|
77
|
+
if (db == null) {
|
|
78
|
+
const { foldRefusal } = require('../core/machine-db.ts') as typeof import('../core/machine-db.ts')
|
|
79
|
+
const why = foldRefusal('daemon file', path)
|
|
80
|
+
if (why != null) throw cardsRefused(why)
|
|
81
|
+
// the open was refused by a walk that ended since: once more, where the store is now
|
|
82
|
+
forgetStoreHomes()
|
|
83
|
+
path = daemonDbPath()
|
|
84
|
+
db = openDaemonDb(path)
|
|
85
|
+
if (db == null) {
|
|
86
|
+
const again = foldRefusal('daemon file', path)
|
|
87
|
+
if (again != null) throw cardsRefused(again)
|
|
88
|
+
throw new Error(`the daemon's database ${path} does not open: the review cards live there while the switch cards-in-db is on`)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
opened.set(path, { db, ino: lstatSync(path, { throwIfNoEntry: false })?.ino ?? 0 })
|
|
92
|
+
// no file before this open: the file it made is the one these connections found, never a walk
|
|
93
|
+
if (ino === 0) walked = lstatSync(oldStorePath('daemon file'), { throwIfNoEntry: false })?.ino ?? 0
|
|
94
|
+
return db
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const cardsRefused = (why: string): Error => {
|
|
98
|
+
const { StoreRefused } = require('../core/machine-db.ts') as typeof import('../core/machine-db.ts')
|
|
99
|
+
const refused = new StoreRefused(why)
|
|
100
|
+
refused.message = `the review cards do not read now: ${refused.message}`
|
|
101
|
+
return refused
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** `fn` whose error a walk of the daemon file caused is told as the walk's line (walkedUnder) */
|
|
105
|
+
export const walking =
|
|
106
|
+
<A extends unknown[], R>(fn: (...a: A) => R) =>
|
|
107
|
+
(...a: A): R => {
|
|
108
|
+
try {
|
|
109
|
+
return fn(...a)
|
|
110
|
+
} catch (e) {
|
|
111
|
+
throw walkedUnder(e)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** an error of a held connection that a walk of the daemon file moved the store from under (its tables renamed away,
|
|
116
|
+
* its file a tombstone): the walk's one line, a wait, and the connections closed so the next call opens where the
|
|
117
|
+
* store is now. Any other error as it is */
|
|
118
|
+
export function walkedUnder(e: unknown): unknown {
|
|
119
|
+
if (!(e instanceof Error) || e.name === 'StoreRefused' || !/no such table: (\w+\.)?review_|disk I\/O error/.test(e.message)) return e
|
|
120
|
+
const { foldRefusal, forgetStoreHomes, isTombstone, oldStorePath, waitRefused } = require('../core/machine-db.ts') as typeof import('../core/machine-db.ts')
|
|
121
|
+
const { daemonDbPath } = require('../hq/outbox.ts') as typeof import('../hq/outbox.ts')
|
|
122
|
+
const old = oldStorePath('daemon file')
|
|
123
|
+
const moved = (lstatSync(old, { throwIfNoEntry: false })?.ino ?? 0) !== walked
|
|
124
|
+
const why = foldRefusal('daemon file', daemonDbPath())
|
|
125
|
+
if (why == null && !moved) return e
|
|
126
|
+
closeCardsDb()
|
|
127
|
+
forgetStoreHomes()
|
|
128
|
+
walked = null
|
|
129
|
+
if (why != null) return cardsRefused(why)
|
|
130
|
+
const ended = waitRefused(`a ${isTombstone(old) ? 'fold' : 'way back'} of the daemon file moved the threads as this ran: run it again`)
|
|
131
|
+
ended.message = `the review cards do not read now: ${ended.message}`
|
|
132
|
+
return ended
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** closes this process's connections to the copy (a fold of this process, a test that moves it) */
|
|
136
|
+
export function closeCardsDb(): void {
|
|
137
|
+
for (const { db } of opened.values()) {
|
|
138
|
+
try {
|
|
139
|
+
db.close()
|
|
140
|
+
} catch {
|
|
141
|
+
// already gone
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
opened.clear()
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** a folder's real path, its own path while it does not exist */
|
|
148
|
+
const realOf = (p: string): string => {
|
|
149
|
+
try {
|
|
150
|
+
return realpathSync(p)
|
|
151
|
+
} catch {
|
|
152
|
+
return p
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** the real path of a repo's git common dir, read from its files with no git process: `.git` itself, or for a worktree
|
|
157
|
+
* the folder its `.git` file names and that folder's `commondir`. Null for a folder that is no repo's root */
|
|
158
|
+
export function gitCommonDir(root: string): string | null {
|
|
159
|
+
const { readFileSync, statSync } = require('node:fs') as typeof import('node:fs')
|
|
160
|
+
const dot = join(root, '.git')
|
|
161
|
+
try {
|
|
162
|
+
if (statSync(dot).isDirectory()) return realpathSync(dot)
|
|
163
|
+
const m = /^gitdir:\s*(.+)$/m.exec(readFileSync(dot, 'utf8'))
|
|
164
|
+
if (m == null) return null
|
|
165
|
+
const gitdir = resolve(root, m[1]!.trim())
|
|
166
|
+
let common = gitdir
|
|
167
|
+
try {
|
|
168
|
+
common = resolve(gitdir, readFileSync(join(gitdir, 'commondir'), 'utf8').trim())
|
|
169
|
+
} catch {
|
|
170
|
+
// a gitdir with no commondir is its own common dir
|
|
171
|
+
}
|
|
172
|
+
return realpathSync(common)
|
|
173
|
+
} catch {
|
|
174
|
+
return null
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** the repo id of each store folder, made once a process */
|
|
179
|
+
const ids = new Map<string, string>()
|
|
180
|
+
|
|
181
|
+
/** the id a store's cards are filed under: the one its folder was first filed under, else the repo's key (its first
|
|
182
|
+
* remote, as the hq names it), else its folder. Two folders of one remote (a worktree and its checkout) share it */
|
|
183
|
+
export function repoIdOf(dir: string): string {
|
|
184
|
+
const key = resolve(dir)
|
|
185
|
+
const held = ids.get(key)
|
|
186
|
+
if (held != null) return held
|
|
187
|
+
const db = cardsDb()
|
|
188
|
+
const tail = `/${LAYOUT.review}`
|
|
189
|
+
const root = key.endsWith(tail) ? key.slice(0, -tail.length) : key
|
|
190
|
+
// one repo is one git common dir, whatever folder opens it (a worktree, a link) and whatever its remote says now
|
|
191
|
+
const common = gitCommonDir(root)
|
|
192
|
+
const byRepo = common == null ? null : `git:${common}`
|
|
193
|
+
const filed = (k: string): string | undefined => (db.query('select repo from review_repos where dir = ?').get(k) as { repo: string } | null)?.repo
|
|
194
|
+
const first = filed(key) ?? (byRepo == null ? undefined : filed(byRepo))
|
|
195
|
+
const { repoKeySync } = require('../hq/report.ts') as typeof import('../hq/report.ts')
|
|
196
|
+
// a repo with no remote is named by its checkout's real path, a folder that is no repo by its own
|
|
197
|
+
const named = first ?? repoKeySync(root) ?? `path:${common == null ? realOf(root) : dirname(common)}`
|
|
198
|
+
db.transaction(() => {
|
|
199
|
+
db.query('insert or ignore into review_repos (dir, repo) values (?, ?)').run(key, named)
|
|
200
|
+
if (byRepo != null) db.query('insert or ignore into review_repos (dir, repo) values (?, ?)').run(byRepo, named)
|
|
201
|
+
}).immediate()
|
|
202
|
+
const id = filed(key)!
|
|
203
|
+
ids.set(key, id)
|
|
204
|
+
return id
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** where a store keeps the cards it set aside: in the files, and in the media spool for their media */
|
|
208
|
+
export const GONE = '.gone'
|
|
209
|
+
|
|
210
|
+
/** the media spool of each repo, by daemon file and repo id */
|
|
211
|
+
const spools = new Map<string, string>()
|
|
212
|
+
|
|
213
|
+
/** the folder of a repo's card media while its cards are rows: beside the daemon's file, never in the repo, kept there
|
|
214
|
+
* until the media store sent each file up and let it go. The spool's own path is filed under the same repo, so any
|
|
215
|
+
* verb of the store given the spool (the media store's kind) reads the same cards */
|
|
216
|
+
export function spoolOf(dir: string): string {
|
|
217
|
+
const repo = repoIdOf(dir)
|
|
218
|
+
const { daemonDbPath } = require('../hq/outbox.ts') as typeof import('../hq/outbox.ts')
|
|
219
|
+
const base = daemonDbPath()
|
|
220
|
+
const k = `${base}\0${repo}`
|
|
221
|
+
const held = spools.get(k)
|
|
222
|
+
if (held != null) return held
|
|
223
|
+
const safe = repo.replace(/[^A-Za-z0-9._-]+/g, '-').replace(/^-+|-+$/g, '').slice(-60)
|
|
224
|
+
const d = join(dirname(base), 'review-media', `${safe}-${new Bun.CryptoHasher('sha256').update(repo).digest('hex').slice(0, 8)}`)
|
|
225
|
+
cardsDb().query('insert or ignore into review_repos (dir, repo) values (?, ?)').run(resolve(d), repo)
|
|
226
|
+
ids.set(resolve(d), repo)
|
|
227
|
+
spools.set(k, d)
|
|
228
|
+
return d
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** a folder moved whole, its parent made; across two disks, copied then removed */
|
|
232
|
+
export function moveFolder(from: string, to: string): void {
|
|
233
|
+
mkdirSync(dirname(to), { recursive: true })
|
|
234
|
+
try {
|
|
235
|
+
renameSync(from, to)
|
|
236
|
+
} catch (e) {
|
|
237
|
+
if ((e as NodeJS.ErrnoException).code !== 'EXDEV') throw e
|
|
238
|
+
cpSync(from, to, { recursive: true })
|
|
239
|
+
rmSync(from, { recursive: true, force: true })
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** the next number of the copy, inside the caller's transaction */
|
|
244
|
+
export function nextSeq(db: Database): number {
|
|
245
|
+
const r = db.query("insert into meta (name, value) values ('review-seq', '1') on conflict (name) do update set value = cast(value as integer) + 1 returning value").get() as { value: string }
|
|
246
|
+
return Number(r.value)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** what moved a repo's cards: the highest number of its cards and of its cards gone */
|
|
250
|
+
export function repoTop(db: Database, repo: string): { cards: number; gone: number } {
|
|
251
|
+
const c = db.query('select max(seq) as n from review_cards where repo = ?').get(repo) as { n: number | null }
|
|
252
|
+
const g = db.query('select max(seq) as n from review_gone where repo = ?').get(repo) as { n: number | null }
|
|
253
|
+
return { cards: c.n ?? 0, gone: g.n ?? 0 }
|
|
254
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
// the review store's backend of rows (wiki tools/shipkit/threads-store.md): the same primitives as its files, a card's
|
|
2
|
+
// head, its thread, a write, a lock, a stamp, on the local copy (card-db.ts). The store picks one backend an operation
|
|
3
|
+
// (store.ts `io`), so every reader and writer is the same code on both. A card's media files stay in its folder.
|
|
4
|
+
// The one constraint a reader breaks first: a lock is a write transaction of the daemon's file, so the work inside one
|
|
5
|
+
// is a few reads and writes of rows, never a file copy or an await
|
|
6
|
+
import type { Database } from 'bun:sqlite'
|
|
7
|
+
import { existsSync } from 'node:fs'
|
|
8
|
+
import { join } from 'node:path'
|
|
9
|
+
import { cardsDb, GONE, moveFolder, nextSeq, repoIdOf, repoTop, spoolOf, walking } from './card-db.ts'
|
|
10
|
+
import { itemProblems, messageProblems, MESSAGE_RE, type Item, type Message, type ReviewItem } from './model.ts'
|
|
11
|
+
import { revOf } from './rev.ts'
|
|
12
|
+
import type { ReadAll } from './store.ts'
|
|
13
|
+
|
|
14
|
+
/** where a store's cards are: its files, or the rows of the local copy. Every method names a card by its id */
|
|
15
|
+
export interface CardBackend {
|
|
16
|
+
readonly rows: boolean
|
|
17
|
+
/** every name the store lists, sorted: each card, and with the files what else holds a folder there */
|
|
18
|
+
names(): string[]
|
|
19
|
+
/** does the card have a head */
|
|
20
|
+
has(id: string): boolean
|
|
21
|
+
/** may a new card not take this id */
|
|
22
|
+
taken(id: string): boolean
|
|
23
|
+
/** the head as stored, and the time it was written; null with none */
|
|
24
|
+
head(id: string): { head: unknown; at: number } | null
|
|
25
|
+
/** the ids of its messages, oldest first */
|
|
26
|
+
threadIds(id: string): string[]
|
|
27
|
+
/** one message as stored; throws with none */
|
|
28
|
+
message(id: string, mid: string): unknown
|
|
29
|
+
hasMessage(id: string, mid: string): boolean
|
|
30
|
+
/** the card checked, its thread oldest first: throws for what does not read, null with no head */
|
|
31
|
+
raw(id: string): ReviewItem | null
|
|
32
|
+
/** a new card, its files waiting in the folder `tmp`: they land, then its head */
|
|
33
|
+
create(id: string, tmp: string, head: Item): void
|
|
34
|
+
/** the head rewritten; `at` its time when it is not now (a file imported) */
|
|
35
|
+
write(id: string, head: unknown, at?: number): void
|
|
36
|
+
/** a message, never over another of its id */
|
|
37
|
+
append(id: string, m: Message): void
|
|
38
|
+
/** `fn` alone on this card: two writers that check then write never both win */
|
|
39
|
+
lock<T>(id: string, fn: () => T, waitMs?: number): T
|
|
40
|
+
/** the card out of the store, whole, kept GONE_KEEP_MS: what it did. `created`: only the card made then; `before`:
|
|
41
|
+
* only one made before that moment */
|
|
42
|
+
setAside(id: string, o: { created?: string; before?: number }): 'moved' | 'none' | 'other'
|
|
43
|
+
/** the head a landing replaced, kept beside it */
|
|
44
|
+
keepReplaced(id: string, head: Item): void
|
|
45
|
+
hasReplaced(id: string): boolean
|
|
46
|
+
/** moves with any write of the card */
|
|
47
|
+
stamp(id: string): string
|
|
48
|
+
/** the folder of the card's media files */
|
|
49
|
+
folder(id: string): string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** a write's error that names its card, as the files' backend says it */
|
|
53
|
+
const noCard = (id: string): Error => Object.assign(new Error(`no item ${id}`), { code: 'ENOENT' })
|
|
54
|
+
|
|
55
|
+
/** the rows of one store folder's repo */
|
|
56
|
+
export function rowsIO(dir: string): CardBackend {
|
|
57
|
+
const repo = repoIdOf(dir)
|
|
58
|
+
const db = (): Database => cardsDb()
|
|
59
|
+
const headRow = (id: string): { head: string; at: number; seq: number } | null => db().query('select head, at, seq from review_cards where repo = ? and id = ?').get(repo, id) as { head: string; at: number; seq: number } | null
|
|
60
|
+
const has = (id: string): boolean => db().query('select 1 from review_cards where repo = ? and id = ?').get(repo, id) != null
|
|
61
|
+
const messages = (id: string): { id: string; body: string }[] => db().query('select id, body from review_msgs where repo = ? and card = ? order by id').all(repo, id) as { id: string; body: string }[]
|
|
62
|
+
const write = (id: string, head: unknown, at: number): void => {
|
|
63
|
+
db().query('insert into review_cards (repo, id, seq, at, rev, head) values (?, ?, ?, ?, ?, ?) on conflict (repo, id) do update set seq = excluded.seq, at = excluded.at, rev = excluded.rev, head = excluded.head').run(repo, id, nextSeq(db()), at, revOf(head), JSON.stringify(head))
|
|
64
|
+
}
|
|
65
|
+
const tx = <T>(fn: () => T): T => db().transaction(fn).immediate()
|
|
66
|
+
const io: CardBackend = {
|
|
67
|
+
rows: true,
|
|
68
|
+
names: () => (db().query('select id from review_cards where repo = ? order by id').all(repo) as { id: string }[]).map((r) => r.id),
|
|
69
|
+
has,
|
|
70
|
+
taken: (id) => has(id) || existsSync(join(dir, id)) || existsSync(join(spoolOf(dir), id)),
|
|
71
|
+
head: (id) => {
|
|
72
|
+
const r = headRow(id)
|
|
73
|
+
return r == null ? null : { head: JSON.parse(r.head) as unknown, at: r.at }
|
|
74
|
+
},
|
|
75
|
+
threadIds: (id) => (db().query('select id from review_msgs where repo = ? and card = ? order by id').all(repo, id) as { id: string }[]).map((r) => r.id),
|
|
76
|
+
message: (id, mid) => {
|
|
77
|
+
const r = db().query('select body from review_msgs where repo = ? and card = ? and id = ?').get(repo, id, mid) as { body: string } | null
|
|
78
|
+
if (r == null) throw Object.assign(new Error(`no message ${mid} of card ${id}`), { code: 'ENOENT' })
|
|
79
|
+
return JSON.parse(r.body) as unknown
|
|
80
|
+
},
|
|
81
|
+
hasMessage: (id, mid) => db().query('select 1 from review_msgs where repo = ? and card = ? and id = ?').get(repo, id, mid) != null,
|
|
82
|
+
raw: (id) => {
|
|
83
|
+
const r = headRow(id)
|
|
84
|
+
return r == null ? null : readCard(r.head, messages(id))
|
|
85
|
+
},
|
|
86
|
+
create: (id, tmp, head) => {
|
|
87
|
+
const { readdirSync, rmSync } = require('node:fs') as typeof import('node:fs')
|
|
88
|
+
// the media first, into the spool, so no reader sees a head that names a file not there yet
|
|
89
|
+
if (readdirSync(tmp).length > 0) moveFolder(tmp, join(spoolOf(dir), id))
|
|
90
|
+
else rmSync(tmp, { recursive: true, force: true })
|
|
91
|
+
tx(() => {
|
|
92
|
+
if (has(id)) throw new Error(`${id}: another item took this id meanwhile, add it again`)
|
|
93
|
+
write(id, head, Date.now())
|
|
94
|
+
})
|
|
95
|
+
},
|
|
96
|
+
write: (id, head, at) => tx(() => write(id, head, at ?? Date.now())),
|
|
97
|
+
append: (id, m) =>
|
|
98
|
+
tx(() => {
|
|
99
|
+
if (!has(id)) throw noCard(id)
|
|
100
|
+
const ran = db().query('insert into review_msgs (repo, card, id, rev, body) values (?, ?, ?, ?, ?) on conflict (repo, card, id) do nothing').run(repo, id, m.id, revOf(m), JSON.stringify(m))
|
|
101
|
+
if (ran.changes === 0) throw Object.assign(new Error(`message ${m.id} of card ${id}: another message holds that id`), { code: 'EEXIST' })
|
|
102
|
+
db().query('update review_cards set seq = ? where repo = ? and id = ?').run(nextSeq(db()), repo, id)
|
|
103
|
+
}),
|
|
104
|
+
lock: (_id, fn) => tx(fn),
|
|
105
|
+
setAside: (id, o) => {
|
|
106
|
+
let entry = id
|
|
107
|
+
const did = tx((): 'moved' | 'none' | 'other' => {
|
|
108
|
+
const r = headRow(id)
|
|
109
|
+
if (r == null) return 'none'
|
|
110
|
+
const cur = JSON.parse(r.head) as { created?: unknown }
|
|
111
|
+
if (o.created !== undefined && cur.created !== o.created) return 'other'
|
|
112
|
+
if (o.before !== undefined && !(Date.parse(String(cur.created)) < o.before)) return 'other'
|
|
113
|
+
const taken = new Set((db().query('select entry from review_gone where repo = ? and id = ?').all(repo, id) as { entry: string }[]).map((g) => g.entry))
|
|
114
|
+
for (let n = 2; taken.has(entry); n++) entry = `${id}.${n}`
|
|
115
|
+
const thread = JSON.stringify(messages(id).map((m) => JSON.parse(m.body) as unknown))
|
|
116
|
+
db().query('insert into review_gone (repo, entry, id, created, seq, at, head, thread) values (?, ?, ?, ?, ?, ?, ?, ?)').run(repo, entry, id, String(cur.created ?? ''), nextSeq(db()), Date.now(), r.head, thread)
|
|
117
|
+
db().query('delete from review_msgs where repo = ? and card = ?').run(repo, id)
|
|
118
|
+
db().query('delete from review_cards where repo = ? and id = ?').run(repo, id)
|
|
119
|
+
return 'moved'
|
|
120
|
+
})
|
|
121
|
+
// its media go aside with it, and the sweep takes them with its row
|
|
122
|
+
const media = join(spoolOf(dir), id)
|
|
123
|
+
if (did === 'moved' && existsSync(media)) {
|
|
124
|
+
const { rmSync } = require('node:fs') as typeof import('node:fs')
|
|
125
|
+
rmSync(join(spoolOf(dir), GONE, entry), { recursive: true, force: true })
|
|
126
|
+
moveFolder(media, join(spoolOf(dir), GONE, entry))
|
|
127
|
+
}
|
|
128
|
+
return did
|
|
129
|
+
},
|
|
130
|
+
keepReplaced: (id, head) => void db().query('insert or replace into review_replaced (repo, id, at, head) values (?, ?, ?, ?)').run(repo, id, Date.now(), JSON.stringify(head)),
|
|
131
|
+
hasReplaced: (id) => db().query('select 1 from review_replaced where repo = ? and id = ?').get(repo, id) != null,
|
|
132
|
+
stamp: (id) => {
|
|
133
|
+
const r = db().query('select seq from review_cards where repo = ? and id = ?').get(repo, id) as { seq: number } | null
|
|
134
|
+
return r == null ? '-' : `#${r.seq}`
|
|
135
|
+
},
|
|
136
|
+
folder: (id) => join(spoolOf(dir), id),
|
|
137
|
+
}
|
|
138
|
+
// each call told the walk's line when a walk moved the store from under the held connection, never sqlite's words
|
|
139
|
+
for (const [k, v] of Object.entries(io)) if (typeof v === 'function') (io as unknown as Record<string, unknown>)[k] = walking(v as (...a: unknown[]) => unknown)
|
|
140
|
+
return io
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** a card from its rows, checked as the files' backend checks its files, with the same words */
|
|
144
|
+
function readCard(head: string, msgs: readonly { id: string; body: string }[]): ReviewItem {
|
|
145
|
+
const item = JSON.parse(head) as unknown
|
|
146
|
+
const problems = itemProblems(item)
|
|
147
|
+
if (problems.length > 0) throw new Error(`item.json: ${problems.join('; ')}`)
|
|
148
|
+
const thread = msgs.map((r) => {
|
|
149
|
+
if (!MESSAGE_RE.test(r.id)) throw new Error(`thread/${r.id}.json: not a message name`)
|
|
150
|
+
const m = JSON.parse(r.body) as unknown
|
|
151
|
+
const p = messageProblems(m, r.id)
|
|
152
|
+
if (p.length > 0) throw new Error(`thread/${r.id}.json: ${p.join('; ')}`)
|
|
153
|
+
return m as Message
|
|
154
|
+
})
|
|
155
|
+
return { item: item as Item, thread }
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
type Read = { x: ReviewItem } | { error: string }
|
|
159
|
+
type Held = { top: { cards: number; gone: number }; reads: Map<string, Read>; all: ReadAll }
|
|
160
|
+
/** every store this process read, by its connection and its repo: read again only for the cards whose number moved */
|
|
161
|
+
const helds = new WeakMap<Database, Map<string, Held>>()
|
|
162
|
+
|
|
163
|
+
/** one card's read, its error kept as the files' backend keeps a broken folder */
|
|
164
|
+
const readOf = (head: string, msgs: readonly { id: string; body: string }[]): Read => {
|
|
165
|
+
try {
|
|
166
|
+
return { x: readCard(head, msgs) }
|
|
167
|
+
} catch (e) {
|
|
168
|
+
return { error: (e as Error).message }
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** every card of a store folder's repo, as one read of the rows the first time a process asks, then only the cards
|
|
173
|
+
* written since. A count that disagrees with what is held reads every card again: a card never stays shown after
|
|
174
|
+
* it went, nor missing after it came */
|
|
175
|
+
function rowsAllHere(dir: string): ReadAll {
|
|
176
|
+
// the repo first: its own ask for the connection may open it again after a walk, never under the one held here
|
|
177
|
+
const repo = repoIdOf(dir)
|
|
178
|
+
const db = cardsDb()
|
|
179
|
+
let byRepo = helds.get(db)
|
|
180
|
+
if (byRepo == null) helds.set(db, (byRepo = new Map()))
|
|
181
|
+
// the numbers before the rows: a write between the two is read again next time, never lost
|
|
182
|
+
const top = repoTop(db, repo)
|
|
183
|
+
const held = byRepo.get(repo)
|
|
184
|
+
if (held != null && held.top.cards === top.cards && held.top.gone === top.gone) return held.all
|
|
185
|
+
let reads: Map<string, Read>
|
|
186
|
+
if (held == null) reads = readEvery(db, repo)
|
|
187
|
+
else {
|
|
188
|
+
reads = held.reads
|
|
189
|
+
const moved = db.query('select id, head from review_cards where repo = ? and seq > ?').all(repo, held.top.cards) as { id: string; head: string }[]
|
|
190
|
+
const msg = db.query('select id, body from review_msgs where repo = ? and card = ? order by id')
|
|
191
|
+
for (const r of moved) reads.set(r.id, readOf(r.head, msg.all(repo, r.id) as { id: string; body: string }[]))
|
|
192
|
+
for (const g of db.query('select distinct id from review_gone where repo = ? and seq > ?').all(repo, held.top.gone) as { id: string }[])
|
|
193
|
+
if (db.query('select 1 from review_cards where repo = ? and id = ?').get(repo, g.id) == null) reads.delete(g.id)
|
|
194
|
+
const n = (db.query('select count(*) as n from review_cards where repo = ?').get(repo) as { n: number }).n
|
|
195
|
+
if (n !== reads.size) reads = readEvery(db, repo)
|
|
196
|
+
}
|
|
197
|
+
const all: ReadAll = { items: [], broken: [] }
|
|
198
|
+
for (const id of [...reads.keys()].sort()) {
|
|
199
|
+
const r = reads.get(id) as Read
|
|
200
|
+
if ('x' in r) all.items.push(r.x)
|
|
201
|
+
else all.broken.push({ id, error: r.error })
|
|
202
|
+
}
|
|
203
|
+
byRepo.set(repo, { top, reads, all })
|
|
204
|
+
return all
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function readEvery(db: Database, repo: string): Map<string, Read> {
|
|
208
|
+
const msgs = new Map<string, { id: string; body: string }[]>()
|
|
209
|
+
for (const m of db.query('select card, id, body from review_msgs where repo = ? order by card, id').all(repo) as { card: string; id: string; body: string }[]) {
|
|
210
|
+
const l = msgs.get(m.card)
|
|
211
|
+
if (l == null) msgs.set(m.card, [{ id: m.id, body: m.body }])
|
|
212
|
+
else l.push({ id: m.id, body: m.body })
|
|
213
|
+
}
|
|
214
|
+
const reads = new Map<string, Read>()
|
|
215
|
+
for (const r of db.query('select id, head from review_cards where repo = ?').all(repo) as { id: string; head: string }[]) reads.set(r.id, readOf(r.head, msgs.get(r.id) ?? []))
|
|
216
|
+
return reads
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** the cards a store's repo set aside, as the files' `.gone` names them: each one's id and its entry */
|
|
220
|
+
const rowsGoneHere = (dir: string): { id: string; entry: string }[] => cardsDb().query('select id, entry from review_gone where repo = ? order by entry').all(repoIdOf(dir)) as { id: string; entry: string }[]
|
|
221
|
+
|
|
222
|
+
/** the `created` of a card set aside, null when it has none */
|
|
223
|
+
function rowsGoneCreatedHere(dir: string, entry: string): string | null {
|
|
224
|
+
const r = cardsDb().query('select created from review_gone where repo = ? and entry = ?').get(repoIdOf(dir), entry) as { created: string } | null
|
|
225
|
+
return r == null || r.created === '' ? null : r.created
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function rowsGoneUseHere(dir: string): { count: number; oldest: number | null } {
|
|
229
|
+
const r = cardsDb().query('select count(*) as count, min(at) as oldest from review_gone where repo = ?').get(repoIdOf(dir)) as { count: number; oldest: number | null }
|
|
230
|
+
return { count: r.count, oldest: r.oldest }
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** the cards set aside before `now - keepMs` go for good: how many */
|
|
234
|
+
function rowsSweepGoneHere(dir: string, now: number, keepMs: number): number {
|
|
235
|
+
const repo = repoIdOf(dir)
|
|
236
|
+
const old = (cardsDb().query('select entry from review_gone where repo = ? and at < ?').all(repo, now - keepMs) as { entry: string }[]).map((g) => g.entry)
|
|
237
|
+
const n = cardsDb().query('delete from review_gone where repo = ? and at < ?').run(repo, now - keepMs).changes
|
|
238
|
+
const { rmSync } = require('node:fs') as typeof import('node:fs')
|
|
239
|
+
for (const e of old) rmSync(join(spoolOf(dir), GONE, e), { recursive: true, force: true })
|
|
240
|
+
return n
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** a card set aside in the files, kept as a row of the cards gone under the same entry; false when one is there */
|
|
244
|
+
function rowsKeepGoneHere(dir: string, g: { entry: string; id: string; created: string; at: number; head: unknown; thread: unknown[] }): boolean {
|
|
245
|
+
const db = cardsDb()
|
|
246
|
+
const repo = repoIdOf(dir)
|
|
247
|
+
return db.transaction(() => {
|
|
248
|
+
if (db.query('select 1 from review_gone where repo = ? and entry = ?').get(repo, g.entry) != null) return false
|
|
249
|
+
db.query('insert into review_gone (repo, entry, id, created, seq, at, head, thread) values (?, ?, ?, ?, ?, ?, ?, ?)').run(repo, g.entry, g.id, g.created, nextSeq(db), g.at, JSON.stringify(g.head), JSON.stringify(g.thread))
|
|
250
|
+
return true
|
|
251
|
+
}).immediate()
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** the stamp of a store folder's rows: 'none' while its repo holds no card and no card gone, as a folder that is not */
|
|
255
|
+
function rowsStampHere(dir: string): string {
|
|
256
|
+
const top = repoTop(cardsDb(), repoIdOf(dir))
|
|
257
|
+
return top.cards === 0 && top.gone === 0 ? 'none' : `rows.${top.cards}.${top.gone}`
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// the store's reads and writes, each told the walk's line when a walk moved the store from under the held connection
|
|
261
|
+
export const rowsAll = walking(rowsAllHere)
|
|
262
|
+
export const rowsGone = walking(rowsGoneHere)
|
|
263
|
+
export const rowsGoneCreated = walking(rowsGoneCreatedHere)
|
|
264
|
+
export const rowsGoneUse = walking(rowsGoneUseHere)
|
|
265
|
+
export const rowsSweepGone = walking(rowsSweepGoneHere)
|
|
266
|
+
export const rowsKeepGone = walking(rowsKeepGoneHere)
|
|
267
|
+
export const rowsStamp = walking(rowsStampHere)
|