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,112 @@
|
|
|
1
|
+
// the vault route (wiki services/secrets, Another Mac): the one vault, the master beside the hq, read by another
|
|
2
|
+
// machine of the house through the hq's port, which tailscale serves to the tailnet over https. bao itself never
|
|
3
|
+
// leaves loopback. A read passes only as a GET of a name, its metadata, the token's own lookup or the health, from a
|
|
4
|
+
// live node (its hq token), from the tailnet device bound to that node (tailscale's whois), with the vault token the
|
|
5
|
+
// hq gave that node; then bao applies the node's policy. The one constraint a reader breaks first: a node token
|
|
6
|
+
// holds create, update and delete on its folders, so the method and path filter below is the route's only write
|
|
7
|
+
// guard, and the upstream request is built from the matched path and the vault token alone
|
|
8
|
+
import type { HqNode, HqStore, Refused } from './hq-store.ts'
|
|
9
|
+
import type { VaultMinter } from './vault-grant.ts'
|
|
10
|
+
import { isPhone, ownersDevice, servedCaller, type TailnetPeer, type TailnetWho } from '../serve/tailnet-caller.ts'
|
|
11
|
+
|
|
12
|
+
/** the route's prefix under the hq's own `/hq/` */
|
|
13
|
+
export const VAULT_ROUTE = 'vault/'
|
|
14
|
+
/** one call to bao on loopback: a reader on another machine waits 1.5 s in all (secrets/read.ts) */
|
|
15
|
+
const BAO_MS = 1_000
|
|
16
|
+
/** a reader row's last read is written at most once a minute a node */
|
|
17
|
+
const READ_MARK_MS = 60_000
|
|
18
|
+
|
|
19
|
+
const SEGMENT = '[a-z0-9_~-][a-z0-9._~-]*'
|
|
20
|
+
/** what passes, matched on the path tailscaled and URL normalised: a segment never of dots alone, never `*` */
|
|
21
|
+
const PASSES = new RegExp(`^v1/(?:rv/(?:data|metadata)/${SEGMENT}(?:/${SEGMENT})*|auth/token/lookup-self|sys/health)$`)
|
|
22
|
+
|
|
23
|
+
/** the bao path a request may read, or null: GET only, no query, the shape above */
|
|
24
|
+
export function passing(req: Request, rest: string): string | null {
|
|
25
|
+
if (req.method !== 'GET' || new URL(req.url).search !== '') return null
|
|
26
|
+
return PASSES.test(rest) ? rest : null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type Reader = { node: string; device: string; name: string; os: string; bound: number; read_at: number | null }
|
|
30
|
+
export const readerOf = (store: HqStore, node: string): Reader | null => store.db.query('select node, device, name, os, bound, read_at from vault_readers where node = ?').get(node) as Reader | null
|
|
31
|
+
|
|
32
|
+
/** `errors` as bao words its own, so a reader's vault client says the route's reason */
|
|
33
|
+
const refuse = (refused: string, status = 403): Response => Response.json({ refused, errors: [refused] }, { status })
|
|
34
|
+
|
|
35
|
+
/** the tailnet device a request came from, an untagged device of the hq Mac's owner and no phone; or why not */
|
|
36
|
+
async function deviceOf(req: Request, who: TailnetWho | undefined): Promise<TailnetPeer | Refused> {
|
|
37
|
+
const caller = servedCaller(req.headers)
|
|
38
|
+
if ('refused' in caller) return caller
|
|
39
|
+
if (who == null) return { refused: 'this hq asks no tailscale: it reads no tailnet device' }
|
|
40
|
+
const self = await who.self()
|
|
41
|
+
if (self == null) return { refused: 'tailscale does not answer on the Mac that carries the hq' }
|
|
42
|
+
const peer = await ownersDevice(who, self, caller)
|
|
43
|
+
if ('refused' in peer) return peer
|
|
44
|
+
if (isPhone(peer)) return { refused: `${peer.node} is a phone: no reader of the vault` }
|
|
45
|
+
return peer
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const otherDevice = (peer: TailnetPeer, r: Reader): string =>
|
|
49
|
+
peer.node === r.name
|
|
50
|
+
? `${peer.node} came back under another tailscale id than the one bound to this node (a logout and login of tailscale): on the Mac that carries the hq, sk hq end <this node>, then a new invite`
|
|
51
|
+
: `${peer.node} is not the device bound to this node (${r.name}): a node reads the vault from its own device only`
|
|
52
|
+
|
|
53
|
+
/** `GET /hq/vault/v1/<path>`: every proof, then bao's answer with its content type alone */
|
|
54
|
+
export async function vaultRoute(store: HqStore, req: Request, rest: string, now: number, o: { vault?: VaultMinter; who?: TailnetWho }): Promise<Response> {
|
|
55
|
+
const path = passing(req, rest)
|
|
56
|
+
if (path == null) return refuse('the vault route answers a GET of a name, its metadata, lookup-self or the health, and nothing else', 404)
|
|
57
|
+
const token = /^Bearer (.+)$/.exec(req.headers.get('authorization') ?? '')?.[1] ?? ''
|
|
58
|
+
const node = store.nodeOf(token)
|
|
59
|
+
if (node == null) return refuse('this hq token is unknown or was ended: the vault route reads for a live node only')
|
|
60
|
+
const peer = await deviceOf(req, o.who)
|
|
61
|
+
if ('refused' in peer) return refuse(peer.refused)
|
|
62
|
+
const r = readerOf(store, node.id)
|
|
63
|
+
if (r == null) return refuse('this node has no device bound: its first vault token asked over the tailnet binds the device it came from')
|
|
64
|
+
if (peer.id !== r.device) return refuse(otherDevice(peer, r))
|
|
65
|
+
const vaultToken = req.headers.get('x-vault-token') ?? ''
|
|
66
|
+
if (vaultToken === '') return refuse('no vault token: ask your hq for one (the vault job of your daemon)')
|
|
67
|
+
const api = o.vault?.()
|
|
68
|
+
if (api == null) return refuse("the Mac that carries the hq runs no vault, or it is not initialised (sk vault status there)", 503)
|
|
69
|
+
const held = store.db.query('select accessor from vault_tokens where node = ?').get(node.id) as { accessor: string } | null
|
|
70
|
+
let accessor: string | null = null
|
|
71
|
+
try {
|
|
72
|
+
const look = await fetch(`${api.url}/v1/auth/token/lookup-self`, { headers: { 'X-Vault-Token': vaultToken }, signal: AbortSignal.timeout(BAO_MS) })
|
|
73
|
+
const body = (await look.json().catch(() => ({}))) as { data?: { accessor?: string } }
|
|
74
|
+
if (look.ok) accessor = body.data?.accessor ?? null
|
|
75
|
+
} catch (e) {
|
|
76
|
+
return refuse(`the vault does not answer on the Mac that carries the hq: ${(e as Error).message}`, 503)
|
|
77
|
+
}
|
|
78
|
+
if (accessor == null) return refuse('this vault token is dead or unknown to the vault: ask your hq for a new one')
|
|
79
|
+
if (held == null || held.accessor !== accessor) return refuse('this vault token is not the one the hq gave this node: ask your hq for a new one')
|
|
80
|
+
let up: Response
|
|
81
|
+
try {
|
|
82
|
+
up = await fetch(`${api.url}/${path}`, { method: 'GET', headers: { 'X-Vault-Token': vaultToken }, redirect: 'manual', signal: AbortSignal.timeout(BAO_MS) })
|
|
83
|
+
} catch (e) {
|
|
84
|
+
return refuse(`the vault does not answer on the Mac that carries the hq: ${(e as Error).message}`, 503)
|
|
85
|
+
}
|
|
86
|
+
if (r.read_at == null || now - r.read_at >= READ_MARK_MS) store.db.query('update vault_readers set read_at = ? where node = ?').run(now, node.id)
|
|
87
|
+
return new Response(await up.arrayBuffer(), { status: up.status, headers: { 'content-type': up.headers.get('content-type') ?? 'application/json' } })
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** a mint's own proof, before any call to bao: over the tailnet, the device bound to the node (or none bound yet);
|
|
91
|
+
* with no forwarded header, only a node of the hq's own machine with no device bound. `bind` keeps the device once
|
|
92
|
+
* the mint made its token */
|
|
93
|
+
export async function mintProof(store: HqStore, req: Request, node: HqNode, o: { who?: TailnetWho; ownMachine?: string }): Promise<{ bind: (now: number) => void } | Refused> {
|
|
94
|
+
const r = readerOf(store, node.id)
|
|
95
|
+
if (!req.headers.has('x-forwarded-for')) {
|
|
96
|
+
if (o.ownMachine != null && node.machine !== o.ownMachine) return { refused: 'a vault token for a node of another machine is asked over the tailnet, never on loopback' }
|
|
97
|
+
if (r != null) return { refused: `this node reads the vault from the device bound to it (${r.name}): it asks its token from there` }
|
|
98
|
+
return { bind: () => {} }
|
|
99
|
+
}
|
|
100
|
+
const peer = await deviceOf(req, o.who)
|
|
101
|
+
if ('refused' in peer) return peer
|
|
102
|
+
if (r != null) return peer.id === r.device ? { bind: () => {} } : { refused: otherDevice(peer, r) }
|
|
103
|
+
return {
|
|
104
|
+
bind: (now) => void store.db.query('insert into vault_readers (node, device, name, os, bound) values (?, ?, ?, ?, ?) on conflict (node) do nothing').run(node.id, peer.id, peer.node, peer.os, now),
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type VaultReader = { node: string; machine: string; device: string; os: string; bound: number; readAt: number | null; minted: number | null }
|
|
109
|
+
|
|
110
|
+
/** every live node bound to a device, for `sk vault status` and the page: names and days, never a token */
|
|
111
|
+
export const vaultReaders = (store: HqStore): VaultReader[] =>
|
|
112
|
+
(store.db.query('select r.node, m.name as machine, r.name as device, r.os, r.bound, r.read_at as readAt, t.minted from vault_readers r join nodes n on n.id = r.node and n.ended is null join machines m on m.id = n.machine left join vault_tokens t on t.node = r.node order by m.name').all() as VaultReader[])
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { existsSync } from 'node:fs'
|
|
6
6
|
import { join } from 'node:path'
|
|
7
7
|
import { type Collection, type Instance } from '../collections/collection-types.ts'
|
|
8
|
-
import {
|
|
8
|
+
import { HOUSE_LAYOUT } from '../core/house-layout.ts'
|
|
9
9
|
import { DEFAULT_HOME_PORT } from '../home/home-paths.ts'
|
|
10
10
|
import { identityAddress } from '../serve/hub-app/identity-address.ts'
|
|
11
11
|
import { readIdentities, type Identities } from './identities.ts'
|
|
@@ -43,7 +43,7 @@ export function pictureNeeds(ids: Identities, home = `http://127.0.0.1:${DEFAULT
|
|
|
43
43
|
|
|
44
44
|
/** only in the repo that holds the identities folder, the house repo */
|
|
45
45
|
export function picturesCollection(root: string): Collection | null {
|
|
46
|
-
const dir = join(root,
|
|
46
|
+
const dir = join(root, HOUSE_LAYOUT.identities)
|
|
47
47
|
if (!existsSync(dir)) return null
|
|
48
48
|
return { id: PICTURES_COL, title: 'pictures', kind: 'ask', media: 'text', list: async () => pictureNeeds(readIdentities(dir)) }
|
|
49
49
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// the identities, who speaks (wiki
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// the identities, who speaks (wiki meta/identity-folder): one folder an identity in the house repo,
|
|
2
|
+
// `wiki/identities/<id>/`, its profile, brand, accounts and their places, and a company's legal rows. A folder whose
|
|
3
|
+
// name starts with `_` (`_common/`) is the owner's, no identity. Read from the disk as it is on every call; the one
|
|
4
|
+
// constraint: never in the npm package, a project names its identity
|
|
4
5
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
|
5
6
|
import { homedir } from 'node:os'
|
|
6
7
|
import { isAbsolute, join } from 'node:path'
|
|
7
|
-
import {
|
|
8
|
+
import { HOUSE_LAYOUT } from '../core/house-layout.ts'
|
|
8
9
|
import { parseFrontmatter, rows, section, table, type ProfileRow } from '../social/md.ts'
|
|
9
10
|
import { ceilingOf, ratingIn, type PostRating } from './rating.ts'
|
|
10
11
|
import { uploadsOf, type Upload } from './shown.ts'
|
|
@@ -89,7 +90,7 @@ export type Account = {
|
|
|
89
90
|
footer: string
|
|
90
91
|
/** live, free, paid, limited or none */
|
|
91
92
|
automation: string
|
|
92
|
-
/** with `automation: live`, the secret name of its token, read through the house
|
|
93
|
+
/** with `automation: live`, the secret name of its token, read through the house store */
|
|
93
94
|
secret: string
|
|
94
95
|
/** Discord: the server's id, its messages' links and the bot's posts */
|
|
95
96
|
guild: string
|
|
@@ -168,12 +169,11 @@ const read = (abs: string): string => readFileSync(abs, 'utf8')
|
|
|
168
169
|
const home = (p: string): string => (p.startsWith('~/') ? join(homedir(), p.slice(2)) : p)
|
|
169
170
|
|
|
170
171
|
/** the folder of every identity: `SHIPKIT_IDENTITIES_DIR`, else the house repo's; null when this machine has no house */
|
|
171
|
-
export async function identitiesDir(cwd = process.cwd()): Promise<string | null> {
|
|
172
|
+
export async function identitiesDir(cwd = process.cwd(), known?: string | null): Promise<string | null> {
|
|
172
173
|
const env = process.env['SHIPKIT_IDENTITIES_DIR']
|
|
173
174
|
if (env) return env
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
return house == null ? null : join(house, LAYOUT.identities)
|
|
175
|
+
const house = known !== undefined ? known : (await import('../home/home-start.ts')).houseRootOf(cwd)
|
|
176
|
+
return house == null ? null : join(house, HOUSE_LAYOUT.identities)
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/** the words a `write` link fills from a message (`fillLink`) */
|
|
@@ -498,12 +498,12 @@ function identity(id: string, dir: string, errors: string[]): Identity {
|
|
|
498
498
|
/** every identity in its order; a broken folder is an error line, never a silence */
|
|
499
499
|
export function readIdentities(dir: string | null): Identities {
|
|
500
500
|
const errors: string[] = []
|
|
501
|
-
if (dir == null) return { dir, identities: [], errors: [
|
|
501
|
+
if (dir == null) return { dir, identities: [], errors: [`no house repo on this machine: the identities live in its ${HOUSE_LAYOUT.identities}/`] }
|
|
502
502
|
if (!existsSync(dir)) return { dir, identities: [], errors: [`${dir}: no identities folder`] }
|
|
503
503
|
const out: Identity[] = []
|
|
504
504
|
for (const id of readdirSync(dir).sort()) {
|
|
505
505
|
const idir = join(dir, id)
|
|
506
|
-
if (!statSync(idir).isDirectory()) continue
|
|
506
|
+
if (id.startsWith('_') || !statSync(idir).isDirectory()) continue
|
|
507
507
|
if (!SLUG.test(id)) errors.push(`${idir}: an identity id is kebab case`)
|
|
508
508
|
else if (!existsSync(join(idir, 'identity.md'))) errors.push(`${idir}: no identity.md`)
|
|
509
509
|
else out.push(identity(id, idir, errors))
|
|
@@ -524,6 +524,19 @@ export function speakerOf(speaksAs: string | undefined, ids: Identities): Identi
|
|
|
524
524
|
return ids.identities.find((i) => i.default) ?? ids.identities[0] ?? null
|
|
525
525
|
}
|
|
526
526
|
|
|
527
|
+
/** the id `speakerOf` answers, from the folder names and each `identity.md`'s head alone: a scope check asks it at
|
|
528
|
+
* every secret read, where the whole model costs 50 ms */
|
|
529
|
+
export function speakerIdIn(dir: string | null, speaksAs: string | undefined): string | null {
|
|
530
|
+
if (dir == null || !existsSync(dir)) return null
|
|
531
|
+
const has = (id: string): boolean => SLUG.test(id) && existsSync(join(dir, id, 'identity.md')) && statSync(join(dir, id)).isDirectory()
|
|
532
|
+
if (speaksAs != null) return has(speaksAs) ? speaksAs : null
|
|
533
|
+
const heads = readdirSync(dir)
|
|
534
|
+
.filter(has)
|
|
535
|
+
.map((id) => ({ id, meta: parseFrontmatter(read(join(dir, id, 'identity.md'))).meta }))
|
|
536
|
+
.sort((a, b) => Number(a.meta.order ?? 99) - Number(b.meta.order ?? 99) || a.id.localeCompare(b.id))
|
|
537
|
+
return (heads.find((h) => h.meta.default === 'true') ?? heads[0])?.id ?? null
|
|
538
|
+
}
|
|
539
|
+
|
|
527
540
|
/** one identity by id, or a loud error naming the ones there are */
|
|
528
541
|
export function identityOf(id: string, ids: Identities): Identity {
|
|
529
542
|
const i = ids.identities.find((x) => x.id === id)
|
|
@@ -5,7 +5,10 @@ import { existsSync, readdirSync } from 'node:fs'
|
|
|
5
5
|
import { homedir } from 'node:os'
|
|
6
6
|
import { openInCode } from '../serve/project-gutter-route.ts'
|
|
7
7
|
import { houseRepoRoots } from '../social/house.ts'
|
|
8
|
-
import {
|
|
8
|
+
import { cardsDb } from '../review/card-db.ts'
|
|
9
|
+
import { eventsRepo } from '../review/events.ts'
|
|
10
|
+
import { storeDir } from '../review/store.ts'
|
|
11
|
+
import { postMediaDir } from '../social/post-sources.ts'
|
|
9
12
|
import { veilleLogDir } from '../veille/identity.ts'
|
|
10
13
|
import { identitiesDir, readIdentities, type Identities, type Identity } from './identities.ts'
|
|
11
14
|
import { railOf, speakerIdOf, type RailIdentity } from './machine.ts'
|
|
@@ -64,9 +67,11 @@ function placesOf(i: Identity, repos: Repo[], ids: Identities): (DataPlace & { a
|
|
|
64
67
|
if (i.files != null && i.files !== i.dir) out.push({ place: 'pictures', repo: null, label: 'its pictures (files: in identity.md)', abs: i.files, shown: '', exists: existsSync(i.files), count: null })
|
|
65
68
|
const log = veilleLogDir(i.id)
|
|
66
69
|
out.push({ place: 'veille', repo: null, label: 'its Veille log, this machine only', abs: log, shown: '', exists: existsSync(log), count: count(log, (n) => n.endsWith('.jsonl')) })
|
|
70
|
+
// a repo's posts are events of the thread store; the place shown is the copy of their files
|
|
67
71
|
for (const r of mine) {
|
|
68
|
-
const d =
|
|
69
|
-
|
|
72
|
+
const d = postMediaDir(r.path)
|
|
73
|
+
const groups = (cardsDb().query('select count(*) as n from thread_post_groups where repo = ?').get(eventsRepo(storeDir(r.path))) as { n: number } | null)?.n ?? 0
|
|
74
|
+
out.push({ place: 'drafts', repo: r.name, label: `the posts of ${r.name} (their words in the thread store), their files`, abs: d, shown: '', exists: existsSync(d), count: groups })
|
|
70
75
|
}
|
|
71
76
|
return out.map((p) => ({ ...p, shown: tilde(p.abs) }))
|
|
72
77
|
}
|
package/src/identities/steps.ts
CHANGED
|
@@ -3,3 +3,34 @@
|
|
|
3
3
|
|
|
4
4
|
/** the rows the steps name, `[[field]]`: the form he fills */
|
|
5
5
|
export const stepRefs = (list: readonly { text: string }[]): Set<string> => new Set(list.flatMap((s) => [...s.text.matchAll(/\[\[([^\]]+)\]\]/g)].map((m) => m[1]!)))
|
|
6
|
+
|
|
7
|
+
/** a step's secret: `[[secret:<name>]]` draws the field that stores that name, in the step itself */
|
|
8
|
+
const SECRET_REF = /^secret:([a-z0-9][a-z0-9/_-]*)$/
|
|
9
|
+
|
|
10
|
+
/** the secret a ref names; null for a row's ref */
|
|
11
|
+
export const secretOfRef = (ref: string): string | null => SECRET_REF.exec(ref)?.[1] ?? null
|
|
12
|
+
|
|
13
|
+
/** every secret the steps take, in their order */
|
|
14
|
+
export const stepSecrets = (list: readonly { text: string }[]): string[] => [...stepRefs(list)].flatMap((r) => secretOfRef(r) ?? [])
|
|
15
|
+
|
|
16
|
+
/** a step that tells a story in place of an act: what was set for him, or a state of his screen to check */
|
|
17
|
+
const STORY = /\bonly a look\b|\bcheck that [^.;]* reads\b|\bset (?:it|them) through\b/i
|
|
18
|
+
|
|
19
|
+
/** the rows a Discord bot's steps name: each field of the developer portal that holds words or a picture of ours */
|
|
20
|
+
export const BOT_ROWS = ['bot name', 'bot description', 'bot tags', 'bot banner'] as const
|
|
21
|
+
|
|
22
|
+
/** what is wrong in an account's setup steps, one line each:
|
|
23
|
+
* - a step still to do that sends him elsewhere to store a secret (an ask's page, a command to type): the step holds
|
|
24
|
+
* the field. A done step is history and stays as written
|
|
25
|
+
* - a Discord account's bot token taken with no profile for the bot: its name and its description are rows the steps name */
|
|
26
|
+
export function setupProblems(a: { id: string; secret: string; steps: readonly { text: string; done?: boolean }[] }): string[] {
|
|
27
|
+
const out: string[] = []
|
|
28
|
+
for (const [i, s] of a.steps.entries())
|
|
29
|
+
if (!s.done && /#item:asks:|\b[\w-]*secret set\b/.test(s.text)) out.push(`step ${i + 1} sends him elsewhere to store a secret: write [[secret:<name>]] in the step, which draws the field there`)
|
|
30
|
+
for (const [i, s] of a.steps.entries())
|
|
31
|
+
if (!s.done && STORY.test(s.text)) out.push(`step ${i + 1} tells what was done or what the screen should read: name the control and the value he sets it to`)
|
|
32
|
+
const refs = stepRefs(a.steps)
|
|
33
|
+
if (a.id === 'discord' && a.secret !== '' && stepSecrets(a.steps).includes(a.secret))
|
|
34
|
+
for (const row of BOT_ROWS) if (!refs.has(row)) out.push(`the steps take the bot's token and never name [[${row}]]: a bot he creates needs its name, its description, its tags and its banner in the steps, page by page of the platform's form`)
|
|
35
|
+
return out
|
|
36
|
+
}
|
package/src/ledger/db.ts
CHANGED
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
// of the repo shares it, which is safe for answers because no key component
|
|
25
25
|
// is a path (ledger/toolchain-identity.ts).
|
|
26
26
|
import { Database } from 'bun:sqlite'
|
|
27
|
-
import { existsSync, mkdirSync } from 'fs'
|
|
28
|
-
import { dirname, join } from 'path'
|
|
27
|
+
import { chmodSync, existsSync, mkdirSync, readdirSync, rmSync, statSync } from 'fs'
|
|
28
|
+
import { basename, dirname, join } from 'path'
|
|
29
29
|
|
|
30
30
|
import { shipkitRoot } from '../core/git-root.ts'
|
|
31
|
+
import { createRefusal } from '../core/machine-layout.ts'
|
|
31
32
|
export { shipkitRoot }
|
|
32
33
|
|
|
33
34
|
export const DB_FILE = 'shipkit.sqlite'
|
|
@@ -195,9 +196,16 @@ export type Opened = { db: Database }
|
|
|
195
196
|
* a handle the caller CLOSES. Null for every failure there is: no path, no
|
|
196
197
|
* db and `create: false`, a corrupt file, a locked one, a read only disk. */
|
|
197
198
|
export function openDb(path: string, o: { create?: boolean; busyMs?: number } = {}): Opened | null {
|
|
199
|
+
return openWith(path, o, migrate)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** the same open for another database of shipkit's (the hq's): its own `schema` runs where the record's migration
|
|
203
|
+
* does, and every failure is null the same way */
|
|
204
|
+
export function openWith(path: string, o: { create?: boolean; busyMs?: number }, schema: (db: Database) => void): Opened | null {
|
|
198
205
|
if (path === '') return null
|
|
199
206
|
const create = o.create !== false
|
|
200
207
|
if (!create && !existsSync(path)) return null
|
|
208
|
+
if (create && createRefusal(path) != null) return null
|
|
201
209
|
let db: Database | null = null
|
|
202
210
|
try {
|
|
203
211
|
if (create) mkdirSync(dirname(path), { recursive: true })
|
|
@@ -207,11 +215,12 @@ export function openDb(path: string, o: { create?: boolean; busyMs?: number } =
|
|
|
207
215
|
// another process's transaction instead of failing
|
|
208
216
|
db.exec(`pragma busy_timeout = ${busyMs}`)
|
|
209
217
|
ensureWal(db, busyMs)
|
|
210
|
-
db
|
|
211
|
-
|
|
218
|
+
storeSync(db, 'NORMAL')
|
|
219
|
+
schema(db)
|
|
212
220
|
return { db }
|
|
213
|
-
} catch {
|
|
221
|
+
} catch (e) {
|
|
214
222
|
try { db?.close() } catch { /* never opened, or already gone */ }
|
|
223
|
+
if (e instanceof NoCopy) console.error(`WARN ${e.message}`)
|
|
215
224
|
return null
|
|
216
225
|
}
|
|
217
226
|
}
|
|
@@ -238,33 +247,57 @@ export function ensureWal(db: Database, busyMs: number): void {
|
|
|
238
247
|
}
|
|
239
248
|
}
|
|
240
249
|
|
|
250
|
+
/** how a store's commits wait for the disk: `onMachine` on a machine; never in a suite, whose stores are scratch
|
|
251
|
+
* files in a temp home (tests/_setup.ts sets SHIPKIT_SUITE_HOME): a write's sync, and the checkpoint's when its last
|
|
252
|
+
* connection closes, were most of a suite's sqlite time, and a killed process still loses nothing the system holds */
|
|
253
|
+
export function storeSync(db: Database, onMachine: 'FULL' | 'NORMAL'): void {
|
|
254
|
+
db.exec(`pragma synchronous = ${process.env.SHIPKIT_SUITE_HOME === '1' ? 'OFF' : onMachine}`)
|
|
255
|
+
}
|
|
256
|
+
|
|
241
257
|
const userVersion = (db: Database): number => Number((db.query('pragma user_version').get() as { user_version?: number } | null)?.user_version ?? 0)
|
|
242
258
|
|
|
243
|
-
/**
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
259
|
+
/** a migration held for want of its copy: every open says it, the file stays as it was */
|
|
260
|
+
class NoCopy extends Error {
|
|
261
|
+
override readonly name = 'NoCopy'
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** where a file keeps itself from before its schema went to `version` */
|
|
265
|
+
export const beforeCopy = (path: string, version: number): string => `${path}.before-v${version}`
|
|
266
|
+
|
|
267
|
+
/** a file that held something keeps one whole copy of itself before its shape changes, mode 0600:
|
|
268
|
+
* the roles of a machine run the source as it is saved, so a migration that is wrong runs on a live file, and the
|
|
269
|
+
* copy is the way back. One copy a file: the next change of shape replaces it. No copy, no migration: a copy that
|
|
270
|
+
* cannot be made (a full disk) holds the file at its version and throws why */
|
|
271
|
+
function keepBefore(db: Database, was: number, version: number): void {
|
|
272
|
+
const path = db.filename
|
|
273
|
+
if (was <= 0 || path === '' || path === ':memory:') return
|
|
274
|
+
const to = beforeCopy(path, version)
|
|
275
|
+
try {
|
|
276
|
+
rmSync(to, { force: true })
|
|
277
|
+
db.exec(`vacuum into '${to.replace(/'/g, "''")}'`)
|
|
278
|
+
// the copy holds what the file held, whatever its own mode: the owner's only
|
|
279
|
+
chmodSync(to, 0o600)
|
|
280
|
+
for (const f of readdirSync(dirname(path))) if (f.startsWith(`${basename(path)}.before-v`) && f !== basename(to)) rmSync(join(dirname(path), f), { force: true })
|
|
281
|
+
} catch (e) {
|
|
282
|
+
try { rmSync(to, { force: true }) } catch { /* what is in the way stays: the next open says it again */ }
|
|
283
|
+
let mb = 0
|
|
284
|
+
try { mb = Math.ceil(statSync(path).size / 1e6) } catch { /* the size is unknown */ }
|
|
285
|
+
throw new NoCopy(`${path} stays at version ${was}: no copy of it could be made before it goes to version ${version} (${(e as Error).message}); free room on the disk (about ${mb} MB), then open it again`)
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** bring a file to `version`, once: `apply(was)` runs under the write lock, where the version is read a SECOND time,
|
|
290
|
+
* since two processes can open a fresh db at the same moment and the loser must find the schema already there */
|
|
291
|
+
export function migrateTo(db: Database, version: number, apply: (was: number) => void): void {
|
|
292
|
+
const seen = userVersion(db)
|
|
293
|
+
if (seen >= version) return
|
|
294
|
+
keepBefore(db, seen, version)
|
|
248
295
|
db.exec('begin immediate')
|
|
249
296
|
try {
|
|
250
297
|
const was = userVersion(db)
|
|
251
|
-
if (was <
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
// adds tables, v3 to v4 renames one, v4 to v5 adds one and v5 to
|
|
255
|
-
// v6 and every step to v9 add columns (v8 a table too), and v10
|
|
256
|
-
// adds a table, so their rows stay
|
|
257
|
-
if (was < 2) db.exec('drop table if exists runs; drop table if exists unit_last;')
|
|
258
|
-
else if (was < 4 && db.query("select 1 from sqlite_master where type = 'table' and name = 'unit_last'").get() != null) db.exec('alter table unit_last rename to check_last; alter table check_last rename column unit to id; drop index if exists runs_unit;')
|
|
259
|
-
const suites = db.query("select name from pragma_table_info('suites')").all() as { name: string }[]
|
|
260
|
-
if (suites.length > 0 && !suites.some((c) => c.name === 'check_id')) db.exec("alter table suites add column check_id text not null default ''")
|
|
261
|
-
if (suites.length > 0 && !suites.some((c) => c.name === 'unit')) db.exec("alter table suites add column unit text not null default ''")
|
|
262
|
-
if (suites.length > 0 && !suites.some((c) => c.name === 'cpu_ms')) db.exec('alter table suites add column cpu_ms integer default null')
|
|
263
|
-
if (suites.length > 0 && !suites.some((c) => c.name === 'phase')) db.exec("alter table suites add column phase text not null default ''")
|
|
264
|
-
if (suites.length > 0 && !suites.some((c) => c.name === 'phase_ms')) db.exec('alter table suites add column phase_ms integer default null')
|
|
265
|
-
if (suites.length > 0 && !suites.some((c) => c.name === 'fail_line')) db.exec("alter table suites add column fail_line text not null default ''")
|
|
266
|
-
db.exec(SCHEMA)
|
|
267
|
-
db.exec(`pragma user_version = ${SCHEMA_VERSION}`)
|
|
298
|
+
if (was < version) {
|
|
299
|
+
apply(was)
|
|
300
|
+
db.exec(`pragma user_version = ${version}`)
|
|
268
301
|
}
|
|
269
302
|
db.exec('commit')
|
|
270
303
|
} catch (e) {
|
|
@@ -273,6 +306,27 @@ function migrate(db: Database): void {
|
|
|
273
306
|
}
|
|
274
307
|
}
|
|
275
308
|
|
|
309
|
+
/** the record's own schema, once */
|
|
310
|
+
function migrate(db: Database): void {
|
|
311
|
+
migrateTo(db, SCHEMA_VERSION, (was) => {
|
|
312
|
+
// the pre-v2 tables carry a `kind` column and keys of the form
|
|
313
|
+
// `<kind>:<id>`, which no reader speaks any more. v2 to v3 only
|
|
314
|
+
// adds tables, v3 to v4 renames one, v4 to v5 adds one and v5 to
|
|
315
|
+
// v6 and every step to v9 add columns (v8 a table too), and v10
|
|
316
|
+
// adds a table, so their rows stay
|
|
317
|
+
if (was < 2) db.exec('drop table if exists runs; drop table if exists unit_last;')
|
|
318
|
+
else if (was < 4 && db.query("select 1 from sqlite_master where type = 'table' and name = 'unit_last'").get() != null) db.exec('alter table unit_last rename to check_last; alter table check_last rename column unit to id; drop index if exists runs_unit;')
|
|
319
|
+
const suites = db.query("select name from pragma_table_info('suites')").all() as { name: string }[]
|
|
320
|
+
if (suites.length > 0 && !suites.some((c) => c.name === 'check_id')) db.exec("alter table suites add column check_id text not null default ''")
|
|
321
|
+
if (suites.length > 0 && !suites.some((c) => c.name === 'unit')) db.exec("alter table suites add column unit text not null default ''")
|
|
322
|
+
if (suites.length > 0 && !suites.some((c) => c.name === 'cpu_ms')) db.exec('alter table suites add column cpu_ms integer default null')
|
|
323
|
+
if (suites.length > 0 && !suites.some((c) => c.name === 'phase')) db.exec("alter table suites add column phase text not null default ''")
|
|
324
|
+
if (suites.length > 0 && !suites.some((c) => c.name === 'phase_ms')) db.exec('alter table suites add column phase_ms integer default null')
|
|
325
|
+
if (suites.length > 0 && !suites.some((c) => c.name === 'fail_line')) db.exec("alter table suites add column fail_line text not null default ''")
|
|
326
|
+
db.exec(SCHEMA)
|
|
327
|
+
})
|
|
328
|
+
}
|
|
329
|
+
|
|
276
330
|
/** give the file back its free pages once more than half of it is free and
|
|
277
331
|
* that is worth it: a DELETE frees pages for reuse but never shrinks the
|
|
278
332
|
* file. VACUUM holds the write lock while it runs: a gate that asks then
|
|
@@ -77,6 +77,9 @@ export function rawAccessDecl(raw: string, toolkitCheckElsewhere: boolean): Pick
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
export const FULL_TESTS_ENV = 'SHIPKIT_TEST_FULL'
|
|
80
|
+
/** a suite that runs only with SHIPKIT_<NAME>_LIVE=1 (it starts real servers on scratch): each such switch set joins
|
|
81
|
+
* every task's env, so its key, and a green of a run without it never answers for a run with it */
|
|
82
|
+
export const liveEnv = (env: Record<string, string | undefined> = process.env): Record<string, string> => Object.fromEntries(Object.keys(env).filter((k) => /^SHIPKIT_[A-Z0-9_]+_LIVE$/.test(k) && env[k] === '1').sort().map((k) => [k, '1']))
|
|
80
83
|
|
|
81
84
|
export type TestTier = 'quick' | 'full'
|
|
82
85
|
|
|
@@ -336,7 +339,8 @@ export async function composeChecks(root: string, c: RepoConfig, o: ComposeOpts
|
|
|
336
339
|
const audit = readAuditReport(root)
|
|
337
340
|
const extrasOf = (id: string): string[] => [...new Set([...ignoredFor(c.ignoredInputs, id), ...auditedExtras(audit, id)])].filter(onDisk).sort()
|
|
338
341
|
for (const raw of [...floor.tasks, ...(c.tasks ?? []).filter((t) => foldedInto.get(t.id) !== t)]) {
|
|
339
|
-
const
|
|
342
|
+
const added = { ...(full ? { [FULL_TESTS_ENV]: '1' } : {}), ...liveEnv() }
|
|
343
|
+
const t: TaskDef = Object.keys(added).length > 0 ? { ...raw, env: { ...raw.env, ...added } } : raw
|
|
340
344
|
const own = t.id === 'test' && floor.tasks.includes(raw) ? rootTest : null
|
|
341
345
|
const declared = own?.inputs ?? t.inputs
|
|
342
346
|
// the declared extras join a declared list too: a list names what the
|
|
@@ -441,7 +445,7 @@ export async function composeChecks(root: string, c: RepoConfig, o: ComposeOpts
|
|
|
441
445
|
ttl: cache.ttl,
|
|
442
446
|
never: cache.never,
|
|
443
447
|
argv: u.def.cmd,
|
|
444
|
-
extra: cache.reads === true ? `${extra ?? ''}|tier=${full ? 'full' : 'quick'}` : extra,
|
|
448
|
+
extra: cache.reads === true ? `${extra ?? ''}|tier=${full ? 'full' : 'quick'}${Object.keys(liveEnv()).map((k) => `|${k}=1`).join('')}` : extra,
|
|
445
449
|
writes: u.def.writes,
|
|
446
450
|
...(cache.reads === true && raw == null ? { reads: true } : {}),
|
|
447
451
|
...(raw != null ? rawAccessDecl(raw, toolkitCheckElsewhere(root, u)) : {}),
|
package/src/ledger/run-log.ts
CHANGED
|
@@ -34,6 +34,9 @@ export const KEEP_MS = 30 * 24 * 60 * 60 * 1000
|
|
|
34
34
|
* tens of thousands of run rows a day, so age alone is no cap */
|
|
35
35
|
export const MAX_ROWS = 200_000
|
|
36
36
|
|
|
37
|
+
/** the most rows the suites table keeps: it gains one row a test file a run, the fastest of the record */
|
|
38
|
+
export const SUITES_MAX_ROWS = 50_000
|
|
39
|
+
|
|
37
40
|
/** one check, one run. `ms` is what it MEASURED: a replay measured nothing and
|
|
38
41
|
* says 0, so the two can never be averaged together by accident. */
|
|
39
42
|
export type RunRow = {
|
|
@@ -240,7 +243,7 @@ const sweepAll = (db: Database, now: number, cutoff: number, max?: number): void
|
|
|
240
243
|
db.query('delete from suites where at < ?').run(cutoff)
|
|
241
244
|
db.query('delete from suite_runs where at < ?').run(cutoff)
|
|
242
245
|
if (max == null) return
|
|
243
|
-
for (const [table, col] of RECORD_TABLES) db.query(`delete from ${table} where rowid in (select rowid from ${table} order by ${col} desc limit -1 offset ?)`).run(max)
|
|
246
|
+
for (const [table, col] of RECORD_TABLES) db.query(`delete from ${table} where rowid in (select rowid from ${table} order by ${col} desc limit -1 offset ?)`).run(table === 'suites' ? Math.min(max, SUITES_MAX_ROWS) : max)
|
|
244
247
|
}
|
|
245
248
|
|
|
246
249
|
/** every record table and the column its age is read from */
|
|
@@ -362,8 +365,9 @@ export function readLastStatusReadonly(path: string, o: { lines?: boolean } = {}
|
|
|
362
365
|
}
|
|
363
366
|
|
|
364
367
|
/** every check's last result and how many runs in a row ended on that same
|
|
365
|
-
* status: what the planner hands a check's `every` lambda.
|
|
366
|
-
*
|
|
368
|
+
* status: what the planner hands a check's `every` lambda. A check with no
|
|
369
|
+
* row left in the history answers from its last outcome on record, streak 1.
|
|
370
|
+
* `{}` when the record cannot be read, so a plan look never crashes on it */
|
|
367
371
|
export function readLastResults(path: string): Record<string, { status: RunStatus; at: number; streak: number }> {
|
|
368
372
|
const opened = openDb(path, { create: false })
|
|
369
373
|
if (opened == null) return {}
|
|
@@ -376,6 +380,10 @@ export function readLastResults(path: string): Record<string, { status: RunStatu
|
|
|
376
380
|
from (select d.id as id, (select r3.rowid from runs r3 where r3.id = d.id order by r3.at desc, r3.rowid desc limit 1) as rid from (select distinct id from runs) d) x
|
|
377
381
|
join runs l on l.rowid = x.rid`).all() as { id: string; status: string; at: number; streak: number }[]
|
|
378
382
|
for (const r of rows) out[r.id] = { status: r.status as RunStatus, at: Number(r.at), streak: Math.max(1, Number(r.streak)) }
|
|
383
|
+
// the history is capped (MAX_ROWS, KEEP_MS) and check_last is not: a check whose rows left the history still
|
|
384
|
+
// has the last outcome every page shows, and the plan must read that same answer
|
|
385
|
+
for (const r of opened.db.query('select id, status, at from check_last').all() as { id: string; status: string; at: number }[])
|
|
386
|
+
out[r.id] ??= { status: r.status as RunStatus, at: Number(r.at), streak: 1 }
|
|
379
387
|
} catch {
|
|
380
388
|
return {}
|
|
381
389
|
} finally {
|
package/src/ledger/store.ts
CHANGED
|
@@ -52,6 +52,15 @@ export const KEEP_MS = 14 * 24 * 60 * 60 * 1000
|
|
|
52
52
|
* dozens of distinct trees; past it the least recently used go first. */
|
|
53
53
|
export const MAX_ANSWERS = 5_000
|
|
54
54
|
|
|
55
|
+
/** the most answers ONE check keeps, the most recently used: each is one state of the tree, and a state older than
|
|
56
|
+
* that many gates is asked again once when it comes back */
|
|
57
|
+
export const MAX_A_CHECK = 40
|
|
58
|
+
|
|
59
|
+
/** a row whose payload holds the key parts it was stored under */
|
|
60
|
+
const HOLDS_PARTS = `instr(payload, '"components":[') > 0 and json_type(payload, '$.components') is not null`
|
|
61
|
+
/** the newest row of each check, as latest() reads it */
|
|
62
|
+
const NEWEST_OF_EACH = 'select rowid from (select rowid, row_number() over (partition by ns, name order by at desc, rowid desc) as n from answers) where n = 1'
|
|
63
|
+
|
|
55
64
|
/** the import takes json answers this young only: every edit of shipkit moves
|
|
56
65
|
* every key, so an older answer is one no gate asks for again */
|
|
57
66
|
export const IMPORT_MAX_AGE_MS = 24 * 60 * 60 * 1000
|
|
@@ -140,8 +149,11 @@ export class Answers {
|
|
|
140
149
|
// the import never overwrites a row a gate already wrote
|
|
141
150
|
const put = h.query(`insert or ${o.keepNewer === true ? 'ignore' : 'replace'} into answers (ns, name, key, v, at, keeps, used, payload) values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
142
151
|
const use = h.query('update answers set used = max(used, ?) where ns = ? and name = ? and key = ?')
|
|
152
|
+
const cut = h.query(`update answers set payload = json_remove(payload, '$.components') where ns = ? and name = ? and ${HOLDS_PARTS} and rowid = (select rowid from answers where ns = ? and name = ? order by at desc, rowid desc limit 1 offset 1)`)
|
|
143
153
|
h.transaction(() => {
|
|
144
154
|
for (const r of rows) put.run(r.ns, r.name, r.key, STORE_VERSION, r.at, r.keeps ?? null, Math.max(r.at, now), JSON.stringify(r.payload))
|
|
155
|
+
// one row a check, the one the write just made second: every older one was cut when it became second
|
|
156
|
+
for (const k of new Set(rows.map((r) => `${r.ns}\0${r.name}`))) cut.run(...(k.split('\0') as [string, string]), ...(k.split('\0') as [string, string]))
|
|
145
157
|
for (const t of o.touched ?? []) use.run(now, t.ns, t.name, t.key)
|
|
146
158
|
}).immediate()
|
|
147
159
|
return true
|
|
@@ -167,7 +179,7 @@ export class Answers {
|
|
|
167
179
|
/** the newest answer of one check under ANY key: what a miss diffs its
|
|
168
180
|
* own key against, to say what moved */
|
|
169
181
|
latest<T>(ns: string, name: string): Stored<T> | null {
|
|
170
|
-
const row = this.with(READ_BUSY_MS, (h) => h.query('select v, key, at, keeps, payload from answers where ns = ? and name = ? order by at desc limit 1').get(ns, name) as (Row & { key: string }) | null)
|
|
182
|
+
const row = this.with(READ_BUSY_MS, (h) => h.query('select v, key, at, keeps, payload from answers where ns = ? and name = ? order by at desc, rowid desc limit 1').get(ns, name) as (Row & { key: string }) | null)
|
|
171
183
|
if (row == null) return null
|
|
172
184
|
try {
|
|
173
185
|
const payload = JSON.parse(row.payload) as T
|
|
@@ -211,14 +223,23 @@ export class Answers {
|
|
|
211
223
|
return r == null ? null : { count: Number(r.n), oldestUsed: r.oldest }
|
|
212
224
|
}
|
|
213
225
|
|
|
226
|
+
/** the key parts cut from every answer that is not the newest of its check: a miss reads them from the newest
|
|
227
|
+
* alone (latest), and one list of them is tens of kB. How many rows it cut, null when the db could not be opened.
|
|
228
|
+
* The text test is the cheap half, json_type the exact one (a line of a check can hold the same words) */
|
|
229
|
+
slim(): number | null {
|
|
230
|
+
return this.with(BUSY_MS, (h) => h.query(`update answers set payload = json_remove(payload, '$.components') where ${HOLDS_PARTS} and rowid not in (${NEWEST_OF_EACH})`).run().changes)
|
|
231
|
+
}
|
|
232
|
+
|
|
214
233
|
/** the cap, enforced: rows not written nor replayed for `keepMs` go, then
|
|
215
|
-
* the least recently used past `max
|
|
234
|
+
* the least recently used past `max`, then past `maxACheck` of one check. A DELETE, so a row written while it
|
|
216
235
|
* runs is kept. How many went, null when the db could not be opened. */
|
|
217
|
-
sweep(now: number, o: { keepMs?: number; max?: number } = {}): number | null {
|
|
236
|
+
sweep(now: number, o: { keepMs?: number; max?: number; maxACheck?: number } = {}): number | null {
|
|
218
237
|
return this.with(BUSY_MS, (h) => {
|
|
219
238
|
// a forever answer is a decided fact: dropping it re-asks the world
|
|
220
239
|
let n = h.query('delete from answers where used < ? and coalesce(keeps, 0) < ?').run(now - (o.keepMs ?? KEEP_MS), FOREVER_MS).changes
|
|
221
240
|
n += h.query('delete from answers where rowid in (select rowid from answers where coalesce(keeps, 0) < ? order by used desc limit -1 offset ?)').run(FOREVER_MS, o.max ?? MAX_ANSWERS).changes
|
|
241
|
+
// one check, its most recently used answers: a forever answer is neither counted nor dropped
|
|
242
|
+
n += h.query('delete from answers where rowid in (select rowid from (select rowid, row_number() over (partition by ns, name order by used desc, rowid desc) as n from answers where coalesce(keeps, 0) < ?) where n > ?)').run(FOREVER_MS, o.maxACheck ?? MAX_A_CHECK).changes
|
|
222
243
|
return n
|
|
223
244
|
})
|
|
224
245
|
}
|
|
@@ -244,7 +265,8 @@ export const listAnswers = (db: string, ns: string): { name: string; at: number;
|
|
|
244
265
|
export const answersStamp = (db: string, ns: string): string => withAnswers(db, (a) => a.stamp(ns))
|
|
245
266
|
export const answerMeasures = (db: string, ns: string): { name: string; at: number; ms: unknown; status: unknown }[] => withAnswers(db, (a) => a.measures(ns))
|
|
246
267
|
export const answersUse = (db: string): AnswersUse | null => withAnswers(db, (a) => a.use())
|
|
247
|
-
export const
|
|
268
|
+
export const slimAnswers = (db: string): number | null => withAnswers(db, (a) => a.slim())
|
|
269
|
+
export const sweepAnswers = (db: string, now: number, o?: { keepMs?: number; max?: number; maxACheck?: number }): number | null => withAnswers(db, (a) => a.sweep(now, o))
|
|
248
270
|
|
|
249
271
|
/** the migration: the json answers of the pre-db store read into the table
|
|
250
272
|
* once, then the dir deleted. An answer older than IMPORT_MAX_AGE_MS is not
|