rvlib-shipkit 2.31.0 → 2.32.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 +31 -0
- package/package.json +1 -1
- package/src/advisors/acts.ts +16 -15
- package/src/advisors/advice.ts +56 -102
- package/src/advisors/advisor-view.ts +98 -73
- package/src/advisors/app-graph.ts +1 -1
- package/src/advisors/app.ts +3 -11
- package/src/advisors/cf-api.ts +1 -1
- package/src/advisors/dir-bucket.ts +4 -3
- package/src/advisors/edge/api.ts +26 -198
- package/src/advisors/edge/bucket.ts +2 -2
- package/src/advisors/edge/handler.ts +13 -155
- package/src/advisors/edge/here.ts +5 -5
- package/src/advisors/edge/pages.ts +12 -9
- package/src/advisors/edge/shell.ts +6 -5
- package/src/advisors/edge/sign-in.ts +101 -36
- package/src/advisors/edge/status.ts +19 -6
- package/src/advisors/edge/types.ts +36 -60
- package/src/advisors/expose.ts +29 -29
- package/src/advisors/here.ts +12 -12
- package/src/advisors/invite-send.ts +79 -35
- package/src/advisors/invite.ts +31 -8
- package/src/advisors/job.ts +24 -16
- package/src/advisors/login.ts +40 -15
- package/src/advisors/owner-store.ts +46 -22
- package/src/advisors/photos.ts +3 -3
- package/src/advisors/project.ts +25 -23
- package/src/advisors/reach.ts +89 -0
- package/src/advisors/rights.ts +1 -1
- package/src/advisors/routes.ts +55 -74
- package/src/advisors/scan.ts +0 -4
- package/src/advisors/setup-run.ts +14 -14
- package/src/advisors/share-trace.ts +3 -3
- package/src/advisors/{door-probe.ts → sign-in-probe.ts} +7 -6
- package/src/advisors/speaks.ts +29 -0
- package/src/advisors/sync.ts +92 -182
- package/src/advisors/tunnel.ts +6 -5
- package/src/advisors/users-listen.ts +92 -0
- package/src/advisors/users-router.ts +257 -85
- package/src/advisors/users-store.ts +81 -0
- package/src/agent-time/blocked-scan.ts +181 -0
- package/src/agent-time/registry.ts +12 -5
- package/src/agent-time/store.ts +9 -109
- package/src/asks/ask-bar-fold.ts +2 -1
- package/src/asks/ask-close.ts +2 -1
- package/src/asks/ask-doc.ts +2 -1
- package/src/asks/ask-migrate.ts +3 -2
- package/src/asks/ask-steps-fold.ts +2 -1
- package/src/asks/ask-store.ts +4 -3
- package/src/check.ts +3 -43
- package/src/checks/SK001-package-json-shape.check.ts +4 -55
- package/src/checks/SK004-gitignore-policy.check.ts +24 -69
- package/src/checks/SK013-one-way-in-policy.check.ts +3 -7
- package/src/checks/SK017-vscode-hub-task.check.ts +4 -4
- package/src/checks/SK019-tests-run-in-units.check.ts +3 -14
- package/src/checks/SK020-self-spawning-check.check.ts +5 -7
- package/src/checks/SK035-public-clean.check.ts +1 -1
- package/src/checks/SK039-vscode-watch-generated.check.ts +1 -1
- package/src/checks/SK042-post-kinds.check.ts +5 -14
- package/src/checks/SK054-agent-allow-list.check.ts +5 -74
- package/src/checks/SK055-retired-config-keys.check.ts +45 -0
- package/src/cli/cmd_Advisors.ts +11 -45
- package/src/cli/cmd_Asks.ts +3 -10
- package/src/cli/cmd_Backup.ts +25 -127
- package/src/cli/cmd_BackupTargets.ts +1 -1
- package/src/cli/cmd_Checks.ts +0 -14
- package/src/cli/cmd_Db.ts +3 -82
- package/src/cli/cmd_Home.ts +4 -32
- package/src/cli/cmd_Hq.ts +0 -17
- package/src/cli/cmd_Releases.ts +57 -4
- package/src/cli/cmd_Review.ts +333 -354
- package/src/cli/cmd_SocialDrafts.ts +6 -13
- package/src/cli/cmd_ThreadSyncNeeds.ts +6 -2
- package/src/cli/cmd_Time.ts +1 -1
- package/src/cli/cmd_Trailer.ts +1 -1
- package/src/cli/inbox-hook-run.ts +5 -23
- package/src/cli/registry-heads.ts +5 -55
- package/src/cli/registry.ts +1 -5
- package/src/cli/review-here.ts +1 -1
- package/src/cli.ts +2 -2
- package/src/collections/collection-types.ts +1 -1
- package/src/collections/review.ts +5 -4
- package/src/core/agent-allow-policy.ts +32 -2
- package/src/core/agent-env.ts +8 -0
- package/src/core/allow-rows.ts +74 -0
- package/src/core/check-file-names.ts +19 -106
- package/src/core/footprint.ts +17 -13
- package/src/core/identities-root.ts +1 -4
- package/src/core/layout.ts +1 -2
- package/src/core/machine-db.ts +33 -208
- package/src/core/machine-layout.ts +14 -127
- package/src/core/mask-source.ts +60 -0
- package/src/core/memory-watch.ts +17 -14
- package/src/core/motherhome.ts +8 -35
- package/src/core/one-way-in-policy.ts +0 -3
- package/src/core/repo-walk.ts +0 -9
- package/src/core/retention.ts +1 -9
- package/src/core/retired-checks.ts +2 -0
- package/src/core/tmux-policy.ts +1 -1
- package/src/core/tree-watch.ts +2 -2
- package/src/core/when.ts +7 -45
- package/src/gate/discover-checks.ts +42 -32
- package/src/gate/gate-checks.ts +21 -131
- package/src/gate/pre-commit-discovery.ts +16 -25
- package/src/gate/run-check.ts +0 -4
- package/src/gate/run-fix.ts +5 -17
- package/src/gate/run-fixers.ts +6 -42
- package/src/home/app-sign.ts +2 -2
- package/src/home/backup-status.ts +52 -92
- package/src/home/backup-verdict.ts +2 -2
- package/src/home/daemon-jobs.ts +51 -95
- package/src/home/database-words.ts +1 -2
- package/src/home/databases.ts +9 -25
- package/src/home/home-launchd.ts +0 -6
- package/src/home/home-paths.ts +8 -4
- package/src/home/home-routes.ts +3 -10
- package/src/home/home-state.ts +2 -14
- package/src/home/inbox-shape.ts +14 -15
- package/src/home/inbox.ts +1 -1
- package/src/home/machine-repair.ts +102 -103
- package/src/home/resume.ts +1 -15
- package/src/home/run-daemon.ts +4 -11
- package/src/home/space-page.ts +3 -2
- package/src/home/supervise.ts +3 -7
- package/src/hooks/hook-config.ts +6 -7
- package/src/hooks/leak-guard.ts +1 -1
- package/src/hooks/run-hooks.ts +0 -5
- package/src/hq/daemon-db.ts +8 -8
- package/src/hq/door.ts +3 -16
- package/src/hq/hq-db.ts +4 -3
- package/src/hq/hq-local.ts +1 -2
- package/src/hq/hq-store.ts +0 -15
- package/src/hq/item-direct.ts +8 -10
- package/src/hq/item-fill.ts +37 -0
- package/src/hq/kinds/item-gone.ts +7 -10
- package/src/hq/kinds/item-msg.ts +12 -18
- package/src/hq/kinds/item.ts +13 -19
- package/src/hq/kinds/report.ts +3 -4
- package/src/hq/owner-switch.ts +3 -3
- package/src/hq/report.ts +5 -9
- package/src/hq/switch.ts +2 -11
- package/src/hq/thread-sync.ts +5 -17
- package/src/hq/{shapes-words.ts → threads-words.ts} +2 -12
- package/src/http/owner-word.ts +1 -1
- package/src/identities/machine.ts +16 -0
- package/src/init-repo.ts +0 -1
- package/src/ledger/check-stats.ts +6 -5
- package/src/ledger/db.ts +2 -4
- package/src/ledger/record-kept.ts +117 -48
- package/src/ledger/run-log.ts +21 -2
- package/src/ledger/slow-tests.ts +96 -0
- package/src/ledger/store.ts +3 -86
- package/src/ledger/suite-log.ts +8 -2
- package/src/media-store/backup/facts.ts +3 -37
- package/src/media-store/backup/keys.ts +1 -8
- package/src/media-store/backup/manifest.ts +6 -67
- package/src/media-store/backup/restore.ts +4 -13
- package/src/media-store/backup/retention.ts +13 -1
- package/src/media-store/backup/run.ts +6 -267
- package/src/media-store/backup/snapshot.ts +2 -38
- package/src/media-store/backup/sources.ts +3 -113
- package/src/media-store/backup/target-send.ts +5 -29
- package/src/media-store/db.ts +8 -7
- package/src/media-store/forget-one.ts +1 -1
- package/src/media-store/forget.ts +1 -80
- package/src/orchestrator/guards.ts +0 -1
- package/src/orchestrator/presence.ts +2 -2
- package/src/orchestrator/routes.ts +1 -1
- package/src/orchestrator/started.ts +0 -9
- package/src/orchestrator/talk-key.ts +3 -4
- package/src/orchestrator/unheard.ts +1 -1
- package/src/recordings/edit.ts +3 -3
- package/src/recordings/marks-draw.ts +17 -6
- package/src/recordings/marks.ts +120 -9
- package/src/reflections/reflections-queue.ts +3 -10
- package/src/release/notes.ts +1 -1
- package/src/release/public-clean.ts +66 -6
- package/src/release/run-bump.ts +11 -0
- package/src/release/run-release.ts +4 -0
- package/src/releases/from-thread.ts +3 -3
- package/src/releases/model.ts +186 -36
- package/src/releases/store.ts +13 -3
- package/src/releases/validate.ts +83 -0
- package/src/repo-config.ts +29 -64
- package/src/review/answer-kinds.ts +61 -4
- package/src/review/blocked-guard.ts +11 -0
- package/src/review/blocked-object.ts +298 -0
- package/src/review/cells.ts +116 -229
- package/src/review/close.ts +39 -1
- package/src/review/doc-save.ts +3 -2
- package/src/review/draft-item.ts +1 -1
- package/src/review/events.ts +3 -7
- package/src/review/expect.ts +23 -39
- package/src/review/format.ts +79 -46
- package/src/review/glyphs.ts +1 -0
- package/src/review/hand-over.ts +3 -3
- package/src/review/heard.ts +1 -1
- package/src/review/holds-sync.ts +2 -1
- package/src/review/inbox-hook.ts +2 -2
- package/src/review/inbox-read.ts +39 -33
- package/src/review/instruction-guards.ts +12 -0
- package/src/review/instructions.ts +0 -1
- package/src/review/item-db.ts +13 -43
- package/src/review/item-hq.ts +2 -2
- package/src/review/item-rows.ts +3 -14
- package/src/review/kind-catalog.ts +3 -1
- package/src/review/kinds.ts +18 -8
- package/src/review/live-view.ts +3 -0
- package/src/review/media-kind.ts +1 -1
- package/src/review/mentions.ts +1 -2
- package/src/review/model.ts +158 -114
- package/src/review/move.ts +149 -0
- package/src/review/need-threads.ts +3 -2
- package/src/review/object-card.ts +11 -0
- package/src/review/object-read.ts +6 -1
- package/src/review/one-block.ts +1 -1
- package/src/review/owner-read.ts +1 -1
- package/src/review/phone-push.ts +10 -9
- package/src/review/previews.ts +32 -4
- package/src/review/push.ts +2 -2
- package/src/review/recap.ts +129 -0
- package/src/review/referring.ts +6 -3
- package/src/review/reflection-object.ts +4 -3
- package/src/review/routes.ts +49 -19
- package/src/review/secret-route.ts +3 -2
- package/src/review/settle.ts +0 -6
- package/src/review/snooze.ts +5 -3
- package/src/review/speaker.ts +68 -0
- package/src/review/start-title.ts +19 -0
- package/src/review/store.ts +86 -59
- package/src/review/{wakes.ts → thread-events.ts} +92 -7
- package/src/review/thread-md.ts +35 -14
- package/src/review/thread-state.ts +798 -0
- package/src/review/threads.ts +29 -347
- package/src/review/traces.ts +104 -7
- package/src/review/trailer-item.ts +1 -1
- package/src/review/unit.ts +7 -9
- package/src/review/verdict-items.ts +12 -10
- package/src/review/view-layout.ts +25 -1
- package/src/review/watch-feed.ts +1 -2
- package/src/review/working-guards.ts +2 -3
- package/src/rules/untrack-generated.ts +1 -15
- package/src/secrets/lapse.ts +2 -1
- package/src/serve/hub-app/advisor-app.tsx +4 -4
- package/src/serve/hub-app/advisor-face.tsx +9 -3
- package/src/serve/hub-app/advisor-host.ts +27 -27
- package/src/serve/hub-app/advisors-model.ts +17 -8
- package/src/serve/hub-app/advisors-rights.tsx +1 -1
- package/src/serve/hub-app/advisors-st.ts +15 -14
- package/src/serve/hub-app/advisors-view.tsx +13 -11
- package/src/serve/hub-app/app-bridge.ts +23 -3
- package/src/serve/hub-app/asks-page.tsx +1 -1
- package/src/serve/hub-app/auto-text.tsx +71 -16
- package/src/serve/hub-app/check-view.tsx +0 -8
- package/src/serve/hub-app/controls.css +14 -3
- package/src/serve/hub-app/database-view.tsx +1 -2
- package/src/serve/hub-app/git-view.tsx +3 -1
- package/src/serve/hub-app/hub.css +12 -5
- package/src/serve/hub-app/icons.tsx +1 -1
- package/src/serve/hub-app/inbox-view.tsx +1 -2
- package/src/serve/hub-app/live-sources.ts +2 -2
- package/src/serve/hub-app/main-panel.tsx +2 -1
- package/src/serve/hub-app/panel-repo.ts +0 -9
- package/src/serve/hub-app/pic.tsx +29 -12
- package/src/serve/hub-app/polled.ts +16 -2
- package/src/serve/hub-app/recordings-st.ts +23 -2
- package/src/serve/hub-app/recordings-view.tsx +68 -10
- package/src/serve/hub-app/ref-pill.ts +1 -1
- package/src/serve/hub-app/repo-st.ts +1 -2
- package/src/serve/hub-app/review/advisor-add.tsx +1 -1
- package/src/serve/hub-app/review/advisor-invite.tsx +1 -1
- package/src/serve/hub-app/review/draft-body.tsx +2 -2
- package/src/serve/hub-app/review/heard-line.tsx +1 -1
- package/src/serve/hub-app/review/instructions-view.tsx +1 -8
- package/src/serve/hub-app/review/kind-states.tsx +14 -9
- package/src/serve/hub-app/review/kit.tsx +4 -11
- package/src/serve/hub-app/review/lane-bar.tsx +3 -3
- package/src/serve/hub-app/review/lightbox.tsx +15 -11
- package/src/serve/hub-app/review/line-window.ts +4 -1
- package/src/serve/hub-app/review/live-bar-st.ts +2 -2
- package/src/serve/hub-app/review/live-view.tsx +57 -1
- package/src/serve/hub-app/review/object-panel.tsx +20 -8
- package/src/serve/hub-app/review/question-views.tsx +181 -54
- package/src/serve/hub-app/review/recap-bar.tsx +40 -0
- package/src/serve/hub-app/review/request-cell.tsx +48 -0
- package/src/serve/hub-app/review/review-cells.tsx +154 -96
- package/src/serve/hub-app/review/review-host.ts +2 -2
- package/src/serve/hub-app/review/review-kit.ts +17 -11
- package/src/serve/hub-app/review/review-list.tsx +23 -31
- package/src/serve/hub-app/review/review-st.ts +30 -40
- package/src/serve/hub-app/review/review-thread.tsx +139 -85
- package/src/serve/hub-app/review/review-views.tsx +124 -68
- package/src/serve/hub-app/review/share-lines.tsx +4 -4
- package/src/serve/hub-app/review/start-st.ts +2 -5
- package/src/serve/hub-app/review/superseded-runs.ts +4 -3
- package/src/serve/hub-app/review/thread-close.tsx +10 -7
- package/src/serve/hub-app/review/thread-st.ts +372 -201
- package/src/serve/hub-app/review/tone-bar.tsx +126 -0
- package/src/serve/hub-app/review/tones.ts +35 -0
- package/src/serve/hub-app/review/trailer-body.tsx +2 -2
- package/src/serve/hub-app/review/trailer-st.ts +3 -2
- package/src/serve/hub-app/review/trailer-voices-st.ts +3 -2
- package/src/serve/hub-app/review.css +180 -106
- package/src/serve/hub-app/search-view.tsx +1 -1
- package/src/serve/hub-app/social/social-model.ts +0 -4
- package/src/serve/hub-app/source-acts.ts +2 -1
- package/src/serve/hub-app/stores/stores-page.tsx +2 -2
- package/src/serve/hub-app/terminal-sources.tsx +2 -1
- package/src/serve/hub-app/thread-row.tsx +3 -4
- package/src/serve/hub-app/tree-build.ts +0 -4
- package/src/serve/hub-app/urls-view.tsx +2 -1
- package/src/serve/hub-app/view-layout.css +13 -3
- package/src/serve/hub-app/wikis-view.tsx +5 -2
- package/src/serve/hub-runtime.ts +7 -37
- package/src/serve/project-gutter-route.ts +6 -2
- package/src/serve/read-thread.ts +20 -2
- package/src/serve/read-worker.ts +9 -1
- package/src/serve/record-pages.ts +46 -0
- package/src/serve/serve-hub.ts +2 -2
- package/src/serve/terminal-host.ts +1 -1
- package/src/serve/terminal-route.ts +1 -3
- package/src/serve/tracked-watch.ts +1 -3
- package/src/setup-house.ts +2 -2
- package/src/shipkit-files.ts +1 -1
- package/src/shipkit.ts +1 -6
- package/src/shot/film-box.ts +0 -20
- package/src/social/drafts.ts +1 -1
- package/src/social/kinds.ts +6 -29
- package/src/social/load.ts +2 -2
- package/src/social/post-object.ts +3 -2
- package/src/social/release-stage.ts +1 -1
- package/src/social/stage.ts +2 -2
- package/src/stores/model.ts +4 -0
- package/src/stores/routes.ts +11 -3
- package/src/suite/judge-suites.ts +58 -0
- package/src/suite/red-alone.ts +54 -18
- package/src/suite/runner-shapes.ts +2 -2
- package/src/suite/suite-cli.ts +67 -14
- package/src/suite/test-units.ts +2 -1
- package/src/urls/fill.ts +1 -1
- package/src/urls/places.ts +1 -2
- package/src/vault/vault-config.ts +2 -2
- package/src/vault/vault-init.ts +1 -5
- package/src/wiki/graph-page.ts +14 -2
- package/src/advisors/copy-truth.ts +0 -49
- package/src/advisors/door-child.ts +0 -112
- package/src/advisors/door-serve.ts +0 -52
- package/src/advisors/door.ts +0 -118
- package/src/checks/SK016-legacy-check-shapes.check.ts +0 -189
- package/src/checks/SK029-explicit-check-files.check.ts +0 -112
- package/src/checks/SK048-one-local-file.check.ts +0 -36
- package/src/core/config-rewrite.ts +0 -111
- package/src/core/daemon-port.ts +0 -10
- package/src/core/legacy-shapes.ts +0 -263
- package/src/core/migrate-layout.ts +0 -638
- package/src/core/port-check-cli.ts +0 -52
- package/src/core/port-check-file.ts +0 -295
- package/src/core/port-check-files.ts +0 -31
- package/src/gate/discover-legacy-checks.ts +0 -26
- package/src/home/home-move.ts +0 -527
- package/src/home/machine-fold.ts +0 -810
- package/src/hq/item-shapes.ts +0 -54
- package/src/hq/kinds/items-read.ts +0 -4
- package/src/media-store/backup/daemon.ts +0 -220
- package/src/media-store/backup/kept.ts +0 -241
- package/src/media-store/backup/prune.ts +0 -359
- package/src/media-store/backup/secret.ts +0 -88
- package/src/media-store/backup/ssh-space.ts +0 -202
- package/src/media-store/backup/watch.ts +0 -117
- package/src/review/band.ts +0 -182
- package/src/review/folders.ts +0 -216
- package/src/review/hook-ask.ts +0 -58
- package/src/review/role.ts +0 -48
- package/src/review/thread-fold.ts +0 -64
- package/src/review/wait.ts +0 -91
- package/src/rules/rule.ts +0 -43
- package/src/serve/hook-thread.ts +0 -37
- package/src/serve/hook-work.ts +0 -92
- package/src/serve/hook-worker.ts +0 -57
- package/src/serve/hub-app/review/dock.tsx +0 -147
- package/src/serve/hub-app/review/faces.tsx +0 -18
- package/src/serve/hub-app/review/item-verdict.tsx +0 -112
- package/src/serve/hub-app/review/review-board.tsx +0 -48
- /package/src/{scaffold → core}/jsonc-spans.ts +0 -0
package/src/home/app-sign.ts
CHANGED
|
@@ -39,8 +39,8 @@ const realOf = (p: string): string => {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/** the signing keychain in the user's search list, once, at its path now: codesign finds an identity only there,
|
|
42
|
-
* `--keychain` or not. An entry that names the same file by another path (
|
|
43
|
-
* one
|
|
42
|
+
* `--keychain` or not. An entry that names the same file by another path (`~/.config/shipkit`, a link to the machine's
|
|
43
|
+
* one root) gives way to it */
|
|
44
44
|
export function listed(kc: string, r: Run): void {
|
|
45
45
|
const now = r(['security', 'list-keychains', '-d', 'user']).out.split('\n').map((l) => l.trim().replace(/^"|"$/g, '')).filter((l) => l !== '')
|
|
46
46
|
if (now.includes(kc)) return
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// where every backup of the house lives and whether it works (wiki tools/shipkit/media-store-backup.md, The status):
|
|
2
|
-
// one table, a row a store
|
|
3
|
-
// database of a machine: the hq holds every thread, a machine's rows are its outbox, judged by hq-holds),
|
|
2
|
+
// one table, a row a store (the vault, the hq, the Space; never a machine's untracked files, whose backup is retired,
|
|
3
|
+
// nor a database of a machine: the hq holds every thread, a machine's rows are its outbox, judged by hq-holds),
|
|
4
4
|
// a column a place (its own disk, Time Machine, each backup target), every cell its newest copy, its last proof and its
|
|
5
|
-
// state. ONE judgement, made on the machine that carries the hq: the
|
|
6
|
-
//
|
|
5
|
+
// state. ONE judgement, made on the machine that carries the hq: the other machines read the table from the hq, so
|
|
6
|
+
// every hub (the hq's Mac, a client, the phone) draws the same rows.
|
|
7
7
|
//
|
|
8
8
|
// The constraint a reader breaks first: it reads what the senders and the drills KEPT (the machine db, Litestream's own
|
|
9
9
|
// files, Time Machine's prefs), never the network, so a page asks it often; a store with no working copy off its
|
|
@@ -12,14 +12,15 @@ import { machineGet, machineSet } from '../core/machine-db.ts'
|
|
|
12
12
|
import { ageWords } from '../core/words.ts'
|
|
13
13
|
import type { BackupTarget } from '../hq/backup-targets.ts'
|
|
14
14
|
import { type Drill, healthWords, REPLICA_BEHIND_MS, replicaLag, type ReplicaHealth, type ReplicaPlace } from '../hq/replica.ts'
|
|
15
|
-
import type {
|
|
16
|
-
import
|
|
17
|
-
import { type BackupFacts, isBackupFacts, timeMachineFacts, type TimeMachineFacts } from '../media-store/backup/facts.ts'
|
|
15
|
+
import type { TargetSent } from '../media-store/backup/target-send.ts'
|
|
16
|
+
import { timeMachineFacts, type TimeMachineFacts } from '../media-store/backup/facts.ts'
|
|
18
17
|
import { rowName } from './backup-verdict.ts'
|
|
19
18
|
import type { Proof } from '../media-store/copy/proof.ts'
|
|
20
19
|
import type { ProvedRecord, Sent } from '../vault/vault-snapshot.ts'
|
|
21
20
|
|
|
22
21
|
export type CellState = 'ok' | 'warn' | 'danger' | 'dim'
|
|
22
|
+
/** the stores of the table: the vault, the hq, and the Space, whose one copy off its provider is the second place */
|
|
23
|
+
export type StoreId = 'vault' | 'hq' | 'space'
|
|
23
24
|
/** `row` names the store and its machine; `short` is the cell of the matrix (an age, or a word for a state), `text`
|
|
24
25
|
* and `proof` its full line; `off`: the place is off the store's machine, so it counts as a copy; `of`: a cell judged
|
|
25
26
|
* by the proof of the Space's second copy */
|
|
@@ -38,17 +39,13 @@ const BROKEN = new Set(['drill FAILED', 'proof FAILED', 'stopped', 'stalled'])
|
|
|
38
39
|
export const STORES: { id: StoreId; name: string; what: string }[] = [
|
|
39
40
|
{ id: 'vault', name: 'the vault', what: 'every secret, sealed: OpenBao' },
|
|
40
41
|
{ id: 'hq', name: 'the hq', what: 'hq.sqlite: machines, nodes, the items, messages and events of every thread' },
|
|
41
|
-
{ id: '
|
|
42
|
+
{ id: 'space', name: 'the Space', what: 'every media file the store keeps, the release pictures, the backup runs made before the backup of untracked files retired' },
|
|
42
43
|
]
|
|
43
|
-
/** the stores every machine keeps of its own; the vault and the hq live on the hq's machine alone */
|
|
44
|
-
const OWN_STORES: readonly StoreId[] = ['files']
|
|
45
44
|
|
|
46
45
|
const H = 3_600_000
|
|
47
|
-
/** past these a copy is stale: the vault's snapshot is daily,
|
|
48
|
-
*
|
|
49
|
-
export const BOUNDS = { vault: 26 * H,
|
|
50
|
-
/** a machine's report older than this is stale: its rows are shown as they were, orange, never red */
|
|
51
|
-
export const REPORT_STALE_MS = 15 * 60_000
|
|
46
|
+
/** past these a copy is stale: the vault's snapshot is daily, the hq's copy to a target is hourly, the Space copied
|
|
47
|
+
* to the second place nightly */
|
|
48
|
+
export const BOUNDS = { vault: 26 * H, hqCopy: 2 * H, hqCopyDanger: 26 * H, drill: 8 * 24 * H, timeMachine: 3 * 24 * H, spaceCopy: 26 * H, spaceCopyDanger: 50 * H }
|
|
52
49
|
|
|
53
50
|
/** what the status reads, gathered by `readBackupInputs` in the daemon or handed by a test */
|
|
54
51
|
export type BackupInputs = {
|
|
@@ -62,8 +59,6 @@ export type BackupInputs = {
|
|
|
62
59
|
vaultNear: { count: number; newest: number | null }
|
|
63
60
|
timeMachine: TimeMachineFacts
|
|
64
61
|
secondPlaceKey: boolean | null
|
|
65
|
-
/** every other machine's own stores, as its last hq report said them */
|
|
66
|
-
others?: { machine: string; at: number; facts: BackupFacts | null }[]
|
|
67
62
|
}
|
|
68
63
|
|
|
69
64
|
const ago = (at: number, now: number): string => `${ageWords(at, now)}`
|
|
@@ -112,28 +107,30 @@ function sentCell(s: TargetSent | null, now: number, warnAt: number, dangerAt: n
|
|
|
112
107
|
return { state: age > dangerAt ? 'danger' : age > warnAt ? 'warn' : 'ok', short: ago(s.at, now), text: `${s.name}, ${(s.bytes / 1e6).toFixed(1)} MB, ${ago(s.at, now)}`, proof: 'its sha checked on arrival', fix }
|
|
113
108
|
}
|
|
114
109
|
|
|
115
|
-
/** a store
|
|
116
|
-
|
|
117
|
-
function cellOf(store: StoreId, p: Place, d: BackupInputs, machine: string, mine: Pick<BackupInputs, 'get' | 'timeMachine'>): Draft {
|
|
110
|
+
/** a store at a place, judged on `machine`, the one that carries the hq */
|
|
111
|
+
function cellOf(store: StoreId, p: Place, d: BackupInputs, machine: string): Draft {
|
|
118
112
|
const now = d.now
|
|
119
113
|
const c = (state: CellState, short: string, text: string, proof: string | null = null, fix: string | null = null): Draft => ({ state, short, text, proof, fix })
|
|
120
|
-
const shortOf = (state: CellState, at: number
|
|
114
|
+
const shortOf = (state: CellState, at: number): string => (state === 'danger' ? `${ago(at, now)}, stale` : ago(at, now))
|
|
115
|
+
const target = d.targets.find((x) => x.id === p.id)
|
|
116
|
+
const space = target?.address.kind === 's3' && target.address.config === 'mediaSpace'
|
|
117
|
+
// the Space is at its provider, on no disk of a machine: its one copy off it is the second place
|
|
118
|
+
if (store === 'space' && !(target?.address.kind === 's3' && !space)) return c('dim', space ? 'itself' : 'not here', space ? 'the Space itself, at its provider' : `the Space is not copied to ${p.label}: its copy off its provider is the second place`)
|
|
121
119
|
if (p.kind === 'mac') {
|
|
122
120
|
if (store === 'vault') return c('dim', 'live', `the live vault on ${machine}${d.vaultNear.count > 0 ? `, ${d.vaultNear.count} sealed snapshots beside it${d.vaultNear.newest == null ? '' : `, the newest ${ago(d.vaultNear.newest, now)}`}` : ''}`, 'the same disk: no help if it dies')
|
|
123
|
-
return c('dim', 'live',
|
|
121
|
+
return c('dim', 'live', `the live hq.sqlite on ${machine}`, 'the same disk: no help if it dies')
|
|
124
122
|
}
|
|
125
123
|
if (p.kind === 'disk') {
|
|
126
|
-
const tm =
|
|
124
|
+
const tm = d.timeMachine
|
|
127
125
|
if (tm?.configured === false) return c('dim', 'not set up', `Time Machine is not set up on ${machine}: no copy there`, null, 'System Settings › General › Time Machine')
|
|
128
126
|
if (tm?.newest == null) return c('warn', 'unknown', `no Time Machine snapshot known on ${machine}`, null, 'System Settings › General › Time Machine')
|
|
129
127
|
const age = now - tm.newest
|
|
130
128
|
return c(age > BOUNDS.timeMachine ? 'warn' : 'ok', ago(tm.newest, now), `in its last snapshot, ${ago(tm.newest, now)}`, 'encrypted; not restore tested by shipkit (no Full Disk Access)', age > BOUNDS.timeMachine ? 'plug the disk in, or Time Machine › Back Up Now' : null)
|
|
131
129
|
}
|
|
132
|
-
const t =
|
|
130
|
+
const t = target!
|
|
133
131
|
const stream = d.replica.place === undefined ? 'mediaSpace' : d.replica.place
|
|
134
132
|
if (t.address.kind === 'ssh' && sameHost(t.address.host, machine)) return c('dim', 'itself', `${p.label} is the machine of this store: no copy off it`)
|
|
135
133
|
if (!p.on) return c('warn', 'off', 'the target is switched off', null, `sk backup targets on ${p.id}`)
|
|
136
|
-
const space = t.address.kind === 's3' && t.address.config === 'mediaSpace'
|
|
137
134
|
if (space) {
|
|
138
135
|
if (store === 'vault') {
|
|
139
136
|
const sent = d.get<Sent>('vault-snapshot-sent')
|
|
@@ -141,17 +138,9 @@ function cellOf(store: StoreId, p: Place, d: BackupInputs, machine: string, mine
|
|
|
141
138
|
if (sent == null) return c('danger', 'none', 'no sealed snapshot sent yet', null, 'sk vault snapshot')
|
|
142
139
|
const age = now - sent.at
|
|
143
140
|
const back = proved?.key === sent.key ? `restored with the seal key alone ${ago(proved.at, now)}` : proved == null ? 'never restored' : `the newest not restored yet (the last proof ${ago(proved.at, now)})`
|
|
144
|
-
return c(age > BOUNDS.vault ? 'danger' : proved?.key === sent.key || age < H ? 'ok' : 'warn', shortOf(age > BOUNDS.vault ? 'danger' : 'ok', sent.at
|
|
141
|
+
return c(age > BOUNDS.vault ? 'danger' : proved?.key === sent.key || age < H ? 'ok' : 'warn', shortOf(age > BOUNDS.vault ? 'danger' : 'ok', sent.at), `sealed snapshot ${ago(sent.at, now)}, ${sent.names} names`, back, age > BOUNDS.vault ? 'sk vault status' : null)
|
|
145
142
|
}
|
|
146
|
-
|
|
147
|
-
const last = mine.get<{ at: string }>('backup-last')
|
|
148
|
-
const parsed = last == null ? NaN : Date.parse(last.at)
|
|
149
|
-
const at = Number.isFinite(parsed) ? parsed : null
|
|
150
|
-
if (at == null) return c('danger', 'none', last == null ? 'no backup run yet' : 'its last run has no time that reads', null, 'sk backup')
|
|
151
|
-
const fresh: CellState = now - at > BOUNDS.run ? 'danger' : 'ok'
|
|
152
|
-
const drill = mine.get<BackupDrill>('backup-drill')
|
|
153
|
-
const dw = drillWords(drill?.at, drill == null ? null : drill.failed === 0, now, BOUNDS.drill, `restored with every sha${drill == null ? '' : ` (${drill.restored} files)`}${drill?.first == null ? '' : `: ${drill.first.path}: ${drill.first.error}`}`)
|
|
154
|
-
return c(worse(fresh, dw.state), shortOf(fresh, at, dw.state), `the backup run of ${ago(at, now)}`, dw.text, fresh === 'danger' ? 'sk backup' : dw.state === 'ok' ? null : 'sk backup drill')
|
|
143
|
+
return stream === 'mediaSpace' ? streamCell(d) : notStreamed(stream)
|
|
155
144
|
}
|
|
156
145
|
const second = t.address.kind === 's3'
|
|
157
146
|
if (second && d.secondPlaceKey === false) return c('warn', 'no key yet', 'no key yet: nothing goes there', null, 'ask 035: the three rv/shipkit/copy-* secrets')
|
|
@@ -159,7 +148,7 @@ function cellOf(store: StoreId, p: Place, d: BackupInputs, machine: string, mine
|
|
|
159
148
|
if (store === 'vault') return sentCell(d.get<TargetSent>(`target-sent:vault:${p.id}`), now, BOUNDS.vault, BOUNDS.vault + 2 * H, 'sk daemon job backup targets')
|
|
160
149
|
if (store === 'hq') return sentCell(d.get<TargetSent>(`target-sent:hq:${p.id}`), now, BOUNDS.hqCopy, BOUNDS.hqCopyDanger, 'sk daemon job backup targets')
|
|
161
150
|
if (second) {
|
|
162
|
-
// the second place copies the whole Space each night, the
|
|
151
|
+
// the second place copies the whole Space each night, the old backup runs with it
|
|
163
152
|
const proof = d.get<Proof>('space-copy-proof')
|
|
164
153
|
const copy = (x: Draft): Draft => ({ ...x, of: 'space copy' })
|
|
165
154
|
if (proof == null) return copy(d.get<boolean>('space-copy') === true ? c('warn', 'not yet', 'the first copy of the Space runs each night until it is whole: no proof yet', null, 'sk space') : c('warn', 'not yet', 'the Space is not copied there: the nightly copy is off', null, 'sk space copy --auto on'))
|
|
@@ -167,7 +156,7 @@ function cellOf(store: StoreId, p: Place, d: BackupInputs, machine: string, mine
|
|
|
167
156
|
const of = `the nightly copy of ${first}`
|
|
168
157
|
if (!proof.ok) return copy(c('danger', 'proof FAILED', `${of} failed its proof ${ago(proof.at, now)}`, proof.why[0] ?? 'the proof failed', 'sk space proof'))
|
|
169
158
|
const age = now - proof.at
|
|
170
|
-
// the backup runs are
|
|
159
|
+
// the backup runs are counted, each night's copy sends them first: the media filling behind them is not
|
|
171
160
|
const waiting = proof.kinds.find((k) => k.kind === 'backup')?.waiting ?? 0
|
|
172
161
|
const state: CellState = age > BOUNDS.spaceCopyDanger ? 'danger' : age > BOUNDS.spaceCopy || waiting > 0 ? 'warn' : 'ok'
|
|
173
162
|
const proved = `${of}, proved ${ago(proof.at, now)}`
|
|
@@ -179,11 +168,7 @@ function cellOf(store: StoreId, p: Place, d: BackupInputs, machine: string, mine
|
|
|
179
168
|
}
|
|
180
169
|
return copy(c(state, state === 'danger' ? `${ago(proof.at, now)}, stale` : ago(proof.at, now), waiting > 0 ? `${proved}; ${waiting} files of the backup runs are not there yet` : proved, 'counts and a sample hashed', state === 'ok' ? null : 'sk space proof'))
|
|
181
170
|
}
|
|
182
|
-
|
|
183
|
-
const sent = sentCell(d.get<TargetSent>(`target-sent:files:${p.id}`), now, BOUNDS.run, BOUNDS.run * 4, 'sk daemon job backup targets')
|
|
184
|
-
const drill = d.get<BackupDrill>(`target-drill:files:${p.id}`)
|
|
185
|
-
const dw = drillWords(drill?.at, drill == null ? null : drill.failed === 0, now, BOUNDS.drill, `restored from it with every sha${drill == null ? '' : ` (${drill.restored} files)`}${drill?.first == null ? '' : `: ${drill.first.path}: ${drill.first.error}`}`)
|
|
186
|
-
return { ...sent, state: worse(sent.state, dw.state), short: dw.state === 'danger' ? 'drill FAILED' : sent.short, proof: dw.text, fix: dw.state === 'ok' || sent.state !== 'ok' ? sent.fix : `sk backup drill --target ${p.id}` }
|
|
171
|
+
return c('dim', 'not here', `nothing of ${store} goes to ${p.label}`)
|
|
187
172
|
}
|
|
188
173
|
|
|
189
174
|
const whereOf = (t: BackupTarget): string => (t.address.kind === 'ssh' ? `${t.address.host}:${t.address.folder}` : t.address.config === 'mediaSpace' ? 'the private Space (s3)' : 'the second place (s3)')
|
|
@@ -201,47 +186,33 @@ export function backupStatus(d: BackupInputs): BackupStatus {
|
|
|
201
186
|
return a?.kind === 'ssh' ? a.host : ''
|
|
202
187
|
}
|
|
203
188
|
const offOf = (p: Place, machine: string): boolean => p.kind === 's3' || (p.kind === 'ssh' && !sameHost(hostOf(p.id), machine))
|
|
204
|
-
const none: Pick<BackupInputs, 'get' | 'timeMachine'> = { get: () => null, timeMachine: null }
|
|
205
|
-
const groups: { machine: string; stale: string | null; mine: Pick<BackupInputs, 'get' | 'timeMachine'>; ids: readonly StoreId[] }[] = [
|
|
206
|
-
{ machine: judge, stale: null, mine: d, ids: STORES.map((s) => s.id) },
|
|
207
|
-
...(d.others ?? []).map((o) => {
|
|
208
|
-
// a machine whose report holds no backup records (an older shipkit, records of a wrong shape) is a row too,
|
|
209
|
-
// orange: a machine left out of the table would let the headline go green over it
|
|
210
|
-
if (o.facts == null) return { machine: o.machine, stale: `${o.machine} does not report its backups (its shipkit is older, or its records did not read): not judged`, mine: none, ids: OWN_STORES }
|
|
211
|
-
const rec = o.facts.records as Record<string, unknown>
|
|
212
|
-
const get = <T,>(k: string): T | null => (k in rec ? ((rec[k] ?? null) as T | null) : null)
|
|
213
|
-
return { machine: o.machine, stale: d.now - o.at > REPORT_STALE_MS ? `${o.machine}'s last report is ${ageWords(o.at, d.now, { short: true })} old: its rows as they were` : null, mine: { get, timeMachine: o.facts.timeMachine }, ids: OWN_STORES }
|
|
214
|
-
}),
|
|
215
|
-
]
|
|
216
189
|
const cells: Cell[] = []
|
|
217
190
|
const stores: StoreRow[] = []
|
|
218
191
|
const alarms: string[] = []
|
|
219
|
-
for (const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
for (const id of g.ids) {
|
|
230
|
-
const s = STORES.find((x) => x.id === id)!
|
|
231
|
-
const row = `${g.machine}/${id}`
|
|
232
|
-
const mine = drafts.get(id)!
|
|
233
|
-
cells.push(...mine)
|
|
234
|
-
const off = mine.filter((c) => c.off)
|
|
235
|
-
const good = off.filter((c) => c.state === 'ok')
|
|
236
|
-
const label = rowName({ id, name: s.name, machine: g.machine })
|
|
237
|
-
if (g.stale == null) {
|
|
238
|
-
// a copy there but not proven (never restored, behind) is said as such: the fix differs from a copy gone
|
|
239
|
-
if (good.length === 0) alarms.unshift(off.some((c) => c.state === 'warn') ? `${label}: NO proven copy off ${g.machine}` : `${label}: NO working copy off ${g.machine}`)
|
|
240
|
-
for (const c of off.filter((x) => x.state === 'danger' && BROKEN.has(x.short))) alarms.push(`${label} on ${places.find((p) => p.id === c.place)!.label}: ${c.text}`)
|
|
192
|
+
for (const s of STORES) {
|
|
193
|
+
const row = `${judge}/${s.id}`
|
|
194
|
+
const mine = places.map((p): Cell => {
|
|
195
|
+
// a record that does not read leaves its cell orange, never the whole table thrown
|
|
196
|
+
let cell: Draft
|
|
197
|
+
try {
|
|
198
|
+
cell = cellOf(s.id, p, d, judge)
|
|
199
|
+
} catch (e) {
|
|
200
|
+
cell = { state: 'warn', short: 'unknown', text: `its records do not read (${(e as Error).message}): not judged`, proof: null, fix: null }
|
|
241
201
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
202
|
+
// the Space's own place and a place it never goes to are no copy of it
|
|
203
|
+
return { ...cell, row, store: s.id, place: p.id, off: offOf(p, judge) && !(s.id === 'space' && cell.state === 'dim') }
|
|
204
|
+
})
|
|
205
|
+
cells.push(...mine)
|
|
206
|
+
const off = mine.filter((c) => c.off)
|
|
207
|
+
const good = off.filter((c) => c.state === 'ok')
|
|
208
|
+
const label = rowName(s)
|
|
209
|
+
// the Space is its provider's: its second copy missing is orange, a broken one red, never « no copy »
|
|
210
|
+
const none = good.length === 0 && s.id !== 'space'
|
|
211
|
+
// a copy there but not proven (never restored, behind) is said as such: the fix differs from a copy gone
|
|
212
|
+
if (none) alarms.unshift(off.some((c) => c.state === 'warn') ? `${label}: NO proven copy off ${judge}` : `${label}: NO working copy off ${judge}`)
|
|
213
|
+
for (const c of off.filter((x) => x.state === 'danger' && BROKEN.has(x.short))) alarms.push(`${label} on ${places.find((p) => p.id === c.place)!.label}: ${c.text}`)
|
|
214
|
+
const state: CellState = none ? 'danger' : off.some((c) => c.state === 'danger') ? 'danger' : off.some((c) => c.state === 'warn') || good.length === 0 ? 'warn' : 'ok'
|
|
215
|
+
stores.push({ row, id: s.id, machine: judge, name: s.name, what: s.what, state, line: `${good.length} of ${off.length} copies off ${judge} work` })
|
|
245
216
|
}
|
|
246
217
|
// the headline is the cells': a cell not proven (unknown, never drilled, behind) keeps it from green
|
|
247
218
|
const unproven = cells.some((c) => c.state === 'warn' || c.state === 'danger') || stores.some((r) => r.state !== 'ok')
|
|
@@ -250,7 +221,7 @@ export function backupStatus(d: BackupInputs): BackupStatus {
|
|
|
250
221
|
}
|
|
251
222
|
|
|
252
223
|
/** every input, read on the machine that carries the hq: the targets of its hq, the kept records, Litestream's files,
|
|
253
|
-
* pm's word on the replica's process, the vault's snapshot folder, Time Machine's prefs
|
|
224
|
+
* pm's word on the replica's process, the vault's snapshot folder, Time Machine's prefs */
|
|
254
225
|
export async function readBackupInputs(now = Date.now()): Promise<BackupInputs> {
|
|
255
226
|
const [{ carriedHq }, { carriesHq }] = await Promise.all([import('../hq/hq-local.ts'), import('../hq/hq-role.ts')])
|
|
256
227
|
const { listTargets } = await import('../hq/backup-targets.ts')
|
|
@@ -264,16 +235,6 @@ export async function readBackupInputs(now = Date.now()): Promise<BackupInputs>
|
|
|
264
235
|
const store = carriesHq() ? carriedHq() : null
|
|
265
236
|
const targets = store == null ? [] : listTargets(store.db)
|
|
266
237
|
const machine = machineName()
|
|
267
|
-
const others: NonNullable<BackupInputs['others']> = []
|
|
268
|
-
// every machine of the owner's (a live node with the grant all), its newest report: one that says nothing of its
|
|
269
|
-
// backups is a row too, orange; a guest's node never adds rows
|
|
270
|
-
for (const m of store?.machines(null) ?? []) {
|
|
271
|
-
if (sameHost(m.name, machine)) continue
|
|
272
|
-
const latest = m.nodes.filter((n) => n.ended == null && n.report != null && store!.seesAll(n.id)).sort((a, b) => b.report!.at - a.report!.at)[0]
|
|
273
|
-
if (latest == null) continue
|
|
274
|
-
const b = latest.report!.body.backups
|
|
275
|
-
others.push({ machine: m.name, at: latest.report!.at, facts: isBackupFacts(b) ? b : null })
|
|
276
|
-
}
|
|
277
238
|
const r = (await askPm().catch(() => null))?.resources.find((x) => x.id === 'hq-replica')
|
|
278
239
|
let folder: string | null = null
|
|
279
240
|
try {
|
|
@@ -303,7 +264,6 @@ export async function readBackupInputs(now = Date.now()): Promise<BackupInputs>
|
|
|
303
264
|
vaultNear: { count, newest },
|
|
304
265
|
timeMachine: await timeMachineFacts(now),
|
|
305
266
|
secondPlaceKey: second == null ? null : !('failed' in second && second.failed.startsWith('no key yet')),
|
|
306
|
-
others,
|
|
307
267
|
}
|
|
308
268
|
}
|
|
309
269
|
|
|
@@ -335,7 +295,7 @@ export const alarmKeys = (s: BackupStatus): string[] =>
|
|
|
335
295
|
s.stale != null
|
|
336
296
|
? []
|
|
337
297
|
: [
|
|
338
|
-
...s.stores.filter((r) => r.stale !== true && !s.cells.some((c) => c.row === r.row && c.state === 'ok' && c.off)).map((r) => `${r.row}:none`),
|
|
298
|
+
...s.stores.filter((r) => r.stale !== true && r.id !== 'space' && !s.cells.some((c) => c.row === r.row && c.state === 'ok' && c.off)).map((r) => `${r.row}:none`),
|
|
339
299
|
...s.cells.filter((c) => c.state === 'danger' && BROKEN.has(c.short) && c.off && s.stores.find((r) => r.row === c.row)?.stale !== true).map((c) => `${c.row}@${c.place}`),
|
|
340
300
|
]
|
|
341
301
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// check. Pure: the hub's bundle imports it
|
|
3
3
|
import type { BackupStatus, StoreRow } from './backup-status.ts'
|
|
4
4
|
|
|
5
|
-
/** the name a line says:
|
|
6
|
-
export const rowName = (r: Pick<StoreRow, '
|
|
5
|
+
/** the name a line says: every store of the table is the house's */
|
|
6
|
+
export const rowName = (r: Pick<StoreRow, 'name'>): string => r.name
|
|
7
7
|
|
|
8
8
|
export function verdictWords(s: BackupStatus): string {
|
|
9
9
|
if (s.stale != null) return `not read: ${s.stale}`
|
package/src/home/daemon-jobs.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// THE DAEMON'S BACKGROUND JOBS, OFF ITS LOOP (wiki tools/shipkit/home.md, Nothing heavy on the daemon's loop): the
|
|
2
|
-
// backup, the retention sweep, the media store, the annex, the house's global context and the process apps each run as a child process (`sk daemon job <id>`, niced), started
|
|
2
|
+
// backup targets, the retention sweep, the media store, the annex, the house's global context and the process apps each run as a child process (`sk daemon job <id>`, niced), started
|
|
3
3
|
// detached with its pid in a file, its lines appended to the daemon's log. The daemon only starts it and reads the
|
|
4
4
|
// pid: an in place restart adopts a child still running and never starts a second one. What a job remembers between
|
|
5
5
|
// two runs lives in the machine db, so a restart never redoes a job's work.
|
|
@@ -8,10 +8,8 @@
|
|
|
8
8
|
// every page; a sync walk, a VACUUM or a hash pass there holds every page with it (tests/daemon-jobs.test.ts)
|
|
9
9
|
import { existsSync, mkdirSync, readFileSync, rmSync } from 'node:fs'
|
|
10
10
|
import { join } from 'node:path'
|
|
11
|
-
import { homedir } from 'node:os'
|
|
12
11
|
import { machineGet } from '../core/machine-db.ts'
|
|
13
12
|
import { loopWatch } from '../core/loop-watch.ts'
|
|
14
|
-
import { BACKUP_EVERY_MS } from '../media-store/backup/daemon.ts'
|
|
15
13
|
import { MEDIA_EVERY_MS, mediaDue } from '../media-store/daemon.ts'
|
|
16
14
|
import { ANNEX_EVERY_MS, annexDue } from '../annex/tidy.ts'
|
|
17
15
|
import { SWEEP_EVERY_MS, SWEPT_AT } from './machine-stores.ts'
|
|
@@ -21,7 +19,10 @@ import { REPORT_EVERY_MS } from '../hq/machine-notes.ts'
|
|
|
21
19
|
import { FOLLOW_FACT } from '../hq/follow-fact.ts'
|
|
22
20
|
import { pidAlive } from '../core/pid-alive.ts'
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
/** the looks of the backup targets and of the backup alarm */
|
|
23
|
+
const BACKUP_EVERY_MS = 120_000
|
|
24
|
+
|
|
25
|
+
export type JobId = 'retention sweep' | 'media store' | 'annex' | 'global context' | 'apps' | 'agent time' | 'hq report' | 'hq threads' | 'places' | 'db census' | 'space copy' | 'space listing' | 'vault' | 'backup targets' | 'backup alarm' | 'worktrees' | 'advisors' | 'thread search' | 'previews' | 'house follow' | 'blocked'
|
|
25
26
|
|
|
26
27
|
/** the look of the job 'backup targets', in the daemon's process: the targets of the hq it carries, read in place */
|
|
27
28
|
async function targetsDueHere(now: number): Promise<boolean> {
|
|
@@ -33,9 +34,8 @@ async function targetsDueHere(now: number): Promise<boolean> {
|
|
|
33
34
|
const { vaultPlace } = await import('../vault/vault-config.ts')
|
|
34
35
|
const { snapshotsDir } = await import('../vault/vault-snapshot.ts')
|
|
35
36
|
const { houseReplicaPlace } = await import('../hq/replica.ts')
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
return due.vault.length + due.hq.length + due.files.length + due.drill.length > 0
|
|
37
|
+
const due = targetsDue(listTargets(store.db), { vaultDir: snapshotsDir(vaultPlace()), carriesHq: true, now, stream: await houseReplicaPlace() })
|
|
38
|
+
return due.vault.length + due.hq.length > 0
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/** the body of the job 'backup targets', in its child: the list asked of the daemon, then every due send */
|
|
@@ -48,22 +48,13 @@ async function targetsJob(now: number): Promise<string[]> {
|
|
|
48
48
|
const { snapshotsDir } = await import('../vault/vault-snapshot.ts')
|
|
49
49
|
const { hqDbPath } = await import('../hq/hq-role.ts')
|
|
50
50
|
const { machineName } = await import('./machine-host.ts')
|
|
51
|
-
const { houseRetention } = await import('../media-store/backup/
|
|
51
|
+
const { houseRetention } = await import('../media-store/backup/retention.ts')
|
|
52
52
|
const { houseCopy } = await import('../media-store/copy/config.ts')
|
|
53
53
|
const { putStream } = await import('../media-store/copy/stream.ts')
|
|
54
|
-
const { machineSpace } = await import('../media-store/space.ts')
|
|
55
|
-
const { sshSpace, mirrorNewestRun } = await import('../media-store/backup/ssh-space.ts')
|
|
56
54
|
const { houseReplicaPlace } = await import('../hq/replica.ts')
|
|
57
55
|
const machine = machineName()
|
|
58
|
-
|
|
59
|
-
run: machineGet<{ key: string }>('backup-last')?.key ?? null,
|
|
56
|
+
return targetsTick({
|
|
60
57
|
stream: await houseReplicaPlace(),
|
|
61
|
-
mirror: async (t) => {
|
|
62
|
-
if (t.address.kind !== 'ssh') throw new Error('the mirror goes to an ssh target')
|
|
63
|
-
const { space, why } = await machineSpace()
|
|
64
|
-
if (space == null) throw new Error(`no Space to read the run from: ${why}`)
|
|
65
|
-
return mirrorNewestRun({ from: space, to: sshSpace({ peer: t.address.host, folder: t.address.folder, machine }), machine, home: (await import('node:os')).homedir() })
|
|
66
|
-
},
|
|
67
58
|
targets: r.targets,
|
|
68
59
|
vaultDir: snapshotsDir(vaultPlace()),
|
|
69
60
|
hqFile: (await import('../hq/hq-role.ts')).carriesHq() ? hqDbPath() : null,
|
|
@@ -78,21 +69,6 @@ async function targetsJob(now: number): Promise<string[]> {
|
|
|
78
69
|
},
|
|
79
70
|
},
|
|
80
71
|
})
|
|
81
|
-
// the mirror of each ssh target restored with every sha once a week, its result kept for the status
|
|
82
|
-
const { targetsDue } = await import('../media-store/backup/target-send.ts')
|
|
83
|
-
const { homedir } = await import('node:os')
|
|
84
|
-
const { drill } = await import('../media-store/backup/restore.ts')
|
|
85
|
-
for (const t of targetsDue(r.targets, { vaultDir: null, carriesHq: false, now: Date.now() }).drill) {
|
|
86
|
-
if (t.address.kind !== 'ssh') continue
|
|
87
|
-
try {
|
|
88
|
-
const d = await drill(sshSpace({ peer: t.address.host, folder: t.address.folder, machine }), { home: homedir(), recordAs: `target-drill:files:${t.id}` })
|
|
89
|
-
lines.push(`${d.failed.length === 0 ? 'ok:' : 'WARN'} files on ${t.label}: the run ${d.run} restored from it, ${d.restored} of ${d.files} files with their sha${d.failed.length === 0 ? '' : `, ${d.failed.length} FAILED (${d.failed[0]!.path})`}`)
|
|
90
|
-
} catch (e) {
|
|
91
|
-
// a drill that did not run proves nothing either way: kept as it was, tried again at the next look
|
|
92
|
-
lines.push(`WARN files on ${t.label}: the drill did not run: ${(e as Error).message}`)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return lines
|
|
96
72
|
}
|
|
97
73
|
|
|
98
74
|
let seats: import('../orchestrator/places-look.ts').SessionSeats | null = null
|
|
@@ -110,6 +86,19 @@ async function sessionSeats(): Promise<import('../orchestrator/places-look.ts').
|
|
|
110
86
|
|
|
111
87
|
/** how often the transcripts' new lines join the index of `sk time` */
|
|
112
88
|
export const AGENT_TIME_EVERY_MS = 10 * 60_000
|
|
89
|
+
let refusalTail: import('../agent-time/blocked-scan.ts').RefusalTail | null = null
|
|
90
|
+
let blockedAt = 0
|
|
91
|
+
|
|
92
|
+
/** the blocked job's look: a live transcript grew with a refusal in it, or 10 min passed since its last pass */
|
|
93
|
+
async function blockedDue(now: number): Promise<boolean> {
|
|
94
|
+
const [{ RefusalTail }, { liveTranscripts }] = await Promise.all([import('../agent-time/blocked-scan.ts'), import('../agent-time/registry.ts')])
|
|
95
|
+
refusalTail ??= new RefusalTail()
|
|
96
|
+
const saw = refusalTail.saw(liveTranscripts().map((f) => f.path))
|
|
97
|
+
if (!saw && now - blockedAt < AGENT_TIME_EVERY_MS) return false
|
|
98
|
+
blockedAt = now
|
|
99
|
+
return true
|
|
100
|
+
}
|
|
101
|
+
|
|
113
102
|
/** the vault job's look: the worst a missed end or a grant made narrower waits for the hq's settle */
|
|
114
103
|
export const VAULT_EVERY_MS = 15 * 60_000
|
|
115
104
|
|
|
@@ -122,20 +111,12 @@ export interface DaemonJob {
|
|
|
122
111
|
/** a cheap read in the daemon (a stat, never a walk; async when it gives the loop back between two): false skips
|
|
123
112
|
* the child for this look. `root` is the house repo the children run in; `printErr` the daemon's log */
|
|
124
113
|
due?: (now: number, root: string, printErr?: (l: string) => void) => boolean | Promise<boolean>
|
|
125
|
-
/** what the daemon holds for this job while it runs (a file watch whose callback only notes a path): started with
|
|
126
|
-
* the jobs, stopped with them; its `due` replaces the job's */
|
|
127
|
-
hold?: (root: string, printErr: (l: string) => void) => Promise<JobHold>
|
|
128
114
|
/** after a child killed (by a signal, or with its launch shell), the next look comes this soon instead of at the
|
|
129
115
|
* next period: what it left half way ends in seconds. A child that failed by itself waits its period, it would fail
|
|
130
116
|
* again */
|
|
131
117
|
againMs?: number
|
|
132
118
|
}
|
|
133
119
|
|
|
134
|
-
export interface JobHold {
|
|
135
|
-
due: (now: number) => boolean
|
|
136
|
-
stop: () => void
|
|
137
|
-
}
|
|
138
|
-
|
|
139
120
|
/** a child gets this long; past it, it is killed and said */
|
|
140
121
|
export const JOB_MAX_MS = 60 * 60_000
|
|
141
122
|
/** the niceness of every job child: the pages and the agents' tools go first */
|
|
@@ -143,16 +124,10 @@ export const JOB_NICE = 15
|
|
|
143
124
|
|
|
144
125
|
export const DAEMON_JOBS: readonly DaemonJob[] = [
|
|
145
126
|
// a stat of each store folder: a pass that found nothing waits MEDIA_QUIET_MS, unless a store moves
|
|
146
|
-
// the media index and the agent time index into the machine db, once, at the first start of a daemon of this code:
|
|
147
|
-
// until then the media store reads neither file and nothing goes up to the Space (home/machine-fold.ts). It runs
|
|
148
|
-
// with the home up and loses no writer's row; a look is two lstats and a row of the machine db
|
|
149
|
-
{ id: 'db fold', everyMs: 10 * 60_000, firstMs: 5_000, againMs: 5_000, due: async () => (await import('./machine-fold.ts')).foldDue() },
|
|
150
127
|
{ id: 'media store', everyMs: MEDIA_EVERY_MS, firstMs: 15_000, due: (now) => mediaDue(now) },
|
|
151
128
|
// the scratch on the annex: a spill when the drive leaves, merged back when it returns, born folders, stale scratch
|
|
152
129
|
{ id: 'annex', everyMs: ANNEX_EVERY_MS, firstMs: 20_000, due: (now) => annexDue(now) },
|
|
153
130
|
{ id: 'retention sweep', everyMs: 5 * 60_000, firstMs: 10_000, due: (now) => now - (machineGet<number>(SWEPT_AT) ?? 0) >= SWEEP_EVERY_MS },
|
|
154
|
-
// a watch of the sources: a look only once a source may have moved, a run waits, or a clock says so
|
|
155
|
-
{ id: 'backup', everyMs: BACKUP_EVERY_MS, firstMs: BACKUP_EVERY_MS, hold: (root, printErr) => backupHold(root, printErr) },
|
|
156
131
|
// the vault's newest sealed snapshot and the hq's hourly copy to every backup target but the Space: a look is a
|
|
157
132
|
// query of the hq's targets, rows of the machine db and one directory read (media-store/backup/target-send.ts)
|
|
158
133
|
{ id: 'backup targets', everyMs: BACKUP_EVERY_MS, firstMs: 75_000, due: async (now) => targetsDueHere(now) },
|
|
@@ -166,6 +141,11 @@ export const DAEMON_JOBS: readonly DaemonJob[] = [
|
|
|
166
141
|
{ id: 'apps', everyMs: APPS_EVERY_MS, firstMs: 45_000, due: async (now, root) => appsDue(now, await appsSourcesStamp(root)) },
|
|
167
142
|
// no cheap read tells which of ten thousand transcripts grew: a pass with nothing to read is their stats, about a second niced
|
|
168
143
|
{ id: 'agent time', everyMs: AGENT_TIME_EVERY_MS, firstMs: 90_000 },
|
|
144
|
+
// a command the auto mode classifier refused becomes a card in its repo's threads within seconds: a look reads the
|
|
145
|
+
// bytes each live transcript grew by for the refusal's words (agent-time/blocked-scan.ts RefusalTail), and the child
|
|
146
|
+
// indexes the live transcripts and reads the index rows since its last pass. A pass runs every 10 min anyway, for a
|
|
147
|
+
// refusal a look missed (a daemon restart)
|
|
148
|
+
{ id: 'blocked', everyMs: 10_000, firstMs: 25_000, due: (now) => blockedDue(now) },
|
|
169
149
|
// what this machine says of itself to the hq: one git status a repo, a second in a child, then the outbox (hq/hq-local.ts)
|
|
170
150
|
// a look every 30 s: the child once 5 min passed, or once the house follow's fact moved since (two machine db reads)
|
|
171
151
|
{ id: 'hq report', everyMs: 30_000, firstMs: 40_000, due: (now) => reportDue(now) },
|
|
@@ -227,20 +207,6 @@ export const DAEMON_JOBS: readonly DaemonJob[] = [
|
|
|
227
207
|
{ id: 'previews', everyMs: 1_000, firstMs: 20_000, due: async () => (await import('../review/previews-job.ts')).previewsDue() },
|
|
228
208
|
]
|
|
229
209
|
|
|
230
|
-
async function backupHold(root: string, printErr: (l: string) => void): Promise<JobHold> {
|
|
231
|
-
const { houseRepos } = await import('../house/project-gutter.ts')
|
|
232
|
-
const { BackupWatch } = await import('../media-store/backup/watch.ts')
|
|
233
|
-
let w: InstanceType<typeof BackupWatch>
|
|
234
|
-
try {
|
|
235
|
-
const house = houseRepos(root, homedir())
|
|
236
|
-
w = await new BackupWatch({ home: homedir(), repos: [...house.repos, ...house.archived].map((r) => r.path), printErr }).start()
|
|
237
|
-
} catch (e) {
|
|
238
|
-
printErr(`WARN daemon job backup: no watch of its sources (${(e as Error).message}): each look walks every source`)
|
|
239
|
-
w = new BackupWatch({ home: homedir(), repos: [] }).blindly()
|
|
240
|
-
}
|
|
241
|
-
return { due: (now) => w.due(now), stop: () => w.stop() }
|
|
242
|
-
}
|
|
243
|
-
|
|
244
210
|
/** when the last report was built, a machine db row the report's child writes */
|
|
245
211
|
export const REPORT_AT = 'hq-report-at'
|
|
246
212
|
|
|
@@ -261,10 +227,6 @@ export function contextDue(now: number, stamp: string | null): boolean {
|
|
|
261
227
|
|
|
262
228
|
export const isJobId = (s: string): s is JobId => DAEMON_JOBS.some((j) => j.id === s)
|
|
263
229
|
|
|
264
|
-
/** a job's names before: a daemon still on the older code starts its child by that name, from this checkout */
|
|
265
|
-
const JOB_BEFORE: Readonly<Record<string, JobId>> = { 'hq cards': 'hq threads' }
|
|
266
|
-
/** the job a name names, its older name included; null for none */
|
|
267
|
-
export const jobIdOf = (s: string): JobId | null => (isJobId(s) ? s : (JOB_BEFORE[s] ?? null))
|
|
268
230
|
|
|
269
231
|
/** SHIPKIT_DAEMON_JOBS=a,b: the only jobs a daemon looks at and runs (a trial on a scratch home), empty for none;
|
|
270
232
|
* unset, every job. A name no job has is refused */
|
|
@@ -272,9 +234,9 @@ export function jobsLimit(env: Record<string, string | undefined> = process.env)
|
|
|
272
234
|
const v = env.SHIPKIT_DAEMON_JOBS
|
|
273
235
|
if (v == null) return null
|
|
274
236
|
const names = v.split(',').map((x) => x.trim()).filter((x) => x !== '')
|
|
275
|
-
const bad = names.filter((n) =>
|
|
237
|
+
const bad = names.filter((n) => !isJobId(n))
|
|
276
238
|
if (bad.length > 0) throw new Error(`SHIPKIT_DAEMON_JOBS names no daemon job ${bad.map((n) => JSON.stringify(n)).join(', ')}: the jobs are ${DAEMON_JOBS.map((j) => j.id).join(', ')}`)
|
|
277
|
-
return new Set(names.
|
|
239
|
+
return new Set(names.filter(isJobId))
|
|
278
240
|
}
|
|
279
241
|
|
|
280
242
|
const limitLine = (limit: Set<JobId>): string => `SHIPKIT_DAEMON_JOBS limits this daemon to ${limit.size === 0 ? 'no job' : [...limit].join(', ')}`
|
|
@@ -320,7 +282,6 @@ export function startJobs(d: JobsDeps, all: readonly DaemonJob[] = DAEMON_JOBS,
|
|
|
320
282
|
const pidFile = (id: JobId): string => join(d.dir, `${slug(id)}.pid`)
|
|
321
283
|
const exitFile = (id: JobId): string => join(d.dir, `${slug(id)}.exit`)
|
|
322
284
|
const startedAt = new Map<JobId, number>()
|
|
323
|
-
const holds = new Map<JobId, JobHold>()
|
|
324
285
|
|
|
325
286
|
/** the pid of the job's child that still runs, else null; a finished child's failure said once */
|
|
326
287
|
const running = (id: JobId): number | null => {
|
|
@@ -365,8 +326,7 @@ export function startJobs(d: JobsDeps, all: readonly DaemonJob[] = DAEMON_JOBS,
|
|
|
365
326
|
const asking = new Set<JobId>()
|
|
366
327
|
const look = async (job: DaemonJob, force: boolean): Promise<number | null> => {
|
|
367
328
|
if (running(job.id) != null) return null
|
|
368
|
-
const
|
|
369
|
-
const due = hold != null ? (t: number): boolean => hold.due(t) : job.due
|
|
329
|
+
const due = job.due
|
|
370
330
|
if (!force && due != null) {
|
|
371
331
|
if (asking.has(job.id)) return null
|
|
372
332
|
asking.add(job.id)
|
|
@@ -394,12 +354,6 @@ export function startJobs(d: JobsDeps, all: readonly DaemonJob[] = DAEMON_JOBS,
|
|
|
394
354
|
}
|
|
395
355
|
if (o.timers !== false)
|
|
396
356
|
for (const job of jobs) {
|
|
397
|
-
// a hold that does not start leaves the job's own due: the look runs as it would with no hold
|
|
398
|
-
if (job.hold != null)
|
|
399
|
-
void job.hold(d.cwd, d.printErr).then(
|
|
400
|
-
(h) => (stopped ? h.stop() : void holds.set(job.id, h)),
|
|
401
|
-
(e) => d.printErr(`WARN daemon job ${job.id}: its watch did not start (${(e as Error).message}): each look runs as with no watch`),
|
|
402
|
-
)
|
|
403
357
|
const first = setTimeout(() => {
|
|
404
358
|
tick(job)
|
|
405
359
|
const every = setInterval(() => tick(job), job.everyMs)
|
|
@@ -414,8 +368,6 @@ export function startJobs(d: JobsDeps, all: readonly DaemonJob[] = DAEMON_JOBS,
|
|
|
414
368
|
stop: () => {
|
|
415
369
|
stopped = true
|
|
416
370
|
for (const t of timers) clearTimeout(t)
|
|
417
|
-
for (const h of holds.values()) h.stop()
|
|
418
|
-
holds.clear()
|
|
419
371
|
},
|
|
420
372
|
async run(id, ro = {}) {
|
|
421
373
|
const job = jobs.find((j) => j.id === id)
|
|
@@ -441,16 +393,11 @@ export async function runJobBody(id: JobId, o: { root: string; home: string; pri
|
|
|
441
393
|
const { tunnelStart } = await import('./advisors-tunnel-start.ts')
|
|
442
394
|
const r = await advisorsPass({ house: o.root, cwd: o.root, tunnel: tunnelStart() })
|
|
443
395
|
if (!('local' in r)) {
|
|
444
|
-
if (r.
|
|
396
|
+
if (r.advice > 0) o.print(`advisors: ${r.advice} advice delivered`)
|
|
445
397
|
for (const e of r.errors) o.printErr(`WARN advisors: ${e}`)
|
|
446
398
|
}
|
|
447
399
|
return
|
|
448
400
|
}
|
|
449
|
-
if (id === 'backup') {
|
|
450
|
-
const { backupTick } = await import('../media-store/backup/daemon.ts')
|
|
451
|
-
const { machineSpace } = await import('../media-store/space.ts')
|
|
452
|
-
return backupTick({ home: o.home, repos: [...repos, ...house.archived.map((r) => r.path)], space: machineSpace, print: o.print, printErr: o.printErr, drill: true })
|
|
453
|
-
}
|
|
454
401
|
if (id === 'backup targets') {
|
|
455
402
|
for (const l of await targetsJob(Date.now())) (l.startsWith('WARN') ? o.printErr : o.print)(l)
|
|
456
403
|
return
|
|
@@ -474,17 +421,6 @@ export async function runJobBody(id: JobId, o: { root: string; home: string; pri
|
|
|
474
421
|
await hqThreadsTick({ repos: house.repos.map((r) => ({ name: r.name, path: r.path })), print: o.print, printErr: o.printErr })
|
|
475
422
|
return
|
|
476
423
|
}
|
|
477
|
-
if (id === 'db fold') {
|
|
478
|
-
const { fold, foldAutoOn, foldDue, foldNotice } = await import('./machine-fold.ts')
|
|
479
|
-
if (!foldDue()) return
|
|
480
|
-
if (foldAutoOn()) {
|
|
481
|
-
const done = await fold({ print: o.print })
|
|
482
|
-
for (const f of done) if (f.done) o.print(`ok: db fold: the ${f.store} folded into the machine db in ${(f.ms / 1000).toFixed(1)} s, the longest step ${f.heldMs} ms`)
|
|
483
|
-
}
|
|
484
|
-
const ask = await foldNotice(o.root)
|
|
485
|
-
if (ask != null) o.print(`ok: db fold: the owner's notice is the ask ${ask}`)
|
|
486
|
-
return
|
|
487
|
-
}
|
|
488
424
|
if (id === 'db census') {
|
|
489
425
|
const { censusTick, houseProjects } = await import('./databases.ts')
|
|
490
426
|
censusTick({ repos: house.repos, carries: (await import('../hq/hq-role.ts')).carriesHq(), projects: await houseProjects(house.repos), print: o.print })
|
|
@@ -561,6 +497,26 @@ export async function runJobBody(id: JobId, o: { root: string; home: string; pri
|
|
|
561
497
|
}
|
|
562
498
|
return
|
|
563
499
|
}
|
|
500
|
+
if (id === 'blocked') {
|
|
501
|
+
const t0 = performance.now()
|
|
502
|
+
const [{ agentTimeDbPath, indexTranscripts, openIndex }, { liveTranscripts, readParties }, { blockedPass }, { sessionLabel }] = await Promise.all([
|
|
503
|
+
import('../agent-time/store.ts'),
|
|
504
|
+
import('../agent-time/registry.ts'),
|
|
505
|
+
import('../agent-time/blocked-scan.ts'),
|
|
506
|
+
import('../review/parties.ts'),
|
|
507
|
+
])
|
|
508
|
+
const db = openIndex(agentTimeDbPath(o.home))
|
|
509
|
+
try {
|
|
510
|
+
// the live sessions' new lines first: the refusal a look saw is in the index before the pass reads it
|
|
511
|
+
const live = liveTranscripts()
|
|
512
|
+
const ix = indexTranscripts(db, live)
|
|
513
|
+
const p = await blockedPass(db, house.repos, { label: async (s) => sessionLabel(s, await readParties({ sessions: [s] })), printErr: o.printErr })
|
|
514
|
+
if (p.refusals > 0) o.print(`ok: blocked: ${p.refusals} refusal(s), ${p.counted} counted, ${p.opened} card(s) opened, ${p.skipped} of no house repo; index of ${live.length} live transcript(s) ${ix.ms.toFixed(0)} ms, scan ${p.scanMs.toFixed(1)} ms, pass ${(performance.now() - t0).toFixed(0)} ms`)
|
|
515
|
+
} finally {
|
|
516
|
+
db.close()
|
|
517
|
+
}
|
|
518
|
+
return
|
|
519
|
+
}
|
|
564
520
|
if (id === 'global context') {
|
|
565
521
|
const { contextSourcesStamp, houseContext, writeIfChanged } = await import('./global-context.ts')
|
|
566
522
|
const { machineSet } = await import('../core/machine-db.ts')
|
|
@@ -4,7 +4,7 @@ import type { Part, ProjectView, Unsplit } from './database-projects.ts'
|
|
|
4
4
|
import type { DatabasesPage, DbPart, DbRole, DbSpec, DbView, KindUse, TableCount } from './databases.ts'
|
|
5
5
|
import { ageWords, bytesWords } from '../core/words.ts'
|
|
6
6
|
import { holdState, holdWords, type MachineHolds } from '../hq/holds-shape.ts'
|
|
7
|
-
import {
|
|
7
|
+
import { threadsLine } from '../hq/threads-words.ts'
|
|
8
8
|
|
|
9
9
|
export const count = (n: number): string => n.toLocaleString('en-US')
|
|
10
10
|
|
|
@@ -205,7 +205,6 @@ export function hqFacts(p: DatabasesPage, now: number): string[] {
|
|
|
205
205
|
if (h.error != null) out.push(`its kinds are unread: ${h.error}`)
|
|
206
206
|
const version = h.fileVersion == null ? null : h.fileVersion === h.codeVersion ? `file version ${h.fileVersion}` : `file version ${h.fileVersion}, this code makes ${h.codeVersion}`
|
|
207
207
|
out.push([version, `wire version ${h.wire}`, h.feedTop == null ? null : `the feed's top is ${count(h.feedTop)}`].filter((x) => x != null).join(', '))
|
|
208
|
-
if (h.shapes != null) out.push(`${shapesLine(h.shapes)} (compared ${ageWords(h.shapes.at, now)})`)
|
|
209
208
|
const r = h.replica
|
|
210
209
|
out.push(!r.configured ? 'no replica: the file is on this disk only' : r.running ? `replica: Litestream runs${r.since == null ? '' : ` for ${ageWords(r.since, now, { short: true })}`}${r.to == null ? '' : `, to ${r.to}`}` : `replica: Litestream is not running${r.to == null ? '' : `, its copy at ${r.to} stops where it was`}`)
|
|
211
210
|
const d = h.drill
|