rvlib-shipkit 2.31.0 → 2.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/package.json +1 -1
- package/src/advisors/acts.ts +16 -15
- package/src/advisors/advice.ts +56 -102
- package/src/advisors/advisor-view.ts +122 -76
- package/src/advisors/app-graph.ts +1 -1
- package/src/advisors/app.ts +3 -11
- package/src/advisors/cf-api.ts +1 -1
- package/src/advisors/dir-bucket.ts +4 -3
- package/src/advisors/edge/api.ts +20 -221
- package/src/advisors/edge/bucket.ts +2 -2
- package/src/advisors/edge/handler.ts +13 -155
- package/src/advisors/edge/here.ts +5 -5
- package/src/advisors/edge/pages.ts +12 -9
- package/src/advisors/edge/shell.ts +6 -5
- package/src/advisors/edge/sign-in.ts +101 -36
- package/src/advisors/edge/status.ts +19 -6
- package/src/advisors/edge/types.ts +36 -60
- package/src/advisors/expose.ts +29 -29
- package/src/advisors/here.ts +12 -12
- package/src/advisors/invite-send.ts +79 -35
- package/src/advisors/invite.ts +31 -8
- package/src/advisors/job.ts +24 -16
- package/src/advisors/login.ts +40 -15
- package/src/advisors/owner-store.ts +46 -22
- package/src/advisors/photos.ts +3 -3
- package/src/advisors/project.ts +27 -25
- package/src/advisors/reach.ts +89 -0
- package/src/advisors/rights.ts +1 -1
- package/src/advisors/routes.ts +55 -74
- package/src/advisors/scan.ts +0 -4
- package/src/advisors/setup-run.ts +14 -14
- package/src/advisors/share-trace.ts +3 -3
- package/src/advisors/{door-probe.ts → sign-in-probe.ts} +7 -6
- package/src/advisors/speaks.ts +29 -0
- package/src/advisors/sync.ts +97 -183
- package/src/advisors/tunnel.ts +6 -5
- package/src/advisors/users-listen.ts +92 -0
- package/src/advisors/users-router.ts +261 -87
- package/src/advisors/users-store.ts +81 -0
- package/src/agent-time/blocked-scan.ts +181 -0
- package/src/agent-time/registry.ts +12 -5
- package/src/agent-time/store.ts +9 -109
- package/src/asks/ask-bar-fold.ts +2 -1
- package/src/asks/ask-close.ts +2 -1
- package/src/asks/ask-doc.ts +2 -1
- package/src/asks/ask-migrate.ts +3 -2
- package/src/asks/ask-steps-fold.ts +2 -1
- package/src/asks/ask-store.ts +4 -3
- package/src/check.ts +3 -43
- package/src/checks/SK001-package-json-shape.check.ts +4 -55
- package/src/checks/SK004-gitignore-policy.check.ts +24 -69
- package/src/checks/SK013-one-way-in-policy.check.ts +3 -7
- package/src/checks/SK017-vscode-hub-task.check.ts +4 -4
- package/src/checks/SK019-tests-run-in-units.check.ts +3 -14
- package/src/checks/SK020-self-spawning-check.check.ts +5 -7
- package/src/checks/SK035-public-clean.check.ts +1 -1
- package/src/checks/SK039-vscode-watch-generated.check.ts +1 -1
- package/src/checks/SK042-post-kinds.check.ts +5 -14
- package/src/checks/SK054-agent-allow-list.check.ts +5 -74
- package/src/checks/SK055-retired-config-keys.check.ts +45 -0
- package/src/cli/cmd_Advisors.ts +11 -45
- package/src/cli/cmd_Asks.ts +3 -10
- package/src/cli/cmd_Backup.ts +25 -127
- package/src/cli/cmd_BackupTargets.ts +1 -1
- package/src/cli/cmd_Capacity.ts +6 -2
- package/src/cli/cmd_Checks.ts +0 -14
- package/src/cli/cmd_Ci.ts +2 -1
- package/src/cli/cmd_Db.ts +3 -82
- package/src/cli/cmd_Home.ts +4 -32
- package/src/cli/cmd_Hq.ts +0 -17
- package/src/cli/cmd_Releases.ts +57 -4
- package/src/cli/cmd_Review.ts +333 -354
- package/src/cli/cmd_Shot.ts +26 -4
- package/src/cli/cmd_SocialDrafts.ts +6 -13
- package/src/cli/cmd_ThreadSyncNeeds.ts +6 -2
- package/src/cli/cmd_Time.ts +1 -1
- package/src/cli/cmd_Trailer.ts +1 -1
- package/src/cli/inbox-hook-run.ts +5 -23
- package/src/cli/registry-heads.ts +5 -55
- package/src/cli/registry.ts +1 -5
- package/src/cli/review-here.ts +1 -1
- package/src/cli.ts +15 -4
- package/src/collections/collection-types.ts +1 -1
- package/src/collections/review.ts +5 -4
- package/src/core/admission.ts +268 -0
- package/src/core/agent-allow-policy.ts +32 -2
- package/src/core/agent-env.ts +8 -0
- package/src/core/allow-rows.ts +74 -0
- package/src/core/check-file-names.ts +19 -106
- package/src/core/code-lines.ts +36 -21
- package/src/core/footprint.ts +17 -13
- package/src/core/identities-root.ts +1 -4
- package/src/core/layout.ts +1 -2
- package/src/core/machine-db.ts +33 -208
- package/src/core/machine-layout.ts +14 -127
- package/src/core/machine-read.ts +5 -2
- package/src/core/mask-source.ts +60 -0
- package/src/core/memory-watch.ts +17 -14
- package/src/core/motherhome.ts +8 -35
- package/src/core/one-way-in-policy.ts +0 -3
- package/src/core/peer-sk.ts +8 -0
- package/src/core/repo-walk.ts +0 -9
- package/src/core/retention.ts +1 -9
- package/src/core/retired-checks.ts +2 -0
- package/src/core/tmux-policy.ts +1 -1
- package/src/core/tree-watch.ts +2 -2
- package/src/core/when.ts +7 -45
- package/src/gate/admit-heavy.ts +150 -0
- package/src/gate/check-runner.ts +6 -0
- package/src/gate/discover-checks.ts +42 -32
- package/src/gate/gate-checks.ts +21 -131
- package/src/gate/head-gate.ts +1 -1
- package/src/gate/job-run.ts +2 -1
- package/src/gate/pre-commit-discovery.ts +22 -28
- package/src/gate/run-check.ts +3 -4
- package/src/gate/run-ci.ts +4 -0
- package/src/gate/run-fix.ts +5 -17
- package/src/gate/run-fixers.ts +6 -42
- package/src/home/app-sign.ts +2 -2
- package/src/home/backup-status.ts +52 -92
- package/src/home/backup-verdict.ts +2 -2
- package/src/home/daemon-jobs.ts +51 -95
- package/src/home/database-words.ts +1 -2
- package/src/home/databases.ts +9 -25
- package/src/home/home-launchd.ts +0 -6
- package/src/home/home-paths.ts +8 -4
- package/src/home/home-routes.ts +3 -10
- package/src/home/home-state.ts +2 -14
- package/src/home/inbox-shape.ts +14 -15
- package/src/home/inbox.ts +1 -1
- package/src/home/machine-repair.ts +102 -103
- package/src/home/resume.ts +1 -15
- package/src/home/run-daemon.ts +7 -12
- package/src/home/space-page.ts +3 -2
- package/src/home/supervise.ts +3 -7
- package/src/hooks/commit-msg-run.ts +61 -0
- package/src/hooks/commit-run.ts +16 -166
- package/src/hooks/gate-outcome.ts +108 -0
- package/src/hooks/git-hook.ts +9 -9
- package/src/hooks/hook-config.ts +8 -8
- package/src/hooks/leak-guard.ts +1 -1
- package/src/hooks/pre-commit-checks.ts +1 -1
- package/src/hooks/run-hooks.ts +2 -6
- package/src/hooks/shared-file.ts +3 -2
- package/src/hq/daemon-db.ts +8 -8
- package/src/hq/door.ts +3 -16
- package/src/hq/hq-db.ts +4 -3
- package/src/hq/hq-local.ts +1 -2
- package/src/hq/hq-store.ts +0 -15
- package/src/hq/item-direct.ts +8 -10
- package/src/hq/item-fill.ts +37 -0
- package/src/hq/kinds/item-gone.ts +7 -10
- package/src/hq/kinds/item-msg.ts +12 -18
- package/src/hq/kinds/item.ts +13 -19
- package/src/hq/kinds/report.ts +3 -4
- package/src/hq/owner-switch.ts +3 -3
- package/src/hq/report.ts +5 -9
- package/src/hq/switch.ts +2 -11
- package/src/hq/thread-sync.ts +5 -17
- package/src/hq/{shapes-words.ts → threads-words.ts} +2 -12
- package/src/http/owner-word.ts +1 -1
- package/src/identities/machine.ts +16 -0
- package/src/init-repo.ts +0 -1
- package/src/ledger/check-stats.ts +6 -5
- package/src/ledger/db.ts +2 -4
- package/src/ledger/record-kept.ts +117 -48
- package/src/ledger/run-log.ts +21 -2
- package/src/ledger/slow-tests.ts +96 -0
- package/src/ledger/store.ts +3 -86
- package/src/ledger/suite-log.ts +8 -2
- package/src/media-store/backup/facts.ts +3 -37
- package/src/media-store/backup/keys.ts +1 -8
- package/src/media-store/backup/manifest.ts +6 -67
- package/src/media-store/backup/restore.ts +4 -13
- package/src/media-store/backup/retention.ts +13 -1
- package/src/media-store/backup/run.ts +6 -267
- package/src/media-store/backup/snapshot.ts +2 -38
- package/src/media-store/backup/sources.ts +3 -113
- package/src/media-store/backup/target-send.ts +5 -29
- package/src/media-store/db.ts +8 -7
- package/src/media-store/forget-one.ts +1 -1
- package/src/media-store/forget.ts +1 -80
- package/src/orchestrator/guards.ts +0 -1
- package/src/orchestrator/presence.ts +2 -2
- package/src/orchestrator/routes.ts +1 -1
- package/src/orchestrator/started.ts +0 -9
- package/src/orchestrator/talk-key.ts +3 -4
- package/src/orchestrator/unheard.ts +1 -1
- package/src/plan/planner.ts +3 -2
- package/src/recordings/edit.ts +3 -3
- package/src/recordings/marks-draw.ts +17 -6
- package/src/recordings/marks.ts +120 -9
- package/src/reflections/reflections-queue.ts +3 -10
- package/src/release/notes.ts +1 -1
- package/src/release/public-clean.ts +66 -6
- package/src/release/run-bump.ts +11 -0
- package/src/release/run-release.ts +4 -0
- package/src/releases/from-thread.ts +3 -3
- package/src/releases/model.ts +186 -36
- package/src/releases/store.ts +13 -3
- package/src/releases/validate.ts +83 -0
- package/src/repo-config.ts +36 -64
- package/src/review/answer-kinds.ts +63 -4
- package/src/review/blocked-guard.ts +11 -0
- package/src/review/blocked-object.ts +298 -0
- package/src/review/cells.ts +144 -230
- package/src/review/close.ts +39 -1
- package/src/review/doc-save.ts +3 -2
- package/src/review/draft-item.ts +1 -1
- package/src/review/events.ts +3 -7
- package/src/review/expect.ts +23 -39
- package/src/review/format.ts +79 -46
- package/src/review/glyphs.ts +1 -0
- package/src/review/hand-over.ts +3 -3
- package/src/review/heard.ts +1 -1
- package/src/review/holds-sync.ts +2 -1
- package/src/review/inbox-hook.ts +2 -2
- package/src/review/inbox-read.ts +39 -33
- package/src/review/instruction-guards.ts +12 -0
- package/src/review/instructions.ts +0 -1
- package/src/review/item-db.ts +13 -43
- package/src/review/item-hq.ts +2 -2
- package/src/review/item-rows.ts +3 -14
- package/src/review/kind-catalog.ts +3 -1
- package/src/review/kinds.ts +18 -8
- package/src/review/live-view.ts +3 -0
- package/src/review/media-kind.ts +1 -1
- package/src/review/mentions.ts +1 -2
- package/src/review/model.ts +158 -114
- package/src/review/move.ts +149 -0
- package/src/review/need-threads.ts +3 -2
- package/src/review/object-card.ts +11 -0
- package/src/review/object-read.ts +6 -1
- package/src/review/one-block.ts +1 -1
- package/src/review/owner-read.ts +1 -1
- package/src/review/phone-push.ts +10 -9
- package/src/review/previews.ts +32 -4
- package/src/review/push.ts +2 -2
- package/src/review/recap.ts +129 -0
- package/src/review/referring.ts +6 -3
- package/src/review/reflection-object.ts +4 -3
- package/src/review/routes.ts +51 -47
- package/src/review/secret-route.ts +3 -2
- package/src/review/settle.ts +0 -6
- package/src/review/snooze.ts +5 -3
- package/src/review/speaker.ts +68 -0
- package/src/review/start-title.ts +19 -0
- package/src/review/store-parties.ts +28 -0
- package/src/review/store.ts +94 -59
- package/src/review/{wakes.ts → thread-events.ts} +92 -7
- package/src/review/thread-md.ts +35 -14
- package/src/review/thread-state.ts +804 -0
- package/src/review/threads.ts +29 -347
- package/src/review/traces.ts +104 -7
- package/src/review/trailer-item.ts +1 -1
- package/src/review/unit.ts +7 -9
- package/src/review/verdict-items.ts +12 -10
- package/src/review/view-layout.ts +25 -1
- package/src/review/watch-feed.ts +1 -2
- package/src/review/working-guards.ts +2 -3
- package/src/rules/untrack-generated.ts +1 -15
- package/src/secrets/copy.ts +4 -4
- package/src/secrets/lapse.ts +2 -1
- package/src/serve/hub-app/advisor-app.tsx +4 -4
- package/src/serve/hub-app/advisor-face.tsx +9 -3
- package/src/serve/hub-app/advisor-host.ts +27 -27
- package/src/serve/hub-app/advisors-model.ts +17 -8
- package/src/serve/hub-app/advisors-rights.tsx +1 -1
- package/src/serve/hub-app/advisors-st.ts +15 -14
- package/src/serve/hub-app/advisors-view.tsx +13 -11
- package/src/serve/hub-app/app-bridge.ts +23 -3
- package/src/serve/hub-app/asks-page.tsx +1 -1
- package/src/serve/hub-app/auto-text.tsx +71 -16
- package/src/serve/hub-app/check-view.tsx +0 -8
- package/src/serve/hub-app/controls.css +14 -3
- package/src/serve/hub-app/database-view.tsx +1 -2
- package/src/serve/hub-app/dock-st.ts +1 -1
- package/src/serve/hub-app/git-view.tsx +3 -1
- package/src/serve/hub-app/hub.css +12 -5
- package/src/serve/hub-app/icons.tsx +1 -1
- package/src/serve/hub-app/inbox-view.tsx +1 -2
- package/src/serve/hub-app/live-sources.ts +2 -2
- package/src/serve/hub-app/main-panel.tsx +2 -1
- package/src/serve/hub-app/panel-repo.ts +0 -9
- package/src/serve/hub-app/pic.tsx +29 -12
- package/src/serve/hub-app/polled.ts +16 -2
- package/src/serve/hub-app/recordings-st.ts +23 -2
- package/src/serve/hub-app/recordings-view.tsx +68 -10
- package/src/serve/hub-app/ref-pill.ts +1 -1
- package/src/serve/hub-app/repo-st.ts +1 -2
- package/src/serve/hub-app/review/advisor-add.tsx +1 -1
- package/src/serve/hub-app/review/advisor-invite.tsx +1 -1
- package/src/serve/hub-app/review/draft-body.tsx +2 -2
- package/src/serve/hub-app/review/heard-line.tsx +1 -1
- package/src/serve/hub-app/review/instructions-view.tsx +1 -8
- package/src/serve/hub-app/review/kind-states.tsx +14 -9
- package/src/serve/hub-app/review/kit.tsx +4 -11
- package/src/serve/hub-app/review/lane-bar.tsx +3 -3
- package/src/serve/hub-app/review/lightbox.tsx +15 -11
- package/src/serve/hub-app/review/line-window.ts +4 -1
- package/src/serve/hub-app/review/live-bar-st.ts +2 -2
- package/src/serve/hub-app/review/live-view.tsx +57 -1
- package/src/serve/hub-app/review/object-panel.tsx +20 -8
- package/src/serve/hub-app/review/question-views.tsx +191 -53
- package/src/serve/hub-app/review/recap-bar.tsx +40 -0
- package/src/serve/hub-app/review/request-cell.tsx +48 -0
- package/src/serve/hub-app/review/review-cells.tsx +154 -96
- package/src/serve/hub-app/review/review-host.ts +8 -4
- package/src/serve/hub-app/review/review-kit.ts +17 -11
- package/src/serve/hub-app/review/review-list.tsx +30 -35
- package/src/serve/hub-app/review/review-st.ts +32 -42
- package/src/serve/hub-app/review/review-thread.tsx +139 -85
- package/src/serve/hub-app/review/review-views.tsx +127 -68
- package/src/serve/hub-app/review/share-lines.tsx +4 -4
- package/src/serve/hub-app/review/start-st.ts +2 -5
- package/src/serve/hub-app/review/superseded-runs.ts +4 -3
- package/src/serve/hub-app/review/thread-close.tsx +10 -7
- package/src/serve/hub-app/review/thread-st.ts +381 -202
- package/src/serve/hub-app/review/tone-bar.tsx +129 -0
- package/src/serve/hub-app/review/tones.ts +53 -0
- package/src/serve/hub-app/review/trailer-body.tsx +2 -2
- package/src/serve/hub-app/review/trailer-st.ts +3 -2
- package/src/serve/hub-app/review/trailer-voices-st.ts +3 -2
- package/src/serve/hub-app/review.css +189 -106
- package/src/serve/hub-app/search-view.tsx +1 -1
- package/src/serve/hub-app/social/social-model.ts +0 -4
- package/src/serve/hub-app/source-acts.ts +2 -1
- package/src/serve/hub-app/stores/stores-page.tsx +2 -2
- package/src/serve/hub-app/terminal-sources.tsx +2 -1
- package/src/serve/hub-app/thread-row.tsx +3 -4
- package/src/serve/hub-app/tree-build.ts +0 -4
- package/src/serve/hub-app/urls-view.tsx +2 -1
- package/src/serve/hub-app/view-layout.css +13 -3
- package/src/serve/hub-app/wikis-view.tsx +5 -2
- package/src/serve/hub-runtime.ts +7 -37
- package/src/serve/project-gutter-route.ts +6 -2
- package/src/serve/read-thread.ts +20 -2
- package/src/serve/read-worker.ts +9 -1
- package/src/serve/record-pages.ts +46 -0
- package/src/serve/serve-hub.ts +2 -2
- package/src/serve/terminal-host.ts +1 -1
- package/src/serve/terminal-route.ts +1 -3
- package/src/serve/tracked-watch.ts +1 -3
- package/src/setup-house.ts +2 -2
- package/src/shipkit-files.ts +1 -1
- package/src/shipkit.ts +1 -6
- package/src/shot/client.ts +2 -1
- package/src/shot/film-box.ts +0 -20
- package/src/shot/on-place.ts +141 -0
- package/src/social/drafts.ts +1 -1
- package/src/social/kinds.ts +6 -29
- package/src/social/load.ts +2 -2
- package/src/social/post-object.ts +3 -2
- package/src/social/release-stage.ts +1 -1
- package/src/social/stage.ts +2 -2
- package/src/stores/model.ts +4 -0
- package/src/stores/routes.ts +11 -3
- package/src/suite/judge-suites.ts +58 -0
- package/src/suite/red-alone.ts +54 -18
- package/src/suite/runner-shapes.ts +2 -2
- package/src/suite/suite-cli.ts +67 -14
- package/src/suite/test-units.ts +2 -1
- package/src/urls/fill.ts +1 -1
- package/src/urls/places.ts +1 -2
- package/src/vault/vault-config.ts +2 -2
- package/src/vault/vault-init.ts +1 -5
- package/src/wiki/graph-page.ts +14 -2
- package/src/advisors/copy-truth.ts +0 -49
- package/src/advisors/door-child.ts +0 -112
- package/src/advisors/door-serve.ts +0 -52
- package/src/advisors/door.ts +0 -118
- package/src/checks/SK016-legacy-check-shapes.check.ts +0 -189
- package/src/checks/SK029-explicit-check-files.check.ts +0 -112
- package/src/checks/SK048-one-local-file.check.ts +0 -36
- package/src/core/config-rewrite.ts +0 -111
- package/src/core/daemon-port.ts +0 -10
- package/src/core/legacy-shapes.ts +0 -263
- package/src/core/migrate-layout.ts +0 -638
- package/src/core/port-check-cli.ts +0 -52
- package/src/core/port-check-file.ts +0 -295
- package/src/core/port-check-files.ts +0 -31
- package/src/gate/discover-legacy-checks.ts +0 -26
- package/src/home/home-move.ts +0 -527
- package/src/home/machine-fold.ts +0 -810
- package/src/hq/item-shapes.ts +0 -54
- package/src/hq/kinds/items-read.ts +0 -4
- package/src/media-store/backup/daemon.ts +0 -220
- package/src/media-store/backup/kept.ts +0 -241
- package/src/media-store/backup/prune.ts +0 -359
- package/src/media-store/backup/secret.ts +0 -88
- package/src/media-store/backup/ssh-space.ts +0 -202
- package/src/media-store/backup/watch.ts +0 -117
- package/src/review/band.ts +0 -182
- package/src/review/folders.ts +0 -216
- package/src/review/hook-ask.ts +0 -58
- package/src/review/role.ts +0 -48
- package/src/review/thread-fold.ts +0 -64
- package/src/review/wait.ts +0 -91
- package/src/rules/rule.ts +0 -43
- package/src/serve/hook-thread.ts +0 -37
- package/src/serve/hook-work.ts +0 -92
- package/src/serve/hook-worker.ts +0 -57
- package/src/serve/hub-app/review/dock.tsx +0 -147
- package/src/serve/hub-app/review/faces.tsx +0 -18
- package/src/serve/hub-app/review/item-verdict.tsx +0 -112
- package/src/serve/hub-app/review/review-board.tsx +0 -48
- /package/src/{scaffold → core}/jsonc-spans.ts +0 -0
package/src/advisors/sync.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
1
|
+
// what a person reads of a share, and the owner's pass (wiki tools/shipkit/advisors.md): `prepare` projects one live
|
|
2
|
+
// share, scanned, through the hub's own builders, for the users' port to answer at the request; the pass keeps the
|
|
3
|
+
// owner's store true about the people: who may sign in, each share's reach and what it masks, where each reader
|
|
4
|
+
// stopped, the advice the owner's rights make direct since, the sweeps of the port's folder. A thread a person reads is
|
|
5
|
+
// prepared at their request, never kept from a pass
|
|
6
|
+
import { createHash } from 'node:crypto'
|
|
5
7
|
import { existsSync, readFileSync, statSync } from 'node:fs'
|
|
6
8
|
import { HOUSE_LAYOUT } from '../core/house-layout.ts'
|
|
7
9
|
import { identitiesFile } from '../core/identities-root.ts'
|
|
8
|
-
import { imageFile, readAll, storeDir, threadFile } from '../review/store.ts'
|
|
10
|
+
import { imageFile, readAll, storeDir, threadCodeOf, threadFile } from '../review/store.ts'
|
|
9
11
|
import { isGallery, verdictOf, type ReviewItem } from '../review/model.ts'
|
|
10
12
|
import type { ReplyCell } from '../review/cells.ts'
|
|
11
|
-
import type { Turn } from '../review/band.ts'
|
|
12
13
|
import { namedFiles } from '../review/file-tags.ts'
|
|
13
|
-
import { membersOf,
|
|
14
|
+
import { membersOf, threadOfAddress, type Thread } from '../review/threads.ts'
|
|
14
15
|
import { cursorOf } from '../review/traces.ts'
|
|
15
16
|
import { advisorThread, personReads, storeNames, type AdvisorThread } from './advisor-view.ts'
|
|
16
|
-
import { truthfulCopy } from './copy-truth.ts'
|
|
17
|
-
import type { AppBundle } from './app.ts'
|
|
18
17
|
import { ADVISOR_WHO } from '../serve/hub-app/review/review-host.ts'
|
|
19
18
|
import { getJson, type Bucket, type Bytes } from './edge/bucket.ts'
|
|
20
|
-
import { KEYS, type ServedProject, type
|
|
21
|
-
import {
|
|
19
|
+
import { KEYS, type ServedProject, type ShareManifest } from './edge/types.ts'
|
|
20
|
+
import { deliverPending, sweepUploads } from './advice.ts'
|
|
22
21
|
import { shareAllOfAccess } from './acts.ts'
|
|
23
22
|
import { opaqueItem, opaqueMessage, picturesOf, projectItems, questionHash, type Masked } from './project.ts'
|
|
24
23
|
import { maskHits, privateWordsOf } from './scan.ts'
|
|
25
|
-
import { photoBytes } from './photos.ts'
|
|
26
24
|
import { rightsOf } from './rights.ts'
|
|
27
25
|
import { keepLogins } from './login.ts'
|
|
28
|
-
import { identityOfRoot } from './
|
|
26
|
+
import { identityOfRoot } from './speaks.ts'
|
|
29
27
|
import { ownerNameOf } from './owner-name.ts'
|
|
30
28
|
import { displayOf, isLive, startPlacesOf, readState, servedShares, withState, type OwnerState, type Share, type ShareRead } from './owner-store.ts'
|
|
29
|
+
import { bandOf, threadState } from '../review/thread-state.ts'
|
|
30
|
+
import { partiesOfStore } from '../review/store-parties.ts'
|
|
31
31
|
|
|
32
32
|
/** a picture as the advisor gets it: re-encoded, no metadata (EXIF, PNG text) survives */
|
|
33
33
|
export type Encode = (path: string) => Promise<Bytes>
|
|
@@ -47,23 +47,21 @@ export function privateWords(house: string | null): string[] {
|
|
|
47
47
|
return existsSync(f) ? privateWordsOf(readFileSync(f, 'utf8')) : []
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
/** what one live share shows the advisor now
|
|
51
|
-
*
|
|
50
|
+
/** what one live share shows the advisor now: the hub's own view and row, the manifest the port checks requests
|
|
51
|
+
* against, every picture of the thread by the hash of its raw bytes */
|
|
52
52
|
export interface Prepared {
|
|
53
53
|
/** the project's name as the advisor reads it, scanned */
|
|
54
54
|
project: string
|
|
55
|
-
/**
|
|
55
|
+
/** the owner's name as this share's project reads it, scanned */
|
|
56
56
|
owner: string
|
|
57
|
-
/** the advisor's
|
|
58
|
-
|
|
57
|
+
/** what the advisor reads, the hub's view and row: null when nothing of the thread leaves */
|
|
58
|
+
theirs: AdvisorThread | null
|
|
59
59
|
manifest: ShareManifest | null
|
|
60
60
|
/** the entries that went out with strings masked */
|
|
61
61
|
masked: Masked[]
|
|
62
|
-
/** each
|
|
63
|
-
served: { sha: string; path: string }[]
|
|
64
|
-
/** each image of the projection, raw content hash, file: the preview draws all of them */
|
|
62
|
+
/** each image of the projection, raw content hash, file: the port encodes one at its request */
|
|
65
63
|
all: { ref: string; sha: string; path: string }[]
|
|
66
|
-
/** the time of
|
|
64
|
+
/** the time of the owner's newest word in the thread: a read up to it is « seen by <name> » in the owner's hub */
|
|
67
65
|
his: string | null
|
|
68
66
|
/** the thread's versions and how many the person sees */
|
|
69
67
|
parts: { versions: number; shown: number }
|
|
@@ -71,8 +69,8 @@ export interface Prepared {
|
|
|
71
69
|
|
|
72
70
|
const ISO = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z$/
|
|
73
71
|
|
|
74
|
-
/**
|
|
75
|
-
*
|
|
72
|
+
/** a person's read cursor of a share (users-router.ts writes it, `upTo` one of the view's own cell times): a small
|
|
73
|
+
* object of two times; anything else is no read */
|
|
76
74
|
export function readOf(bytes: Bytes | null, his: string | null): ShareRead | null {
|
|
77
75
|
if (bytes === null || bytes.byteLength > 512) return null
|
|
78
76
|
let v: unknown
|
|
@@ -89,9 +87,6 @@ export function readOf(bytes: Bytes | null, his: string | null): ShareRead | nul
|
|
|
89
87
|
return { at, upTo, seen: his === null || upTo >= his }
|
|
90
88
|
}
|
|
91
89
|
|
|
92
|
-
/** the re-encoded bytes of this run, by served name: put once each */
|
|
93
|
-
const encoded = new Map<string, Bytes>()
|
|
94
|
-
|
|
95
90
|
const resolverOf =
|
|
96
91
|
(root: string) =>
|
|
97
92
|
(itemId: string, name: string, of: 'view' | 'message'): string | null =>
|
|
@@ -99,17 +94,17 @@ const resolverOf =
|
|
|
99
94
|
|
|
100
95
|
const ADVICE_WORDS: Record<string, string> = { approve: 'I approve', change: "I'd change this", words: '' }
|
|
101
96
|
|
|
102
|
-
/** the cell of a person's own advice in their
|
|
97
|
+
/** the cell of a person's own advice in their view */
|
|
103
98
|
const adviceCell = (head: string, advice: string): string => `${head}/m${sha256(`advice|${advice}`).slice(0, 12)}`
|
|
104
99
|
|
|
105
|
-
/** each word the person's rights let in at once, as
|
|
100
|
+
/** each word the person's rights let in at once, as their view names it (opaqueMessage), and its cell there: an agent's
|
|
106
101
|
* read of it links that cell. The thread's word is the one its advice wrote, at the moment the advice says it was done */
|
|
107
102
|
function ownCells(s: OwnerState, x: Share, thread: Thread, head: string): Map<string, string> {
|
|
108
103
|
const out = new Map<string, string>()
|
|
109
104
|
const direct = s.advice.filter((a) => a.share === x.id && a.state === 'direct' && a.done !== undefined)
|
|
110
105
|
for (const y of membersOf(thread))
|
|
111
106
|
for (const m of y.thread) {
|
|
112
|
-
// their verdict is a cell of the
|
|
107
|
+
// their verdict is a cell of the view itself, never an advice's
|
|
113
108
|
if (m.who !== 'player' || m.advisor?.id !== x.advisor || m.verdict !== undefined) continue
|
|
114
109
|
const a = direct.find((z) => z.done === m.at)
|
|
115
110
|
if (a !== undefined) out.set(opaqueMessage(x.id, m.id), adviceCell(head, a.id))
|
|
@@ -117,11 +112,11 @@ function ownCells(s: OwnerState, x: Share, thread: Thread, head: string): Map<st
|
|
|
117
112
|
return out
|
|
118
113
|
}
|
|
119
114
|
|
|
120
|
-
/** the person's own advice on this share: drawn in their
|
|
121
|
-
* One their rights made direct is in the thread as a `player` word, which the projection never
|
|
122
|
-
* person's word stays theirs), so their
|
|
115
|
+
/** the person's own advice on this share: drawn in their view as their words, « waits for <owner> » while it waits.
|
|
116
|
+
* One their rights made direct is in the thread as a `player` word, which the projection never carries (another
|
|
117
|
+
* person's word stays theirs), so their view draws it from here, with no wait */
|
|
123
118
|
function pendingCells(s: OwnerState, x: Share, thread: Thread, view: AdvisorThread['view'], owner: string): AdvisorThread['view']['cells'] {
|
|
124
|
-
// a direct verdict that is the version's verdict is in the
|
|
119
|
+
// a direct verdict that is the version's verdict is in the view already (project.ts); one of the older shape (a word)
|
|
125
120
|
// is drawn from here
|
|
126
121
|
const verdicts = new Set(membersOf(thread).flatMap((y) => y.thread.filter((m) => m.who === 'player' && m.advisor?.id === x.advisor && m.verdict !== undefined).map((m) => m.at)))
|
|
127
122
|
// a pick is drawn on its question's cell (markVotes), never as words of its own
|
|
@@ -135,7 +130,7 @@ function pendingCells(s: OwnerState, x: Share, thread: Thread, view: AdvisorThre
|
|
|
135
130
|
}
|
|
136
131
|
|
|
137
132
|
/** the words a person started this thread with, opened at once by their rights: in the thread as a `player` word, which
|
|
138
|
-
* the projection never
|
|
133
|
+
* the projection never carries, so their view draws them from their proposal, as its first message */
|
|
139
134
|
function proposedCells(s: OwnerState, x: Share, thread: Thread, view: AdvisorThread['view']): AdvisorThread['view']['cells'] {
|
|
140
135
|
const heads = new Set(membersOf(thread).map((y) => y.item.id))
|
|
141
136
|
return s.proposals.flatMap((p) => {
|
|
@@ -145,12 +140,12 @@ function proposedCells(s: OwnerState, x: Share, thread: Thread, view: AdvisorThr
|
|
|
145
140
|
})
|
|
146
141
|
}
|
|
147
142
|
|
|
148
|
-
/** the person's newest pick on each question, on the question's cell of their
|
|
149
|
-
* OK. A direct pick that answered is in the
|
|
143
|
+
/** the person's newest pick on each question, on the question's cell of their view: their vote while it waits for the
|
|
144
|
+
* owner's OK. A direct pick that answered is in the view already, and wins */
|
|
150
145
|
function markVotes(s: OwnerState, x: Share, view: AdvisorThread['view']): void {
|
|
151
146
|
const newest = new Map<string, { option: number; at: string }>()
|
|
152
147
|
for (const a of s.advice) {
|
|
153
|
-
// a direct one of the older shape (a word with no answer on it) is theirs too: the
|
|
148
|
+
// a direct one of the older shape (a word with no answer on it) is theirs too: the view holds no answer for it
|
|
154
149
|
if (a.share !== x.id || a.kind !== 'pick' || (a.state !== 'pending' && a.state !== 'direct') || a.item === undefined || a.message === undefined || a.option === undefined) continue
|
|
155
150
|
const cell = `${opaqueItem(x.id, a.item)}/${opaqueMessage(x.id, a.message)}`
|
|
156
151
|
if ((newest.get(cell)?.at ?? '') <= a.at) newest.set(cell, { option: a.option, at: a.at })
|
|
@@ -174,11 +169,9 @@ function rawSha(path: string): string {
|
|
|
174
169
|
return sha
|
|
175
170
|
}
|
|
176
171
|
|
|
177
|
-
/** a share projected and its pictures
|
|
178
|
-
*
|
|
179
|
-
|
|
180
|
-
export async function prepare(s: OwnerState, x: Share, o: { words: string[]; encode: Encode; now: Date; preview?: boolean; names?: 'raw' }): Promise<Prepared | null> {
|
|
181
|
-
const raw = o.preview === true || o.names === 'raw'
|
|
172
|
+
/** a share projected and its pictures named: a thread the owner shared goes whole, its pictures with it, each named by
|
|
173
|
+
* the hash of its raw bytes and encoded by the reader on request (the owner's preview, the users' port), never here */
|
|
174
|
+
export async function prepare(s: OwnerState, x: Share, o: { words: string[]; now: Date }): Promise<Prepared | null> {
|
|
182
175
|
const a = s.advisors.find((y) => y.id === x.advisor)
|
|
183
176
|
if (a === undefined) return null
|
|
184
177
|
const stored = readAll(storeDir(x.root)).items
|
|
@@ -190,10 +183,9 @@ export async function prepare(s: OwnerState, x: Share, o: { words: string[]; enc
|
|
|
190
183
|
const name = ownerNameOf(s, { project: x.repo, identity: await identityOfRoot(x.root) })
|
|
191
184
|
const owner = maskHits(name, scan).length === 0 ? name : 'the owner'
|
|
192
185
|
const resolve = resolverOf(x.root)
|
|
193
|
-
// every picture once,
|
|
194
|
-
const served: Prepared['served'] = []
|
|
186
|
+
// every picture once, named by the hash of its raw bytes; the port encodes it at the request
|
|
195
187
|
const all: Prepared['all'] = []
|
|
196
|
-
const byPath = new Map<string,
|
|
188
|
+
const byPath = new Map<string, string | null>()
|
|
197
189
|
for (const pic of picturesOf(thread)) {
|
|
198
190
|
const path = resolve(pic.itemId, pic.name, pic.of)
|
|
199
191
|
if (path === null || byPath.has(path)) continue
|
|
@@ -203,61 +195,49 @@ export async function prepare(s: OwnerState, x: Share, o: { words: string[]; enc
|
|
|
203
195
|
}
|
|
204
196
|
const rawHash = rawSha(path)
|
|
205
197
|
all.push({ ref: path, sha: rawHash, path })
|
|
206
|
-
|
|
207
|
-
byPath.set(path, { raw: rawHash, served: null })
|
|
208
|
-
continue
|
|
209
|
-
}
|
|
210
|
-
const bytes = await o.encode(path)
|
|
211
|
-
const sha = sha256(bytes)
|
|
212
|
-
if (!served.some((y) => y.sha === sha)) served.push({ sha, path })
|
|
213
|
-
byPath.set(path, { raw: rawHash, served: sha })
|
|
214
|
-
encoded.set(sha, bytes)
|
|
198
|
+
byPath.set(path, rawHash)
|
|
215
199
|
}
|
|
216
|
-
/** a picture's name in the
|
|
200
|
+
/** a picture's name in what the person reads: the hash of its raw bytes */
|
|
217
201
|
const nameOf = (path: string | null): string | null => {
|
|
218
202
|
const b = path === null ? null : (byPath.get(path) ?? null)
|
|
219
|
-
|
|
220
|
-
return raw ? `${b.raw}.webp` : b.served === null ? null : `${b.served}.webp`
|
|
203
|
+
return b === null ? null : `${b}.webp`
|
|
221
204
|
}
|
|
222
205
|
const answers = rightsOf(s.rights, { person: x.advisor, project: x.repo, thread: x.address }).answers
|
|
223
206
|
const items = projectItems({ thread, share: x.id, advisor: x.advisor, answers, scan, include: x.include, picture: (itemId, name, of) => nameOf(resolve(itemId, name, of)) })
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
207
|
+
const real = threadState(thread, o.now)
|
|
208
|
+
// the band his hub draws: a live agent works it now, read of his parties (never theirs to read)
|
|
209
|
+
const works = real.turn === 'agents' && bandOf(real, (await partiesOfStore(storeDir(x.root))).parties, o.now) === 'working'
|
|
210
|
+
const theirs = advisorThread(items, { scan, now: o.now, owner, cursor: cursorOf(thread, o.now), names: storeNames(thread), real, deferred: x.deferred === true, code: threadCodeOf(storeDir(x.root))(thread), works })
|
|
211
|
+
if (theirs !== null) {
|
|
212
|
+
// their words at their own time among the thread's cells, as the owner's hub draws them (a stable sort keeps the
|
|
228
213
|
// builders' order of cells of one time)
|
|
229
|
-
|
|
230
|
-
markVotes(s, x,
|
|
231
|
-
personReads(
|
|
232
|
-
// the turn as the advisor reads it: a thread deferred to them and set aside on his side is theirs; his turn, or a
|
|
233
|
-
// thread he set aside himself, waits for him (the page says « waits for <owner> », ReviewSt.bandWord)
|
|
234
|
-
const turnFor = (t: Turn): Turn => (x.deferred && t === 'aside' ? 'yours' : t === 'yours' || t === 'aside' ? 'aside' : t)
|
|
235
|
-
copy.view.turn = turnFor(copy.view.turn)
|
|
236
|
-
copy.row.turn = turnFor(copy.row.turn)
|
|
214
|
+
theirs.view.cells = [...theirs.view.cells, ...proposedCells(s, x, thread, theirs.view), ...pendingCells(s, x, thread, theirs.view, owner)].sort((p, q) => p.at.localeCompare(q.at))
|
|
215
|
+
markVotes(s, x, theirs.view)
|
|
216
|
+
personReads(theirs.view, items.items, { owner, own: ownCells(s, x, thread, theirs.view.head) })
|
|
237
217
|
}
|
|
238
|
-
const manifest =
|
|
218
|
+
const manifest = theirs === null ? null : manifestOf(theirs, thread, x.id, x.advisor)
|
|
239
219
|
const his = membersOf(thread).flatMap((y) => y.thread.filter((m) => m.who === 'owner' && m.op !== 'seen').map((m) => m.at)).sort().at(-1) ?? null
|
|
240
|
-
return { project, owner,
|
|
220
|
+
return { project, owner, theirs, manifest, masked: items.masked, all, his, parts: { versions: items.versions, shown: items.shown } }
|
|
241
221
|
}
|
|
242
222
|
|
|
243
|
-
/** what the
|
|
223
|
+
/** what the users' port checks a share's reads and writes against: the view's ids and pictures, each version that waits with
|
|
244
224
|
* its count of views in the store, each choice question open to `advisor` (open, or answered by their own pick alone,
|
|
245
225
|
* which they may change) with the hash of its words in the store */
|
|
246
|
-
export function manifestOf(
|
|
226
|
+
export function manifestOf(read: AdvisorThread, thread: Thread, share: string, advisor?: string): ShareManifest {
|
|
247
227
|
const real = new Map<string, ReviewItem>()
|
|
248
228
|
for (const x of membersOf(thread)) real.set(opaqueItem(share, x.item.id), x)
|
|
249
|
-
const ids = [
|
|
229
|
+
const ids = [read.view.head, ...read.view.members, ...read.view.cells.map((c) => c.id)]
|
|
250
230
|
const images = new Set<string>()
|
|
251
231
|
const judge: ShareManifest['judge'] = []
|
|
252
232
|
const questions: ShareManifest['questions'] = []
|
|
253
|
-
for (const c of
|
|
233
|
+
for (const c of read.view.cells) {
|
|
254
234
|
if (c.kind === 'version') {
|
|
255
235
|
for (const v of c.item.views) for (const f of isGallery(v) ? v.gallery.map((g) => g.file) : 'image' in v.files ? [v.files.image] : 'before' in v.files ? [v.files.before, v.files.after] : []) images.add(f.slice(0, 64))
|
|
256
236
|
const x = real.get(c.item.id)
|
|
257
237
|
// waits, or holds their own direct verdict alone, which they may change
|
|
258
238
|
const v = x === undefined ? null : verdictOf(x)
|
|
259
239
|
const theirs = v !== null && advisor !== undefined && x!.thread.some((m) => m.id === v.id && m.who === 'player' && m.advisor?.id === advisor)
|
|
260
|
-
if (x !== undefined && c.id ===
|
|
240
|
+
if (x !== undefined && c.id === read.view.head && (read.view.state.headWaits || theirs)) judge.push({ item: c.item.id, version: x.item.views.length })
|
|
261
241
|
}
|
|
262
242
|
if (c.kind === 'reply') {
|
|
263
243
|
if (c.image !== undefined) images.add(c.image.slice(0, 64))
|
|
@@ -272,10 +252,11 @@ export function manifestOf(copy: AdvisorThread, thread: Thread, share: string, a
|
|
|
272
252
|
}
|
|
273
253
|
}
|
|
274
254
|
}
|
|
275
|
-
return { v: 1, head:
|
|
255
|
+
return { v: 1, head: read.view.head, ids: [...new Set(ids)], images: [...images], judge, questions }
|
|
276
256
|
}
|
|
277
257
|
|
|
278
|
-
/** where each person may start a thread (startPlacesOf), by the
|
|
258
|
+
/** where each person may start a thread (startPlacesOf), by the id the advisors page names it by; its names scanned
|
|
259
|
+
* like any text that leaves */
|
|
279
260
|
export async function projectsOf(s: OwnerState, words: string[], now = new Date()): Promise<Record<string, ServedProject>> {
|
|
280
261
|
const out: Record<string, ServedProject> = {}
|
|
281
262
|
for (const x of startPlacesOf(s, now)) {
|
|
@@ -290,132 +271,75 @@ export async function projectsOf(s: OwnerState, words: string[], now = new Date(
|
|
|
290
271
|
}
|
|
291
272
|
|
|
292
273
|
export interface SyncReport {
|
|
293
|
-
|
|
294
|
-
|
|
274
|
+
/** the shares a person reads now */
|
|
275
|
+
reached: number
|
|
276
|
+
/** the advice his rights made direct since and that landed */
|
|
295
277
|
advice: number
|
|
296
278
|
errors: string[]
|
|
297
279
|
}
|
|
298
280
|
|
|
299
|
-
/**
|
|
300
|
-
|
|
281
|
+
/** the owner's pass over the users' port's folder `bucket` (users-store.ts): who may sign in kept equal to the grants,
|
|
282
|
+
* each live share prepared once for its reach and what it masks, where each reader stopped pulled into his store, the
|
|
283
|
+
* advice his rights make direct since delivered, the files staged and waiting swept, the sessions and passwords of
|
|
284
|
+
* people no longer listed ended. A failed share is said on it (`reach`) and in the report */
|
|
285
|
+
export async function syncOnce(dir: string, o: { bucket: Bucket; words: string[]; now?: Date }): Promise<SyncReport> {
|
|
301
286
|
const now = o.now ?? new Date()
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
// a project's access that shows every thread shares each new one before the push
|
|
287
|
+
const report: SyncReport = { reached: 0, advice: 0, errors: [] }
|
|
288
|
+
// a project's access that shows every thread shares each new one
|
|
305
289
|
shareAllOfAccess(dir, now)
|
|
306
|
-
// who may sign in: each person with a live grant, and whether the
|
|
290
|
+
// who may sign in: each person with a live grant, and whether the port says their code set a password
|
|
307
291
|
const used = new Map<string, number>()
|
|
308
292
|
for (const a of readState(dir).advisors) {
|
|
309
|
-
if (a.login === undefined || a.login.used === true) continue
|
|
293
|
+
if (a.login === undefined || (a.login.used === true && a.login.reset === undefined)) continue
|
|
310
294
|
const kept = await getJson<{ gen?: unknown }>(o.bucket, KEYS.password(sha256(a.email))).catch(() => null)
|
|
311
295
|
if (typeof kept?.gen === 'number') used.set(a.email, kept.gen)
|
|
312
296
|
}
|
|
313
297
|
const logins = withState(dir, (st) => keepLogins(st, now, used))
|
|
314
298
|
const s = readState(dir)
|
|
315
|
-
// the door opens what this writes and nothing else: the one answer to « who can open a thread » (owner-store.ts)
|
|
316
299
|
const live = servedShares(s, now)
|
|
317
|
-
const results = new Map<string, { prepared: Prepared | null;
|
|
318
|
-
const fallback = ownerNameOf(s)
|
|
319
|
-
const shares: SharesFile = { v: 1, shares: {}, projects: await projectsOf(s, o.words, now), owner: maskHits(fallback, { advisorEmail: '', words: o.words }).length === 0 ? fallback : 'the owner', logins }
|
|
320
|
-
const media = new Set<string>()
|
|
300
|
+
const results = new Map<string, { prepared: Prepared | null; read?: ShareRead | null; reach: Share['reach'] }>()
|
|
321
301
|
for (const x of live) {
|
|
322
302
|
try {
|
|
323
|
-
const p = await prepare(s, x, { words: o.words,
|
|
303
|
+
const p = await prepare(s, x, { words: o.words, now })
|
|
324
304
|
if (p === null) {
|
|
325
305
|
results.set(x.id, { prepared: null, reach: { ok: false, at: now.toISOString(), why: 'its thread or advisor is gone' } })
|
|
326
306
|
continue
|
|
327
307
|
}
|
|
328
|
-
if (p.
|
|
329
|
-
// a value the
|
|
330
|
-
report.errors.push(`${x.id}: the
|
|
331
|
-
results.set(x.id, { prepared: null, reach: { ok: false, at: now.toISOString(), why: `its
|
|
308
|
+
if (p.theirs !== null && p.theirs.faults.length > 0) {
|
|
309
|
+
// a value the output whitelist refused: a builder wrote what a person must not read, so the port shows nothing of it
|
|
310
|
+
report.errors.push(`${x.id}: the whitelist refused ${p.theirs.faults.length} values: ${p.theirs.faults.slice(0, 3).join('; ')}`)
|
|
311
|
+
results.set(x.id, { prepared: null, reach: { ok: false, at: now.toISOString(), why: `its whitelist refused ${p.theirs.faults.length} values: an agent's fix waits` } })
|
|
332
312
|
continue
|
|
333
313
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
for (const m of p.served) media.add(m.sha)
|
|
338
|
-
results.set(x.id, { prepared: p, reach: { ok: true, at: now.toISOString() } })
|
|
314
|
+
report.reached++
|
|
315
|
+
// where the person's reading stands, written by the port on their own page
|
|
316
|
+
results.set(x.id, { prepared: p, read: readOf(await o.bucket.get(KEYS.reads(x.id)), p.his), reach: { ok: true, at: now.toISOString() } })
|
|
339
317
|
} catch (e) {
|
|
340
318
|
report.errors.push(`${x.id}: ${(e as Error).message}`)
|
|
341
319
|
results.set(x.id, { prepared: null, reach: { ok: false, at: now.toISOString(), why: (e as Error).message } })
|
|
342
320
|
}
|
|
343
321
|
}
|
|
344
322
|
try {
|
|
345
|
-
|
|
346
|
-
//
|
|
347
|
-
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
shares.app = b.pin
|
|
323
|
+
const keep = new Set(live.map((x) => x.id))
|
|
324
|
+
// an ended share's read cursor goes with it (the privacy page says so)
|
|
325
|
+
for (const k of await o.bucket.list('reads/')) {
|
|
326
|
+
const id = /^reads\/(.+)\.json$/.exec(k)?.[1]
|
|
327
|
+
if (id !== undefined && !keep.has(id)) await o.bucket.delete(k)
|
|
351
328
|
}
|
|
352
|
-
// the
|
|
353
|
-
|
|
354
|
-
for (const x of live) {
|
|
355
|
-
const r = results.get(x.id)!
|
|
356
|
-
if (r.prepared === null) continue
|
|
357
|
-
for (const m of r.prepared.served) if ((await o.bucket.get(KEYS.media(m.sha))) === null) await o.bucket.put(KEYS.media(m.sha), encoded.get(m.sha)!, 'image/webp')
|
|
358
|
-
const { copy, manifest } = r.prepared
|
|
359
|
-
const h = sha256(JSON.stringify({ copy: copy === null ? null : { view: copy.view, row: copy.row }, manifest }))
|
|
360
|
-
if (h !== x.pushed) {
|
|
361
|
-
if (copy !== null && manifest !== null) {
|
|
362
|
-
// the manifest last: the door serves a share's copy once its manifest names it
|
|
363
|
-
await o.bucket.put(KEYS.view(x.id), JSON.stringify(copy.view), 'application/json')
|
|
364
|
-
await o.bucket.put(KEYS.row(x.id), JSON.stringify(copy.row), 'application/json')
|
|
365
|
-
await o.bucket.put(KEYS.files(x.id), JSON.stringify(manifest), 'application/json')
|
|
366
|
-
}
|
|
367
|
-
report.pushed++
|
|
368
|
-
}
|
|
369
|
-
r.pushed = h
|
|
370
|
-
// where the advisor's reading stands: pulled each pass, written by the door on their own page
|
|
371
|
-
r.read = readOf(await o.bucket.get(KEYS.reads(x.id)), r.prepared.his)
|
|
372
|
-
}
|
|
373
|
-
const keep = new Set(Object.keys(shares.shares))
|
|
374
|
-
// an ended share's copy: its manifest first, so the door stops serving it before its view goes; its cursor after
|
|
375
|
-
for (const prefix of ['files/', 'view/', 'row/', 'reads/'])
|
|
376
|
-
for (const k of await o.bucket.list(prefix)) {
|
|
377
|
-
const id = /^[a-z]+\/(.+)\.json$/.exec(k)?.[1]
|
|
378
|
-
if (id !== undefined && !keep.has(id)) {
|
|
379
|
-
await o.bucket.delete(k)
|
|
380
|
-
if (prefix === 'files/') report.removed++
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
// a file the page staged and no words took: gone after an hour, or with its share
|
|
384
|
-
const projects = new Set(Object.keys(shares.projects ?? {}))
|
|
329
|
+
// a file the page staged and no words took: gone after an hour, or with its share or project
|
|
330
|
+
const places = new Set(startPlacesOf(s, now).map((x) => x.id))
|
|
385
331
|
for (const k of await o.bucket.list('stage/')) {
|
|
386
332
|
const m = /^stage\/(s|p)\/([^/]+)\/(\d{13})-/.exec(k)
|
|
387
|
-
const open = m !== null && (m[1] === 's' ? keep :
|
|
333
|
+
const open = m !== null && (m[1] === 's' ? keep : places).has(m[2]!)
|
|
388
334
|
if (m === null || !open || Number(m[3]) < now.getTime() - 3_600_000) await o.bucket.delete(k)
|
|
389
335
|
}
|
|
390
|
-
// each advisor's own photo, while a share or a project names it: read by that advisor's page alone (edge/handler.ts)
|
|
391
|
-
const photos = new Map<string, string>()
|
|
392
|
-
for (const v of [...Object.values(shares.shares), ...Object.values(shares.projects ?? {})]) {
|
|
393
|
-
const a = s.advisors.find((y) => y.email === v.email)
|
|
394
|
-
if (v.photo !== undefined && a !== undefined) photos.set(v.photo, a.id)
|
|
395
|
-
}
|
|
396
|
-
for (const [sha, id] of photos) {
|
|
397
|
-
if ((await o.bucket.get(KEYS.photo(sha))) !== null) continue
|
|
398
|
-
const bytes = photoBytes(dir, 'advisors', id, 64)
|
|
399
|
-
if (bytes !== null) await o.bucket.put(KEYS.photo(sha), bytes, 'image/webp')
|
|
400
|
-
}
|
|
401
336
|
// a person no longer in the list: their sessions end; one no longer known: their password too
|
|
402
337
|
const signed = new Set(Object.keys(logins).map(sha256))
|
|
403
338
|
const known = new Set(s.advisors.map((a) => sha256(a.email)))
|
|
404
339
|
for (const k of await o.bucket.list('session/')) if (!signed.has(k.split('/')[1] ?? '')) await o.bucket.delete(k)
|
|
405
340
|
for (const k of await o.bucket.list('login/')) if (!known.has(/^login\/([0-9a-f]{64})\./.exec(k)?.[1] ?? '')) await o.bucket.delete(k)
|
|
406
|
-
for (const k of await o.bucket.list('photo/')) {
|
|
407
|
-
const sha = /^photo\/([0-9a-f]{64})\.webp$/.exec(k)?.[1]
|
|
408
|
-
if (sha === undefined || !photos.has(sha)) await o.bucket.delete(k)
|
|
409
|
-
}
|
|
410
|
-
for (const k of await o.bucket.list('media/')) {
|
|
411
|
-
const sha = /^media\/([0-9a-f]{64})\.webp$/.exec(k)?.[1]
|
|
412
|
-
if (sha === undefined || !media.has(sha)) await o.bucket.delete(k)
|
|
413
|
-
}
|
|
414
341
|
} catch (e) {
|
|
415
|
-
report.errors.push(`the
|
|
416
|
-
for (const r of results.values()) r.reach = { ok: false, at: now.toISOString(), why: `the bucket: ${(e as Error).message}` }
|
|
417
|
-
} finally {
|
|
418
|
-
encoded.clear()
|
|
342
|
+
report.errors.push(`the users' folder: ${(e as Error).message}`)
|
|
419
343
|
}
|
|
420
344
|
withState(dir, (st) => {
|
|
421
345
|
for (const x of st.shares) {
|
|
@@ -423,45 +347,35 @@ export async function syncOnce(dir: string, o: { bucket: Bucket; words: string[]
|
|
|
423
347
|
if (r !== undefined) {
|
|
424
348
|
x.reach = r.reach
|
|
425
349
|
if (r.prepared !== null) {
|
|
426
|
-
//
|
|
350
|
+
// a share holds nothing back: the store's stale `held` and `waiting` fields go
|
|
427
351
|
x.masked = r.prepared.masked
|
|
428
352
|
delete x.held
|
|
429
353
|
delete x.waiting
|
|
430
354
|
x.parts = r.prepared.parts
|
|
355
|
+
x.pushed = sha256(JSON.stringify({ view: r.prepared.theirs?.view ?? null, manifest: r.prepared.manifest }))
|
|
431
356
|
}
|
|
432
|
-
if (r.pushed !== undefined) x.pushed = r.pushed
|
|
433
357
|
if (r.read !== undefined) {
|
|
434
358
|
if (r.read === null) delete x.read
|
|
435
359
|
else x.read = r.read
|
|
436
360
|
}
|
|
437
361
|
} else if (x.state === 'revoked' || (x.state === 'live' && !isLive(x, now))) {
|
|
438
362
|
x.reach = report.errors.length === 0 ? { ok: true, at: now.toISOString() } : { ok: false, at: now.toISOString(), why: report.errors[0]! }
|
|
439
|
-
// where they stopped reading goes with the share
|
|
363
|
+
// where they stopped reading goes with the share
|
|
440
364
|
delete x.read
|
|
441
365
|
}
|
|
442
366
|
}
|
|
443
367
|
})
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
report.advice = (await importAdvice(dir, o.bucket, now)).length
|
|
447
|
-
// what came back is drawn in the copies by this pass, not the next: the person's page shows their act (their
|
|
448
|
-
// words, « waits for <owner> », a thread they opened) within one pass of the job
|
|
449
|
-
if (o.again !== false && (report.advice > 0 || readState(dir).proposals.length > proposed)) {
|
|
450
|
-
const r = await syncOnce(dir, { ...o, now, again: false })
|
|
451
|
-
report.pushed += r.pushed
|
|
452
|
-
report.removed += r.removed
|
|
453
|
-
report.errors.push(...r.errors)
|
|
454
|
-
}
|
|
455
|
-
}
|
|
368
|
+
report.advice = await deliverPending(dir, o.bucket, now)
|
|
369
|
+
await sweepUploads(dir, o.bucket, now)
|
|
456
370
|
return report
|
|
457
371
|
}
|
|
458
372
|
|
|
459
|
-
/** with no advisors page yet (not set up): each live share's masked entries, for
|
|
373
|
+
/** with no advisors page yet (not set up): each live share's masked entries, for the owner's preview */
|
|
460
374
|
export async function refreshLocal(dir: string, o: { words: string[]; now?: Date }): Promise<void> {
|
|
461
375
|
const now = o.now ?? new Date()
|
|
462
376
|
const s = readState(dir)
|
|
463
377
|
const got = new Map<string, Prepared | null>()
|
|
464
|
-
for (const x of s.shares.filter((y) => isLive(y, now))) got.set(x.id, await prepare(s, x, { words: o.words,
|
|
378
|
+
for (const x of s.shares.filter((y) => isLive(y, now))) got.set(x.id, await prepare(s, x, { words: o.words, now }))
|
|
465
379
|
withState(dir, (st) => {
|
|
466
380
|
for (const x of st.shares) {
|
|
467
381
|
const p = got.get(x.id)
|
package/src/advisors/tunnel.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
// the tunnel to the advisors
|
|
2
|
-
// (src/advisors-tunnel.shipkit.ts), keeps `cloudflared tunnel run` up while this machine carries
|
|
3
|
-
// tunnel's token is stored, and stops it when the hq moves: one connector only, on the Mac
|
|
1
|
+
// the tunnel to the advisors page (wiki tools/shipkit/advisors.md, Who calls: the users' port): `sk advisors
|
|
2
|
+
// tunnel`, a pm process (src/advisors-tunnel.shipkit.ts), keeps `cloudflared tunnel run` up while this machine carries
|
|
3
|
+
// the hq and the tunnel's token is stored, and stops it when the hq moves: one connector only, on the Mac whose daemon
|
|
4
|
+
// opens the users' port.
|
|
4
5
|
// The one constraint a reader breaks first: the token goes to cloudflared by its environment (TUNNEL_TOKEN), never on
|
|
5
6
|
// its command line and never in a line of the log
|
|
6
7
|
import { existsSync } from 'node:fs'
|
|
7
8
|
import { readSecretHere } from '../secrets/read.ts'
|
|
8
|
-
import { TUNNEL_TOKEN } from './
|
|
9
|
+
import { TUNNEL_TOKEN } from './reach.ts'
|
|
9
10
|
|
|
10
11
|
export type Proc = { exited: Promise<unknown>; kill: () => void }
|
|
11
12
|
|
|
@@ -38,7 +39,7 @@ export const cloudflaredBin = (): string | null => BINS.find((b) => existsSync(b
|
|
|
38
39
|
/** the global process that keeps cloudflared up (src/advisors-tunnel.shipkit.ts at the house's root) */
|
|
39
40
|
export const TUNNEL_PROCESS = 'advisors-tunnel'
|
|
40
41
|
|
|
41
|
-
/** cloudflared for the
|
|
42
|
+
/** cloudflared for the advisors page's setup: its binary, and the tunnel process started through the one road that starts a
|
|
42
43
|
* global process (pm's switch), null once it runs, else why not. A surface that reaches pm hands it in */
|
|
43
44
|
export interface TunnelStart {
|
|
44
45
|
bin: () => string | null
|