rvlib-shipkit 2.31.0 → 2.33.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 +51 -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 +122 -76
- 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 +20 -221
- 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 +27 -25
- 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 +97 -183
- package/src/advisors/tunnel.ts +6 -5
- package/src/advisors/users-listen.ts +92 -0
- package/src/advisors/users-router.ts +261 -87
- 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_Capacity.ts +6 -2
- package/src/cli/cmd_Checks.ts +0 -14
- package/src/cli/cmd_Ci.ts +2 -1
- 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_Shot.ts +26 -4
- 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 +15 -4
- package/src/collections/collection-types.ts +1 -1
- package/src/collections/review.ts +5 -4
- package/src/core/admission.ts +268 -0
- 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/code-lines.ts +36 -21
- 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/machine-read.ts +5 -2
- 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/peer-sk.ts +8 -0
- 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/admit-heavy.ts +150 -0
- package/src/gate/check-runner.ts +6 -0
- package/src/gate/discover-checks.ts +42 -32
- package/src/gate/gate-checks.ts +21 -131
- package/src/gate/head-gate.ts +1 -1
- package/src/gate/job-run.ts +2 -1
- package/src/gate/pre-commit-discovery.ts +22 -28
- package/src/gate/run-check.ts +3 -4
- package/src/gate/run-ci.ts +4 -0
- 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 +7 -12
- package/src/home/space-page.ts +3 -2
- package/src/home/supervise.ts +3 -7
- package/src/hooks/commit-msg-run.ts +61 -0
- package/src/hooks/commit-run.ts +16 -166
- package/src/hooks/gate-outcome.ts +108 -0
- package/src/hooks/git-hook.ts +9 -9
- package/src/hooks/hook-config.ts +8 -8
- package/src/hooks/leak-guard.ts +1 -1
- package/src/hooks/pre-commit-checks.ts +1 -1
- package/src/hooks/run-hooks.ts +2 -6
- package/src/hooks/shared-file.ts +3 -2
- 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/plan/planner.ts +3 -2
- 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 +36 -64
- package/src/review/answer-kinds.ts +63 -4
- package/src/review/blocked-guard.ts +11 -0
- package/src/review/blocked-object.ts +298 -0
- package/src/review/cells.ts +144 -230
- 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 +51 -47
- 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-parties.ts +28 -0
- package/src/review/store.ts +94 -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 +804 -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/copy.ts +4 -4
- 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/dock-st.ts +1 -1
- 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 +191 -53
- 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 +8 -4
- package/src/serve/hub-app/review/review-kit.ts +17 -11
- package/src/serve/hub-app/review/review-list.tsx +30 -35
- package/src/serve/hub-app/review/review-st.ts +32 -42
- package/src/serve/hub-app/review/review-thread.tsx +139 -85
- package/src/serve/hub-app/review/review-views.tsx +127 -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 +381 -202
- package/src/serve/hub-app/review/tone-bar.tsx +129 -0
- package/src/serve/hub-app/review/tones.ts +53 -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 +189 -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/client.ts +2 -1
- package/src/shot/film-box.ts +0 -20
- package/src/shot/on-place.ts +141 -0
- 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/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
|
package/src/home/databases.ts
CHANGED
|
@@ -11,14 +11,14 @@ import { existsSync, readdirSync, readFileSync, statSync } from 'fs'
|
|
|
11
11
|
import { homedir } from 'os'
|
|
12
12
|
import { basename, dirname, join } from 'path'
|
|
13
13
|
import { agentTimeDbPath } from '../agent-time/store.ts'
|
|
14
|
-
import {
|
|
14
|
+
import { machineDbPath, machineGet, machineSet } from '../core/machine-db.ts'
|
|
15
15
|
import { HQ_FILE_VERSION, HQ_SCHEMA_VERSION, hqDbPath } from '../hq/hq-role.ts'
|
|
16
|
-
import { HQ_MAX_BYTES
|
|
16
|
+
import { HQ_MAX_BYTES } from '../hq/hq-store.ts'
|
|
17
17
|
import { KINDS } from '../hq/kinds/index.ts'
|
|
18
18
|
import { DAEMON_TABLES, daemonDbPath } from '../hq/daemon-db.ts'
|
|
19
19
|
import type { Drill } from '../hq/replica.ts'
|
|
20
20
|
import { holdsOfNodes } from '../hq/hq-holds.ts'
|
|
21
|
-
import type {
|
|
21
|
+
import type { ThreadsWhere } from '../hq/threads-words.ts'
|
|
22
22
|
import type { MachineHolds } from '../hq/holds-shape.ts'
|
|
23
23
|
import { yieldLoop } from '../core/loop-watch.ts'
|
|
24
24
|
import { isForeign } from '../core/foreign.ts'
|
|
@@ -35,7 +35,7 @@ export type DbRole = 'truth' | 'cache' | 'machine'
|
|
|
35
35
|
/** one store inside a file that holds several (the machine db): its tables are those its `prefix` starts, the
|
|
36
36
|
* tables no other part names when null */
|
|
37
37
|
/** a part of a file of several stores: its tables are those its prefix starts, or `tables` named whole (a store whose
|
|
38
|
-
* tables keep their own names, as the daemon's
|
|
38
|
+
* tables keep their own names, as the daemon's) */
|
|
39
39
|
export type DbPart = { id: string; kind: DbKind; name: string; prefix: string | null; tables?: readonly string[]; role: DbRole; roleWords: string; split: Split | null }
|
|
40
40
|
/** one database of the machine: `cap` in bytes of pages used, where shipkit gives one; `role` and its words say what
|
|
41
41
|
* deleting it costs; `split` how it names the repo of a row (database-projects.ts); `parts` the stores it holds */
|
|
@@ -57,11 +57,10 @@ export type DbView = DbSpec & { where: string; live: Live | null; count: DbCount
|
|
|
57
57
|
export type KindUse = { kind: string; node: string; who: string; rows: number; bytes: number; maxRows: number; maxBytes: number }
|
|
58
58
|
export type Replica = { configured: boolean; to: string | null; running: boolean; since: number | null }
|
|
59
59
|
/** `holds`: what the hq holds of each live node's rows, from its newest report (hq/hq-holds.ts) */
|
|
60
|
-
export type HqFacts = { carries: boolean; url: string; fileVersion: number | null; codeVersion: number; wire: number; feedTop: number | null; kinds: KindUse[]; holds: MachineHolds[]; replica: Replica; drill: Drill | null; error: string | null; /**
|
|
61
|
-
/** `fold`: where the machine's fold stands, its words (home/machine-fold.ts foldWords) */
|
|
60
|
+
export type HqFacts = { carries: boolean; url: string; fileVersion: number | null; codeVersion: number; wire: number; feedTop: number | null; kinds: KindUse[]; holds: MachineHolds[]; replica: Replica; drill: Drill | null; error: string | null; /** where this machine's threads are read and written (review/item-hq.ts) */ threads?: ThreadsWhere }
|
|
62
61
|
/** `machine`: the one that drew it; `client`: set on a client, which shows the hq machine's page (`hq` names that
|
|
63
62
|
* machine, `stale` says the hq did not answer); `own`: a client's own files, apart from the hq's page */
|
|
64
|
-
export type DatabasesPage = { at: number; machine?: string; dbs: DbView[]; hq: HqFacts | null; projects: ProjectView[]; unsplit: Unsplit[];
|
|
63
|
+
export type DatabasesPage = { at: number; machine?: string; dbs: DbView[]; hq: HqFacts | null; projects: ProjectView[]; unsplit: Unsplit[]; client?: { hq: string; readAt: number; stale?: string }; own?: DbView[] }
|
|
65
64
|
|
|
66
65
|
/** the counts the census job keeps, by file */
|
|
67
66
|
export type Census = { at: number; counts: Record<string, DbCount>; projects?: Project[] }
|
|
@@ -101,13 +100,6 @@ export function machineDatabases(repos: readonly { name: string; path: string }[
|
|
|
101
100
|
...(mediaDbPath() === machine ? [] : [{ id: 'media index', name: 'media index', kind: 'media' as const, what: 'every media file of this machine and its object in the Space', path: mediaDbPath(), cap: MEDIA_INDEX_MAX_BYTES, repo: null, role: 'cache' as const, roleWords: MEDIA_WORDS, roleShort: 'builds again from the files', split: media('media_files'), parts: null }]),
|
|
102
101
|
...(agentTimeDbPath() === machine ? [] : [{ id: 'agent time index', name: 'agent time index', kind: 'agent-time' as const, what: 'every Claude Code transcript, read for sk time', path: agentTimeDbPath(), cap: null, repo: null, role: 'cache' as const, roleWords: TIME_WORDS, roleShort: 'builds again, but holds what Claude Code pruned', split: time('time_files'), parts: null }]),
|
|
103
102
|
]
|
|
104
|
-
// a store's own file still there, not folded yet: listed under its old tables, so a page before the fold shows it
|
|
105
|
-
for (const store of FOLDED_STORES) {
|
|
106
|
-
const old = oldStorePath(store)
|
|
107
|
-
if (!existsSync(old) || isTombstone(old) || own.some((s) => s.path === old)) continue
|
|
108
|
-
const isMedia = store === 'media index'
|
|
109
|
-
own.push({ id: `${store} file`, name: `${store} (not folded)`, kind: isMedia ? 'media' : 'agent-time', what: `its own file until sk db fold moves it into ${tilde(machine)}`, path: old, cap: null, repo: null, role: 'cache', roleWords: `${isMedia ? MEDIA_WORDS : TIME_WORDS}; not read by this code until sk db fold`, roleShort: 'the daemon folds it at its start', split: isMedia ? media('files') : time('files'), parts: null })
|
|
110
|
-
}
|
|
111
103
|
const seen = new Set(own.map((s) => s.path))
|
|
112
104
|
const records: DbSpec[] = []
|
|
113
105
|
for (const r of repos) {
|
|
@@ -401,7 +393,7 @@ export async function replicaOf(config: string, on: Running = running): Promise<
|
|
|
401
393
|
}
|
|
402
394
|
|
|
403
395
|
/** the hq's kinds by node, the feed's top, read live from the file: a few small tables */
|
|
404
|
-
function hqTables(path: string): Pick<HqFacts, 'kinds' | 'feedTop' | 'holds' | 'error'
|
|
396
|
+
function hqTables(path: string): Pick<HqFacts, 'kinds' | 'feedTop' | 'holds' | 'error'> {
|
|
405
397
|
if (!existsSync(path)) return { kinds: [], feedTop: null, holds: [], error: null }
|
|
406
398
|
let db: Database | null = null
|
|
407
399
|
try {
|
|
@@ -416,9 +408,7 @@ function hqTables(path: string): Pick<HqFacts, 'kinds' | 'feedTop' | 'holds' | '
|
|
|
416
408
|
})
|
|
417
409
|
const top = there.has('sqlite_sequence') ? (db.query("select seq from sqlite_sequence where name = 'feed'").get() as { seq: number } | null) : null
|
|
418
410
|
const holds = there.has('reports') && there.has('nodes') ? holdsOfNodes(db) : []
|
|
419
|
-
|
|
420
|
-
const shapes = kept == null ? null : (JSON.parse(kept.value) as ShapesDiff & { at: number })
|
|
421
|
-
return { kinds, feedTop: top?.seq ?? (there.has('feed') ? 0 : null), holds, error: null, ...(shapes == null ? {} : { shapes }) }
|
|
411
|
+
return { kinds, feedTop: top?.seq ?? (there.has('feed') ? 0 : null), holds, error: null }
|
|
422
412
|
} catch (e) {
|
|
423
413
|
return { kinds: [], feedTop: null, holds: [], error: why(e) }
|
|
424
414
|
} finally {
|
|
@@ -474,14 +464,8 @@ export async function databasesPage(o: { repos: readonly { name: string; path: s
|
|
|
474
464
|
const hq = hqFacts == null ? null : { ...(await hqFacts), fileVersion: dbs.find((d) => d.kind === 'hq')?.live?.version ?? null }
|
|
475
465
|
// the projects the census read the configs of, else the repos by their folder's name
|
|
476
466
|
const projects = (census?.projects ?? o.repos.map((r) => ({ name: r.name, id: r.name, path: r.path, key: null }))).filter((p) => o.foreign !== false || !isForeign(p.path))
|
|
477
|
-
let fold: string[] | undefined
|
|
478
|
-
try {
|
|
479
|
-
fold = (await import('./machine-fold.ts')).foldWords()
|
|
480
|
-
} catch (e) {
|
|
481
|
-
fold = [`the fold's state does not read: ${why(e)}`]
|
|
482
|
-
}
|
|
483
467
|
const { machineName } = await import('./machine-host.ts')
|
|
484
|
-
return { at: now, machine: machineName(), dbs, hq, ...projectsOf(dbs, projects)
|
|
468
|
+
return { at: now, machine: machineName(), dbs, hq, ...projectsOf(dbs, projects) }
|
|
485
469
|
}
|
|
486
470
|
|
|
487
471
|
/** the last page a client read from the hq, kept in its daemon */
|
package/src/home/home-launchd.ts
CHANGED
|
@@ -8,8 +8,6 @@ import { dirname, join } from 'path'
|
|
|
8
8
|
import { homeDir, pmLog } from './home-paths.ts'
|
|
9
9
|
|
|
10
10
|
export const LABEL = 'com.shipkit.pm'
|
|
11
|
-
/** the agent that ran `shipkit home` before pm: an install replaces it */
|
|
12
|
-
export const LEGACY_LABEL = 'com.shipkit.home'
|
|
13
11
|
/** where launchd reads user agents. SHIPKIT_LAUNCH_AGENTS_DIR moves it, so a
|
|
14
12
|
* live smoke installs into a scratch dir and never the real one */
|
|
15
13
|
export const agentsDir = (home = homedir()): string => process.env.SHIPKIT_LAUNCH_AGENTS_DIR ?? join(home, 'Library', 'LaunchAgents')
|
|
@@ -106,8 +104,6 @@ export async function installHome(o: { root: string; cli: string; print: (l: str
|
|
|
106
104
|
writeFileSync(file, renderPlist({ bun, cli: o.cli, root: o.root, path: agentPath(process.env.PATH, bun), log }))
|
|
107
105
|
// a loaded copy holds the old arguments: out first, then in
|
|
108
106
|
await run(['bootout', `${domain()}/${LABEL}`])
|
|
109
|
-
await run(['bootout', `${domain()}/${LEGACY_LABEL}`])
|
|
110
|
-
rmSync(plistPath(homedir(), LEGACY_LABEL), { force: true })
|
|
111
107
|
const sleep = o.sleep ?? Bun.sleep
|
|
112
108
|
let r = await run(['bootstrap', domain(), file])
|
|
113
109
|
for (let i = 1; i < BOOTSTRAP_TRIES && r.code !== 0; i++) {
|
|
@@ -128,8 +124,6 @@ export async function uninstallHome(o: { print: (l: string) => void; run?: Launc
|
|
|
128
124
|
const run = o.run ?? launchctl
|
|
129
125
|
const file = plistPath()
|
|
130
126
|
const r = await run(['bootout', `${domain()}/${LABEL}`])
|
|
131
|
-
await run(['bootout', `${domain()}/${LEGACY_LABEL}`])
|
|
132
|
-
rmSync(plistPath(homedir(), LEGACY_LABEL), { force: true })
|
|
133
127
|
if (existsSync(file)) rmSync(file)
|
|
134
128
|
o.print(r.code === 0 ? `ok: pm, the daemon and the web are stopped and will not start at login. The resources and repo processes keep running` : `ok: no pm agent was loaded; ${file} is gone`)
|
|
135
129
|
return 0
|
package/src/home/home-paths.ts
CHANGED
|
@@ -16,9 +16,14 @@ export const homePort = (): number => {
|
|
|
16
16
|
return Number.isInteger(env) && env > 0 ? env : DEFAULT_HOME_PORT
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
/** the daemon's internal port: every repo runtime and every api answer here, and the web on the home port is the one
|
|
20
|
+
* door a browser uses */
|
|
21
|
+
export const DEFAULT_DAEMON_PORT = 4798
|
|
20
22
|
|
|
21
|
-
export
|
|
23
|
+
export const daemonPort = (env: Record<string, string | undefined> = process.env): number => {
|
|
24
|
+
const port = Number(env.SHIPKIT_DAEMON_PORT)
|
|
25
|
+
return Number.isInteger(port) && port > 0 ? port : DEFAULT_DAEMON_PORT
|
|
26
|
+
}
|
|
22
27
|
|
|
23
28
|
/** pm's port: its api (children, resources), which the web proxies at /api/pm/* */
|
|
24
29
|
export const DEFAULT_PM_PORT = 4797
|
|
@@ -78,7 +83,7 @@ export function realHomeRefusal(main: string, env: Record<string, string | undef
|
|
|
78
83
|
return `${main}: a test reached the machine's real home and its machine db; give the run a temp SHIPKIT_HOME_DIR in its test preload (shipkit's: packages/rvlib-shipkit/tests/_setup.ts), or run it through sk ci, whose suite runner gives each run one`
|
|
79
84
|
}
|
|
80
85
|
|
|
81
|
-
/** `~/.shipkit/home
|
|
86
|
+
/** `~/.shipkit/home`, beside the rail order
|
|
82
87
|
* file (project-gutter-route.ts orderFile) */
|
|
83
88
|
export const homeDir = (): string => {
|
|
84
89
|
const dir = process.env.SHIPKIT_HOME_DIR
|
|
@@ -104,7 +109,6 @@ export const childPid = (dir: string, role: string): string => join(dir, `${role
|
|
|
104
109
|
export const childBeat = (dir: string, role: string): string => join(dir, `${role}.beat`)
|
|
105
110
|
export const resourceLog = (dir: string, id: string): string => join(dir, 'resources', `${id}.log`)
|
|
106
111
|
export const resourcePid = (dir: string, id: string): string => join(dir, 'resources', `${id}.pid`)
|
|
107
|
-
export const stateFile = (dir: string): string => join(dir, 'state.json')
|
|
108
112
|
|
|
109
113
|
/** the url prefix of a repo's hub on the home */
|
|
110
114
|
export const hubBase = (name: string): string => `/r/${encodeURIComponent(name)}`
|
package/src/home/home-routes.ts
CHANGED
|
@@ -32,7 +32,8 @@ import { PM_STAMP, ROLES } from './pm.ts'
|
|
|
32
32
|
import { childLog, pmLog, pmUrl } from './home-paths.ts'
|
|
33
33
|
import { machineGet } from '../core/machine-db.ts'
|
|
34
34
|
import { usageDir } from '../agent-time/accounts-usage-disk.ts'
|
|
35
|
-
import { advisorsDir,
|
|
35
|
+
import { advisorsDir, readState } from '../advisors/owner-store.ts'
|
|
36
|
+
import { usersDir } from '../advisors/users-store.ts'
|
|
36
37
|
import { hereStamp } from '../advisors/here.ts'
|
|
37
38
|
import { storeDir } from '../review/store.ts'
|
|
38
39
|
import { veilleBatchRoute } from '../veille/batch.ts'
|
|
@@ -48,7 +49,6 @@ import type { OtherMac } from './other-macs.ts'
|
|
|
48
49
|
import { REVEAL_PATH } from '../serve/terminal-guard.ts'
|
|
49
50
|
import type { AccountUsage } from '../agent-time/accounts-usage.ts'
|
|
50
51
|
import { setHqPages } from '../hq/hq-local.ts'
|
|
51
|
-
import { hookRoute, type HookThread } from '../serve/hook-thread.ts'
|
|
52
52
|
|
|
53
53
|
/** how often the daemon looks at every repo */
|
|
54
54
|
export const TICK_MS = 2_000
|
|
@@ -103,8 +103,6 @@ export type HomeDeps = {
|
|
|
103
103
|
otherMacs?: () => OtherMac[]
|
|
104
104
|
/** each Claude Code account's usage. Absent = none (a test of the routes alone) */
|
|
105
105
|
accountsUsage?: () => AccountUsage[]
|
|
106
|
-
/** the inbox hook's thread (serve/hook-thread.ts): it answers the hooks that ask. Absent = every hook runs in its own process */
|
|
107
|
-
hook?: HookThread
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
/** the sizes the app icon is drawn at: the phone's home screen, the manifest's two */
|
|
@@ -196,7 +194,7 @@ export function homeRoutes(d: HomeDeps) {
|
|
|
196
194
|
// within a second, their beats are not
|
|
197
195
|
const hereNow = held(1_000, () => {
|
|
198
196
|
const dir = advisorsDir()
|
|
199
|
-
return existsSync(join(
|
|
197
|
+
return existsSync(join(usersDir(dir), 'here')) ? hereStamp(readState(dir), usersDir(dir), new Date()) : ''
|
|
200
198
|
})
|
|
201
199
|
const logsStamp = held(1_000, () => `${ROLES.map((r) => fileStamp(childLog(d.dir, r))).join('|')}|${fileStamp(pmLog(d.dir))}|${dirStamp(join(d.dir, 'resources'))}`)
|
|
202
200
|
const homeSources: PushSource[] = [
|
|
@@ -293,11 +291,6 @@ export function homeRoutes(d: HomeDeps) {
|
|
|
293
291
|
const tracked = await postTrackerRoute(req, path)
|
|
294
292
|
if (tracked != null) return tracked
|
|
295
293
|
if (!sameOrigin(req)) return new Response('refused: a request that changes something must come from the home page', { status: 403 })
|
|
296
|
-
// the inbox hook of a session of this machine asks first (review/hook-ask.ts)
|
|
297
|
-
if (d.hook !== undefined) {
|
|
298
|
-
const answered = await hookRoute(req, path, d.hook)
|
|
299
|
-
if (answered != null) return answered
|
|
300
|
-
}
|
|
301
294
|
// the screen recorder's takes of every repo (recordings/routes.ts)
|
|
302
295
|
if (path.startsWith('/api/home/recordings')) {
|
|
303
296
|
const { recordingsRoute } = await import('../recordings/routes.ts')
|
package/src/home/home-state.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// what the home remembers across restarts, and only that: the repos flagged
|
|
2
2
|
// active by hand. One row of the machine db (core/machine-db.ts), edited by
|
|
3
3
|
// the page.
|
|
4
|
-
import {
|
|
5
|
-
import { stateFile } from './home-paths.ts'
|
|
4
|
+
import { machineGet, machineUpdate } from '../core/machine-db.ts'
|
|
6
5
|
|
|
7
6
|
export type HomeStateData = {
|
|
8
7
|
/** repos whose hub runs whether or not an agent works in them */
|
|
@@ -14,21 +13,10 @@ const KEY = 'home.active'
|
|
|
14
13
|
export class HomeState {
|
|
15
14
|
data: HomeStateData
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
* read once into the db */
|
|
19
|
-
constructor(dir: string) {
|
|
20
|
-
importMachineFile<string[]>(KEY, stateFile(dir), (t) => HomeState.parse(t).active)
|
|
16
|
+
constructor() {
|
|
21
17
|
this.data = { active: HomeState.clean(machineGet<unknown>(KEY)) }
|
|
22
18
|
}
|
|
23
19
|
|
|
24
|
-
static parse(text: string): HomeStateData {
|
|
25
|
-
try {
|
|
26
|
-
return { active: HomeState.clean((JSON.parse(text) as Partial<HomeStateData>).active) }
|
|
27
|
-
} catch {
|
|
28
|
-
return { active: [] }
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
20
|
private static clean(v: unknown): string[] {
|
|
33
21
|
return Array.isArray(v) ? v.filter((x): x is string => typeof x === 'string') : []
|
|
34
22
|
}
|