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/hq/kinds/item-msg.ts
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
// may reach the hq before its item's head: it is kept, and a daemon holds it until the head lands
|
|
4
4
|
import { MESSAGE_RE, ID_RE } from '../../review/model.ts'
|
|
5
5
|
import type { Database } from 'bun:sqlite'
|
|
6
|
+
import { HQ_ITEM_SCHEMA } from '../../review/item-db.ts'
|
|
6
7
|
import { putMessage } from '../../review/item-rows.ts'
|
|
7
8
|
import { holdsMessage, landMessage, MAX_ID_LENGTH, revOf, storeDir } from '../../review/store.ts'
|
|
8
9
|
import type { Ledger } from '../ledger.ts'
|
|
9
10
|
import { noItemLeft } from './item-gone.ts'
|
|
10
11
|
import { isRepoId, kind, type Landed } from './kind.ts'
|
|
11
|
-
import { ITEMS_READ } from './items-read.ts'
|
|
12
12
|
|
|
13
13
|
export type ItemMsgBody = { repo: string; card: string; id: string; msg: Record<string, unknown> }
|
|
14
14
|
|
|
@@ -37,30 +37,25 @@ export function landItemMsg(b: ItemMsgBody, ledger: Ledger, o: { dry: boolean; a
|
|
|
37
37
|
return r
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
/** a message in
|
|
41
|
-
* keeps of a row it took, and what a store write straight into the hq's file keeps (item-direct.ts) */
|
|
42
|
-
export function storeMsg(db: Database, body: ItemMsgBody, node: string
|
|
43
|
-
|
|
44
|
-
// the store's shape of the same message (item-shapes.ts)
|
|
45
|
-
putMessage(db, body.repo, body.card, body.msg as { id: string }, { node })
|
|
46
|
-
return true
|
|
40
|
+
/** a message in the store's tables of the hq's file, in the caller's transaction: false when one holds its id. What
|
|
41
|
+
* the kind keeps of a row it took, and what a store write straight into the hq's file keeps (item-direct.ts) */
|
|
42
|
+
export function storeMsg(db: Database, body: ItemMsgBody, node: string): boolean {
|
|
43
|
+
return putMessage(db, body.repo, body.card, body.msg as { id: string }, { node })
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
export const itemMsgKind = kind<ItemMsgBody>({
|
|
50
47
|
kind: 'card-msg',
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
`,
|
|
55
|
-
tables: ['card_msgs', 'review_msgs'],
|
|
48
|
+
// the store's tables, which each of the three item kinds makes (`if not exists`)
|
|
49
|
+
schema: HQ_ITEM_SCHEMA,
|
|
50
|
+
tables: ['review_msgs'],
|
|
56
51
|
check: (v): v is ItemMsgBody => isObj(v) && isRepoId(v['repo']) && typeof v['card'] === 'string' && v['card'].length <= MAX_ID_LENGTH && ID_RE.test(v['card']) && typeof v['id'] === 'string' && v['id'].length <= MAX_ID_LENGTH && MESSAGE_RE.test(v['id']) && isObj(v['msg']) && v['msg']['id'] === v['id'],
|
|
57
52
|
repoOf: (b) => b.repo,
|
|
58
|
-
insert: (db, r) => (storeMsg(db, r.body, r.node
|
|
53
|
+
insert: (db, r) => (storeMsg(db, r.body, r.node) ? { rows: 1, bytes: Buffer.byteLength(JSON.stringify(r.body.msg)) } : null),
|
|
59
54
|
outbox: 'cards',
|
|
60
55
|
refuses: (db, b) => (noItemLeft(db, b.repo, b.card) ? `a message of item ${b.card} of ${b.repo}, which was deleted` : null),
|
|
61
56
|
// the hq never holds the thread of an item it lacks: the message waits at its daemon for its item
|
|
62
|
-
keeps: (db, b) => (db.query(
|
|
63
|
-
usage: (db) => db.query(
|
|
57
|
+
keeps: (db, b) => (db.query('select 1 from review_cards where repo = ? and id = ?').get(b.repo, b.card) == null ? `a message of item ${b.card} of ${b.repo}: its item is not in the hq` : null),
|
|
58
|
+
usage: (db) => db.query('select node, count(*) as rows, sum(length(cast(body as blob))) as bytes from review_msgs group by node').all() as { node: string; rows: number; bytes: number }[],
|
|
64
59
|
maxPerNode: NODE_MAX_ITEM_MSGS,
|
|
65
60
|
maxBytesPerNode: NODE_MAX_ITEM_MSG_BYTES,
|
|
66
61
|
sweep: () => 0,
|
|
@@ -68,12 +63,11 @@ create index if not exists card_msgs_node on card_msgs (node);
|
|
|
68
63
|
nameOf: (b) => itemMsgName(b.repo, b.card, b.id),
|
|
69
64
|
read: (db, name) => {
|
|
70
65
|
const [repo, item, id] = JSON.parse(name) as [string, string, string]
|
|
71
|
-
if (ITEMS_READ === 'cards') return (db.query('select body from card_msgs where repo = ? and card = ? and id = ?').get(repo, item, id) as { body: string } | null)?.body ?? null
|
|
72
66
|
// the body as its sender sent it: the message under its repo, its item and its id
|
|
73
67
|
const r = db.query('select body from review_msgs where repo = ? and card = ? and id = ?').get(repo, item, id) as { body: string } | null
|
|
74
68
|
return r == null ? null : JSON.stringify({ repo, card: item, id, msg: JSON.parse(r.body) as unknown })
|
|
75
69
|
},
|
|
76
|
-
revs: (db, repo) => db.query(
|
|
70
|
+
revs: (db, repo) => db.query("select card || '/' || id as name, rev from review_msgs where repo = ? order by card, id").all(repo) as { name: string; rev: string }[],
|
|
77
71
|
},
|
|
78
72
|
land: landItemMsg,
|
|
79
73
|
})
|
package/src/hq/kinds/item.ts
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
// says so
|
|
10
10
|
import { ID_RE } from '../../review/model.ts'
|
|
11
11
|
import type { Database } from 'bun:sqlite'
|
|
12
|
+
import { HQ_ITEM_SCHEMA } from '../../review/item-db.ts'
|
|
12
13
|
import { putHead } from '../../review/item-rows.ts'
|
|
13
14
|
import { holdsItem, landHead, MAX_ID_LENGTH, revOf, storeDir } from '../../review/store.ts'
|
|
14
15
|
import { isGone } from './item-gone.ts'
|
|
15
16
|
import { landItemMsg } from './item-msg.ts'
|
|
16
|
-
import { ITEMS_READ } from './items-read.ts'
|
|
17
17
|
import { isRepoId, kind } from './kind.ts'
|
|
18
18
|
|
|
19
19
|
export type ItemBody = { repo: string; id: string; head: Record<string, unknown>; rev: string; base?: string }
|
|
@@ -29,36 +29,31 @@ const isObj = (v: unknown): v is Record<string, unknown> => v != null && typeof
|
|
|
29
29
|
|
|
30
30
|
export const itemName = (repo: string, id: string): string => JSON.stringify([repo, id])
|
|
31
31
|
|
|
32
|
-
/** a head in
|
|
33
|
-
* what a store write straight into the hq's file keeps (item-direct.ts) */
|
|
34
|
-
export function storeHead(db: Database, body: ItemBody, node: string, at: number
|
|
35
|
-
db.query('insert into cards (repo, id, node, at, rev, body) values (?, ?, ?, ?, ?, ?) on conflict (repo, id) do update set node = excluded.node, at = excluded.at, rev = excluded.rev, body = excluded.body').run(body.repo, body.id, node, at, body.rev, text)
|
|
36
|
-
// the store's shape of the same head (item-shapes.ts)
|
|
32
|
+
/** a head in the store's tables of the hq's file, in the caller's transaction: what the kind keeps of a row it took,
|
|
33
|
+
* and what a store write straight into the hq's file keeps (item-direct.ts) */
|
|
34
|
+
export function storeHead(db: Database, body: ItemBody, node: string, at: number): void {
|
|
37
35
|
putHead(db, body.repo, body.id, body.head, at, { node, base: body.base ?? null })
|
|
38
36
|
}
|
|
39
|
-
// the kinds `card`, `card-msg` and `card-gone`
|
|
40
|
-
//
|
|
37
|
+
// the kinds `card`, `card-msg` and `card-gone` keep their stored names (wiki tools/shipkit/threads.md, The words):
|
|
38
|
+
// every machine sends them. Their rows are the store's own tables (item-db.ts HQ_ITEM_SCHEMA)
|
|
41
39
|
export const itemKind = kind<ItemBody>({
|
|
42
40
|
kind: 'card',
|
|
43
|
-
schema:
|
|
44
|
-
|
|
45
|
-
create index if not exists cards_node on cards (node);
|
|
46
|
-
`,
|
|
47
|
-
tables: ['cards', 'review_cards', 'review_replaced'],
|
|
41
|
+
schema: HQ_ITEM_SCHEMA,
|
|
42
|
+
tables: ['review_cards', 'review_replaced'],
|
|
48
43
|
// the rev is the head's own: a row that names another is a lie, and its readers would compare it for nothing
|
|
49
44
|
check: (v): v is ItemBody => isObj(v) && isRepoId(v['repo']) && typeof v['id'] === 'string' && v['id'].length <= MAX_ID_LENGTH && ID_RE.test(v['id']) && isObj(v['head']) && v['head']['id'] === v['id'] && typeof v['rev'] === 'string' && v['rev'] === revOf(v['head']) && (v['base'] === undefined || (typeof v['base'] === 'string' && /^[0-9a-f]{64}$/.test(v['base']))),
|
|
50
45
|
repoOf: (b) => b.repo,
|
|
51
46
|
insert: (db, r) => {
|
|
52
|
-
const bytes =
|
|
53
|
-
const held = db.query(
|
|
47
|
+
const bytes = Buffer.byteLength(JSON.stringify(r.body.head))
|
|
48
|
+
const held = db.query('select at, rev, length(cast(head as blob)) as bytes from review_cards where repo = ? and id = ?').get(r.body.repo, r.body.id) as { at: number; rev: string; bytes: number } | null
|
|
54
49
|
if (held != null && (held.rev === r.body.rev || !(r.at > held.at || (r.at === held.at && r.body.rev > held.rev)))) return null
|
|
55
|
-
storeHead(db, r.body, r.node, r.at
|
|
50
|
+
storeHead(db, r.body, r.node, r.at)
|
|
56
51
|
return held == null ? { rows: 1, bytes } : { rows: 0, bytes: bytes - held.bytes }
|
|
57
52
|
},
|
|
58
53
|
outbox: 'cards',
|
|
59
54
|
maxRowBytes: ITEM_MAX_ROW_BYTES,
|
|
60
55
|
refuses: (db, b) => (isGone(db, b.repo, b.id, String(b.head['created'])) ? `item ${b.id} of ${b.repo} made ${String(b.head['created'])} was deleted: that item is never taken again` : null),
|
|
61
|
-
usage: (db) => db.query(
|
|
56
|
+
usage: (db) => db.query('select node, count(*) as rows, sum(length(cast(head as blob))) as bytes from review_cards group by node').all() as { node: string; rows: number; bytes: number }[],
|
|
62
57
|
maxPerNode: NODE_MAX_ITEMS,
|
|
63
58
|
maxBytesPerNode: NODE_MAX_ITEM_BYTES,
|
|
64
59
|
sweep: () => 0,
|
|
@@ -66,12 +61,11 @@ create index if not exists cards_node on cards (node);
|
|
|
66
61
|
nameOf: (b) => itemName(b.repo, b.id),
|
|
67
62
|
read: (db, name) => {
|
|
68
63
|
const [repo, id] = JSON.parse(name) as [string, string]
|
|
69
|
-
if (ITEMS_READ === 'cards') return (db.query('select body from cards where repo = ? and id = ?').get(repo, id) as { body: string } | null)?.body ?? null
|
|
70
64
|
// the body as its sender sent it: the head, its rev, and the rev it was made on top of
|
|
71
65
|
const r = db.query('select head, rev, base from review_cards where repo = ? and id = ?').get(repo, id) as { head: string; rev: string; base: string | null } | null
|
|
72
66
|
return r == null ? null : JSON.stringify({ repo, id, head: JSON.parse(r.head) as unknown, rev: r.rev, ...(r.base == null ? {} : { base: r.base }) })
|
|
73
67
|
},
|
|
74
|
-
revs: (db, repo) => db.query(
|
|
68
|
+
revs: (db, repo) => db.query('select id as name, rev from review_cards where repo = ? order by id').all(repo) as { name: string; rev: string }[],
|
|
75
69
|
},
|
|
76
70
|
// a head is written over this machine's only when this machine holds no change of it the hq has not seen, and
|
|
77
71
|
// only over the same item: two items made apart under one id stay each on its machine, and the check names them
|
package/src/hq/kinds/report.ts
CHANGED
|
@@ -15,8 +15,7 @@ export const REPORT_ACTIVITY_MS = 24 * 3600_000
|
|
|
15
15
|
/** a report past a day: what only the newest one is read for (its activity, each repo's gate, each process's url, its
|
|
16
16
|
* url facts) goes */
|
|
17
17
|
export function slimReport(r: Report): Report {
|
|
18
|
-
|
|
19
|
-
const { activity: _activity, urls: _urls, backups: _backups, ...rest } = r
|
|
18
|
+
const { activity: _activity, urls: _urls, ...rest } = r
|
|
20
19
|
return { ...rest, repos: r.repos.map(({ gate: _gate, ...x }) => x), ...(r.processes == null ? {} : { processes: r.processes.map(({ url: _url, ...p }) => p) }) }
|
|
21
20
|
}
|
|
22
21
|
|
|
@@ -33,8 +32,8 @@ create index if not exists reports_at on reports (node, at);
|
|
|
33
32
|
repoOf: () => '',
|
|
34
33
|
insert: (db, r) => {
|
|
35
34
|
// its url facts rebuilt field by field: a login or a secret's name a sender put beside one is never stored; its
|
|
36
|
-
//
|
|
37
|
-
const text = r.body.urls === undefined && r.body.
|
|
35
|
+
// holds of a wrong shape dropped, the rest of the report kept
|
|
36
|
+
const text = r.body.urls === undefined && r.body.holds === undefined ? r.text : JSON.stringify(storedReport(r.body))
|
|
38
37
|
if (db.query('insert into reports (node, epoch, seq, at, body) values (?, ?, ?, ?, ?) on conflict (node, epoch, seq) do nothing').run(r.node, r.epoch, r.seq, r.at, text).changes === 0) return null
|
|
39
38
|
// a wanted switch value is done once a report of its node shows it
|
|
40
39
|
const sw = r.body.switches
|
package/src/hq/owner-switch.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
// terminal refuse it too. The daemon's own variables prove nothing either way (an agent may have started it): his
|
|
8
8
|
// click is judged by the gates of the route (the owner's word, loopback only), never by the daemon's env
|
|
9
9
|
import { machineName } from '../core/machine-name.ts'
|
|
10
|
-
import { AGENT_ENV, SSH_ENV } from '../
|
|
11
|
-
import {
|
|
10
|
+
import { AGENT_ENV, SSH_ENV } from '../core/agent-env.ts'
|
|
11
|
+
import { switchOf, SWITCHES, switchValue, type SwitchDecl } from './switch.ts'
|
|
12
12
|
import { hqHostOf } from './terminal-hop.ts'
|
|
13
13
|
import { machineGet } from '../core/machine-db.ts'
|
|
14
14
|
|
|
@@ -56,6 +56,6 @@ export function ownerSwitchesView(get: (name: string) => unknown = machineGet, o
|
|
|
56
56
|
return {
|
|
57
57
|
machine: (o.machine ?? machineName)(),
|
|
58
58
|
hq,
|
|
59
|
-
switches: ownerSwitches().map((d) => ({ name: d.name, on: switchValue(d,
|
|
59
|
+
switches: ownerSwitches().map((d) => ({ name: d.name, on: switchValue(d, get(d.name)) === true, title: d.byOwner!.title, ask: d.byOwner!.ask(label), what: d.what })),
|
|
60
60
|
}
|
|
61
61
|
}
|
package/src/hq/report.ts
CHANGED
|
@@ -11,7 +11,6 @@ import { maskSecrets } from '../agent-time/mask.ts'
|
|
|
11
11
|
import { maskFields } from './kinds/kind.ts'
|
|
12
12
|
import { realGit } from '../core/git.ts'
|
|
13
13
|
import { isFollowFact, MAX_WHY, type FollowFact } from './follow-fact.ts'
|
|
14
|
-
import { type BackupFacts, isBackupFacts } from '../media-store/backup/facts.ts'
|
|
15
14
|
import { type Holds, isHolds } from './holds-shape.ts'
|
|
16
15
|
|
|
17
16
|
export type RepoFacts = {
|
|
@@ -72,8 +71,6 @@ export type Report = {
|
|
|
72
71
|
follow?: FollowFact
|
|
73
72
|
/** each one time ask (switch.ts ONCE_ASKS) by the time of the last one this machine took: absent before */
|
|
74
73
|
taken?: Record<string, number>
|
|
75
|
-
/** its own backups' records (media-store/backup/facts.ts), which the hq's machine judges: absent before */
|
|
76
|
-
backups?: BackupFacts
|
|
77
74
|
/** what the hq holds of its rows, kind by kind, as it last counted them (hq/hq-holds.ts): absent before */
|
|
78
75
|
holds?: Holds
|
|
79
76
|
}
|
|
@@ -175,11 +172,11 @@ export function urlFacts(v: unknown): UrlFact[] {
|
|
|
175
172
|
return out
|
|
176
173
|
}
|
|
177
174
|
|
|
178
|
-
/** a report as the hq stores it: its url facts rebuilt by urlFacts, its
|
|
179
|
-
*
|
|
175
|
+
/** a report as the hq stores it: its url facts rebuilt by urlFacts, its holds dropped when their shape is wrong (the
|
|
176
|
+
* rest of the report stays), nothing else changed */
|
|
180
177
|
export function storedReport(r: Report): Report {
|
|
181
|
-
const {
|
|
182
|
-
const out: Report = { ...rest, ...(
|
|
178
|
+
const { holds, ...rest } = r
|
|
179
|
+
const out: Report = { ...rest, ...(holds === undefined || !isHolds(holds) ? {} : { holds }) }
|
|
183
180
|
return out.urls === undefined ? out : { ...out, urls: urlFacts(out.urls) }
|
|
184
181
|
}
|
|
185
182
|
|
|
@@ -306,7 +303,7 @@ async function gateOf(path: string): Promise<GateFact | undefined> {
|
|
|
306
303
|
}
|
|
307
304
|
|
|
308
305
|
/** this machine's report. `house` is the checkout shipkit runs from, null on a machine with none */
|
|
309
|
-
export async function buildReport(o: { repos: { name: string; path: string }[]; house: string | null; tailnet: { name: string | null; up: boolean }; diskOf: string; cards?: { waiting: number; since: number | null }; media?: MediaReport | null; now?: number } & Pick<Report, 'processes' | 'lanes' | 'switches' | 'urls' | 'follow' | 'taken' | '
|
|
306
|
+
export async function buildReport(o: { repos: { name: string; path: string }[]; house: string | null; tailnet: { name: string | null; up: boolean }; diskOf: string; cards?: { waiting: number; since: number | null }; media?: MediaReport | null; now?: number } & Pick<Report, 'processes' | 'lanes' | 'switches' | 'urls' | 'follow' | 'taken' | 'holds'>): Promise<Report> {
|
|
310
307
|
const since = (o.now ?? Date.now()) - ACTIVITY_MS
|
|
311
308
|
const read = await Promise.all(
|
|
312
309
|
o.repos.slice(0, MAX_REPOS).map(async (r) => {
|
|
@@ -334,7 +331,6 @@ export async function buildReport(o: { repos: { name: string; path: string }[];
|
|
|
334
331
|
...(o.urls == null ? {} : { urls: urlFacts(o.urls) }),
|
|
335
332
|
...(o.follow == null ? {} : { follow: { ...o.follow, why: o.follow.why == null ? null : o.follow.why.slice(0, MAX_WHY) } }),
|
|
336
333
|
...(o.taken == null ? {} : { taken: o.taken }),
|
|
337
|
-
...(o.backups == null ? {} : { backups: o.backups }),
|
|
338
334
|
...(o.holds == null ? {} : { holds: o.holds }),
|
|
339
335
|
}
|
|
340
336
|
return maskFields(report, REPORT_TEXTS)
|
package/src/hq/switch.ts
CHANGED
|
@@ -27,8 +27,6 @@ export type SwitchValue = boolean | number | null
|
|
|
27
27
|
|
|
28
28
|
export type SwitchDecl = {
|
|
29
29
|
name: string
|
|
30
|
-
/** its name before: read where the machine db holds none under `name`, until its owner's code moves the value */
|
|
31
|
-
was?: string
|
|
32
30
|
/** on or off, or a time (ms) the owner's code writes */
|
|
33
31
|
type: 'bool' | 'time'
|
|
34
32
|
/** its value while the machine db holds none */
|
|
@@ -52,7 +50,7 @@ export const SWITCHES: readonly SwitchDecl[] = [
|
|
|
52
50
|
{ name: VAULT_SNAPSHOTS_PRUNE, type: 'bool', default: false, owner: 'hq/switch.ts', what: "the vault's sealed snapshots older than 30 days deleted from the Space for good", deletes: true },
|
|
53
51
|
{ name: 'hq-open', type: 'bool', default: false, owner: 'hq/hq-role.ts', what: "the hq's port to the other machines" },
|
|
54
52
|
{ name: 'hq-proxy', type: 'bool', default: false, owner: 'hq/door.ts', what: "the hq's home opens a process of any machine at <process>.<machine>.localhost, on the hq's machine only" },
|
|
55
|
-
{ name: 'machine-urls',
|
|
53
|
+
{ name: 'machine-urls', type: 'bool', default: false, owner: 'hq/door.ts', what: "this machine's web opens its own global processes and loopback urls to the hq's proxy, for the key the hq gave it", byOwner: { set: async (on) => (await import('./door.ts')).setUrlsOn(on), title: "urls to the hq's home", ask: (hq) => `let the hq's home (${hq}) open this machine's global processes and urls` } },
|
|
56
54
|
{ name: 'machine-terminals', type: 'bool', default: false, owner: 'hq/terminal-hop.ts', what: "the hq Mac's page types into this machine's terminals, for the key the hq gave it; never the phone", byOwner: { set: async (on) => (await import('./terminal-hop.ts')).setTerminalsOn(on), title: "terminals to the hq's Mac", ask: (hq) => `let the hq's Mac (${hq}) type into this machine's terminals` } },
|
|
57
55
|
{ name: 'media-purge-auto', type: 'bool', default: false, owner: 'media-store/daemon.ts', what: 'an uploaded media file leaves the disk after a day', deletes: true, afar: async (on) => (await import('../media-store/daemon.ts')).setAutoPurge(on) },
|
|
58
56
|
{ name: 'annex-auto', type: 'bool', default: false, owner: 'annex/tidy.ts', what: 'the daemon tidies the annex on its own', deletes: true, afar: async (on) => (await import('../annex/tidy.ts')).setAnnexAuto(on) },
|
|
@@ -60,7 +58,6 @@ export const SWITCHES: readonly SwitchDecl[] = [
|
|
|
60
58
|
{ name: 'temp-auto-at', type: 'time', default: null, owner: 'home/machine-temp.ts', what: 'since when the temp sweep is on' },
|
|
61
59
|
{ name: 'temp-repos-from', type: 'time', default: null, owner: 'home/machine-temp.ts', what: "since when the sweep deletes in each repo's .shipkit/tmp" },
|
|
62
60
|
{ name: 'hq-threads', type: 'bool', default: false, owner: 'review/item-hq.ts', what: "on the machine that carries the hq, the threads of the repos it holds are read and written in the hq's file; off, in the daemon's file, the hq holding their copy" },
|
|
63
|
-
{ name: 'db-fold-auto', type: 'bool', default: true, owner: 'core/machine-db.ts', what: 'the daemon folds the media index and the agent time index into the machine db; off (a way back), a store not folded is read in its own file' },
|
|
64
61
|
{ name: 'time-diet', type: 'bool', default: false, owner: 'agent-time/diet.ts', what: "the agent time index drops the command text of an ordinary call older than 7 days (never back: Claude Code prunes the transcripts)", deletes: true },
|
|
65
62
|
{ name: HOUSE_FOLLOW, type: 'bool', default: true, owner: 'hq/switch.ts', what: "the daemon merges the house checkout's upstream when nothing holds it, pushes its machine commits and restarts the web and the daemon onto it", afar: async (on) => setFollowOn(on) },
|
|
66
63
|
{ name: 'trace.enabled', type: 'bool', default: true, owner: 'trace/tracer.ts', what: 'the traces of shipkit runs', afar: async (on) => ((await import('../trace/tracer.ts')).setTraceEnabled(on), true) },
|
|
@@ -75,13 +72,7 @@ export function switchValue(d: SwitchDecl, v: unknown): SwitchValue {
|
|
|
75
72
|
}
|
|
76
73
|
|
|
77
74
|
/** every declared switch with its value on this machine */
|
|
78
|
-
export const switchValues = (get: (name: string) => unknown = machineGet): Record<string, SwitchValue> => Object.fromEntries(SWITCHES.map((d) => [d.name, switchValue(d,
|
|
79
|
-
|
|
80
|
-
/** what the machine db holds for a switch: under its name, else under the name it had before */
|
|
81
|
-
export function heldSwitch(d: SwitchDecl, get: (name: string) => unknown = machineGet): unknown {
|
|
82
|
-
const v = get(d.name)
|
|
83
|
-
return v == null && d.was != null ? get(d.was) : v
|
|
84
|
-
}
|
|
75
|
+
export const switchValues = (get: (name: string) => unknown = machineGet): Record<string, SwitchValue> => Object.fromEntries(SWITCHES.map((d) => [d.name, switchValue(d, get(d.name))]))
|
|
85
76
|
|
|
86
77
|
/** why the hq's machine may not ask this value of a node, null when it may */
|
|
87
78
|
export function afarRefusal(name: string, on: boolean): string | null {
|
package/src/hq/thread-sync.ts
CHANGED
|
@@ -336,24 +336,12 @@ export async function hqThreadsTick(o: { repos: { name: string; path: string }[]
|
|
|
336
336
|
|
|
337
337
|
/** the lease one look of the threads job holds, beside the daemon's own database */
|
|
338
338
|
export const threadsLease = (): string => `${daemonDbPath()}-threads`
|
|
339
|
-
/** its name before: still taken, so an older copy of shipkit on this machine (a worktree's, a daemon not restarted yet)
|
|
340
|
-
* and this one never run a look or a move at once */
|
|
341
|
-
const threadsLeaseBefore = (): string => `${daemonDbPath()}-cards`
|
|
342
|
-
|
|
343
|
-
/** both leases, or null while either is held; its release frees both */
|
|
344
|
-
export function tryThreadsLease(label: string): { release: () => void } | null {
|
|
345
|
-
const now = tryLease(threadsLease(), label)
|
|
346
|
-
if (now == null) return null
|
|
347
|
-
const before = tryLease(threadsLeaseBefore(), label)
|
|
348
|
-
if (before == null) {
|
|
349
|
-
now.release()
|
|
350
|
-
return null
|
|
351
|
-
}
|
|
352
|
-
return { release: () => (before.release(), now.release()) }
|
|
353
|
-
}
|
|
354
339
|
|
|
355
|
-
/**
|
|
356
|
-
export const
|
|
340
|
+
/** the lease, or null while it is held */
|
|
341
|
+
export const tryThreadsLease = (label: string): { release: () => void } | null => tryLease(threadsLease(), label)
|
|
342
|
+
|
|
343
|
+
/** who holds the lease */
|
|
344
|
+
export const threadsLeaseHolder = (): ReturnType<typeof leaseHolder> => leaseHolder(threadsLease())
|
|
357
345
|
|
|
358
346
|
/** the heads and messages this machine's store holds */
|
|
359
347
|
const storeRows = (db: Database): number => (db.query('select (select count(*) from review_cards) + (select count(*) from review_msgs) as n').get() as { n: number }).n
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
// the hq's threads as words: where this machine reads them (review/item-hq.ts), the
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
/** both shapes by rev: the heads and messages of each, the ones that differ or are in one alone. `ok` when none */
|
|
5
|
-
export type ShapesDiff = { heads: number; messages: number; storeHeads: number; storeMessages: number; differ: number; onlyOld: number; onlyStore: number; ok: boolean }
|
|
1
|
+
// the hq's threads as words: where this machine reads them (review/item-hq.ts). No import, so the hub's page reads
|
|
2
|
+
// it too
|
|
6
3
|
|
|
7
4
|
/** where this machine's threads are read and written now (review/item-hq.ts threadsWhere), and why */
|
|
8
5
|
export type ThreadsWhere = { where: 'hq' | 'machine'; switchOn: boolean; carries: boolean; why: string }
|
|
@@ -22,10 +19,3 @@ export function threadsLine(t: ThreadsWhere): string {
|
|
|
22
19
|
const w = threadsWords(t)
|
|
23
20
|
return `threads: ${w.read}, ${w.copy} (${w.tip})`
|
|
24
21
|
}
|
|
25
|
-
|
|
26
|
-
/** the compare as one line, the same in the daemon's log, `sk db hq` and the database page */
|
|
27
|
-
export function shapesLine(d: ShapesDiff): string {
|
|
28
|
-
const n = (x: number): string => x.toLocaleString('en-US')
|
|
29
|
-
if (d.ok) return `both shapes of the threads agree: ${n(d.heads)} heads, ${n(d.messages)} messages`
|
|
30
|
-
return `the threads differ between the two shapes: ${n(d.heads)} heads and ${n(d.messages)} messages in the old tables, ${n(d.storeHeads)} and ${n(d.storeMessages)} in the store's tables; ${d.differ} at two revs, ${d.onlyOld} only in the old tables, ${d.onlyStore} only in the store's tables`
|
|
31
|
-
}
|
package/src/http/owner-word.ts
CHANGED
|
@@ -24,7 +24,7 @@ export const FETCH_SITE_HEADER = 'x-shipkit-fetch-site'
|
|
|
24
24
|
export type OwnerRoutes = { under: string; what: string; not?: readonly string[] }
|
|
25
25
|
|
|
26
26
|
export const OWNER_WORD_ROUTES: readonly OwnerRoutes[] = [
|
|
27
|
-
{ under: '/api/review', what: 'a thread: his reply, the delete of his own message, answer, verdict, close, reopen, snooze, mute, attach, lane ask, note, raised item, rating, action, read mark, staged draft, file, share, secret' },
|
|
27
|
+
{ under: '/api/review', what: 'a thread: his reply, the delete of his own message, answer, verdict, close, reopen, rename, snooze, mute, attach, lane ask, note, raised item, rating, action, read mark, staged draft, file, share, secret' },
|
|
28
28
|
{ under: '/api/trailer', what: 'a trailer: his note on a frame, its state and words, his voice takes' },
|
|
29
29
|
{ under: '/api/act', what: "an ask's done, decline, proof and remark, his act on a reflection, a note on an asset" },
|
|
30
30
|
{ under: '/api/docs', what: 'the editor: his save of a document, a picture he drops into it' },
|
|
@@ -47,6 +47,22 @@ export const markUrl = (i: Identity): string | null => {
|
|
|
47
47
|
return f == null ? null : `/api/projects/identity-mark/${encodeURIComponent(i.id)}?v=${pictureVersion(f)}`
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/** the side in px the hub's mark is served at: it draws at 28 px at most (a tile's badge 14, the identities page 28),
|
|
51
|
+
* sharp at 2x with room; the avatar file itself is often 1024 px, 4 MB decoded for a 14 px badge on every page */
|
|
52
|
+
export const MARK_PX = 96
|
|
53
|
+
const marks = new Map<string, Promise<ArrayBuffer | null>>()
|
|
54
|
+
/** the mark as the hub draws it: the avatar file down to MARK_PX, a png, made once per file and version; null when
|
|
55
|
+
* the file does not decode */
|
|
56
|
+
export function markPng(file: string, version: string): Promise<ArrayBuffer | null> {
|
|
57
|
+
const key = `${file}@${version}`
|
|
58
|
+
let m = marks.get(key)
|
|
59
|
+
if (m == null) {
|
|
60
|
+
m = import('sharp').then(({ default: sharp }) => sharp(file).resize(MARK_PX, MARK_PX, { fit: 'cover', withoutEnlargement: true }).png().toBuffer()).then((b) => new Uint8Array(b).buffer, () => null)
|
|
61
|
+
marks.set(key, m)
|
|
62
|
+
}
|
|
63
|
+
return m
|
|
64
|
+
}
|
|
65
|
+
|
|
50
66
|
export const railOf = (i: Identity): RailIdentity => ({ id: i.id, name: i.name, default: i.default, colour: colourOf(i), mark: markUrl(i) })
|
|
51
67
|
|
|
52
68
|
/** the identities of a folder, read once per change of an identity.md; one cache per caller */
|
package/src/init-repo.ts
CHANGED
|
@@ -37,7 +37,6 @@ export default defineRepo({
|
|
|
37
37
|
name: '${name}',
|
|
38
38
|
venues: [], // e.g. ['itch', 'steam'], selects which .shipkit/<venue>/ contracts are REQUIRED
|
|
39
39
|
${speaksAsLine(speaksAs)}
|
|
40
|
-
tasks: [], // repo commit-gate tasks; deps double as race guards
|
|
41
40
|
// lint, typecheck, imports:check and cycles are cached on the tracked tree.
|
|
42
41
|
// \`test\` runs every time until you say what it reads, because an
|
|
43
42
|
// ignored path (a fixture, a local db, a .env) is not in a tree key:
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// never measured however often it runs. The record is the only source that
|
|
16
16
|
// measures a check, and the store is only ever the history of the other two.
|
|
17
17
|
import type { RunRow, RunStatus } from './run-log.ts'
|
|
18
|
-
import { readRuns, runsPath, runsStamp } from './run-log.ts'
|
|
18
|
+
import { readFirstRuns, readRuns, runsPath, runsStamp } from './run-log.ts'
|
|
19
19
|
import { answerMeasures, answersDb, answersStamp } from './store.ts'
|
|
20
20
|
|
|
21
21
|
/** one measurement read back off the store */
|
|
@@ -41,12 +41,13 @@ export type CheckStat = {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/** the ONE merge. Pure, so the rules above are testable without a disk. */
|
|
44
|
-
export function mergeCheckStats(o: { runs: RunRow[]; store: StoreSample[] }): Map<string, CheckStat> {
|
|
44
|
+
export function mergeCheckStats(o: { runs: RunRow[]; store: StoreSample[]; firstRunAt?: Map<string, number> }): Map<string, CheckStat> {
|
|
45
45
|
// each check's own first row is its boundary: what the store holds from
|
|
46
46
|
// before it is history the record never saw, and what comes after it is a
|
|
47
47
|
// measurement the record already carries. A check with no rows at all keeps
|
|
48
|
-
// its whole stored history
|
|
49
|
-
|
|
48
|
+
// its whole stored history. The record's own first row when the caller read
|
|
49
|
+
// it: the runs given are a recent window of each check
|
|
50
|
+
const firstRunAt = new Map(o.firstRunAt ?? [])
|
|
50
51
|
for (const r of o.runs) {
|
|
51
52
|
const prev = firstRunAt.get(r.id)
|
|
52
53
|
if (prev == null || r.at < prev) firstRunAt.set(r.id, r.at)
|
|
@@ -124,7 +125,7 @@ export function checkStatsFor(root: string, checks: { id: string }[], o?: { fres
|
|
|
124
125
|
const storeKey = `${checks.map((c) => c.id).join(',')}:${answersStamp(db, 'checks')}`
|
|
125
126
|
let store = stores.get(root)
|
|
126
127
|
if (store?.key !== storeKey) stores.set(root, (store = { key: storeKey, samples: scanCheckStore(db, checks) }))
|
|
127
|
-
const stats = mergeCheckStats({ runs: readRuns(record), store: store.samples })
|
|
128
|
+
const stats = mergeCheckStats({ runs: readRuns(record), store: store.samples, firstRunAt: readFirstRuns(record) })
|
|
128
129
|
cache.set(root, { stamp, stats })
|
|
129
130
|
return stats
|
|
130
131
|
}
|
package/src/ledger/db.ts
CHANGED
|
@@ -28,7 +28,6 @@ import { chmodSync, closeSync, existsSync, mkdirSync, openSync, readdirSync, rmS
|
|
|
28
28
|
import { basename, dirname, join } from 'path'
|
|
29
29
|
|
|
30
30
|
import { shipkitRoot } from '../core/git-root.ts'
|
|
31
|
-
import { createRefusal } from '../core/machine-layout.ts'
|
|
32
31
|
export { shipkitRoot }
|
|
33
32
|
|
|
34
33
|
export const DB_FILE = 'shipkit.sqlite'
|
|
@@ -203,10 +202,9 @@ export function openDb(path: string, o: { create?: boolean; busyMs?: number } =
|
|
|
203
202
|
* does, and every failure is null the same way */
|
|
204
203
|
export function openWith(path: string, o: { create?: boolean; busyMs?: number }, schema: (db: Database) => void): Opened | null {
|
|
205
204
|
if (path === '') return null
|
|
206
|
-
// a store that exists opens with no create and no folder made
|
|
207
|
-
// look, the open fails, and never makes the folder and an empty store again where the move set it aside
|
|
205
|
+
// a store that exists opens with no create and no folder made
|
|
208
206
|
const exists = existsSync(path)
|
|
209
|
-
if (!exists &&
|
|
207
|
+
if (!exists && o.create === false) return null
|
|
210
208
|
let db: Database | null = null
|
|
211
209
|
try {
|
|
212
210
|
if (!exists) mkdirSync(dirname(path), { recursive: true })
|