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,276 @@
|
|
|
1
|
+
// the vault's audit file kept bounded: renamed aside once a day or past a size, bao made to reopen its path (SIGHUP),
|
|
2
|
+
// the new file proved written before the old one is compressed. A file audit device that cannot write makes the vault
|
|
3
|
+
// refuse every request, so each step leaves bao writing somewhere, and a failure puts the old file back at its path
|
|
4
|
+
import { chmodSync, existsSync, linkSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from 'fs'
|
|
5
|
+
import { basename, dirname, isAbsolute, join } from 'path'
|
|
6
|
+
import { configFile, markerFile, type VaultPlace } from './vault-config.ts'
|
|
7
|
+
|
|
8
|
+
/** rotated between two days when it passes this size */
|
|
9
|
+
export const AUDIT_ROTATE_BYTES = 50_000_000
|
|
10
|
+
export const AUDIT_DAY_MS = 24 * 3600_000
|
|
11
|
+
/** a month of who read what is enough for a vault of one person: the snapshots are its backup, this file is a log */
|
|
12
|
+
export const AUDIT_KEEP_MS = 30 * AUDIT_DAY_MS
|
|
13
|
+
/** a cap on the count too, so a loop of size rotations cannot fill the disk */
|
|
14
|
+
export const AUDIT_KEEP_FILES = 40
|
|
15
|
+
/** a failed rotation is tried again after this long, never at every tick */
|
|
16
|
+
export const AUDIT_RETRY_MS = 3600_000
|
|
17
|
+
/** how often the vault's process looks at the file */
|
|
18
|
+
export const AUDIT_TICK_MS = 10 * 60_000
|
|
19
|
+
|
|
20
|
+
/** the bao that writes the file: `reopen` makes it reopen its audit path, `probe` makes one request it audits */
|
|
21
|
+
export type AuditBao = { reopen: () => void; probe: () => Promise<unknown> }
|
|
22
|
+
/** the last rotation tried, kept beside the vault: what the status says. Words, sizes and names only */
|
|
23
|
+
export type AuditRecord = { at: number; ok: boolean; tone: 'ok' | 'warn' | 'danger'; text: string; file?: string }
|
|
24
|
+
export type AuditShape = { bytes: number | null; rotatedAt: number | null; files: number; filesBytes: number; last: AuditRecord | null }
|
|
25
|
+
|
|
26
|
+
const stampOf = (at: number): string => new Date(at).toISOString().replace(/[-:]|\.\d{3}/g, '')
|
|
27
|
+
const stemOf = (live: string): string => basename(live).replace(/\.log$/, '')
|
|
28
|
+
/** `audit-20260131T120000Z.log` beside `audit.log`, sorted by its time; `-<n>` after the stamp for a second one in the same second */
|
|
29
|
+
export const rotatedName = (live: string, at: number, n = 0): string => join(dirname(live), `${stemOf(live)}-${stampOf(at)}${n > 0 ? `-${n}` : ''}.log`)
|
|
30
|
+
|
|
31
|
+
const escape = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
32
|
+
const rotatedRe = (live: string): RegExp => new RegExp(`^${escape(stemOf(live))}-(\\d{8}T\\d{6}Z)(?:-(\\d+))?\\.log(\\.gz)?(\\.tmp)?$`)
|
|
33
|
+
const atOfStamp = (s: string): number => Date.UTC(+s.slice(0, 4), +s.slice(4, 6) - 1, +s.slice(6, 8), +s.slice(9, 11), +s.slice(11, 13), +s.slice(13, 15))
|
|
34
|
+
|
|
35
|
+
/** the rotated files beside `live`, oldest first; the live file and any other name never among them */
|
|
36
|
+
export function rotatedFiles(live: string): { name: string; at: number; n: number; gz: boolean; tmp: boolean; bytes: number }[] {
|
|
37
|
+
const re = rotatedRe(live)
|
|
38
|
+
let names: string[] = []
|
|
39
|
+
try {
|
|
40
|
+
names = readdirSync(dirname(live))
|
|
41
|
+
} catch {
|
|
42
|
+
return []
|
|
43
|
+
}
|
|
44
|
+
return names
|
|
45
|
+
.flatMap((name) => {
|
|
46
|
+
const m = re.exec(name)
|
|
47
|
+
if (m == null || name === basename(live)) return []
|
|
48
|
+
let bytes = 0
|
|
49
|
+
try {
|
|
50
|
+
bytes = statSync(join(dirname(live), name)).size
|
|
51
|
+
} catch {
|
|
52
|
+
return []
|
|
53
|
+
}
|
|
54
|
+
return [{ name, at: atOfStamp(m[1]!), n: Number(m[2] ?? 0), gz: m[3] != null, tmp: m[4] != null, bytes }]
|
|
55
|
+
})
|
|
56
|
+
.sort((a, b) => a.at - b.at || a.n - b.n || a.name.localeCompare(b.name))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const sizeOf = (f: string): number | null => {
|
|
60
|
+
try {
|
|
61
|
+
return statSync(f).size
|
|
62
|
+
} catch {
|
|
63
|
+
return null
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const codeOf = (e: unknown): string => (e as NodeJS.ErrnoException)?.code ?? (e as Error)?.message ?? String(e)
|
|
67
|
+
|
|
68
|
+
async function until(ok: () => boolean, ms: number): Promise<boolean> {
|
|
69
|
+
const end = Date.now() + ms
|
|
70
|
+
for (;;) {
|
|
71
|
+
if (ok()) return true
|
|
72
|
+
if (Date.now() >= end) return false
|
|
73
|
+
await Bun.sleep(20)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** a request audited, then the file at `live` seen grown: proof bao writes there */
|
|
78
|
+
async function writesTo(live: string, bao: AuditBao, ms: number): Promise<boolean> {
|
|
79
|
+
const before = sizeOf(live)
|
|
80
|
+
if (before == null) return false
|
|
81
|
+
await bao.probe().catch(() => null)
|
|
82
|
+
return until(() => (sizeOf(live) ?? 0) > before, ms)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const REFUSES = 'the vault refuses requests while its audit file is not written: sk gp restart vault'
|
|
86
|
+
|
|
87
|
+
/** the old file back at its path through a hard link, which never replaces a file a late reload made there (EEXIST) */
|
|
88
|
+
export function putBackNoClobber(from: string, to: string): void {
|
|
89
|
+
linkSync(from, to)
|
|
90
|
+
rmSync(from)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** the live file renamed to its dated name, bao made to reopen, the new file proved at 0600 and written. When bao
|
|
94
|
+
* makes no new file, the old one goes back to its path, where bao writes again; never a step that leaves it no file */
|
|
95
|
+
export async function rotateAudit(o: { live: string; bao: AuditBao; now: number; rename?: (a: string, b: string) => void; putBack?: (from: string, to: string) => void; appearMs?: number }): Promise<AuditRecord> {
|
|
96
|
+
const { live, bao, now } = o
|
|
97
|
+
const rename = o.rename ?? renameSync
|
|
98
|
+
const appearMs = o.appearMs ?? 500
|
|
99
|
+
const rec = (ok: boolean, tone: AuditRecord['tone'], text: string, file?: string): AuditRecord => ({ at: now, ok, tone, text, ...(file != null ? { file } : {}) })
|
|
100
|
+
if (!existsSync(live)) {
|
|
101
|
+
bao.reopen()
|
|
102
|
+
if ((await until(() => existsSync(live), appearMs)) && (await writesTo(live, bao, 2_000))) return rec(true, 'warn', 'the audit file was not there: the vault opened a new one and writes in it')
|
|
103
|
+
return rec(false, 'danger', `the audit file was not there and the vault made no new one: ${REFUSES}`)
|
|
104
|
+
}
|
|
105
|
+
const taken = (f: string): boolean => [f, `${f}.gz`, `${f}.gz.tmp`].some((x) => existsSync(x))
|
|
106
|
+
let n = 0
|
|
107
|
+
while (n < 100 && taken(rotatedName(live, now, n))) n++
|
|
108
|
+
const target = rotatedName(live, now, n)
|
|
109
|
+
if (taken(target)) return rec(false, 'warn', `the audit file was not rotated: ${basename(target)} is there already`)
|
|
110
|
+
try {
|
|
111
|
+
rename(live, target)
|
|
112
|
+
} catch (e) {
|
|
113
|
+
return rec(false, 'warn', `the audit file was not rotated, its rename failed (${codeOf(e)}): nothing changed`)
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
bao.reopen()
|
|
117
|
+
} catch {
|
|
118
|
+
// no signal reached bao: the put back below
|
|
119
|
+
}
|
|
120
|
+
const proveNew = async (): Promise<AuditRecord> => {
|
|
121
|
+
let fixed = ''
|
|
122
|
+
if ((statSync(live).mode & 0o777) !== 0o600) {
|
|
123
|
+
chmodSync(live, 0o600)
|
|
124
|
+
fixed = ', its mode set to 0600'
|
|
125
|
+
}
|
|
126
|
+
if (await writesTo(live, bao, 2_000)) return rec(true, 'ok', `rotated to ${basename(target)}${fixed}`, target)
|
|
127
|
+
return rec(false, 'danger', `the vault reopened its audit file and writes nothing in it: ${REFUSES}`)
|
|
128
|
+
}
|
|
129
|
+
if (await until(() => existsSync(live), appearMs)) return proveNew()
|
|
130
|
+
const putBack = o.putBack ?? putBackNoClobber
|
|
131
|
+
try {
|
|
132
|
+
putBack(target, live)
|
|
133
|
+
} catch (e) {
|
|
134
|
+
if (codeOf(e) === 'EEXIST') return proveNew()
|
|
135
|
+
return rec(false, 'danger', `the vault did not reopen its audit file and the old one could not go back (${codeOf(e)}): ${REFUSES}`)
|
|
136
|
+
}
|
|
137
|
+
if (await writesTo(live, bao, 2_000)) return rec(false, 'warn', 'the vault did not reopen its audit file: the old one is put back at its path and the vault writes in it')
|
|
138
|
+
return rec(false, 'danger', `the vault did not reopen its audit file, the old one is put back and still nothing is written: ${REFUSES}`)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** every rotated plain file gzipped beside itself at 0600, its bytes checked before the plain one goes. Run only after
|
|
142
|
+
* a proved rotation: bao then writes in none of them */
|
|
143
|
+
export async function compressRotated(live: string): Promise<{ done: string[]; failed: string | null }> {
|
|
144
|
+
const done: string[] = []
|
|
145
|
+
let failed: string | null = null
|
|
146
|
+
for (const f of rotatedFiles(live).filter((r) => !r.gz && !r.tmp)) {
|
|
147
|
+
const from = join(dirname(live), f.name)
|
|
148
|
+
const tmp = `${from}.gz.tmp`
|
|
149
|
+
try {
|
|
150
|
+
// streamed both ways, so a large file never sits in memory
|
|
151
|
+
const size = statSync(from).size
|
|
152
|
+
writeFileSync(tmp, '', { mode: 0o600 })
|
|
153
|
+
await Bun.write(tmp, new Response(Bun.file(from).stream().pipeThrough(new CompressionStream('gzip'))))
|
|
154
|
+
let back = 0
|
|
155
|
+
for await (const c of Bun.file(tmp).stream().pipeThrough(new DecompressionStream('gzip'))) back += c.byteLength
|
|
156
|
+
if (back !== size) throw new Error('the compressed copy reads back another size')
|
|
157
|
+
linkSync(tmp, `${from}.gz`)
|
|
158
|
+
rmSync(tmp)
|
|
159
|
+
rmSync(from)
|
|
160
|
+
done.push(f.name)
|
|
161
|
+
} catch (e) {
|
|
162
|
+
rmSync(tmp, { force: true })
|
|
163
|
+
failed = `${f.name} stays uncompressed (${codeOf(e)})`
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return { done, failed }
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** rotated files past 30 days removed, then all but the newest 40, and any temp a killed compression left; the live
|
|
170
|
+
* file and every other name are never touched. The names removed */
|
|
171
|
+
export function pruneRotated(live: string, now: number): string[] {
|
|
172
|
+
const all = rotatedFiles(live)
|
|
173
|
+
const kept = all.filter((r) => !r.tmp && now - r.at <= AUDIT_KEEP_MS).slice(-AUDIT_KEEP_FILES)
|
|
174
|
+
const gone: string[] = []
|
|
175
|
+
for (const r of all) {
|
|
176
|
+
if (kept.includes(r)) continue
|
|
177
|
+
rmSync(join(dirname(live), r.name), { force: true })
|
|
178
|
+
gone.push(r.name)
|
|
179
|
+
}
|
|
180
|
+
return gone
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** why the file is due a rotation now, null when it is not: a day since it was born, past its size, or gone */
|
|
184
|
+
export function auditDue(o: { live: string; record: AuditRecord | null; now: number; bytes?: number }): 'day' | 'size' | 'missing' | null {
|
|
185
|
+
if (o.record != null && !o.record.ok && o.now - o.record.at < AUDIT_RETRY_MS) return null
|
|
186
|
+
let s: ReturnType<typeof statSync>
|
|
187
|
+
try {
|
|
188
|
+
s = statSync(o.live)
|
|
189
|
+
} catch {
|
|
190
|
+
return 'missing'
|
|
191
|
+
}
|
|
192
|
+
if ((o.bytes ?? s.size) >= AUDIT_ROTATE_BYTES) return 'size'
|
|
193
|
+
const born = s.birthtimeMs > 0 ? s.birthtimeMs : (o.record?.at ?? 0)
|
|
194
|
+
return s.size > 0 && o.now - born >= AUDIT_DAY_MS ? 'day' : null
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export const auditRecordFile = (dir: string): string => join(dir, 'audit-rotation.json')
|
|
198
|
+
export function readAuditRecord(dir: string): AuditRecord | null {
|
|
199
|
+
try {
|
|
200
|
+
return JSON.parse(readFileSync(auditRecordFile(dir), 'utf8')) as AuditRecord
|
|
201
|
+
} catch {
|
|
202
|
+
return null
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function writeAuditRecord(dir: string, r: AuditRecord): void {
|
|
206
|
+
const tmp = `${auditRecordFile(dir)}.tmp-${process.pid}`
|
|
207
|
+
writeFileSync(tmp, `${JSON.stringify(r)}\n`, { mode: 0o600 })
|
|
208
|
+
renameSync(tmp, auditRecordFile(dir))
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const real = (p: string): string | null => {
|
|
212
|
+
try {
|
|
213
|
+
return realpathSync(p)
|
|
214
|
+
} catch {
|
|
215
|
+
return null
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** the file audit device the config on disk declares, its path as bao opens it (relative to the vault's folder) */
|
|
220
|
+
function declaredAudit(place: VaultPlace): string | null {
|
|
221
|
+
try {
|
|
222
|
+
const path = /audit "file" "[^"]+" \{[^}]*?file_path = "([^"]+)"/.exec(readFileSync(configFile(place), 'utf8'))?.[1]
|
|
223
|
+
return path == null ? null : isAbsolute(path) ? path : join(place.dir, path)
|
|
224
|
+
} catch {
|
|
225
|
+
return null
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** why the tick must touch nothing, null when it may. An audit file outside the vault's own folder (a stale marker) is
|
|
230
|
+
* never renamed, signalled for or pruned. A SIGHUP applies bao.hcl again, so a config that no longer declares this
|
|
231
|
+
* audit file would turn the device off: no signal then */
|
|
232
|
+
function refusal(place: VaultPlace, live: string): Pick<AuditRecord, 'tone' | 'text'> | null {
|
|
233
|
+
const dir = real(dirname(live))
|
|
234
|
+
if (dir == null || dir !== real(place.dir)) return { tone: 'warn', text: `the audit file ${live} is not in the vault's folder ${place.dir}: nothing is rotated, signalled or deleted while the marker's auditPath names another folder` }
|
|
235
|
+
const declared = declaredAudit(place)
|
|
236
|
+
if (declared == null || basename(declared) !== basename(live) || real(dirname(declared)) !== dir) return { tone: 'danger', text: `${configFile(place)} no longer declares the audit file ${live}: no rotation, as the reload it needs would turn the audit off. sk gp restart vault writes the config again` }
|
|
237
|
+
return null
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** the vault process's look at its audit file: rotated when due, compressed and pruned after a proved rotation, the
|
|
241
|
+
* outcome recorded and said. Null, with nothing said, where no vault is initialised or nothing is due */
|
|
242
|
+
export async function auditTick(o: { place: VaultPlace; live: string; bao: AuditBao; now?: number; say: (l: string) => void }): Promise<AuditRecord | null> {
|
|
243
|
+
if (!existsSync(markerFile(o.place))) return null
|
|
244
|
+
const now = o.now ?? Date.now()
|
|
245
|
+
const last = readAuditRecord(o.place.dir)
|
|
246
|
+
const held = refusal(o.place, o.live)
|
|
247
|
+
if (held != null) {
|
|
248
|
+
if (last?.text === held.text) return last
|
|
249
|
+
const r: AuditRecord = { at: now, ok: false, ...held }
|
|
250
|
+
writeAuditRecord(o.place.dir, r)
|
|
251
|
+
o.say(`${r.tone === 'danger' ? 'DANGER' : 'WARN'} vault audit file: ${r.text}`)
|
|
252
|
+
return r
|
|
253
|
+
}
|
|
254
|
+
const due = auditDue({ live: o.live, record: last, now })
|
|
255
|
+
if (due == null) return null
|
|
256
|
+
const r = await rotateAudit({ live: o.live, bao: o.bao, now })
|
|
257
|
+
if (r.ok) {
|
|
258
|
+
const c = await compressRotated(o.live)
|
|
259
|
+
const gone = pruneRotated(o.live, now)
|
|
260
|
+
if (c.failed != null) Object.assign(r, { tone: 'warn', text: `${r.text}; ${c.failed}` })
|
|
261
|
+
if (gone.length > 0) r.text += `; ${gone.length} old rotated file${gone.length === 1 ? '' : 's'} removed`
|
|
262
|
+
}
|
|
263
|
+
writeAuditRecord(o.place.dir, r)
|
|
264
|
+
o.say(`${r.tone === 'danger' ? 'DANGER' : r.tone === 'warn' ? 'WARN' : 'ok:'} vault audit file (${due}): ${r.text}`)
|
|
265
|
+
return r
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** what the status says of the audit file: its size, its last rotation, the rotated files kept. Sizes only, never a
|
|
269
|
+
* line read. Null where no vault is initialised */
|
|
270
|
+
export function auditShape(p: VaultPlace, live: string): AuditShape | null {
|
|
271
|
+
if (!existsSync(markerFile(p))) return null
|
|
272
|
+
const files = rotatedFiles(live).filter((r) => !r.tmp)
|
|
273
|
+
const last = readAuditRecord(p.dir)
|
|
274
|
+
const rotatedAt = [...files.map((f) => f.at), ...(last?.ok === true ? [last.at] : [])].reduce<number | null>((a, b) => (a == null || b > a ? b : a), null)
|
|
275
|
+
return { bytes: sizeOf(live), rotatedAt, files: files.length, filesBytes: files.reduce((n, f) => n + f.bytes, 0), last }
|
|
276
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// a machine as the vault's client (wiki services/secrets, step 2): the vault is the store of secrets. A registry
|
|
2
|
+
// name has one path in it; a write goes to the vault only and is read back before it is called done. The login
|
|
3
|
+
// keychain is a read only legacy here: nothing in this module writes it
|
|
4
|
+
import type { Scope } from '../core/scope.ts'
|
|
5
|
+
import { KV_MOUNT, pathOf } from './layout.ts'
|
|
6
|
+
import type { VaultApi } from './vault-http.ts'
|
|
7
|
+
|
|
8
|
+
/** a path under the mount as the registry name it files: its scope's folder dropped, `rv/` put back. Null for a path
|
|
9
|
+
* no scope folder holds */
|
|
10
|
+
export function nameOfPath(path: string): string | null {
|
|
11
|
+
const parts = path.split('/')
|
|
12
|
+
const n = parts[0] === 'all' ? 1 : parts[0] === 'repo' || parts[0] === 'identity' || parts[0] === 'machine' ? 2 : 0
|
|
13
|
+
return n === 0 || parts.length <= n ? null : `rv/${parts.slice(n).join('/')}`
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** a registry row's path in the vault: a repo its row names by id is filed by that repo's key (host/path of its
|
|
17
|
+
* first remote), found from this machine's checkouts. A repo id no checkout here answers to has no path */
|
|
18
|
+
export async function vaultPathOf(name: string, scope: Scope | undefined, keyOf: (id: string) => Promise<string | null>): Promise<string> {
|
|
19
|
+
if (scope?.repos == null || scope.repos.length === 0) return pathOf(name, scope)
|
|
20
|
+
const repos: string[] = []
|
|
21
|
+
for (const r of scope.repos) {
|
|
22
|
+
if (r.includes('/')) repos.push(r)
|
|
23
|
+
else {
|
|
24
|
+
const key = await keyOf(r)
|
|
25
|
+
if (key == null) throw new Error(`repo:${r}: no checkout on this machine answers to that id, so its key (host/path of its first remote) is unknown`)
|
|
26
|
+
repos.push(key)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return pathOf(name, { ...scope, repos })
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** a value into the vault on top of the version it holds (check and set), then read back: its new version. A write
|
|
33
|
+
* the vault refuses, or a read back that differs by a byte, throws */
|
|
34
|
+
export async function setInVault(o: { vault: Pick<VaultApi, 'currentVersion' | 'writeKvCas' | 'readKv'>; path: string; account: string; value: string }): Promise<number> {
|
|
35
|
+
const cas = await o.vault.currentVersion(KV_MOUNT, o.path)
|
|
36
|
+
const version = await o.vault.writeKvCas(KV_MOUNT, o.path, { value: o.value, account: o.account }, cas)
|
|
37
|
+
const back = await o.vault.readKv(KV_MOUNT, o.path)
|
|
38
|
+
if (back?.['value'] !== o.value) throw new Error(`the vault read ${o.path} back as another value at v${version}`)
|
|
39
|
+
return version
|
|
40
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// the vault's place on this machine (OpenBao beside the hq, wiki tools/shipkit/hq.md) and the config bao reads.
|
|
2
|
+
// The seal key is never in this text: bao reads it from its own environment (env://), where vault-serve.ts puts it
|
|
3
|
+
import { createHash, randomBytes } from 'crypto'
|
|
4
|
+
import { existsSync, realpathSync } from 'fs'
|
|
5
|
+
import { homedir } from 'os'
|
|
6
|
+
import { join, resolve } from 'path'
|
|
7
|
+
import { machinePath } from '../core/machine-layout.ts'
|
|
8
|
+
import { homeDir } from '../home/home-paths.ts'
|
|
9
|
+
|
|
10
|
+
/** the api, on loopback only. 4794 stays free for the vault's door to the tailnet */
|
|
11
|
+
export const DEFAULT_VAULT_PORT = 4793
|
|
12
|
+
/** raft's cluster listener: bao puts it on the api port + 1 unless told, which is the door's port */
|
|
13
|
+
export const DEFAULT_VAULT_CLUSTER_PORT = 4792
|
|
14
|
+
|
|
15
|
+
const envPort = (name: string, fallback: number): number => {
|
|
16
|
+
const n = Number(process.env[name])
|
|
17
|
+
return Number.isInteger(n) && n > 0 ? n : fallback
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** where the vault lives: its folder (mode 0700) and its two ports */
|
|
21
|
+
export type VaultPlace = { dir: string; port: number; clusterPort: number }
|
|
22
|
+
|
|
23
|
+
export const vaultPlace = (): VaultPlace => ({
|
|
24
|
+
dir: join(homeDir(), 'vault'),
|
|
25
|
+
port: envPort('SHIPKIT_VAULT_PORT', DEFAULT_VAULT_PORT),
|
|
26
|
+
clusterPort: envPort('SHIPKIT_VAULT_CLUSTER_PORT', DEFAULT_VAULT_CLUSTER_PORT),
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
export const vaultUrl = (p: VaultPlace): string => `http://127.0.0.1:${p.port}`
|
|
30
|
+
export const healthUrl = (p: VaultPlace): string => `${vaultUrl(p)}/v1/sys/health`
|
|
31
|
+
|
|
32
|
+
export const dataDir = (p: VaultPlace): string => join(p.dir, 'data')
|
|
33
|
+
export const auditLog = (p: VaultPlace): string => join(p.dir, 'audit.log')
|
|
34
|
+
export const configFile = (p: VaultPlace): string => join(p.dir, 'bao.hcl')
|
|
35
|
+
/** the token that mints the nodes' tokens (wiki services/secrets, step 2): 0600, never sent anywhere */
|
|
36
|
+
export const minterTokenFile = (p: VaultPlace): string => join(p.dir, 'minter-token')
|
|
37
|
+
/** written by `sk vault init` once the vault is initialised: no secret in it. Its presence is what starts the vault at login */
|
|
38
|
+
export const markerFile = (p: VaultPlace): string => join(p.dir, 'initialised.json')
|
|
39
|
+
|
|
40
|
+
export const vaultInitialised = (p: VaultPlace = vaultPlace()): boolean => existsSync(markerFile(p))
|
|
41
|
+
|
|
42
|
+
/** the login keychain item that holds the seal key: outside `rv/*`, so the secret manager, sk secret and the import never see it */
|
|
43
|
+
export const SEAL_SERVICE = 'shipkit-vault-seal'
|
|
44
|
+
|
|
45
|
+
/** the OS user's own home, from the user database: os.homedir() and os.userInfo() read $HOME, which a scratch run
|
|
46
|
+
* sets, and the real seal item must never follow it. Off macOS (no login keychain) the home as given */
|
|
47
|
+
let osHome: string | null = null
|
|
48
|
+
export function userHome(): string {
|
|
49
|
+
if (osHome != null) return osHome
|
|
50
|
+
osHome = homedir()
|
|
51
|
+
if (process.platform === 'darwin')
|
|
52
|
+
try {
|
|
53
|
+
const { dlopen, FFIType, CString, read } = require('bun:ffi') as typeof import('bun:ffi')
|
|
54
|
+
const { symbols, close } = dlopen('libc.dylib', { getpwuid: { args: [FFIType.u32], returns: FFIType.ptr }, getuid: { args: [], returns: FFIType.u32 } })
|
|
55
|
+
const pw = symbols.getpwuid(symbols.getuid())
|
|
56
|
+
// struct passwd on darwin: pw_dir after name, passwd, uid, gid, change, class, gecos
|
|
57
|
+
if (pw != null) osHome = new CString(read.ptr(pw, 48) as never).toString()
|
|
58
|
+
close()
|
|
59
|
+
} catch {
|
|
60
|
+
// no user database: the home as given
|
|
61
|
+
}
|
|
62
|
+
return osHome
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** the vault of this machine's real home (the OS user's own, userHome): the default of homeDir() under the machine's one root (layout.ts
|
|
66
|
+
* machinePath, the old root until the machine moved), whatever SHIPKIT_HOME_DIR says. A path that resolves to it
|
|
67
|
+
* through a link (the old root once moved) is it too */
|
|
68
|
+
export function isRealPlace(p: VaultPlace, home: string = userHome()): boolean {
|
|
69
|
+
const real = join(machinePath('home', home), 'vault')
|
|
70
|
+
if (resolve(p.dir) === real) return true
|
|
71
|
+
try {
|
|
72
|
+
return realpathSync(p.dir) === realpathSync(real)
|
|
73
|
+
} catch {
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** the seal item of a place: the real one for the real home only. Any other home gets a name of its own, made from
|
|
79
|
+
* its folder, so no code run under a scratch home can name the real item */
|
|
80
|
+
export const sealServiceOf = (p: VaultPlace, home: string = userHome()): string => (isRealPlace(p, home) ? SEAL_SERVICE : `${SEAL_SERVICE}.scratch-${createHash('sha256').update(resolve(p.dir)).digest('hex').slice(0, 12)}`)
|
|
81
|
+
export const SEAL_ACCOUNT = 'vault'
|
|
82
|
+
/** the variable of bao's environment that carries the key */
|
|
83
|
+
export const SEAL_KEY_ENV = 'SHIPKIT_VAULT_SEAL_KEY'
|
|
84
|
+
/** the key's id in the seal stanza. A rotation adds the next id with the old key as `previous_key` */
|
|
85
|
+
export const SEAL_KEY_ID = 'shipkit-1'
|
|
86
|
+
|
|
87
|
+
/** 32 random bytes as 64 lowercase hex characters: the form bao decodes from env://, and one that needs no quoting
|
|
88
|
+
* on the keychain's stdin nor in a note */
|
|
89
|
+
export const newSealKey = (): string => randomBytes(32).toString('hex')
|
|
90
|
+
export const isSealKey = (s: string): boolean => /^[0-9a-f]{64}$/.test(s)
|
|
91
|
+
|
|
92
|
+
/** `bao` is the version init saw, `baoPath` the absolute binary it ran: the only one `sk vault serve` starts */
|
|
93
|
+
/** `auditPath`: the audit file the vault was initialised with. bao keeps that path inside its own data and answers
|
|
94
|
+
* 429 for good when the file is not there, so a vault served from a moved home declares it again */
|
|
95
|
+
export type MarkerData = { at: string; machine: string; keyId: string; bao: string; baoPath: string; auditPath?: string }
|
|
96
|
+
|
|
97
|
+
const q = (s: string): string => JSON.stringify(s)
|
|
98
|
+
|
|
99
|
+
/** the one audit device, declared in the config: OpenBao keeps a declared device in its own storage, so in every
|
|
100
|
+
* snapshot, and opens it at unseal before anything else; a device it cannot open leaves the node standby for good.
|
|
101
|
+
* Its path is RELATIVE, opened in bao's working folder (startBao runs bao in the vault's folder), so a snapshot
|
|
102
|
+
* restores on any machine and any path. A vault made with the older device `main` (an absolute path) drops it at
|
|
103
|
+
* its first start with this config: OpenBao disables a declared device the config no longer names */
|
|
104
|
+
export const AUDIT_DEVICE = 'local'
|
|
105
|
+
export const AUDIT_FILE = 'audit.log'
|
|
106
|
+
|
|
107
|
+
/** bao's config: raft on one node, loopback without tls, the static seal through env://, one file audit device
|
|
108
|
+
* (2.7 refuses one made through the api). No value in it is secret. `audit: false` is for a scratch vault that
|
|
109
|
+
* takes a snapshot: the snapshot carries the live device */
|
|
110
|
+
/** `unauthedRoot`: the listener takes the unauthenticated `sys/generate-root/*` calls (off by default since OpenBao
|
|
111
|
+
* 2.5.3), the one way to a root token from the recovery key in a vault no token opens: for a restore's run only */
|
|
112
|
+
/** the one road to a root token once the root token is revoked, said the same in every message: OpenBao (2.5.3 on)
|
|
113
|
+
* makes one from the recovery key only on a listener that takes the unauthenticated sys/generate-root calls */
|
|
114
|
+
export const ROOT_ROAD = 'a root token from the recovery key: OpenBao gives one only while its listener takes the unauthenticated sys/generate-root calls (disable_unauthed_generate_root_endpoints = false), which sk vault restore does for its run on an empty vault; on a live vault it is not built'
|
|
115
|
+
|
|
116
|
+
export function vaultHcl(p: VaultPlace, o: { audit?: boolean; unauthedRoot?: boolean } = {}): string {
|
|
117
|
+
const api = `127.0.0.1:${p.port}`
|
|
118
|
+
const cluster = `127.0.0.1:${p.clusterPort}`
|
|
119
|
+
return [
|
|
120
|
+
'ui = false',
|
|
121
|
+
`api_addr = ${q(`http://${api}`)}`,
|
|
122
|
+
`cluster_addr = ${q(`http://${cluster}`)}`,
|
|
123
|
+
'storage "raft" {',
|
|
124
|
+
` path = ${q(dataDir(p))}`,
|
|
125
|
+
' node_id = "shipkit"',
|
|
126
|
+
' performance_multiplier = 1',
|
|
127
|
+
'}',
|
|
128
|
+
'listener "tcp" {',
|
|
129
|
+
` address = ${q(api)}`,
|
|
130
|
+
` cluster_address = ${q(cluster)}`,
|
|
131
|
+
' tls_disable = true',
|
|
132
|
+
...(o.unauthedRoot === true ? [' disable_unauthed_generate_root_endpoints = false'] : []),
|
|
133
|
+
'}',
|
|
134
|
+
'seal "static" {',
|
|
135
|
+
` current_key_id = ${q(SEAL_KEY_ID)}`,
|
|
136
|
+
` current_key = ${q(`env://${SEAL_KEY_ENV}`)}`,
|
|
137
|
+
'}',
|
|
138
|
+
...(o.audit === false ? [] : [`audit "file" ${q(AUDIT_DEVICE)} {`, ' options {', ` file_path = ${q(AUDIT_FILE)}`, ' mode = "0600"', ' log_raw = "false"', ' hmac_accessor = "true"', ' }', '}']),
|
|
139
|
+
'',
|
|
140
|
+
].join('\n')
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** bun test sets NODE_ENV=test in its process, and every child it starts inherits it: the gate's test checks run bun
|
|
144
|
+
* test, so a suite and every tool it spawns carry it */
|
|
145
|
+
export const underTest = (): boolean => process.env['NODE_ENV'] === 'test'
|
|
146
|
+
|
|
147
|
+
/** the guard of this machine's real vault: under a test, its place (isRealPlace) and its port (the default api port on
|
|
148
|
+
* loopback) are refused with a loud error before any file of it is read or any socket opened. A scratch vault on its
|
|
149
|
+
* own port and its own home passes; outside a test nothing is refused */
|
|
150
|
+
export function refuseRealVault(o: { place?: VaultPlace; url?: string }): void {
|
|
151
|
+
if (!underTest()) return
|
|
152
|
+
let hit: string | null = null
|
|
153
|
+
if (o.place != null && isRealPlace(o.place)) hit = o.place.dir
|
|
154
|
+
if (hit == null && o.url != null) {
|
|
155
|
+
const u = new URL(o.url)
|
|
156
|
+
if (['127.0.0.1', 'localhost', '0.0.0.0', '[::1]', '::1'].includes(u.hostname) && Number(u.port) === DEFAULT_VAULT_PORT) hit = o.url
|
|
157
|
+
}
|
|
158
|
+
if (hit != null) throw new Error(`a test reached for this machine's real vault (${hit}): give the suite a scratch SHIPKIT_HOME_DIR, and a scratch bao its own SHIPKIT_VAULT_PORT, as the vault's live suites do`)
|
|
159
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// one secret destroyed for good, the owner's act alone: no token alive may destroy (a node never does, policy.ts), so a
|
|
2
|
+
// root token is made from the recovery key for this one act, in a window like the restore's. The served vault is
|
|
3
|
+
// stopped by the caller; bao runs on the vault's own data from a config in `<vault>.destroy` (the open root generation
|
|
4
|
+
// is never in the vault's bao.hcl), tethered to this process; every version and the metadata of the one path go, the
|
|
5
|
+
// root token is revoked, bao is stopped and the port checked free
|
|
6
|
+
import { existsSync, readFileSync, rmSync } from 'fs'
|
|
7
|
+
import { join } from 'path'
|
|
8
|
+
import { KV_MOUNT } from './layout.ts'
|
|
9
|
+
import { markerFile, vaultUrl, type VaultPlace } from './vault-config.ts'
|
|
10
|
+
import { VaultApi, waitHealth } from './vault-http.ts'
|
|
11
|
+
import { killRecorded, notePids, recordedGone } from './vault-restore.ts'
|
|
12
|
+
import { portHolders, startBao } from './vault-serve.ts'
|
|
13
|
+
|
|
14
|
+
export const destroyDirOf = (p: VaultPlace): string => `${p.dir}.destroy`
|
|
15
|
+
|
|
16
|
+
/** an act's root tokens no process holds any more, revoked by the minter (it may revoke by accessor): what a destroy
|
|
17
|
+
* or a restore killed after its root token leaves. Refused while an act runs (its work folder with a live bao): its
|
|
18
|
+
* token is held then. How many were revoked */
|
|
19
|
+
export async function revokeStrayRoots(place: VaultPlace, minter: Pick<VaultApi, 'accessors' | 'lookupAccessor' | 'revokeAccessor'>): Promise<{ revoked: number } | { refused: string }> {
|
|
20
|
+
for (const dir of [destroyDirOf(place), `${place.dir}.restore`]) {
|
|
21
|
+
if (!existsSync(join(dir, 'bao.pid'))) continue
|
|
22
|
+
const pids = readFileSync(join(dir, 'bao.pid'), 'utf8').split(/\s+/).map(Number).filter((n) => n > 0)
|
|
23
|
+
if (pids.some((pid) => Bun.spawnSync(['ps', '-o', 'command=', '-p', String(pid)]).stdout.toString().includes(`-config=${join(dir, 'bao.hcl')}`))) return { refused: `an act runs now (${dir}): its root token is held, nothing was revoked` }
|
|
24
|
+
}
|
|
25
|
+
let revoked = 0
|
|
26
|
+
for (const a of await minter.accessors()) {
|
|
27
|
+
if (!(await minter.lookupAccessor(a)).policies.includes('root')) continue
|
|
28
|
+
await minter.revokeAccessor(a)
|
|
29
|
+
revoked++
|
|
30
|
+
}
|
|
31
|
+
return { revoked }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** the destroy, its exit code; each line through `say`, none with a key, a token or a value */
|
|
35
|
+
export async function destroyInVault(d: { place: VaultPlace; path: string; sealKey: string; recoveryKey: string; bin: string; say: (l: string) => void; step?: (s: 'root') => void | Promise<void> }): Promise<number> {
|
|
36
|
+
const fail = (l: string): number => (d.say(`FAIL: ${l}`), 1)
|
|
37
|
+
if (!existsSync(markerFile(d.place))) return fail(`no vault is initialised at ${d.place.dir}`)
|
|
38
|
+
if (portHolders(d.place).length > 0) return fail(`127.0.0.1:${d.place.port} is held: stop the vault first (sk gp stop vault)`)
|
|
39
|
+
const work = destroyDirOf(d.place)
|
|
40
|
+
if (existsSync(work)) {
|
|
41
|
+
const stopped = killRecorded(work)
|
|
42
|
+
rmSync(work, { recursive: true, force: true })
|
|
43
|
+
d.say(`ok: a destroy left half way was cleaned: ${work} removed${stopped > 0 ? ', its bao stopped' : ''}; sk vault status says if a root token of it is still alive`)
|
|
44
|
+
}
|
|
45
|
+
const bao = startBao({ place: d.place, key: d.sealKey, bin: d.bin, out: join(work, 'bao.log'), unauthedRoot: true, tethered: true, configDir: work })
|
|
46
|
+
notePids(work, bao)
|
|
47
|
+
const url = vaultUrl(d.place)
|
|
48
|
+
const held: { root: VaultApi | null } = { root: null }
|
|
49
|
+
const act = async (): Promise<number> => {
|
|
50
|
+
if ((await waitHealth(url, (h) => h?.code === 200, { ms: 60_000 }))?.code !== 200) return fail(`the vault did not open: see ${join(work, 'bao.log')}`)
|
|
51
|
+
notePids(work, bao)
|
|
52
|
+
const token = await new VaultApi(url).rootAfterRestore(d.recoveryKey.trim(), 30_000).catch((e: Error) => e)
|
|
53
|
+
if (token instanceof Error) return fail(`a root token from that recovery key: ${token.message}`)
|
|
54
|
+
const root = new VaultApi(url, token)
|
|
55
|
+
held.root = root
|
|
56
|
+
await d.step?.('root')
|
|
57
|
+
const had = await root.currentVersion(KV_MOUNT, d.path)
|
|
58
|
+
if (had === 0) return fail(`the vault holds nothing at ${d.path}: nothing was destroyed`)
|
|
59
|
+
await root.destroyAll(KV_MOUNT, d.path)
|
|
60
|
+
if ((await root.currentVersion(KV_MOUNT, d.path)) !== 0) return fail(`${d.path} still has metadata after the destroy`)
|
|
61
|
+
d.say(`ok: ${d.path} destroyed in the vault, its ${had} version${had === 1 ? '' : 's'} and its metadata, for good`)
|
|
62
|
+
return 0
|
|
63
|
+
}
|
|
64
|
+
let code: number
|
|
65
|
+
try {
|
|
66
|
+
code = await act()
|
|
67
|
+
} finally {
|
|
68
|
+
await held.root?.revokeSelf().catch(() => d.say('FAIL: the root token of this act could not be revoked: it dies with this bao, and sk vault status counts root tokens'))
|
|
69
|
+
await bao.stop()
|
|
70
|
+
killRecorded(work)
|
|
71
|
+
await recordedGone(work)
|
|
72
|
+
for (let i = 0; i < 50 && portHolders(d.place).length > 0; i++) await Bun.sleep(100)
|
|
73
|
+
rmSync(work, { recursive: true, force: true })
|
|
74
|
+
}
|
|
75
|
+
const left = portHolders(d.place)
|
|
76
|
+
if (left.length > 0) return fail(`a process still holds 127.0.0.1:${d.place.port}: ${left.map((h) => `pid ${h.pid}`).join(', ')}. Stop it (kill ${left.map((h) => h.pid).join(' ')}) before sk gp start vault`)
|
|
77
|
+
return code
|
|
78
|
+
}
|