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/resume.ts
CHANGED
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
// is and its age, from what the jobs and the drills already recorded: no download and no restore here (the drills
|
|
3
3
|
// stay their own commands). What is not in the Space by design is said as such, never claimed present
|
|
4
4
|
import type { Drill } from '../hq/replica.ts'
|
|
5
|
-
import type { BackupDrill } from '../media-store/backup/restore.ts'
|
|
6
5
|
import type { ProvedRecord, Sent } from '../vault/vault-snapshot.ts'
|
|
7
6
|
import { snapshotHealth } from '../vault/vault-snapshot.ts'
|
|
8
7
|
|
|
9
8
|
const H = 3600_000
|
|
10
9
|
const DAY = 24 * H
|
|
11
|
-
/** a backup run older than this is stale: the daemon runs one within minutes of a change */
|
|
12
|
-
export const RUN_STALE_MS = 26 * H
|
|
13
10
|
/** a drill older than this is stale: the hq's runs once a week */
|
|
14
11
|
export const DRILL_STALE_MS = 8 * DAY
|
|
15
12
|
|
|
@@ -17,7 +14,6 @@ export type ResumeState = {
|
|
|
17
14
|
now: number
|
|
18
15
|
/** the hq's database: null when this machine joined another hq (its copy is checked there) */
|
|
19
16
|
hq: { replica: boolean; drill: Drill | null } | null
|
|
20
|
-
backup: { lastRun: { at: number } | null; drill: BackupDrill | null }
|
|
21
17
|
/** this machine's media index; null when it does not open */
|
|
22
18
|
media: { waiting: number; bytes: number; failing: number } | null
|
|
23
19
|
/** null when this machine runs no vault */
|
|
@@ -35,13 +31,7 @@ export function resumeLines(s: ResumeState): ResumeLine[] {
|
|
|
35
31
|
else if (s.hq.drill == null) out.push({ level: 'warn', text: "the hq's database: its replica runs, and no drill has proved it yet", fix: 'sk hq drill' })
|
|
36
32
|
else if (!s.hq.drill.ok) out.push({ level: 'fail', text: `the hq's database: its replica failed its last drill, ${age(s.now - s.hq.drill.at)} ago: ${s.hq.drill.why}`, fix: 'sk gp restart hq-replica, then sk hq drill' })
|
|
37
33
|
else out.push({ level: s.now - s.hq.drill.at > DRILL_STALE_MS ? 'warn' : 'ok', text: `the hq's database: in its replica (Litestream); last drill passed ${age(s.now - s.hq.drill.at)} ago, ${s.hq.drill.rows} rows (the replica's last write is not recorded: the drill proves it)`, ...(s.now - s.hq.drill.at > DRILL_STALE_MS ? { fix: 'sk hq drill' } : {}) })
|
|
38
|
-
|
|
39
|
-
if (run == null) out.push({ level: 'fail', text: "this machine's untracked project files: no backup run yet", fix: 'sk backup' })
|
|
40
|
-
else out.push({ level: s.now - run.at > RUN_STALE_MS ? 'warn' : 'ok', text: `this machine's untracked project files: in the backup, last run ${age(s.now - run.at)} ago`, ...(s.now - run.at > RUN_STALE_MS ? { fix: 'sk backup' } : {}) })
|
|
41
|
-
const d = s.backup.drill
|
|
42
|
-
if (d == null) out.push({ level: 'warn', text: 'the backup: no drill has restored it yet', fix: 'sk backup drill' })
|
|
43
|
-
else if (d.failed > 0) out.push({ level: 'fail', text: `the backup: its last drill, ${age(s.now - d.at)} ago, did not bring back ${d.failed} of ${d.files} files`, fix: 'sk backup drill' })
|
|
44
|
-
else out.push({ level: s.now - d.at > DRILL_STALE_MS ? 'warn' : 'ok', text: `the backup: last drill restored ${d.restored} of ${d.files} files ${age(s.now - d.at)} ago`, ...(s.now - d.at > DRILL_STALE_MS ? { fix: 'sk backup drill' } : {}) })
|
|
34
|
+
out.push({ level: 'note', text: "not in the Space, by design: this machine's untracked project files, whose backup is retired. A precious one belongs in git, the hq, the Space or the vault; the house check RV049 names each one that has none" })
|
|
45
35
|
if (s.media == null) out.push({ level: 'warn', text: "this machine's media: not read, its media index does not open, so what waits to go up is not known", fix: 'sk media status' })
|
|
46
36
|
else if (s.media.waiting === 0) out.push({ level: 'ok', text: "this machine's media: every file is up in the Space, none waits" })
|
|
47
37
|
else out.push({ level: 'warn', text: `this machine's media: ${s.media.waiting} files (${(s.media.bytes / 1e6).toFixed(1)} MB) wait to go up${s.media.failing > 0 ? `, ${s.media.failing} failed their last try` : ''}`, fix: 'sk media status' })
|
|
@@ -60,19 +50,15 @@ export async function resumeHere(root: string, now: number = Date.now()): Promis
|
|
|
60
50
|
const { carriesHq } = await import('../hq/hq-role.ts')
|
|
61
51
|
const { lastDrill } = await import('../hq/replica.ts')
|
|
62
52
|
const { loadRepoConfig } = await import('../repo-config.ts')
|
|
63
|
-
const { lastRun } = await import('../media-store/backup/run.ts')
|
|
64
|
-
const { lastBackupDrill } = await import('../media-store/backup/restore.ts')
|
|
65
53
|
const { waitingCounts } = await import('../media-store/daemon.ts')
|
|
66
54
|
const { vaultInitialised, vaultPlace } = await import('../vault/vault-config.ts')
|
|
67
55
|
const { machineGet } = await import('../core/machine-db.ts')
|
|
68
56
|
const { CHANGED_KEY, DEAD_DISK_KEY, PROVED_KEY, SENT_KEY, vaultStamp } = await import('../vault/vault-snapshot.ts')
|
|
69
57
|
const { minterOf } = await import('../vault/vault-minter.ts')
|
|
70
|
-
const run = lastRun()
|
|
71
58
|
const minter = vaultInitialised() ? minterOf(vaultPlace()) : null
|
|
72
59
|
return {
|
|
73
60
|
now,
|
|
74
61
|
hq: carriesHq() ? { replica: (await loadRepoConfig(root).catch(() => null))?.serve?.hqReplica != null, drill: lastDrill() } : null,
|
|
75
|
-
backup: { lastRun: run == null ? null : { at: Date.parse(run.at) }, drill: lastBackupDrill() },
|
|
76
62
|
media: waitingCounts(),
|
|
77
63
|
vault: vaultInitialised()
|
|
78
64
|
? { sent: machineGet<Sent>(SENT_KEY), proved: machineGet<ProvedRecord>(PROVED_KEY), changed: machineGet<{ stamp: string; at: number }>(CHANGED_KEY), deadDisk: machineGet<ProvedRecord>(DEAD_DISK_KEY), stamp: minter == null ? null : await vaultStamp(minter).then((x) => x.stamp, () => null) }
|
package/src/home/run-daemon.ts
CHANGED
|
@@ -17,7 +17,6 @@ import { reloadOnOwnCode } from './lib-watch.ts'
|
|
|
17
17
|
import { modelWatch } from '../review/model-moved.ts'
|
|
18
18
|
import { loadHub } from '../serve/hub-runtime.ts'
|
|
19
19
|
import { ReadThread } from '../serve/read-thread.ts'
|
|
20
|
-
import { HookThread } from '../serve/hook-thread.ts'
|
|
21
20
|
import { readPartiesWith } from '../review/routes.ts'
|
|
22
21
|
import { houseRepos } from '../house/project-gutter.ts'
|
|
23
22
|
import { projectGutter } from '../serve/project-gutter-route.ts'
|
|
@@ -38,7 +37,7 @@ import { serveDaemon } from './serve-daemon.ts'
|
|
|
38
37
|
import { carriedHq, joinCarriedHq, setHqPort } from '../hq/hq-local.ts'
|
|
39
38
|
import { claimRoleAtStart, hqOpen, hqRoleProblem } from '../hq/hq-role.ts'
|
|
40
39
|
import { jobsLimit, startJobs } from './daemon-jobs.ts'
|
|
41
|
-
import {
|
|
40
|
+
import { usersListener } from '../advisors/users-listen.ts'
|
|
42
41
|
import { Widgets } from './widgets.ts'
|
|
43
42
|
import { machineName, machinePublicHost } from './machine-host.ts'
|
|
44
43
|
import { OtherMacs } from './other-macs.ts'
|
|
@@ -127,11 +126,6 @@ export async function runDaemon(root: string, io: HomeIo, o: { port?: number } =
|
|
|
127
126
|
let askedPage: (repo: string) => void = () => {}
|
|
128
127
|
const gutter = projectGutter({ root, warn: (l) => io.printErr(l), declared: (name) => plan.declared(name), asked: (repo) => askedPage(repo) })
|
|
129
128
|
const readThread = new ReadThread()
|
|
130
|
-
// the inbox hook of every session asks here first, a thread of its own (serve/hook-thread.ts)
|
|
131
|
-
// off until its memory is measured: with it the daemon grew past 4 GB in its first minute (every hook then runs in
|
|
132
|
-
// its own process, as before)
|
|
133
|
-
const hookThread: HookThread | undefined = process.env.SHIPKIT_HOOK_THREAD === '1' ? new HookThread() : undefined
|
|
134
|
-
hookThread?.open()
|
|
135
129
|
// every store's parties too: the page and the inbox read them, a lane transcript each
|
|
136
130
|
readPartiesWith((dir) => readThread.parties(dir))
|
|
137
131
|
const hubs = new Hubs({
|
|
@@ -181,7 +175,7 @@ export async function runDaemon(root: string, io: HomeIo, o: { port?: number } =
|
|
|
181
175
|
daemonPort: own,
|
|
182
176
|
dir,
|
|
183
177
|
hubs,
|
|
184
|
-
state: new HomeState(
|
|
178
|
+
state: new HomeState(),
|
|
185
179
|
gutter,
|
|
186
180
|
plan,
|
|
187
181
|
only: onlyRepos(),
|
|
@@ -190,7 +184,6 @@ export async function runDaemon(root: string, io: HomeIo, o: { port?: number } =
|
|
|
190
184
|
machineName: hqMachineName,
|
|
191
185
|
otherMacs: () => otherMacs.get(),
|
|
192
186
|
accountsUsage: () => readAccounts(),
|
|
193
|
-
...(hookThread !== undefined ? { hook: hookThread } : {}),
|
|
194
187
|
})
|
|
195
188
|
askedPage = (repo) => home.routes.push.moved('asked-page', repo)
|
|
196
189
|
io.print(`daemon → http://127.0.0.1:${home.server.port} (the page: http://localhost:${port})`)
|
|
@@ -204,8 +197,8 @@ export async function runDaemon(root: string, io: HomeIo, o: { port?: number } =
|
|
|
204
197
|
// machine-only state, each a niced child process: never a job's body on this loop (daemon-jobs.ts). A daemon
|
|
205
198
|
// limited to some repos (SHIPKIT_DAEMON_ONLY) is a trial and runs none, unless SHIPKIT_DAEMON_JOBS names some
|
|
206
199
|
const jobs = onlyRepos() == null || jobsLimit() != null ? startJobs({ cli: CLI, cwd: root, dir: join(dir, 'jobs'), log: childLog(dir, 'daemon'), printErr: io.printErr }) : null
|
|
207
|
-
// the advisors'
|
|
208
|
-
const door = jobs === null ? null :
|
|
200
|
+
// the advisors' users' port, while this machine carries the hq (advisors/users-listen.ts)
|
|
201
|
+
const door = jobs === null ? null : usersListener({ house: root, print: io.print, printErr: io.printErr })
|
|
209
202
|
// a job that holds the loop holds every page: each stall is said with the work that overlapped it
|
|
210
203
|
const stalls = loopWatch.start(io.printErr)
|
|
211
204
|
// pm tells a starved daemon from a hung one by this beat: it turns with the loop
|
package/src/home/space-page.ts
CHANGED
|
@@ -73,7 +73,7 @@ export function folderWhat(prefix: string, d: Pick<SpacePageDeps, 'kinds' | 'rep
|
|
|
73
73
|
const rest = prefix.slice(PUBLIC_PREFIX.length)
|
|
74
74
|
return rest.split('/').length === 2 ? kind(rest.slice(0, -1)) : null
|
|
75
75
|
}
|
|
76
|
-
if (prefix === `${BACKUP_LABEL}/`) return 'the
|
|
76
|
+
if (prefix === `${BACKUP_LABEL}/`) return 'the old runs of the backup of untracked project files, retired 2026-11-29: kept, nothing deletes them'
|
|
77
77
|
if (prefix === RUNS_PREFIX) return 'one manifest a backup run'
|
|
78
78
|
if (prefix === PARTS_PREFIX) return 'the parts of the manifests'
|
|
79
79
|
if (prefix === SNAPSHOTS) return 'snapshots: the vault\'s sealed ones, the hq\'s nightly one'
|
|
@@ -152,7 +152,8 @@ function healthFacts(e: SpaceEnd, r: ListingRecord | null, d: SpacePageDeps): Fa
|
|
|
152
152
|
if (e.id === 'space') {
|
|
153
153
|
const b = d.backup
|
|
154
154
|
const folder = r == null ? null : d.kept((db) => folderSum(db, e.id, `${BACKUP_LABEL}/`))
|
|
155
|
-
|
|
155
|
+
// the backup of untracked files retired: its last run only ages, never a fault
|
|
156
|
+
out.push(b == null ? { text: 'the backup of untracked files: retired, no run from this machine', tone: 'dim' } : { text: `the backup of untracked files: retired, the last run from this machine ${ageWords(Date.parse(b.at), d.now)}${folder == null ? '' : `; ${BACKUP_LABEL}/ holds ${bytesWords(folder.bytes)} in ${count(folder.objects)} objects, every machine's old runs, kept`}`, tone: 'dim' })
|
|
156
157
|
}
|
|
157
158
|
return out
|
|
158
159
|
}
|
package/src/home/supervise.ts
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
//
|
|
8
8
|
// Truth is the pid and the probe, never this object's memory: tick() asks the
|
|
9
9
|
// kernel whether the pid lives and the probe whether it answers.
|
|
10
|
-
import { closeSync, existsSync, mkdirSync, openSync, readSync,
|
|
10
|
+
import { closeSync, existsSync, mkdirSync, openSync, readSync, statSync, writeFileSync } from 'fs'
|
|
11
11
|
import { dirname } from 'path'
|
|
12
|
-
import {
|
|
12
|
+
import { machineDelete, machineGet, machineSet } from '../core/machine-db.ts'
|
|
13
13
|
import { lastWords } from '../problems/failure-words.ts'
|
|
14
14
|
import { pidAlive } from '../core/pid-alive.ts'
|
|
15
15
|
|
|
@@ -120,7 +120,6 @@ export type PidRecord = { pid: number; cmd: string[]; at: number }
|
|
|
120
120
|
const pidRow = (key: string): string => `pid:${key}`
|
|
121
121
|
|
|
122
122
|
export function readPid(key: string): PidRecord | null {
|
|
123
|
-
importMachineFile<PidRecord>(pidRow(key), key)
|
|
124
123
|
const r = machineGet<PidRecord>(pidRow(key))
|
|
125
124
|
return r != null && Number.isInteger(r.pid) && r.pid > 0 ? r : null
|
|
126
125
|
}
|
|
@@ -135,10 +134,7 @@ export function handPid(key: string, pid: number, cmd: string[], now = Date.now(
|
|
|
135
134
|
writePid(key, { pid, cmd, at: now })
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
const dropPid = (key: string): void =>
|
|
139
|
-
machineDelete(pidRow(key))
|
|
140
|
-
try { rmSync(key, { force: true }) } catch { /* an older copy's file, gone either way */ }
|
|
141
|
-
}
|
|
137
|
+
const dropPid = (key: string): void => machineDelete(pidRow(key))
|
|
142
138
|
|
|
143
139
|
export class Proc {
|
|
144
140
|
status: ProcStatus = 'down'
|
package/src/hooks/hook-config.ts
CHANGED
|
@@ -13,11 +13,11 @@ import { dirname, join } from 'path'
|
|
|
13
13
|
import { gitRoot } from '../core/git-root.ts'
|
|
14
14
|
import type { RepoConfig } from '../repo-config.ts'
|
|
15
15
|
|
|
16
|
-
/** the fields of repo.config.ts the commit hooks read
|
|
17
|
-
export type HookConfig = Pick<RepoConfig, 'hooks' | 'off' | '
|
|
16
|
+
/** the fields of repo.config.ts the commit hooks read */
|
|
17
|
+
export type HookConfig = Pick<RepoConfig, 'hooks' | 'off' | 'visibility'>
|
|
18
18
|
|
|
19
|
-
/** the fields copied as they are
|
|
20
|
-
const COPIED = ['hooks', 'off', '
|
|
19
|
+
/** the fields copied as they are: the copy's key holds this list */
|
|
20
|
+
const COPIED = ['hooks', 'off', 'visibility'] as const satisfies readonly (keyof HookConfig)[]
|
|
21
21
|
|
|
22
22
|
/** the shape of the copy file itself */
|
|
23
23
|
const COPY_VERSION = 3
|
|
@@ -29,10 +29,9 @@ const COPIES_MAX = 16
|
|
|
29
29
|
type Copies = { v: number; copies: Record<string, { config: HookConfig; root?: string }> }
|
|
30
30
|
|
|
31
31
|
export function hookSlice(c: RepoConfig): HookConfig {
|
|
32
|
-
const defaults = Object.fromEntries(Object.entries(c.defaults ?? {}).filter(([, v]) => v === false).map(([k]) => [k, false as const]))
|
|
33
32
|
const out: HookConfig = {}
|
|
34
33
|
for (const k of COPIED) if (c[k] != null) Object.assign(out, { [k]: c[k] })
|
|
35
|
-
return
|
|
34
|
+
return out
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
/** plain data all the way down: what JSON keeps as it is */
|
|
@@ -61,7 +60,7 @@ function readCopies(path: string): Copies {
|
|
|
61
60
|
/** the config file's bytes hashed (a few KB: microseconds), with the copied fields' names; null with no file */
|
|
62
61
|
const stampOf = (path: string): string | null => {
|
|
63
62
|
try {
|
|
64
|
-
return `${Bun.hash(readFileSync(path)).toString(36)}:${COPIED.join(',')}
|
|
63
|
+
return `${Bun.hash(readFileSync(path)).toString(36)}:${COPIED.join(',')}`
|
|
65
64
|
} catch {
|
|
66
65
|
return null
|
|
67
66
|
}
|
package/src/hooks/leak-guard.ts
CHANGED
|
@@ -101,7 +101,7 @@ const escapeRegex = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$
|
|
|
101
101
|
export const SK_KEY_ROW = String.raw`re:(?<![A-Za-z0-9_-])sk-(?=[A-Za-z0-9_-]{20})(?=[A-Za-z0-9_-]*\d)[A-Za-z0-9_-]*?[A-Za-z0-9]{16}[A-Za-z0-9_-]*`
|
|
102
102
|
|
|
103
103
|
/** THE list of what a secret key looks like, for every surface that must never let one through: the commit gate and
|
|
104
|
-
* every scan (`withBuiltinRows`),
|
|
104
|
+
* every scan (`withBuiltinRows`), and the mask of every line
|
|
105
105
|
* `sk time` prints and every prompt that leaves the machine (agent-time/mask.ts, which adds the name rules). A row is
|
|
106
106
|
* a token's own shape, exact in case; never copied into a keyword file */
|
|
107
107
|
export const SECRET_ROWS: readonly string[] = [
|
package/src/hooks/run-hooks.ts
CHANGED
|
@@ -67,11 +67,6 @@ export type HooksConfig = {
|
|
|
67
67
|
/** words the commit-message language gate never counts as French
|
|
68
68
|
* (proper nouns that carry accents without being a language choice) */
|
|
69
69
|
languageAllow?: string[]
|
|
70
|
-
/** RETIRED, read as `off` while SK029 ports it there: a commit gate is
|
|
71
|
-
* turned off like any check, `off: { <gate id>: '<why>' }`
|
|
72
|
-
* (tools/shipkit/runs.md). Dies once `shipkit fleet` shows no repo
|
|
73
|
-
* carrying it */
|
|
74
|
-
disable?: HookGateId[]
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
const HOOK_DIR = LAYOUT.hooks
|
package/src/hq/daemon-db.ts
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
// counts what a thread verb loads)
|
|
6
6
|
import { Database } from 'bun:sqlite'
|
|
7
7
|
import { existsSync } from 'node:fs'
|
|
8
|
-
import {
|
|
8
|
+
import { machineDbPath, openMachineFile, refusalText, storeRefusal } from '../core/machine-db.ts'
|
|
9
9
|
import { isNoCopy, migrateTo, ownerOnly } from '../ledger/db.ts'
|
|
10
10
|
import { ITEM_DB_SCHEMA } from '../review/item-db.ts'
|
|
11
11
|
import { EVENTS_SCHEMA } from '../review/events.ts'
|
|
12
12
|
|
|
13
13
|
/** moves the daemon's own database for one process (a test) */
|
|
14
14
|
export const DAEMON_DB_ENV = 'SHIPKIT_DAEMON_DB'
|
|
15
|
-
export const daemonDbPath = (): string => process.env[DAEMON_DB_ENV] ||
|
|
15
|
+
export const daemonDbPath = (): string => process.env[DAEMON_DB_ENV] || machineDbPath()
|
|
16
16
|
|
|
17
17
|
// outbox the rows bound for the hq, one outbox (`box`) a group of kinds, each numbered from 1 with no gap
|
|
18
18
|
// meta each outbox's name and the highest number it gave (`top:<box>`), and the feed's cursor (ledger.ts)
|
|
@@ -78,16 +78,16 @@ ${EVENTS_SCHEMA}`
|
|
|
78
78
|
/** the version of the daemon's own tables: a new table raises it */
|
|
79
79
|
export const DAEMON_DB_VERSION = 14
|
|
80
80
|
|
|
81
|
-
/** every table of the daemon's: the same names in
|
|
81
|
+
/** every table of the daemon's: the same names in the machine db and in a file a suite moves it to */
|
|
82
82
|
export const DAEMON_TABLES = ['outbox', 'meta', 'sent', 'pending', 'retry', 'kept', 'waiting', 'scanned', 'history_sent', 'history_forgotten', 'history_days', 'history_pending', 'files_sent', 'files_pending', 'media_pending', 'media_kept', 'review_cards', 'review_msgs', 'review_gone', 'review_replaced', 'review_repos', 'thread_events', 'thread_post_groups', 'thread_posts'] as const
|
|
83
83
|
|
|
84
84
|
/** the row of the machine db that says which version its daemon tables are (its own version is the machine db's) */
|
|
85
85
|
export const DAEMON_VERSION_ROW = 'daemon-db-version'
|
|
86
86
|
|
|
87
|
-
/** the daemon's tables, made where they are not
|
|
87
|
+
/** the daemon's tables, made where they are not */
|
|
88
88
|
export function createDaemonTables(db: Database): void {
|
|
89
89
|
db.exec(DAEMON_DB_SCHEMA)
|
|
90
|
-
// its own
|
|
90
|
+
// a file of its own by its version, the machine db by its row
|
|
91
91
|
if (db.query("select 1 from sqlite_master where type = 'table' and name = 'state'").get() != null) db.query('insert or replace into state (name, value, at) values (?, ?, ?)').run(DAEMON_VERSION_ROW, JSON.stringify(DAEMON_DB_VERSION), Date.now())
|
|
92
92
|
else db.exec(`pragma user_version = ${DAEMON_DB_VERSION}`)
|
|
93
93
|
}
|
|
@@ -107,14 +107,14 @@ let saidRefusal: string | null = null
|
|
|
107
107
|
|
|
108
108
|
/** the daemon's own database: its outbox, and its ledger of the feed */
|
|
109
109
|
export function openDaemonDb(path: string = daemonDbPath()): Database | null {
|
|
110
|
-
const refused =
|
|
110
|
+
const refused = storeRefusal('daemon file', path)
|
|
111
111
|
if (refused != null) {
|
|
112
112
|
if (refusalText(refused) !== saidRefusal) console.error(`WARN the daemon's database does not open: ${refusalText(refused)}`)
|
|
113
113
|
saidRefusal = refusalText(refused)
|
|
114
114
|
return null
|
|
115
115
|
}
|
|
116
116
|
saidRefusal = null
|
|
117
|
-
//
|
|
117
|
+
// the machine db's tables, their version its row
|
|
118
118
|
if (path === machineDbPath())
|
|
119
119
|
try {
|
|
120
120
|
return openMachineFile(path, { schema: (db) => (daemonTablesReady(db) ? undefined : createDaemonTables(db)) })
|
|
@@ -143,7 +143,7 @@ export function lookDaemonDb(path: string = daemonDbPath()): Database {
|
|
|
143
143
|
return mem
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
/** the daemon's own
|
|
146
|
+
/** the daemon's tables in a file of their own (a suite's, SHIPKIT_DAEMON_DB), migrated to this code's version */
|
|
147
147
|
export function openDaemonFile(path: string): Database | null {
|
|
148
148
|
ownerOnly(path)
|
|
149
149
|
try {
|
package/src/hq/door.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { createHash, randomBytes, timingSafeEqual } from 'crypto'
|
|
6
6
|
import { chmodSync, linkSync, mkdirSync, readFileSync, rmSync, unlinkSync, writeFileSync } from 'fs'
|
|
7
7
|
import { join } from 'path'
|
|
8
|
-
import {
|
|
8
|
+
import { machineGet, machineSet } from '../core/machine-db.ts'
|
|
9
9
|
import { daemonPort, homeDir, homePort, hqPort, pmPort, publicHome } from '../home/home-paths.ts'
|
|
10
10
|
import { DEFAULT_VAULT_CLUSTER_PORT, DEFAULT_VAULT_PORT } from '../vault/vault-config.ts'
|
|
11
11
|
import { loopbackOrigin, machineLabel, urlLabelOf } from '../http/door-forward.ts'
|
|
@@ -16,28 +16,15 @@ export const HQ_PROXY = 'hq-proxy'
|
|
|
16
16
|
/** a machine's urls to the hq's home: on, its web opens its own global processes and loopback urls to the hq's proxy,
|
|
17
17
|
* for the key the hq gave it */
|
|
18
18
|
export const MACHINE_URLS = 'machine-urls'
|
|
19
|
-
/** the switch's name before: a machine db that holds only it is read under it once, and the value moves to the new name */
|
|
20
|
-
export const MACHINE_URLS_WAS = 'machine-door'
|
|
21
19
|
export const proxyOn = (): boolean => machineGet<boolean>(HQ_PROXY) === true
|
|
22
|
-
export
|
|
23
|
-
const v = machineGet<boolean>(MACHINE_URLS)
|
|
24
|
-
if (v != null) return v === true
|
|
25
|
-
const was = machineGet<boolean>(MACHINE_URLS_WAS)
|
|
26
|
-
if (was == null) return false
|
|
27
|
-
if (machineSet(MACHINE_URLS, was)) machineDelete(MACHINE_URLS_WAS)
|
|
28
|
-
return was === true
|
|
29
|
-
}
|
|
20
|
+
export const urlsOn = (): boolean => machineGet<boolean>(MACHINE_URLS) === true
|
|
30
21
|
/** false when the machine db does not open. Off ends every proxy key at once: the hq's secret goes, and the next on makes new ones */
|
|
31
22
|
export function setProxyOn(on: boolean): boolean {
|
|
32
23
|
if (!machineSet(HQ_PROXY, on)) return false
|
|
33
24
|
if (!on) rmSync(secretFile(), { force: true })
|
|
34
25
|
return true
|
|
35
26
|
}
|
|
36
|
-
export
|
|
37
|
-
if (!machineSet(MACHINE_URLS, on)) return false
|
|
38
|
-
machineDelete(MACHINE_URLS_WAS)
|
|
39
|
-
return true
|
|
40
|
-
}
|
|
27
|
+
export const setUrlsOn = (on: boolean): boolean => machineSet(MACHINE_URLS, on)
|
|
41
28
|
|
|
42
29
|
const secretFile = (): string => join(homeDir(), 'hq-door-secret')
|
|
43
30
|
const keyFile = (): string => join(homeDir(), 'door-key')
|
package/src/hq/hq-db.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Database } from 'bun:sqlite'
|
|
|
4
4
|
import { migrateTo, openWith, ownerOnly } from '../ledger/db.ts'
|
|
5
5
|
import { TARGETS_SCHEMA } from './backup-targets.ts'
|
|
6
6
|
import { KINDS } from './kinds/index.ts'
|
|
7
|
-
import { fillItemRows } from './item-
|
|
7
|
+
import { fillItemRows } from './item-fill.ts'
|
|
8
8
|
import { HQ_FILE_VERSION, hqDbPath } from './hq-role.ts'
|
|
9
9
|
|
|
10
10
|
// people who owns nodes
|
|
@@ -26,7 +26,8 @@ import { HQ_FILE_VERSION, hqDbPath } from './hq-role.ts'
|
|
|
26
26
|
// last read through the vault route (vault-route.ts): one row a node, gone with its end
|
|
27
27
|
// meta the file's own words: its `name`, made once and kept by a restore, and the feed's generation `gen`
|
|
28
28
|
// backup_targets the places the house's backups go (backup-targets.ts): an ssh machine or a bucket the config names (18)
|
|
29
|
-
// review_* the items in the store's own tables
|
|
29
|
+
// review_* the items in the store's own tables, the item kinds' (20). A file of before holds them in `cards` and
|
|
30
|
+
// `card_msgs` too, which fill them once and are kept as they were (item-fill.ts)
|
|
30
31
|
// wanted a switch value the hq's console wants a node to take (sk hq switch): given to that node alone at its
|
|
31
32
|
// hello, `done` once a report of that node shows the value
|
|
32
33
|
// The rows the daemons send are in the tables of their kind (kinds/)
|
|
@@ -83,7 +84,7 @@ export function openHq(path: string = hqDbPath(), o: { create?: boolean } = {}):
|
|
|
83
84
|
if (was > 0 && was < 5) db.exec("insert or ignore into outboxes (node, epoch, applied) select id, epoch, applied from nodes where epoch <> ''")
|
|
84
85
|
for (const k of KINDS) db.exec(k.schema)
|
|
85
86
|
if (db.query("select 1 from sqlite_master where name = 'card_gone_v6'").get() != null) db.exec("insert or ignore into card_gone (repo, id, created, node, at) select repo, id, '', node, at from card_gone_v6; drop table card_gone_v6")
|
|
86
|
-
// the items in the store's own tables, each rev computed again: one that differs keeps the file at its version
|
|
87
|
+
// the items of a file of before 20 in the store's own tables, each rev computed again: one that differs keeps the file at its version
|
|
87
88
|
let filled: ReturnType<typeof fillItemRows>
|
|
88
89
|
try {
|
|
89
90
|
filled = fillItemRows(db)
|
package/src/hq/hq-local.ts
CHANGED
|
@@ -290,7 +290,6 @@ export async function hqReportTick(o: { repos: { name: string; path: string }[];
|
|
|
290
290
|
const waiting = db.query('select count(*) as waiting, min(since) as since from retry').get() as { waiting: number; since: number | null }
|
|
291
291
|
const { machineFacts, realReaders } = await import('./report-facts.ts')
|
|
292
292
|
const { mediaReport } = await import('../media-store/daemon.ts')
|
|
293
|
-
const { ownBackupFacts } = await import('../media-store/backup/facts.ts')
|
|
294
293
|
const facts = await machineFacts({ repos, now, ...(await realReaders()), ...(o.urls == null ? {} : { urls: o.urls }) })
|
|
295
294
|
// what the hq holds of this machine's rows, counted once an hour and carried by every report
|
|
296
295
|
const { holdsTick } = await import('./hq-holds.ts')
|
|
@@ -298,7 +297,7 @@ export async function hqReportTick(o: { repos: { name: string; path: string }[];
|
|
|
298
297
|
o.printErr(`WARN hq report: what the hq holds of this machine is not counted: ${(e as Error).message}`)
|
|
299
298
|
return null
|
|
300
299
|
})
|
|
301
|
-
outbox.push('report', await buildReport({ repos, house: o.house, tailnet: { name: status?.Self?.DNSName?.replace(/\.$/, '') || null, up: status?.BackendState === 'Running' }, diskOf: homeDir(), cards: waiting, media: mediaReport(),
|
|
300
|
+
outbox.push('report', await buildReport({ repos, house: o.house, tailnet: { name: status?.Self?.DNSName?.replace(/\.$/, '') || null, up: status?.BackendState === 'Running' }, diskOf: homeDir(), cards: waiting, media: mediaReport(), ...(holds == null ? {} : { holds }), ...facts }), now)
|
|
302
301
|
const r = await flush(outbox, hq, now)
|
|
303
302
|
if ('refused' in r) return o.printErr(`WARN hq report: ${r.refused} (${outbox.size()} rows wait in the outbox)`)
|
|
304
303
|
if (r.renamed) o.printErr('WARN hq report: the hq held rows this outbox never made (the outbox is an older copy of itself): it took a new name and sent every row it holds again')
|
package/src/hq/hq-store.ts
CHANGED
|
@@ -16,7 +16,6 @@ import { machineLabel } from '../http/door-forward.ts'
|
|
|
16
16
|
import type { Report } from './report.ts'
|
|
17
17
|
import { afarRefusal, type Wanted } from './switch.ts'
|
|
18
18
|
import { isOnceAsk, ONCE_ASKS } from './follow-fact.ts'
|
|
19
|
-
import { compareShapes, shapesLine } from './item-shapes.ts'
|
|
20
19
|
|
|
21
20
|
export type Grant = { kind: 'all' } | { kind: 'repo' | 'identity' | 'machine'; name: string }
|
|
22
21
|
|
|
@@ -76,9 +75,6 @@ export const READ_MAX_ROWS = 2_000
|
|
|
76
75
|
export const SWEEP_EVERY_MS = 3600_000
|
|
77
76
|
const SWEEP_AT_CAP_MS = 60_000
|
|
78
77
|
|
|
79
|
-
/** the `meta` word of the last compare of the items in their two shapes */
|
|
80
|
-
export const SHAPES_WORD = 'item-shapes'
|
|
81
|
-
|
|
82
78
|
const sha = (s: string): string => createHash('sha256').update(s).digest('hex')
|
|
83
79
|
const mint = (bytes: number): string => randomBytes(bytes).toString('base64url')
|
|
84
80
|
|
|
@@ -132,7 +128,6 @@ export class HqStore {
|
|
|
132
128
|
const logged = new Set(gone.map((g) => `${g.kind}\t${g.name}`))
|
|
133
129
|
for (const k of KINDS) for (const name of k.forgotten?.(this.db) ?? []) if (!logged.has(`${k.kind}\t${name}`)) this.forgotten.add(k.kind, name)
|
|
134
130
|
}
|
|
135
|
-
this.keepShapes(Date.now())
|
|
136
131
|
}
|
|
137
132
|
|
|
138
133
|
private word(name: string, make: () => string): string {
|
|
@@ -582,19 +577,9 @@ export class HqStore {
|
|
|
582
577
|
recountUsage(this.db)
|
|
583
578
|
}).immediate()
|
|
584
579
|
const invites = this.db.query('delete from invites where (used is not null and used < ?1) or expires < ?1').run(now - 24 * 3600_000).changes
|
|
585
|
-
this.keepShapes(now)
|
|
586
580
|
return { rows, invites }
|
|
587
581
|
}
|
|
588
582
|
|
|
589
|
-
/** the items in their two shapes compared, at the open and at each sweep (a tenth of a second on the owner's
|
|
590
|
-
* file): kept in `meta` with its time for the database page, a difference said in the daemon's log */
|
|
591
|
-
keepShapes(now: number): void {
|
|
592
|
-
const shapes = compareShapes(this.db)
|
|
593
|
-
if (shapes == null) return
|
|
594
|
-
this.setWord(SHAPES_WORD, JSON.stringify({ at: now, ...shapes }))
|
|
595
|
-
if (!shapes.ok) console.error(`WARN hq: ${shapesLine(shapes)}`)
|
|
596
|
-
}
|
|
597
|
-
|
|
598
583
|
/** a switch value for every live node of one machine with the grant all (its id or its name), from the hq's console alone: never
|
|
599
584
|
* reached from a route a token opens. The switch must be one this code declares settable from afar; the node's
|
|
600
585
|
* own code decides again when it applies it */
|
package/src/hq/item-direct.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// a write of the review store straight into the hq's file, on the machine that carries it (review/item-hq.ts): the
|
|
2
|
-
// checks the hq's door runs on a daemon's row, then
|
|
2
|
+
// checks the hq's door runs on a daemon's row, then the store's rows and the feed entry, inside the store's own write
|
|
3
3
|
// transaction on that file. What a daemon of another machine sends goes through HqStore.apply; these are the same
|
|
4
4
|
// kinds' checks and the same writes (kinds/item*.ts), with no outbox and no hop.
|
|
5
5
|
// The one constraint a reader breaks first: a refusal throws, so the store's transaction takes the whole write back
|
|
@@ -13,14 +13,12 @@ import { feedMove, type RowKind } from './kinds/kind.ts'
|
|
|
13
13
|
|
|
14
14
|
const refused = (why: string): Error => Object.assign(new Error(`the hq file refused this write of the threads: ${why}`), { code: 'EHQREFUSED' })
|
|
15
15
|
|
|
16
|
-
/** the door's checks of one row, as HqStore.apply runs them: its size, its shape, a refusal, a wait
|
|
17
|
-
function door(k: RowKind, body: unknown, max: number, db: Database, node: string, now: number):
|
|
18
|
-
|
|
19
|
-
if (Buffer.byteLength(text) > max) throw refused(`a row of kind ${k.kind} is over ${max} bytes`)
|
|
16
|
+
/** the door's checks of one row, as HqStore.apply runs them: its size, its shape, a refusal, a wait */
|
|
17
|
+
function door(k: RowKind, body: unknown, max: number, db: Database, node: string, now: number): void {
|
|
18
|
+
if (Buffer.byteLength(JSON.stringify(body)) > max) throw refused(`a row of kind ${k.kind} is over ${max} bytes`)
|
|
20
19
|
if (!k.check(body)) throw refused(`the row is no ${k.kind}`)
|
|
21
20
|
const why = k.refuses?.(db, body, { node, now }) ?? k.keeps?.(db, body) ?? null
|
|
22
21
|
if (why != null) throw refused(why)
|
|
23
|
-
return text
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
/** a head written in the hq's file: made on top of the head the file held (`base`), as a daemon's change is */
|
|
@@ -28,16 +26,16 @@ export function directHead(db: Database, repo: string, id: string, head: unknown
|
|
|
28
26
|
const rev = revOf(head)
|
|
29
27
|
const held = (db.query('select rev from review_cards where repo = ? and id = ?').get(repo, id) as { rev: string } | null)?.rev
|
|
30
28
|
const body: ItemBody = { repo, id, head: head as Record<string, unknown>, rev, ...(held == null || held === rev ? {} : { base: held }) }
|
|
31
|
-
|
|
32
|
-
storeHead(db, body, node, at
|
|
29
|
+
door(itemKind, body, ITEM_MAX_ROW_BYTES, db, node, at)
|
|
30
|
+
storeHead(db, body, node, at)
|
|
33
31
|
feedMove(db, 'card', repo, itemName(repo, id), at)
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
/** a message added in the hq's file: false when one holds its id */
|
|
37
35
|
export function directMessage(db: Database, repo: string, card: string, m: { id: string }, at: number, node: string): boolean {
|
|
38
36
|
const body: ItemMsgBody = { repo, card, id: m.id, msg: m as Record<string, unknown> }
|
|
39
|
-
|
|
40
|
-
if (!storeMsg(db, body, node
|
|
37
|
+
door(itemMsgKind, body, MAX_ROW_BYTES, db, node, at)
|
|
38
|
+
if (!storeMsg(db, body, node)) return false
|
|
41
39
|
feedMove(db, 'card-msg', repo, itemMsgName(repo, card, m.id), at)
|
|
42
40
|
return true
|
|
43
41
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// the migration of an hq file older than version 20 (wiki tools/shipkit/hq.md, The items): its items were in `cards`
|
|
2
|
+
// and `card_msgs`, and fill the store's own tables once, each rev computed again. Those two tables stay in such a
|
|
3
|
+
// file with their rows, and nothing reads or writes them after the fill; a file made at 20 never has them.
|
|
4
|
+
// The one constraint a reader breaks first: a head is the store's text of it (`JSON.stringify(head)`), never the
|
|
5
|
+
// body the kind kept, so a rev is always the sha of what the store reads
|
|
6
|
+
import type { Database } from 'bun:sqlite'
|
|
7
|
+
import { putHead, putMessage } from '../review/item-rows.ts'
|
|
8
|
+
import { revOf } from '../review/rev.ts'
|
|
9
|
+
|
|
10
|
+
/** what a fill of the store's tables did, and how long it took */
|
|
11
|
+
export type ItemFill = { heads: number; messages: number; ms: number }
|
|
12
|
+
|
|
13
|
+
const has = (db: Database, table: string): boolean => db.query("select 1 from sqlite_master where type = 'table' and name = ?").get(table) != null
|
|
14
|
+
|
|
15
|
+
/** the store's tables filled once from `cards` and `card_msgs`, in the migration's transaction, the tables made
|
|
16
|
+
* before: a row whose rev does not compute again throws, so the migration takes nothing back but its own
|
|
17
|
+
* transaction and the file stays at its version */
|
|
18
|
+
export function fillItemRows(db: Database): ItemFill {
|
|
19
|
+
const t0 = performance.now()
|
|
20
|
+
const held = (db.query('select (select count(*) from review_cards) + (select count(*) from review_msgs) as n').get() as { n: number }).n
|
|
21
|
+
if (held > 0) return { heads: 0, messages: 0, ms: performance.now() - t0 }
|
|
22
|
+
let heads = 0
|
|
23
|
+
if (has(db, 'cards')) for (const r of db.query('select repo, id, node, at, rev, body from cards order by at, repo, id').iterate() as IterableIterator<{ repo: string; id: string; node: string; at: number; rev: string; body: string }>) {
|
|
24
|
+
const b = JSON.parse(r.body) as { head: unknown; base?: string }
|
|
25
|
+
if (revOf(b.head) !== r.rev) throw new Error(`the hq file stays at its version: head ${r.id} of ${r.repo} holds rev ${r.rev.slice(0, 12)}, its head computes another, nothing is filled`)
|
|
26
|
+
putHead(db, r.repo, r.id, b.head, r.at, { node: r.node, base: b.base ?? null })
|
|
27
|
+
heads++
|
|
28
|
+
}
|
|
29
|
+
let messages = 0
|
|
30
|
+
if (has(db, 'card_msgs')) for (const r of db.query('select repo, card, id, node, rev, body from card_msgs order by repo, card, id').iterate() as IterableIterator<{ repo: string; card: string; id: string; node: string; rev: string; body: string }>) {
|
|
31
|
+
const m = (JSON.parse(r.body) as { msg: { id: string } }).msg
|
|
32
|
+
if (revOf(m) !== r.rev) throw new Error(`the hq file stays at its version: message ${r.card}/${r.id} of ${r.repo} holds rev ${r.rev.slice(0, 12)}, its body computes another, nothing is filled`)
|
|
33
|
+
putMessage(db, r.repo, r.card, m, { node: r.node })
|
|
34
|
+
messages++
|
|
35
|
+
}
|
|
36
|
+
return { heads, messages, ms: performance.now() - t0 }
|
|
37
|
+
}
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
// aside, never another of the same id
|
|
7
7
|
import type { Database } from 'bun:sqlite'
|
|
8
8
|
import { ID_RE } from '../../review/model.ts'
|
|
9
|
+
import { HQ_ITEM_SCHEMA } from '../../review/item-db.ts'
|
|
9
10
|
import { asideRows } from '../../review/item-rows.ts'
|
|
10
11
|
import { MAX_ID_LENGTH, setAside, storeDir } from '../../review/store.ts'
|
|
11
12
|
import { isRepoId, kind } from './kind.ts'
|
|
12
|
-
import { ITEMS_READ } from './items-read.ts'
|
|
13
13
|
|
|
14
14
|
export type ItemGoneBody = { repo: string; id: string; created: string }
|
|
15
15
|
|
|
@@ -22,7 +22,7 @@ export const itemGoneName = (repo: string, id: string, created: string): string
|
|
|
22
22
|
|
|
23
23
|
/** the `created` of the head the hq holds under that id, null for none */
|
|
24
24
|
const heldCreated = (db: Database, repo: string, id: string): string | null => {
|
|
25
|
-
const r = db.query(
|
|
25
|
+
const r = db.query("select json_extract(head, '$.created') as created from review_cards where repo = ? and id = ?").get(repo, id) as { created: unknown } | null
|
|
26
26
|
return r == null ? null : String(r.created)
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -36,16 +36,13 @@ export const isGone = (db: Database, repo: string, id: string, created: string):
|
|
|
36
36
|
/** is some item of that id deleted, and no item of that id held: a message of it has no item to belong to */
|
|
37
37
|
export const noItemLeft = (db: Database, repo: string, id: string): boolean => db.query('select 1 from card_gone where repo = ? and id = ?').get(repo, id) != null && heldCreated(db, repo, id) == null
|
|
38
38
|
|
|
39
|
-
/** a tombstone kept, in the caller's transaction: the item's
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* keeps (item-direct.ts) */
|
|
39
|
+
/** a tombstone kept, in the caller's transaction: the item's feed entries go, its store rows set aside whole as a
|
|
40
|
+
* machine's store keeps a deletion. `held` when the tombstone was there; else what the set aside did and its entry.
|
|
41
|
+
* What the kind keeps of a row it took, and what a store write straight into the hq's file keeps (item-direct.ts) */
|
|
43
42
|
export function storeGone(db: Database, body: ItemGoneBody, node: string, at: number): { did: 'held' | 'moved' | 'none' | 'other'; entry: string } {
|
|
44
43
|
if (isGone(db, body.repo, body.id, body.created)) return { did: 'held', entry: body.id }
|
|
45
44
|
db.query('insert into card_gone (repo, id, created, node, at) values (?, ?, ?, ?, ?)').run(body.repo, body.id, body.created, node, at)
|
|
46
|
-
// that item's
|
|
47
|
-
db.query('delete from cards where repo = ? and id = ?').run(body.repo, body.id)
|
|
48
|
-
db.query('delete from card_msgs where repo = ? and card = ?').run(body.repo, body.id)
|
|
45
|
+
// that item's entries of the feed go with it: no daemon reads them again
|
|
49
46
|
db.query("delete from feed where kind = 'card' and name = ?").run(JSON.stringify([body.repo, body.id]))
|
|
50
47
|
db.query("delete from feed where kind = 'card-msg' and repo = ? and json_extract(name, '$[1]') = ?").run(body.repo, body.id)
|
|
51
48
|
return asideRows(db, body.repo, body.id, { created: body.created }, at, { node })
|
|
@@ -56,7 +53,7 @@ export const itemGoneKind = kind<ItemGoneBody>({
|
|
|
56
53
|
schema: `
|
|
57
54
|
create table if not exists card_gone (repo text not null, id text not null, created text not null, node text not null, at integer not null, primary key (repo, id, created)) without rowid;
|
|
58
55
|
create index if not exists card_gone_node on card_gone (node);
|
|
59
|
-
`,
|
|
56
|
+
${HQ_ITEM_SCHEMA}`,
|
|
60
57
|
tables: ['card_gone', 'review_gone'],
|
|
61
58
|
check: (v): v is ItemGoneBody => isObj(v) && isRepoId(v['repo']) && typeof v['id'] === 'string' && v['id'].length <= MAX_ID_LENGTH && ID_RE.test(v['id']) && typeof v['created'] === 'string' && v['created'].length <= 64,
|
|
62
59
|
repoOf: (b) => b.repo,
|