rvlib-shipkit 2.26.0 → 2.27.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 +20 -0
- package/package.json +1 -1
- package/src/agent-time/diet.ts +77 -0
- package/src/agent-time/family.ts +72 -0
- package/src/agent-time/hooks.ts +6 -4
- package/src/agent-time/limits.ts +44 -0
- package/src/agent-time/live.ts +1 -3
- package/src/agent-time/mask.ts +96 -18
- package/src/agent-time/refused.ts +45 -0
- package/src/agent-time/render.ts +122 -21
- package/src/agent-time/report-cache.ts +57 -0
- package/src/agent-time/report.ts +314 -40
- package/src/agent-time/shape.ts +50 -3
- package/src/agent-time/store.ts +320 -99
- package/src/agent-time/timeline.ts +140 -21
- package/src/agent-time/turns.ts +18 -8
- package/src/annex/offload.ts +17 -6
- package/src/annex/tidy.ts +70 -10
- package/src/asks/ask-after.ts +40 -0
- package/src/asks/asks-queue.ts +205 -47
- package/src/assets/kit-config.ts +7 -3
- package/src/assets/kits/identity-kit.ts +289 -10
- package/src/check.ts +3 -1
- package/src/checks/SK004-gitignore-policy.check.ts +12 -5
- package/src/checks/SK013-one-way-in-policy.check.ts +8 -3
- package/src/checks/SK026-asks-autoclose.check.ts +5 -5
- package/src/checks/SK028-readme.check.ts +7 -66
- package/src/checks/SK030-cache-audit.check.ts +6 -1
- package/src/checks/SK031-trace-audit.check.ts +2 -0
- package/src/checks/SK033-global-contribution.check.ts +3 -1
- package/src/checks/SK035-public-clean.check.ts +2 -2
- package/src/checks/SK043-scratch-on-the-mac.check.ts +59 -4
- package/src/checks/SK047-login-in-description.check.ts +36 -0
- package/src/checks/SK048-one-local-file.check.ts +36 -0
- package/src/cli/cmd_Asks.ts +71 -5
- package/src/cli/cmd_Backup.ts +2 -2
- package/src/cli/cmd_Capacity.ts +2 -2
- package/src/cli/cmd_CrossRepoActivity.ts +5 -4
- package/src/cli/cmd_Db.ts +253 -0
- package/src/cli/cmd_History.ts +212 -0
- package/src/cli/cmd_Home.ts +31 -3
- package/src/cli/cmd_Hq.ts +516 -0
- package/src/cli/cmd_Machines.ts +36 -0
- package/src/cli/cmd_Media.ts +38 -6
- package/src/cli/cmd_Reflect.ts +23 -2
- package/src/cli/cmd_Review.ts +548 -116
- package/src/cli/cmd_Secret.ts +62 -12
- package/src/cli/cmd_Social.ts +83 -1
- package/src/cli/cmd_Space.ts +324 -0
- package/src/cli/cmd_Time.ts +76 -5
- package/src/cli/cmd_Tmp.ts +28 -4
- package/src/cli/cmd_Trailer.ts +14 -10
- package/src/cli/cmd_Urls.ts +56 -0
- package/src/cli/cmd_Vault.ts +583 -0
- package/src/cli/family-help.ts +4 -2
- package/src/cli/family-pages.ts +1 -1
- package/src/cli/registry.ts +24 -3
- package/src/collections/actions.ts +63 -13
- package/src/collections/collection-types.ts +23 -1
- package/src/collections/providers.ts +117 -23
- package/src/collections/review.ts +4 -4
- package/src/contracts/contract-manifests.ts +6 -5
- package/src/contracts/contract-types.ts +6 -4
- package/src/contracts/contracts-engine.ts +11 -0
- package/src/contracts/manifests/chrome-web-store.contract.ts +31 -0
- package/src/core/budget.ts +12 -17
- package/src/core/capacity.ts +27 -18
- package/src/core/check-runner.ts +7 -4
- package/src/core/layout.ts +3 -0
- package/src/core/machine-busy.ts +127 -0
- package/src/core/machine-commit.ts +6 -1
- package/src/core/machine-db.ts +368 -20
- package/src/core/machine-layout.ts +137 -0
- package/src/core/machine-read.ts +81 -0
- package/src/core/migrate-layout.ts +1 -1
- package/src/core/one-way-in-policy.ts +64 -7
- package/src/core/polling-policy.ts +27 -0
- package/src/core/retention.ts +16 -2
- package/src/core/scope.ts +107 -14
- package/src/core/slots.ts +5 -4
- package/src/drill/clean.ts +25 -1
- package/src/drill/run.ts +1 -1
- package/src/drill/seal.ts +27 -4
- package/src/home/activity-shape.ts +2 -0
- package/src/home/activity.ts +66 -3
- package/src/home/app-sign.ts +15 -4
- package/src/home/daemon-jobs.ts +149 -7
- package/src/home/database-projects.ts +111 -0
- package/src/home/database-words.ts +203 -0
- package/src/home/databases.ts +460 -0
- package/src/home/global-units.ts +6 -0
- package/src/home/gui-app/ShipkitGui.swift +122 -1
- package/src/home/gui-app.ts +6 -3
- package/src/home/home-move.ts +514 -0
- package/src/home/home-paths.ts +12 -3
- package/src/home/home-routes.ts +68 -0
- package/src/home/inbox-shape.ts +24 -14
- package/src/home/machine-fold.ts +820 -0
- package/src/home/machine-host.ts +20 -5
- package/src/home/machine-repair.ts +503 -0
- package/src/home/machine-stores.ts +66 -15
- package/src/home/machine-temp.ts +547 -86
- package/src/home/resume.ts +79 -0
- package/src/home/run-daemon.ts +25 -4
- package/src/home/run-pm.ts +18 -5
- package/src/home/serve-daemon.ts +18 -3
- package/src/home/serve-web.ts +175 -7
- package/src/home/space-job.ts +115 -0
- package/src/home/space-page.ts +257 -0
- package/src/home/space-route.ts +167 -0
- package/src/home/space-words.ts +103 -0
- package/src/home/time-page-shape.ts +202 -0
- package/src/home/time-page.ts +64 -0
- package/src/home/vault-page.ts +482 -0
- package/src/home/vault-words.ts +132 -0
- package/src/hooks/leak-guard.ts +40 -13
- package/src/hooks/one-way-in-guard.ts +17 -4
- package/src/hq/cards.ts +581 -0
- package/src/hq/door-route.ts +43 -0
- package/src/hq/door.ts +163 -0
- package/src/hq/files-send.ts +348 -0
- package/src/hq/forgotten-log.ts +35 -0
- package/src/hq/history-check.ts +255 -0
- package/src/hq/history-place.ts +146 -0
- package/src/hq/history-send.ts +487 -0
- package/src/hq/hq-db.ts +99 -0
- package/src/hq/hq-local.ts +469 -0
- package/src/hq/hq-routes.ts +196 -0
- package/src/hq/hq-store.ts +599 -0
- package/src/hq/kinds/ask.ts +147 -0
- package/src/hq/kinds/card-gone.ts +83 -0
- package/src/hq/kinds/card-msg.ts +66 -0
- package/src/hq/kinds/card.ts +99 -0
- package/src/hq/kinds/index.ts +21 -0
- package/src/hq/kinds/kind.ts +126 -0
- package/src/hq/kinds/media.ts +125 -0
- package/src/hq/kinds/prompt.ts +219 -0
- package/src/hq/kinds/reflection.ts +128 -0
- package/src/hq/kinds/report.ts +55 -0
- package/src/hq/kinds/time-day.ts +236 -0
- package/src/hq/ledger.ts +473 -0
- package/src/hq/machine-key.ts +44 -0
- package/src/hq/machine-notes.ts +131 -0
- package/src/hq/outbox.ts +372 -0
- package/src/hq/replica.ts +168 -0
- package/src/hq/repo-id.ts +4 -0
- package/src/hq/report-facts.ts +117 -0
- package/src/hq/report.ts +274 -0
- package/src/hq/switch.ts +151 -0
- package/src/hq/vault-grant.ts +92 -0
- package/src/identities/identities.ts +15 -3
- package/src/identities/steps.ts +31 -0
- package/src/ledger/db.ts +73 -26
- package/src/ledger/gate-checks.ts +6 -2
- package/src/ledger/run-log.ts +11 -3
- package/src/ledger/store.ts +26 -4
- package/src/media-store/backup/daemon.ts +25 -17
- package/src/media-store/backup/kept.ts +241 -0
- package/src/media-store/backup/restore.ts +14 -4
- package/src/media-store/backup/run.ts +11 -11
- package/src/media-store/backup/secret.ts +6 -4
- package/src/media-store/backup/snapshot.ts +4 -2
- package/src/media-store/backup/sources.ts +67 -16
- package/src/media-store/copy/config.ts +77 -0
- package/src/media-store/copy/copy.ts +194 -0
- package/src/media-store/copy/lifecycle.ts +43 -0
- package/src/media-store/copy/night.ts +90 -0
- package/src/media-store/copy/proof.ts +151 -0
- package/src/media-store/copy/snapshot.ts +152 -0
- package/src/media-store/copy/store.ts +62 -0
- package/src/media-store/copy/stream.ts +176 -0
- package/src/media-store/daemon.ts +66 -16
- package/src/media-store/db.ts +22 -11
- package/src/media-store/forget.ts +23 -3
- package/src/media-store/hand.ts +4 -3
- package/src/media-store/hq-find.ts +75 -0
- package/src/media-store/hq-send.ts +277 -0
- package/src/media-store/kind.ts +2 -0
- package/src/media-store/purge.ts +18 -15
- package/src/media-store/put.ts +24 -8
- package/src/media-store/remote.ts +16 -7
- package/src/media-store/space-listing.ts +240 -0
- package/src/media-store/space.ts +40 -21
- package/src/media-store/sync.ts +5 -5
- package/src/media-store/tidy.ts +98 -0
- package/src/media-store/upload.ts +3 -3
- package/src/media-store/webp.ts +66 -0
- package/src/messages/model.ts +16 -7
- package/src/messages/routes.ts +14 -4
- package/src/messages/score.ts +2 -2
- package/src/messages/suggest.ts +96 -0
- package/src/pages/frame-client.ts +10 -0
- package/src/plan/planner.ts +28 -17
- package/src/recordings/media-kind.ts +1 -0
- package/src/recordings/model.ts +1 -1
- package/src/recordings/recorder-app/Capture.swift +9 -7
- package/src/reflect/hq-corpus.ts +56 -0
- package/src/reflect/prompt-corpus.ts +3 -1
- package/src/reflect/transcript.ts +129 -37
- package/src/release/machine-words.ts +67 -0
- package/src/release/public-clean.ts +8 -3
- package/src/releases/from-card.ts +1 -1
- package/src/releases/routes.ts +10 -5
- package/src/releases/store.ts +10 -1
- package/src/repo-config.ts +32 -2
- package/src/review/anim.ts +2 -2
- package/src/review/auto.ts +2 -2
- package/src/review/card-db.ts +244 -0
- package/src/review/card-rows.ts +266 -0
- package/src/review/cells.ts +76 -5
- package/src/review/draft-card.ts +41 -0
- package/src/review/draft-model.ts +78 -0
- package/src/review/format.ts +29 -10
- package/src/review/gone.ts +98 -0
- package/src/review/inbox-hook.ts +4 -4
- package/src/review/marks.ts +1 -1
- package/src/review/media-kind.ts +7 -5
- package/src/review/media-read.ts +9 -7
- package/src/review/media.ts +32 -5
- package/src/review/model.ts +202 -39
- package/src/review/move.ts +491 -0
- package/src/review/notes.ts +12 -20
- package/src/review/previews.ts +15 -19
- package/src/review/project.ts +1 -1
- package/src/review/rev.ts +8 -0
- package/src/review/role.ts +1 -1
- package/src/review/routes.ts +64 -13
- package/src/review/stage-card.ts +8 -4
- package/src/review/stage-routes.ts +1 -1
- package/src/review/store.ts +529 -83
- package/src/review/thread-fold.ts +51 -0
- package/src/review/threads.ts +147 -9
- package/src/review/trailer-auto-mock.ts +63 -0
- package/src/review/trailer-card.ts +4 -4
- package/src/review/trailer-desk.ts +41 -7
- package/src/review/trailer-media.ts +1 -0
- package/src/review/trailer-model.ts +8 -0
- package/src/review/trailer-notes.ts +1 -1
- package/src/review/trailer-routes.ts +9 -1
- package/src/review/unit.ts +6 -6
- package/src/review/watchers.ts +1 -1
- package/src/rules/untrack-generated.ts +92 -8
- package/src/secrets/held.ts +16 -0
- package/src/secrets/keychain.ts +113 -0
- package/src/secrets/list.ts +16 -6
- package/src/secrets/manager.ts +24 -10
- package/src/secrets/read.ts +257 -0
- package/src/secrets/who-reads.ts +49 -0
- package/src/serve/door-forward.ts +268 -0
- package/src/serve/door-names.ts +47 -0
- package/src/serve/embed.ts +1 -1
- package/src/serve/hub-app/activity-view.tsx +56 -32
- package/src/serve/hub-app/activity.css +7 -1
- package/src/serve/hub-app/asks-page.tsx +48 -0
- package/src/serve/hub-app/asks-st.ts +25 -0
- package/src/serve/hub-app/clock-svc.ts +1 -2
- package/src/serve/hub-app/col-card.tsx +64 -13
- package/src/serve/hub-app/col-list-page.tsx +122 -0
- package/src/serve/hub-app/col-list-st.ts +103 -0
- package/src/serve/hub-app/col-tables-view.tsx +10 -41
- package/src/serve/hub-app/col-tables.ts +76 -8
- package/src/serve/hub-app/cols-svc.ts +70 -16
- package/src/serve/hub-app/database-st.ts +260 -0
- package/src/serve/hub-app/database-view.tsx +289 -0
- package/src/serve/hub-app/database.css +32 -0
- package/src/serve/hub-app/entry-bar.css +14 -0
- package/src/serve/hub-app/entry-bar.tsx +33 -0
- package/src/serve/hub-app/entry-pick.ts +31 -0
- package/src/serve/hub-app/floating.tsx +1 -0
- package/src/serve/hub-app/hash-route.ts +11 -1
- package/src/serve/hub-app/header-bar.tsx +14 -18
- package/src/serve/hub-app/home-st.ts +89 -9
- package/src/serve/hub-app/home-strip.css +5 -19
- package/src/serve/hub-app/home-strip.tsx +58 -92
- package/src/serve/hub-app/home.html +7 -0
- package/src/serve/hub-app/hub-app.tsx +31 -142
- package/src/serve/hub-app/hub-types.ts +3 -1
- package/src/serve/hub-app/hub.css +109 -23
- package/src/serve/hub-app/icons.tsx +18 -1
- package/src/serve/hub-app/identities-st.ts +56 -6
- package/src/serve/hub-app/identities-view.tsx +100 -58
- package/src/serve/hub-app/identities.css +17 -15
- package/src/serve/hub-app/identity-address.ts +5 -0
- package/src/serve/hub-app/inbox-st.ts +41 -24
- package/src/serve/hub-app/inbox-view.tsx +37 -41
- package/src/serve/hub-app/inbox.css +2 -5
- package/src/serve/hub-app/index.html +7 -0
- package/src/serve/hub-app/kept-cols.tsx +7 -0
- package/src/serve/hub-app/keys.ts +28 -15
- package/src/serve/hub-app/later.tsx +26 -0
- package/src/serve/hub-app/list-filter.tsx +14 -0
- package/src/serve/hub-app/list-walk.ts +72 -3
- package/src/serve/hub-app/machines-st.ts +251 -0
- package/src/serve/hub-app/machines-view.tsx +224 -0
- package/src/serve/hub-app/machines.css +76 -0
- package/src/serve/hub-app/md-copy.tsx +79 -0
- package/src/serve/hub-app/media-view.tsx +2 -0
- package/src/serve/hub-app/messages/messages-page.tsx +79 -7
- package/src/serve/hub-app/messages/messages-st.ts +99 -3
- package/src/serve/hub-app/messages.css +14 -0
- package/src/serve/hub-app/page-keys.ts +175 -0
- package/src/serve/hub-app/pages-frames.tsx +11 -3
- package/src/serve/hub-app/palette-st.ts +58 -11
- package/src/serve/hub-app/palette-view.tsx +3 -1
- package/src/serve/hub-app/project-list.css +54 -8
- package/src/serve/hub-app/project-list.tsx +128 -59
- package/src/serve/hub-app/projects-svc.ts +78 -7
- package/src/serve/hub-app/reader-chips.tsx +13 -0
- package/src/serve/hub-app/readme-view.tsx +2 -3
- package/src/serve/hub-app/readme.css +27 -5
- package/src/serve/hub-app/reflections-page.tsx +42 -0
- package/src/serve/hub-app/reflections-st.ts +17 -0
- package/src/serve/hub-app/releases/releases-page.tsx +25 -2
- package/src/serve/hub-app/releases/releases-st.ts +1 -1
- package/src/serve/hub-app/repo-sections.ts +9 -5
- package/src/serve/hub-app/repo-st.ts +35 -8
- package/src/serve/hub-app/review/draft-card.tsx +163 -0
- package/src/serve/hub-app/review/kit.tsx +50 -7
- package/src/serve/hub-app/review/note-place.ts +1 -1
- package/src/serve/hub-app/review/review-board.tsx +2 -2
- package/src/serve/hub-app/review/review-cells.tsx +145 -65
- package/src/serve/hub-app/review/review-kit.ts +27 -1
- package/src/serve/hub-app/review/review-list.tsx +68 -30
- package/src/serve/hub-app/review/review-page.tsx +7 -8
- package/src/serve/hub-app/review/review-st.ts +111 -24
- package/src/serve/hub-app/review/review-thread.tsx +49 -19
- package/src/serve/hub-app/review/review-views.tsx +475 -144
- package/src/serve/hub-app/review/thread-control-st.ts +115 -0
- package/src/serve/hub-app/review/thread-control.tsx +74 -0
- package/src/serve/hub-app/review/thread-st.ts +73 -26
- package/src/serve/hub-app/review/trailer-card.tsx +1 -1
- package/src/serve/hub-app/review/trailer-page.tsx +37 -16
- package/src/serve/hub-app/review/trailer-st.ts +41 -7
- package/src/serve/hub-app/review.css +267 -61
- package/src/serve/hub-app/side-lists.ts +72 -0
- package/src/serve/hub-app/sidebar.tsx +6 -3
- package/src/serve/hub-app/site/site-part.tsx +2 -8
- package/src/serve/hub-app/site/site-st.ts +4 -4
- package/src/serve/hub-app/social/comms-page.tsx +20 -5
- package/src/serve/hub-app/social/kit.tsx +30 -4
- package/src/serve/hub-app/social/post-card.tsx +139 -49
- package/src/serve/hub-app/social/serial-writes.ts +13 -0
- package/src/serve/hub-app/social/social-model.ts +11 -0
- package/src/serve/hub-app/social/social-page.tsx +94 -35
- package/src/serve/hub-app/social/social-st.ts +120 -36
- package/src/serve/hub-app/social/stage-popup.tsx +1 -1
- package/src/serve/hub-app/social/stage-st.ts +1 -1
- package/src/serve/hub-app/social/step-layout.ts +1 -1
- package/src/serve/hub-app/social.css +3 -0
- package/src/serve/hub-app/space-st.ts +209 -0
- package/src/serve/hub-app/space-view.tsx +196 -0
- package/src/serve/hub-app/space.css +27 -0
- package/src/serve/hub-app/stores/stores-page.tsx +91 -23
- package/src/serve/hub-app/stores/stores-st.ts +44 -19
- package/src/serve/hub-app/stores.css +6 -1
- package/src/serve/hub-app/theme-st.ts +22 -9
- package/src/serve/hub-app/time-charts.tsx +291 -0
- package/src/serve/hub-app/time-pages.tsx +749 -0
- package/src/serve/hub-app/time-st.ts +162 -0
- package/src/serve/hub-app/time-view.tsx +76 -0
- package/src/serve/hub-app/time.css +138 -0
- package/src/serve/hub-app/tree-build.ts +52 -42
- package/src/serve/hub-app/tree-row.tsx +4 -4
- package/src/serve/hub-app/tree-svc.ts +18 -9
- package/src/serve/hub-app/urls-svc.ts +154 -0
- package/src/serve/hub-app/urls-view.tsx +117 -0
- package/src/serve/hub-app/urls.css +30 -0
- package/src/serve/hub-app/vault-st.ts +127 -0
- package/src/serve/hub-app/vault-view.tsx +154 -0
- package/src/serve/hub-app/vault.css +38 -0
- package/src/serve/hub-app/veille/veille-st.ts +12 -10
- package/src/serve/hub-app/waiting-svc.ts +29 -0
- package/src/serve/hub-app/wikis-view.tsx +2 -2
- package/src/serve/hub-runtime.ts +15 -2
- package/src/serve/project-gutter-route.ts +27 -14
- package/src/serve/project-gutter.ts +25 -12
- package/src/serve/same-origin.ts +10 -0
- package/src/serve/serve-hub.ts +13 -4
- package/src/shipkit-files.ts +16 -2
- package/src/shipkit.ts +1 -1
- package/src/shot/shooter.ts +616 -420
- package/src/shot/shot-ask.ts +246 -155
- package/src/site/desk.ts +2 -2
- package/src/smoke/run-smoke.ts +3 -2
- package/src/social/cover.ts +202 -0
- package/src/social/discord-layout.ts +37 -13
- package/src/social/drafts.ts +3 -0
- package/src/social/load.ts +23 -2
- package/src/social/media-kind.ts +2 -1
- package/src/social/publish/discord.ts +5 -2
- package/src/social/publish/secret.ts +2 -2
- package/src/social/release-stage.ts +28 -13
- package/src/social/routes.ts +26 -1
- package/src/social/stage.ts +1 -1
- package/src/social/stats.ts +12 -9
- package/src/social/strip.ts +4 -1
- package/src/social/thumbnail.ts +255 -0
- package/src/stores/collection.ts +15 -11
- package/src/stores/desk.ts +236 -42
- package/src/stores/model.ts +72 -6
- package/src/stores/routes.ts +37 -12
- package/src/stores/unit.ts +14 -8
- package/src/suite/judge-suites.ts +41 -11
- package/src/suite/select.ts +45 -3
- package/src/suite/suite-cli.ts +16 -10
- package/src/trailer/bed.ts +1 -1
- package/src/trailer/build.ts +134 -21
- package/src/trailer/ffmpeg.ts +7 -0
- package/src/trailer/fonts.ts +3 -2
- package/src/trailer/grammar.ts +201 -2
- package/src/trailer/graph.ts +42 -5
- package/src/trailer/look.ts +21 -0
- package/src/trailer/mock.ts +154 -0
- package/src/trailer/passage.ts +65 -26
- package/src/trailer/score/heard.ts +89 -0
- package/src/trailer/score/sound.ts +14 -8
- package/src/trailer/sound/run.ts +16 -6
- package/src/trailer/stitch.ts +26 -5
- package/src/trailer/titles.ts +82 -19
- package/src/trailer/versions.ts +1 -3
- package/src/trailer/vertical.ts +3 -1
- package/src/urls/frame.ts +195 -0
- package/src/urls/routes.ts +43 -0
- package/src/urls/rows.ts +171 -0
- package/src/urls/unit.ts +73 -0
- package/src/vault/house-keys.ts +42 -0
- package/src/vault/layout.ts +50 -0
- package/src/vault/policy.ts +165 -0
- package/src/vault/vault-audit.ts +276 -0
- package/src/vault/vault-client.ts +40 -0
- package/src/vault/vault-config.ts +159 -0
- package/src/vault/vault-destroy.ts +78 -0
- package/src/vault/vault-handover.ts +305 -0
- package/src/vault/vault-http.ts +352 -0
- package/src/vault/vault-import.ts +208 -0
- package/src/vault/vault-init.ts +328 -0
- package/src/vault/vault-minter.ts +271 -0
- package/src/vault/vault-restore.ts +333 -0
- package/src/vault/vault-serve.ts +342 -0
- package/src/vault/vault-snapshot.ts +281 -0
- package/src/veille/asks.ts +1 -1
- package/src/veille/desk.ts +2 -2
|
@@ -15,6 +15,8 @@ export type Call = {
|
|
|
15
15
|
tool: string
|
|
16
16
|
shape: string
|
|
17
17
|
cmd: string
|
|
18
|
+
/** the sum of the command's text once the diet dropped it (diet.ts cmdSum), absent or null while the text is there */
|
|
19
|
+
cmdSum?: number | null
|
|
18
20
|
outcome: Outcome | null
|
|
19
21
|
code: number | null
|
|
20
22
|
/** it waited for the human to allow it */
|
|
@@ -23,19 +25,34 @@ export type Call = {
|
|
|
23
25
|
perm: string
|
|
24
26
|
/** it only read (turns.ts isReadOnly, judged when indexed) */
|
|
25
27
|
read: boolean
|
|
28
|
+
/** the model message that carries it, the same for every call of one turn; absent or '' when none was recorded */
|
|
29
|
+
msg?: string
|
|
30
|
+
/** the model of the turn that wrote it, '' when the transcript does not say */
|
|
31
|
+
model: string
|
|
32
|
+
/** the tokens that turn read (input, cache read and cache write), 0 when unknown */
|
|
33
|
+
ctx: number
|
|
34
|
+
/** the tokens that turn wrote, 0 when unknown */
|
|
35
|
+
out: number
|
|
36
|
+
/** a call refused before it ran (blocked, denied): what refused it, in the harness's words; absent or '' otherwise */
|
|
37
|
+
why?: string
|
|
26
38
|
/** the call returned while its command ran on in the background: `end`
|
|
27
39
|
* is when it returned, `bgEnd` when the run ended (its task notification),
|
|
28
40
|
* null while no end is recorded */
|
|
29
41
|
bg: boolean
|
|
30
42
|
bgEnd: number | null
|
|
43
|
+
/** its foreground call ended on its time limit, and the harness ran the command on in the background: `end`
|
|
44
|
+
* is the limit, `bgEnd` and `outcome` what became of it after */
|
|
45
|
+
limited: boolean
|
|
31
46
|
}
|
|
32
47
|
|
|
33
|
-
/** `
|
|
34
|
-
|
|
48
|
+
/** `act`: he did something that is no prompt (a slash command, an interrupt);
|
|
49
|
+
* `lapse`: a watch of the agent's ran out in silence, and the harness woke it to arm the watch again;
|
|
50
|
+
* `end`: the agent ended its turn (a text block, stop_reason end_turn), or the API refused its request */
|
|
51
|
+
export type Mark = { at: number; kind: 'prompt' | 'act' | 'wake' | 'lapse' | 'message' | 'reply' | 'end' }
|
|
35
52
|
|
|
36
53
|
export type Stream = { calls: Call[]; marks: Mark[] }
|
|
37
54
|
|
|
38
|
-
/** where a slice of wall time went. `human`: stopped until
|
|
55
|
+
/** where a slice of wall time went. `human`: stopped until he typed or acted;
|
|
39
56
|
* `parked`: stopped until a message relayed in (the coordinator, another
|
|
40
57
|
* session), so a lane that handed back and waits to be written to */
|
|
41
58
|
export type Bucket = 'model' | 'tools' | 'approval' | 'subagent' | 'background' | 'parked' | 'human' | 'idle' | 'unknown'
|
|
@@ -47,6 +64,9 @@ export const IDLE_MS = 30 * 60 * 1000
|
|
|
47
64
|
|
|
48
65
|
export const emptyBreakdown = (): Breakdown => ({ model: 0, tools: 0, approval: 0, subagent: 0, background: 0, parked: 0, human: 0, idle: 0, unknown: 0 })
|
|
49
66
|
|
|
67
|
+
/** the call a sub-agent ends on: its report handed back to the session that started it */
|
|
68
|
+
export const HAND_BACK = 'SubagentHandback'
|
|
69
|
+
|
|
50
70
|
/** a foreground sub-agent call: the session waits on another agent's work */
|
|
51
71
|
export const isAgentCall = (c: Call): boolean => c.tool === 'Agent' || c.tool === 'Task'
|
|
52
72
|
|
|
@@ -91,28 +111,98 @@ export const runMs = (c: Closed): number | null => (!c.bg ? callMs(c) : c.bgEnd
|
|
|
91
111
|
|
|
92
112
|
type Point = { at: number; d: 'start' | 'stop' | Mark['kind']; lane: 'tool' | 'agent' | 'approval'; ix: number }
|
|
93
113
|
|
|
114
|
+
/** a stretch of time, from and to */
|
|
115
|
+
export type Span = readonly [number, number]
|
|
116
|
+
|
|
117
|
+
/** sorted by start, the ones that touch joined */
|
|
118
|
+
export function joinSpans(spans: readonly Span[]): Span[] {
|
|
119
|
+
const out: [number, number][] = []
|
|
120
|
+
for (const [a, b] of [...spans].sort((x, y) => x[0] - y[0])) {
|
|
121
|
+
const last = out[out.length - 1]
|
|
122
|
+
if (last != null && a <= last[1]) last[1] = Math.max(last[1], b)
|
|
123
|
+
else if (b > a) out.push([a, b])
|
|
124
|
+
}
|
|
125
|
+
return out
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** the ms of [a, b] that joined spans hold */
|
|
129
|
+
function heldMs(spans: readonly Span[], a: number, b: number): number {
|
|
130
|
+
let lo = 0
|
|
131
|
+
let hi = spans.length
|
|
132
|
+
while (lo < hi) {
|
|
133
|
+
const mid = (lo + hi) >> 1
|
|
134
|
+
if ((spans[mid] as Span)[1] <= a) lo = mid + 1
|
|
135
|
+
else hi = mid
|
|
136
|
+
}
|
|
137
|
+
let ms = 0
|
|
138
|
+
for (let i = lo; i < spans.length && (spans[i] as Span)[0] < b; i++) ms += Math.min(b, (spans[i] as Span)[1]) - Math.max(a, (spans[i] as Span)[0])
|
|
139
|
+
return ms
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** the buckets of a lane that is not done: in its turn, in a call, or stopped on a run of its own */
|
|
143
|
+
const AT_WORK: ReadonlySet<Bucket> = new Set<Bucket>(['model', 'tools', 'approval', 'subagent', 'background'])
|
|
144
|
+
|
|
145
|
+
/** when the lanes of each session were at work, by session: what a main
|
|
146
|
+
* session's long stop is checked against (wallBreakdown, `lanes`). `now`:
|
|
147
|
+
* the time of the report, so a lane stopped on a run still open counts up to it */
|
|
148
|
+
export function lanesAtWork(streams: readonly { session: string; agent: string; stream: Stream; closed: Closed[] }[], now = Infinity, idleMs = IDLE_MS): Map<string, Span[]> {
|
|
149
|
+
const by = new Map<string, Span[]>()
|
|
150
|
+
for (const g of streams) {
|
|
151
|
+
if (g.agent === '') continue
|
|
152
|
+
const spans = by.get(g.session) ?? []
|
|
153
|
+
cut(g.stream, -Infinity, now, idleMs, g.closed, now, undefined, undefined, (bucket, a, b) => {
|
|
154
|
+
if (AT_WORK.has(bucket)) spans.push([a, b])
|
|
155
|
+
})
|
|
156
|
+
by.set(g.session, spans)
|
|
157
|
+
}
|
|
158
|
+
for (const [session, spans] of by) by.set(session, joinSpans(spans))
|
|
159
|
+
return by
|
|
160
|
+
}
|
|
161
|
+
|
|
94
162
|
/** the wall of one stream cut into buckets, clipped to [from, to]. Between two
|
|
95
163
|
* boundaries: a tool in flight → tools; only calls waiting for his allow →
|
|
96
164
|
* approval; only a sub-agent in flight → subagent;
|
|
97
|
-
* nothing in flight and the next thing is his prompt → human
|
|
98
|
-
* IDLE_MS); a message relayed in → parked (idle past IDLE_MS: a
|
|
99
|
-
* that handed back sits there until the coordinator writes to it);
|
|
100
|
-
* task notification, a hand-back) → background
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
165
|
+
* nothing in flight and the next thing is his prompt or his act → human
|
|
166
|
+
* (idle past IDLE_MS); a message relayed in → parked (idle past IDLE_MS: a
|
|
167
|
+
* sub-agent that handed back sits there until the coordinator writes to it);
|
|
168
|
+
* a wake (a task notification, a hand-back) → background, but for a
|
|
169
|
+
* sub-agent that handed back: it is done until someone writes to it, so a
|
|
170
|
+
* leftover run of its own that ends later finds it parked (idle past
|
|
171
|
+
* IDLE_MS), not waiting. Else, when the
|
|
172
|
+
* agent ended its turn (an `end` mark) and nothing since: it was stopped,
|
|
173
|
+
* and no record says on what → unknown (idle past IDLE_MS); else the agent
|
|
174
|
+
* was in its turn, its API request in flight → model.
|
|
175
|
+
*
|
|
176
|
+
* `lanes` (a main session: when its lanes were at work, lanesAtWork) cuts a
|
|
177
|
+
* wait a wake ends that is longer than IDLE_MS: background only while a lane
|
|
178
|
+
* was at work or a background run of its own ran to its end, the rest idle. A
|
|
179
|
+
* notice written hours after everything of the session ended is no wait.
|
|
180
|
+
* A wait a `lapse` ends is cut the same way whatever its length: the watch
|
|
181
|
+
* ran its whole time and nothing came, so with nothing of its own at work
|
|
182
|
+
* the session was parked on someone else's move. Without `lanes` (a
|
|
183
|
+
* sub-agent, whose own sub-agents are not known here) a lapse counts as a wake.
|
|
104
184
|
*
|
|
105
|
-
* Past the stream's last event nothing counts,
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
185
|
+
* Past the stream's last event nothing counts, but one case: the report
|
|
186
|
+
* runs (`now`, finite) while the stream's stop on a background run of its
|
|
187
|
+
* own is under IDLE_MS old → background up to `now`, or up to the end of
|
|
188
|
+
* that run when it has one (its notice stayed in the queue: nothing woke
|
|
189
|
+
* the stream). `now` is the time of the report, `to` when not given: a cut
|
|
190
|
+
* of one day passes both, since a day's last second is not when the report runs.
|
|
109
191
|
*
|
|
110
192
|
* `turnModel` (one slot per closed call) receives the model stretch that
|
|
111
193
|
* ended in each call: the turn that issued it, split evenly over the calls
|
|
112
194
|
* of one batch. A stretch that ends in his prompt, a wake or the turn's end
|
|
113
195
|
* was the final reply and goes to no call */
|
|
114
|
-
export function wallBreakdown(s: Stream, from = -Infinity, to = Infinity, idleMs = IDLE_MS, closed: Closed[] = closeCalls(s), turnModel?: Float64Array): Breakdown {
|
|
196
|
+
export function wallBreakdown(s: Stream, from = -Infinity, to = Infinity, idleMs = IDLE_MS, closed: Closed[] = closeCalls(s), turnModel?: Float64Array, lanes?: readonly Span[], now = to): Breakdown {
|
|
197
|
+
return cut(s, from, to, idleMs, closed, now, turnModel, lanes)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** the sweep behind wallBreakdown; `slice` receives each stretch that went whole to one bucket */
|
|
201
|
+
function cut(s: Stream, from: number, to: number, idleMs: number, closed: Closed[], now: number, turnModel?: Float64Array, lanes?: readonly Span[], slice?: (bucket: Bucket, a: number, b: number) => void): Breakdown {
|
|
115
202
|
const out = emptyBreakdown()
|
|
203
|
+
// what of its own a main session can be stopped on: its lanes at work, its background runs that ran to their
|
|
204
|
+
// end (a run somebody stopped, a dev server, is nothing it waited on)
|
|
205
|
+
const own = lanes == null ? null : joinSpans([...lanes, ...closed.filter((c) => c.bg && c.bgEnd != null && c.outcome !== 'interrupted').map((c): Span => [c.start, c.bgEnd as number])])
|
|
116
206
|
const points: Point[] = []
|
|
117
207
|
closed.forEach((c, ix) => {
|
|
118
208
|
const lane = isAgentCall(c) ? 'agent' : c.approval ? 'approval' : 'tool'
|
|
@@ -125,6 +215,8 @@ export function wallBreakdown(s: Stream, from = -Infinity, to = Infinity, idleMs
|
|
|
125
215
|
let approvals = 0
|
|
126
216
|
let pending = 0
|
|
127
217
|
let stopped = false
|
|
218
|
+
// it handed its report back, and nobody wrote to it since
|
|
219
|
+
let handed = false
|
|
128
220
|
const issued: number[] = []
|
|
129
221
|
let i = 0
|
|
130
222
|
while (i < points.length) {
|
|
@@ -138,8 +230,10 @@ export function wallBreakdown(s: Stream, from = -Infinity, to = Infinity, idleMs
|
|
|
138
230
|
else if (p.lane === 'approval') approvals += n
|
|
139
231
|
else tools += n
|
|
140
232
|
if (p.d === 'start') issued.push(p.ix)
|
|
141
|
-
else if (p.d === 'prompt' || p.d === 'wake' || p.d === 'message' || p.d === 'end') ended = true
|
|
233
|
+
else if (p.d === 'prompt' || p.d === 'act' || p.d === 'wake' || p.d === 'lapse' || p.d === 'message' || p.d === 'end') ended = true
|
|
142
234
|
if (p.d !== 'stop') stopped = p.d === 'end'
|
|
235
|
+
if (p.d === 'stop' && (closed[p.ix] as Closed).tool === HAND_BACK) handed = true
|
|
236
|
+
else if (p.d === 'prompt' || p.d === 'act' || p.d === 'message') handed = false
|
|
143
237
|
i++
|
|
144
238
|
}
|
|
145
239
|
if (turnModel != null) {
|
|
@@ -147,8 +241,15 @@ export function wallBreakdown(s: Stream, from = -Infinity, to = Infinity, idleMs
|
|
|
147
241
|
if (issued.length > 0 || ended) pending = 0
|
|
148
242
|
}
|
|
149
243
|
if (i >= points.length) {
|
|
150
|
-
|
|
151
|
-
|
|
244
|
+
// the latest end of the runs of its own open at its stop: Infinity while one has no end yet
|
|
245
|
+
let until = -Infinity
|
|
246
|
+
for (const c of closed) if (c.bg && c.start <= at && (c.bgEnd == null || c.bgEnd > at)) until = Math.max(until, c.bgEnd ?? Infinity)
|
|
247
|
+
const a = Math.max(at, from)
|
|
248
|
+
const b = Math.min(to, now, until)
|
|
249
|
+
if (stopped && !handed && Number.isFinite(now) && now - at <= idleMs && b > a) {
|
|
250
|
+
out.background += b - a
|
|
251
|
+
slice?.('background', a, b)
|
|
252
|
+
}
|
|
152
253
|
break
|
|
153
254
|
}
|
|
154
255
|
const nextAt = (points[i] as Point).at
|
|
@@ -165,17 +266,26 @@ export function wallBreakdown(s: Stream, from = -Infinity, to = Infinity, idleMs
|
|
|
165
266
|
let typed = false
|
|
166
267
|
let message = false
|
|
167
268
|
let wake = false
|
|
269
|
+
let lapse = false
|
|
168
270
|
while (next < points.length && (points[next] as Point).at === nextAt) {
|
|
169
271
|
const d = (points[next] as Point).d
|
|
170
|
-
if (d === 'prompt') typed = true
|
|
272
|
+
if (d === 'prompt' || d === 'act') typed = true
|
|
171
273
|
if (d === 'message') message = true
|
|
172
274
|
if (d === 'wake') wake = true
|
|
275
|
+
if (d === 'lapse') lapse = true
|
|
173
276
|
next++
|
|
174
277
|
}
|
|
175
278
|
const gap = nextAt - at
|
|
176
|
-
bucket = typed ? (gap > idleMs ? 'idle' : 'human') : message ? (gap > idleMs ? 'idle' : 'parked') : wake ? 'background' : !stopped ? 'model' : gap > idleMs ? 'idle' : 'unknown'
|
|
279
|
+
bucket = typed ? (gap > idleMs ? 'idle' : 'human') : message || ((wake || lapse) && handed) ? (gap > idleMs ? 'idle' : 'parked') : wake || lapse ? 'background' : !stopped ? 'model' : gap > idleMs ? 'idle' : 'unknown'
|
|
280
|
+
if (bucket === 'background' && own != null && (gap > idleMs || !wake)) {
|
|
281
|
+
const busy = heldMs(own, a, b)
|
|
282
|
+
out.background += busy
|
|
283
|
+
out.idle += len - busy
|
|
284
|
+
continue
|
|
285
|
+
}
|
|
177
286
|
}
|
|
178
287
|
out[bucket] += len
|
|
288
|
+
slice?.(bucket, a, b)
|
|
179
289
|
if (bucket === 'model') pending += len
|
|
180
290
|
}
|
|
181
291
|
return out
|
|
@@ -194,6 +304,15 @@ export const FAILED: ReadonlySet<Outcome> = new Set<Outcome>(['exit', 'error', '
|
|
|
194
304
|
|
|
195
305
|
export type Retry = { failed: Closed; next: Closed; blind: boolean }
|
|
196
306
|
|
|
307
|
+
/** the 53 bit sum of a command's text, trimmed: what the blind retry test compares once the diet dropped a text */
|
|
308
|
+
export const cmdSum = (cmd: string): number => Number(BigInt.asUintN(53, BigInt(Bun.hash(cmd.trim()))))
|
|
309
|
+
|
|
310
|
+
/** two calls ran the same command: their texts, or a text's sum against a sum the diet kept */
|
|
311
|
+
export function sameCommand(a: Pick<Call, 'cmd' | 'cmdSum'>, b: Pick<Call, 'cmd' | 'cmdSum'>): boolean {
|
|
312
|
+
if (a.cmdSum == null && b.cmdSum == null) return a.cmd.trim() === b.cmd.trim()
|
|
313
|
+
return (a.cmdSum ?? cmdSum(a.cmd)) === (b.cmdSum ?? cmdSum(b.cmd))
|
|
314
|
+
}
|
|
315
|
+
|
|
197
316
|
/** every failed call followed by the same shape again: `blind` when the
|
|
198
317
|
* command is the exact same text, so nothing changed between the two.
|
|
199
318
|
* `calls` sorted by start (closeCalls) */
|
|
@@ -206,7 +325,7 @@ export function retries(calls: Closed[]): Retry[] {
|
|
|
206
325
|
nextOfShape.set(c.shape, c)
|
|
207
326
|
if (c.outcome == null || !FAILED.has(c.outcome)) continue
|
|
208
327
|
if (next == null || next.start - c.stop > RETRY_MS) continue
|
|
209
|
-
out.push({ failed: c, next, blind:
|
|
328
|
+
out.push({ failed: c, next, blind: sameCommand(c, next) })
|
|
210
329
|
}
|
|
211
330
|
return out.reverse()
|
|
212
331
|
}
|
package/src/agent-time/turns.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Turn count: what makes an agent slow when no command is. Every tool call
|
|
2
2
|
// costs a model turn before it, so an agent that reads one file per turn
|
|
3
3
|
// spends its wall on the model, not on the reads. The two questions this
|
|
4
|
-
// module answers on pure data: was a call a single read, and did it go out
|
|
5
|
-
//
|
|
4
|
+
// module answers on pure data: was a call a single read, and did it go out
|
|
5
|
+
// with others, in one model message.
|
|
6
6
|
//
|
|
7
7
|
// The constraint a reader breaks first: a read is judged on the WHOLE command,
|
|
8
8
|
// never on its shape alone. `grep -l x | xargs sed -i` shapes as `grep`, and
|
|
9
9
|
// it writes.
|
|
10
|
-
import { stripHeredocs } from './shape.ts'
|
|
10
|
+
import { MORE, stripHeredocs } from './shape.ts'
|
|
11
11
|
import type { Closed } from './timeline.ts'
|
|
12
12
|
|
|
13
13
|
/** bumped with any read rule below: the index judges every stored call again */
|
|
@@ -79,18 +79,28 @@ function partReads(part: string, whole: string): boolean {
|
|
|
79
79
|
* loop over one included) whose every part reads */
|
|
80
80
|
export function isReadOnly(c: { tool: string; shape: string; cmd: string }): boolean {
|
|
81
81
|
if (READ_TOOLS.has(c.tool)) return true
|
|
82
|
-
if (c.tool !== 'Bash' || !READ_SHAPES.has(c.shape.replace(/^\(for\) /, ''))) return false
|
|
82
|
+
if (c.tool !== 'Bash' || !READ_SHAPES.has(c.shape.replace(/^\(for\) /, '').replace(MORE, ''))) return false
|
|
83
83
|
return parts(c.cmd).every((p) => p.trim() === '' || partReads(p, c.cmd))
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
/** a call issued this soon after the one before,
|
|
87
|
-
* went out in the same turn */
|
|
86
|
+
/** with no message id recorded: a call issued this soon after the one before,
|
|
87
|
+
* while that one still ran, went out in the same turn */
|
|
88
88
|
export const PARALLEL_MS = 2000
|
|
89
89
|
|
|
90
|
-
/** one flag per call (sorted by start, closeCalls): it
|
|
91
|
-
*
|
|
90
|
+
/** one flag per call (sorted by start, closeCalls): it is not the first call
|
|
91
|
+
* of its model message, so it cost no model turn of its own. The harness
|
|
92
|
+
* runs some calls as soon as they are written, so an overlap test misses the
|
|
93
|
+
* ones answered before the next was written. A call with no message id (a
|
|
94
|
+
* row indexed before the id was kept) falls back on the overlap: it started
|
|
95
|
+
* before the previous call ended, within PARALLEL_MS of its start */
|
|
92
96
|
export function parallelFlags(calls: readonly Closed[]): boolean[] {
|
|
97
|
+
const seen = new Set<string>()
|
|
93
98
|
return calls.map((c, i) => {
|
|
99
|
+
if (c.msg != null && c.msg !== '') {
|
|
100
|
+
if (seen.has(c.msg)) return true
|
|
101
|
+
seen.add(c.msg)
|
|
102
|
+
return false
|
|
103
|
+
}
|
|
94
104
|
const prev = calls[i - 1]
|
|
95
105
|
return prev != null && c.start < prev.stop && c.start - prev.start <= PARALLEL_MS
|
|
96
106
|
})
|
package/src/annex/offload.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// tools/shipkit/annex.md, Scratch). Each refusal guards what an unplugged drive must never take: a db, a lock, a git
|
|
3
3
|
// worktree, what the backup holds, what the media store indexes, a file a process holds open. A move is a copy checked
|
|
4
4
|
// by its count and bytes, then the swap
|
|
5
|
-
import { closeSync, existsSync, lstatSync, mkdirSync, openSync, readdirSync, readlinkSync, readSync, renameSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'
|
|
5
|
+
import { closeSync, existsSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, readlinkSync, readSync, renameSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'
|
|
6
6
|
import { homedir } from 'node:os'
|
|
7
7
|
import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path'
|
|
8
8
|
import { machineGet, machineRead, machineSet } from '../core/machine-db.ts'
|
|
@@ -98,8 +98,8 @@ const save = (list: Offload[]): void => {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/** a name that marks a db or a lock: never on a drive that can be unplugged. LevelDB keeps `LOCK` and `MANIFEST-<n>`,
|
|
101
|
-
* LMDB `data.mdb` and `lock.mdb` */
|
|
102
|
-
export const DB_NAME = /(\.(sqlite3?|db)(-wal|-shm|-journal)?|\.lock|\.mdb)$|^(LOCK|MANIFEST-\d+|pb_data)$/i
|
|
101
|
+
* LMDB `data.mdb` and `lock.mdb`, DuckDB `<name>.duckdb` and its `.wal` */
|
|
102
|
+
export const DB_NAME = /(\.(sqlite3?|db|duckdb)(-wal|-shm|-journal|\.wal)?|\.lock|\.mdb)$|^(LOCK|MANIFEST-\d+|pb_data)$/i
|
|
103
103
|
/** a package manager's lockfile is a text file, never a lock: it moves */
|
|
104
104
|
const PACKAGE_LOCKS = new Set(['bun.lock', 'yarn.lock', 'Cargo.lock', 'poetry.lock', 'uv.lock', 'Gemfile.lock', 'composer.lock', 'flake.lock', 'Pipfile.lock', 'pdm.lock'])
|
|
105
105
|
/** a vendored package's own marker files (setuptools' `_vendor/.lock`) are files of the package, never a live lock */
|
|
@@ -113,6 +113,13 @@ export function isDb(dir: string, rel: string, file: boolean): boolean {
|
|
|
113
113
|
if (parts.some((p) => p === 'pb_data')) return true
|
|
114
114
|
if (DB_NAME.test(name) && !PACKAGE_LOCKS.has(name) && !(name.endsWith('.lock') && parts.some((p) => PACKAGE_DIRS.has(p)))) return true
|
|
115
115
|
if (!file) return false
|
|
116
|
+
// a LevelDB folder that holds no LOCK: its CURRENT names a manifest, or sits beside its tables and logs
|
|
117
|
+
if (name === 'CURRENT') {
|
|
118
|
+
const at = join(dir, ...parts.slice(0, -1))
|
|
119
|
+
try {
|
|
120
|
+
if (readdirSync(at).some((n) => /\.(ldb|log)$/.test(n)) || readFileSync(join(at, name), 'utf8').startsWith('MANIFEST-')) return true
|
|
121
|
+
} catch { /* unreadable: the header test below */ }
|
|
122
|
+
}
|
|
116
123
|
let fd = -1
|
|
117
124
|
try {
|
|
118
125
|
fd = openSync(join(dir, rel), 'r')
|
|
@@ -211,7 +218,7 @@ export async function refusal(root: string, rel: string, o: Checks = {}): Promis
|
|
|
211
218
|
const kept = await (o.backupHolds ?? backupHolds)(root, path, o.home ?? homedir())
|
|
212
219
|
if (kept) return `the backup holds ${relative(root, kept)}: what a backup keeps stays on the Mac`
|
|
213
220
|
const { mediaDb } = await import('../media-store/db.ts')
|
|
214
|
-
const rows = (mediaDb()?.query('select store, item, name from
|
|
221
|
+
const rows = (mediaDb()?.query('select store, item, name from media_files where local = 1').all() ?? []) as { store: string; item: string; name: string }[]
|
|
215
222
|
const indexed = rows.map((r) => join(r.store, r.item, r.name)).find((p) => p === path || p.startsWith(`${path}/`))
|
|
216
223
|
if (indexed) return `the media store indexes ${relative(root, indexed)}: its purge moves media to the annex, never an offload`
|
|
217
224
|
if (o.open === false) return null
|
|
@@ -221,6 +228,10 @@ export async function refusal(root: string, rel: string, o: Checks = {}): Promis
|
|
|
221
228
|
return null
|
|
222
229
|
}
|
|
223
230
|
|
|
231
|
+
/** no annex is present, or none keeps its free space with the folder: a caller with somewhere else to go (the temp
|
|
232
|
+
* sweep deletes scratch) tells it from a refusal of the folder itself */
|
|
233
|
+
export class NoRoom extends Error {}
|
|
234
|
+
|
|
224
235
|
export interface Moved {
|
|
225
236
|
rel: string
|
|
226
237
|
target: string
|
|
@@ -237,9 +248,9 @@ export async function offload(root: string, rel: string, o: Probe & { dry?: bool
|
|
|
237
248
|
const src = join(root, rel)
|
|
238
249
|
const t = tally(src)
|
|
239
250
|
const present = await presentAnnexes()
|
|
240
|
-
if (present.length === 0) throw new
|
|
251
|
+
if (present.length === 0) throw new NoRoom('no annex is present: plug the drive in, or sk annex init <path>')
|
|
241
252
|
const annex = present.find((a) => driveFree(a.path) - t.bytes >= keepFree(a))
|
|
242
|
-
if (!annex) throw new
|
|
253
|
+
if (!annex) throw new NoRoom(`no annex present keeps its free space with ${rel} (${(t.bytes / GB).toFixed(1)} GB)`)
|
|
243
254
|
const target = join(annex.path, 'offload', basename(root), rel)
|
|
244
255
|
if (existsSync(target)) throw new Error(`${target} exists already: an earlier offload, look before you move`)
|
|
245
256
|
const owner = ownerOf(root, target)
|
package/src/annex/tidy.ts
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
// whatever the pressure: lanes write into scratch all day, and the offload's own checks are the net, not the plan
|
|
8
8
|
import { existsSync, lstatSync, readdirSync, readFileSync, rmSync, type Stats, writeFileSync } from 'node:fs'
|
|
9
9
|
import { dirname, join } from 'node:path'
|
|
10
|
+
import { LAYOUT } from '../core/layout.ts'
|
|
10
11
|
import { machineDbPath, machineGet, machineSet } from '../core/machine-db.ts'
|
|
12
|
+
import { repoSweepOn } from '../home/machine-temp.ts'
|
|
11
13
|
import { freeBytes } from '../media-store/purge.ts'
|
|
12
14
|
import { annexSpecs, type AnnexSpec, driveFree, isPresent, keepFree, type Sweep } from './annex.ts'
|
|
13
15
|
import { bear, bornCheck, deadStage, type Pass, sayOnce, settle } from './born.ts'
|
|
@@ -74,6 +76,26 @@ export function policyOf(house: AnnexScratch | undefined, repo: RepoAnnex | unde
|
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
/** the scratch folders the annex config declares for the repo at `root`, repo relative: its own `annex.born` and
|
|
80
|
+
* `annex.keep` and the house's `serve.annexScratch.born`, read from the configs the annex pass reads. A repo with no
|
|
81
|
+
* repo.config.ts declares the house's only. A config that does not load throws: a caller judges nothing of that repo
|
|
82
|
+
* without its declarations */
|
|
83
|
+
export async function annexDeclared(root: string, house: string | null): Promise<string[]> {
|
|
84
|
+
const { loadRepoConfig } = await import('../repo-config.ts')
|
|
85
|
+
const own = existsSync(join(root, 'repo.config.ts')) ? await loadRepoConfig(root) : null
|
|
86
|
+
const houseScratch = house == null ? undefined : house === root ? own?.serve?.annexScratch : (await loadRepoConfig(house)).serve?.annexScratch
|
|
87
|
+
const p = policyOf(houseScratch, own?.annex ?? {})
|
|
88
|
+
return [...new Set([...p.born, ...p.keep])]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** the one answer to « is this folder declared »: `inside`, at or under a declared folder; `holds`, a folder above one;
|
|
92
|
+
* `which`, the declared folder that keeps `rel` either way, or null */
|
|
93
|
+
export function declaredOf(fixed: readonly string[]): { inside: (rel: string) => boolean; holds: (rel: string) => boolean; which: (rel: string) => string | null } {
|
|
94
|
+
const inside = (rel: string): boolean => fixed.some((k) => rel === k || rel.startsWith(`${k}/`))
|
|
95
|
+
const holds = (rel: string): boolean => fixed.some((k) => k.startsWith(`${rel}/`))
|
|
96
|
+
return { inside, holds, which: (rel) => fixed.find((k) => rel === k || rel.startsWith(`${k}/`) || k.startsWith(`${rel}/`)) ?? null }
|
|
97
|
+
}
|
|
98
|
+
|
|
77
99
|
/** bytes of a repo's scratch on the Mac: `.shipkit/tmp` and `.shipkit/cache`, links not followed, so an offloaded
|
|
78
100
|
* folder counts nothing and a spill counts whole (`du`: 0.5 s on 36 GB) */
|
|
79
101
|
export function scratchOnMac(root: string): number {
|
|
@@ -112,19 +134,18 @@ function walk(dir: string): { bytes: number; newest: number } {
|
|
|
112
134
|
}
|
|
113
135
|
|
|
114
136
|
/** the name a move in flight leaves: an offload's `.part` or aside, a swap first move's aside, a copy brought back */
|
|
115
|
-
const IN_FLIGHT = /\.\d+\.(part|offloading|moving|back)$/
|
|
137
|
+
export const IN_FLIGHT = /\.\d+\.(part|offloading|moving|back)$/
|
|
116
138
|
|
|
117
139
|
export type Stale = { rel: string; bytes: number; newest: number }
|
|
118
140
|
|
|
119
141
|
/** folders of the repo's scratch nothing touched for `days`, 50 MB or more, oldest first: each child of
|
|
120
142
|
* `.shipkit/tmp` and `.shipkit/cache`, and the children of a fresh one of 1 GB or more. Never a born or kept folder,
|
|
121
|
-
* nor one that holds one
|
|
143
|
+
* nor one that holds one. `.shipkit/tmp` is the machine's temp sweep's once its repo roots delete (machine-temp.ts):
|
|
144
|
+
* one mechanism a folder */
|
|
122
145
|
export function staleFolders(root: string, p: ScratchPolicy, now: number, days: number, o: { minBytes?: number; descendBytes?: number } = {}): Stale[] {
|
|
123
146
|
const minBytes = o.minBytes ?? MIN_STALE_BYTES
|
|
124
147
|
const descendBytes = o.descendBytes ?? DESCEND_BYTES
|
|
125
|
-
const
|
|
126
|
-
const inside = (rel: string): boolean => fixed.some((k) => rel === k || rel.startsWith(`${k}/`))
|
|
127
|
-
const holds = (rel: string): boolean => fixed.some((k) => k.startsWith(`${rel}/`))
|
|
148
|
+
const { inside, holds } = declaredOf([...p.born, ...p.keep])
|
|
128
149
|
const out: Stale[] = []
|
|
129
150
|
const look = (rel: string, depth: number): void => {
|
|
130
151
|
for (const name of readdirSync(join(root, rel))) {
|
|
@@ -140,14 +161,15 @@ export function staleFolders(root: string, p: ScratchPolicy, now: number, days:
|
|
|
140
161
|
else if (depth === 1 && w.bytes >= descendBytes) look(r, 2)
|
|
141
162
|
}
|
|
142
163
|
}
|
|
143
|
-
|
|
164
|
+
const bases = SCRATCH.filter((b) => b !== LAYOUT.tmp || !repoSweepOn(now))
|
|
165
|
+
for (const base of bases) if (lstatSync(join(root, base), { throwIfNoEntry: false })?.isDirectory() && !inside(base)) look(base, 1)
|
|
144
166
|
return out.sort((a, b) => a.newest - b.newest || b.bytes - a.bytes)
|
|
145
167
|
}
|
|
146
168
|
|
|
147
169
|
export type Aged = { moved: { rel: string; bytes: number }[]; refused: { rel: string; why: string }[]; onMac: number; free: number; days: number | null }
|
|
148
170
|
|
|
149
171
|
/** stale scratch of `root` to the annex, oldest first, while the disk is under the floor or the repo over its cap */
|
|
150
|
-
export async function agePass(root: string, p: ScratchPolicy, o: Probe & { now?: number; dry?: boolean; minBytes?: number }): Promise<Aged> {
|
|
172
|
+
export async function agePass(root: string, p: ScratchPolicy, o: Probe & { now?: number; dry?: boolean; minBytes?: number; fresh?: boolean }): Promise<Aged> {
|
|
151
173
|
const now = o.now ?? Date.now()
|
|
152
174
|
let onMac = scratchOnMac(root)
|
|
153
175
|
let free = freeBytes(root)
|
|
@@ -156,23 +178,61 @@ export async function agePass(root: string, p: ScratchPolicy, o: Probe & { now?:
|
|
|
156
178
|
if (!pressed()) return out
|
|
157
179
|
const days = free < p.floorGb * GB ? 1 : p.staleDays
|
|
158
180
|
out.days = days
|
|
159
|
-
|
|
181
|
+
// a dry pass and a pass by hand (`fresh`) ask every folder again and leave the memory as it is
|
|
182
|
+
const remembers = o.dry !== true && o.fresh !== true
|
|
183
|
+
const known: Refusals = remembers ? (machineGet<Refusals>(REFUSED) ?? {}) : {}
|
|
184
|
+
let moved = false
|
|
185
|
+
const stale = staleFolders(root, p, now, days, o)
|
|
186
|
+
for (const s of stale) {
|
|
160
187
|
if (!pressed()) break
|
|
188
|
+
const key = refusalKey(root, s.rel)
|
|
189
|
+
const was = known[key]
|
|
190
|
+
if (was !== undefined && was.newest === s.newest && now - was.at < REFUSAL_KEEP_MS) {
|
|
191
|
+
out.refused.push({ rel: s.rel, why: was.why })
|
|
192
|
+
continue
|
|
193
|
+
}
|
|
161
194
|
try {
|
|
162
195
|
const m = await offload(root, s.rel, { ...o, dry: o.dry === true })
|
|
163
196
|
onMac -= m.bytes
|
|
164
197
|
if (o.dry) free += m.bytes
|
|
165
198
|
else free = freeBytes(root)
|
|
166
199
|
out.moved.push({ rel: s.rel, bytes: m.bytes })
|
|
200
|
+
if (was !== undefined) {
|
|
201
|
+
delete known[key]
|
|
202
|
+
moved = true
|
|
203
|
+
}
|
|
167
204
|
} catch (e) {
|
|
168
|
-
|
|
205
|
+
const why = (e as Error).message
|
|
206
|
+
out.refused.push({ rel: s.rel, why })
|
|
207
|
+
if (remembers) {
|
|
208
|
+
known[key] = { why, newest: s.newest, at: now }
|
|
209
|
+
moved = true
|
|
210
|
+
}
|
|
169
211
|
}
|
|
170
212
|
}
|
|
213
|
+
if (remembers) {
|
|
214
|
+
const here = new Set(stale.map((s) => refusalKey(root, s.rel)))
|
|
215
|
+
for (const k of Object.keys(known))
|
|
216
|
+
if (k.startsWith(`${root}\u0000`) && !here.has(k)) {
|
|
217
|
+
delete known[k]
|
|
218
|
+
moved = true
|
|
219
|
+
}
|
|
220
|
+
if (moved) machineSet(REFUSED, known)
|
|
221
|
+
}
|
|
171
222
|
out.onMac = onMac
|
|
172
223
|
out.free = free
|
|
173
224
|
return out
|
|
174
225
|
}
|
|
175
226
|
|
|
227
|
+
/** how long the daemon's pass trusts a refusal of a folder nothing wrote since. Each refused folder costs its
|
|
228
|
+
* checks again at every pass (a `lsof`, a look at the annex: 0.05 to 1.6 s each, 6.4 s for one repo's 14 folders
|
|
229
|
+
* every 10 min): the reason holds while the folder is as it was, and the rest (a process that left, an annex copy
|
|
230
|
+
* someone removed) is asked again after this long */
|
|
231
|
+
export const REFUSAL_KEEP_MS = 6 * 3_600_000
|
|
232
|
+
const REFUSED = 'annex-refused'
|
|
233
|
+
type Refusals = Record<string, { why: string; newest: number; at: number }>
|
|
234
|
+
const refusalKey = (root: string, rel: string): string => `${root}\u0000${rel}`
|
|
235
|
+
|
|
176
236
|
/** trim an annex's scratch (`offload/`) under its `scratchMaxGb`, and its drive to `keepFreeGb`: files untouched for
|
|
177
237
|
* SCRATCH_KEEP_DAYS at the least, oldest first. A loser a merge kept is never one of them: it goes only by a hand.
|
|
178
238
|
* A staging folder shipkit marked whose process is dead goes at every sweep. Its measure is kept for `sk annex` */
|
|
@@ -341,7 +401,7 @@ async function tick(o: TickOpts): Promise<void> {
|
|
|
341
401
|
if (offloads().some(unborn)) editOffloads((list) => list.map((x) => (unborn(x) ? { ...x, born: false } : x)))
|
|
342
402
|
}
|
|
343
403
|
floor = p.floorGb
|
|
344
|
-
const a = await agePass(root, p, { ...o, now })
|
|
404
|
+
const a = await agePass(root, p, { ...o, now, fresh: o.full === true })
|
|
345
405
|
if (a.days === null) {
|
|
346
406
|
if (o.dry) o.print(`${root}: scratch on the Mac ${(a.onMac / GB).toFixed(1)} GB of ${p.capGb} GB, the disk ${(a.free / GB).toFixed(1)} GB free over its ${p.floorGb} GB floor: nothing to move`)
|
|
347
407
|
continue
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// an ask's `after:` value: the moment the ask waits for. Before it the ask is later (out of the open count and the
|
|
2
|
+
// ping), from it an open ask. Pure and browser safe: the queue (asks-queue.ts) parses with it, the hub draws with it
|
|
3
|
+
const VALUE = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2}))?$/
|
|
4
|
+
|
|
5
|
+
export const AFTER_FORMS = 'YYYY-MM-DD or YYYY-MM-DDTHH:MM, local time'
|
|
6
|
+
|
|
7
|
+
/** the moment a value names, local time, a bare date the start of its day; null when it names none */
|
|
8
|
+
export function afterMs(v: string): number | null {
|
|
9
|
+
const m = VALUE.exec(v.trim())
|
|
10
|
+
if (m == null) return null
|
|
11
|
+
const [y, mo, d, h, mi] = [Number(m[1]), Number(m[2]), Number(m[3]), Number(m[4] ?? 0), Number(m[5] ?? 0)]
|
|
12
|
+
const t = new Date(y, mo - 1, d, h, mi)
|
|
13
|
+
// a value that rolls over (02-30, 25:00) names no moment
|
|
14
|
+
if (t.getFullYear() !== y || t.getMonth() !== mo - 1 || t.getDate() !== d || h > 23 || mi > 59) return null
|
|
15
|
+
return t.getTime()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const pad = (n: number): string => String(n).padStart(2, '0')
|
|
19
|
+
const dayOf = (t: Date): string => `${t.getFullYear()}-${pad(t.getMonth() + 1)}-${pad(t.getDate())}`
|
|
20
|
+
|
|
21
|
+
/** what `--after` writes: a date or a date and time as given, `<n>d` or `<n>w` from `now` as that day */
|
|
22
|
+
export function afterValue(arg: string, now: Date): string {
|
|
23
|
+
const v = arg.trim()
|
|
24
|
+
if (afterMs(v) != null) return v
|
|
25
|
+
const rel = /^(\d+)([dw])$/.exec(v)
|
|
26
|
+
if (rel == null) throw new Error(`--after '${arg}' names no day: write ${AFTER_FORMS}, or 2d, 1w from today`)
|
|
27
|
+
const days = Number(rel[1]) * (rel[2] === 'w' ? 7 : 1)
|
|
28
|
+
return dayOf(new Date(now.getFullYear(), now.getMonth(), now.getDate() + days))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
|
|
32
|
+
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
|
33
|
+
|
|
34
|
+
/** `after Sat 21 Nov`, with its time when the value names one; the value itself when it names no moment */
|
|
35
|
+
export function afterWords(v: string): string {
|
|
36
|
+
const ms = afterMs(v)
|
|
37
|
+
if (ms == null) return `after ${v}`
|
|
38
|
+
const t = new Date(ms)
|
|
39
|
+
return `after ${DAYS[t.getDay()]} ${t.getDate()} ${MONTHS[t.getMonth()]}${v.includes('T') ? ` ${pad(t.getHours())}:${pad(t.getMinutes())}` : ''}`
|
|
40
|
+
}
|