@attalabs/vinaya 0.37.0 → 0.38.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/aeg-root/enforcement.md +5 -4
- package/aeg-root/roles/developer/reference.md +24 -22
- package/aeg-root/roles/developer.md +4 -4
- package/aeg-root/roles/planner/reference.md +11 -0
- package/aeg-root/roles/reviewer.md +5 -3
- package/aeg-root/roles/security.md +3 -2
- package/aeg-root/state-machine.md +1 -1
- package/aeg-root/templates/brief-template.md +4 -4
- package/aeg-root/tranche-model.md +6 -0
- package/dist/checks/bin/check-body-bare-digits.js +139 -12
- package/dist/checks/bin/check-branch-topology.js +171 -13
- package/dist/checks/bin/check-brief-shape.js +139 -12
- package/dist/checks/bin/check-changeset-coverage.js +177 -17
- package/dist/checks/bin/check-closes-n.js +171 -13
- package/dist/checks/bin/check-coherence.js +171 -13
- package/dist/checks/bin/check-dead-branch-push.js +139 -12
- package/dist/checks/bin/check-dispatch-readiness.js +195 -23
- package/dist/checks/bin/check-doc-coverage-push.js +173 -13
- package/dist/checks/bin/check-doc-coverage.js +180 -13
- package/dist/checks/bin/check-doctrine-no-procedures.js +139 -12
- package/dist/checks/bin/check-doctrine-portability.js +173 -13
- package/dist/checks/bin/check-evidence-fresh.js +173 -13
- package/dist/checks/bin/check-exec-bits.js +173 -13
- package/dist/checks/bin/check-first-push-dispatch.js +171 -13
- package/dist/checks/bin/check-issue-assignment.js +171 -13
- package/dist/checks/bin/check-issue-milestone-attach.js +139 -12
- package/dist/checks/bin/check-issue-objectives-numbering.js +139 -12
- package/dist/checks/bin/check-issue-parts-coverage.js +139 -12
- package/dist/checks/bin/check-issue-surface-globs.js +171 -13
- package/dist/checks/bin/check-issue-title-grammar.js +139 -12
- package/dist/checks/bin/check-issue-tranche-label.js +139 -12
- package/dist/checks/bin/check-main-branch-refusal.js +139 -12
- package/dist/checks/bin/check-no-disk-state.js +139 -12
- package/dist/checks/bin/check-pr-premise-reassert.js +139 -12
- package/dist/checks/bin/check-pr-report-density.js +139 -12
- package/dist/checks/bin/check-principal-test-plan-wait.js +139 -12
- package/dist/checks/bin/check-quoted-command.js +173 -13
- package/dist/checks/bin/check-reader-resolvable-prose.js +173 -13
- package/dist/checks/bin/check-registry-gates.js +406 -68
- package/dist/checks/bin/check-retired-vocabulary.js +173 -13
- package/dist/checks/bin/check-review-gate.js +139 -12
- package/dist/checks/bin/check-single-plan-pr.js +139 -12
- package/dist/checks/bin/check-surface-scope.js +171 -13
- package/dist/checks/bin/check-test-plan.js +139 -12
- package/dist/checks/bin/check-token-collection-wired.js +139 -12
- package/dist/checks/bin/check-workspace-escape.js +173 -13
- package/dist/checks/bin/verify-dispatch.js +3849 -0
- package/dist/index.js +7348 -2095
- package/dist/lib/pre-push-cache-test-run.js +42 -2
- package/dist/lib/pre-push-changed-files.js +16 -11
- package/dist/lib/pre-push-select-tests.js +177 -21
- package/package.json +1 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +7 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +33 -15
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +51 -12
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +1 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +31 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +31 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +214 -24
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +11 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +5 -4
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +13 -13
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +46 -145
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +63 -14
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/index.ts +3 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/published-prose.ts +30 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +6 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +0 -1
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +56 -7
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +7 -7
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +24 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/custom.ts +157 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +44 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/executions.ts +493 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/fact-sheets.ts +111 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/generator.ts +155 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/index.ts +12 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +128 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/catches.ts +63 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/checks.ts +146 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/common.ts +137 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/completion.ts +137 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/convergence.ts +420 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/determinism.ts +65 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/index.ts +69 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/judgment.ts +132 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/labels.ts +21 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/time.ts +167 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/usage.ts +139 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +219 -15
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +7 -7
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/cache-contract.ts +207 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/contracts.ts +105 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/engine.ts +308 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/index.ts +34 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/measured.ts +20 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/memory-cache.ts +78 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/normalize.ts +156 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/row.ts +103 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +34 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +70 -6
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +19 -14
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +38 -3
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +5 -2
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-phase-history.ts +46 -0
- package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +15 -28
- package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/1q96_modules_@clerk_nextjs_dist_esm_app-router_client_keyless-creator-reader_0lom2js.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__04adkz-._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0h9yhwx._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__14ui9sz._.js → [root-of-the-server]__0jdjsxe._.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_@clerk_nextjs_dist_esm_app-router_server-actions_1x7vfhn.js +2 -2
- package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
- package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1-acpmtfmrc35.js +1 -0
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3qtt1v3ya-ofe.js → 2f2y8xxok8zph.js} +1 -1
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3l56x8wjdzvaw.js → 2xevgia1h8g0y.js} +4 -4
- package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
- package/dist/checks/bin/check-token-report.js +0 -6526
- package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0vtfb0g813gki.js +0 -1
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{yR5RsCxb1OGnYggiaO09S → yNZEFRSjP9BLUfdf96Eol}/_buildManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{yR5RsCxb1OGnYggiaO09S → yNZEFRSjP9BLUfdf96Eol}/_clientMiddlewareManifest.js +0 -0
- /package/studio-standalone/apps/vinaya-studio/web/.next/static/{yR5RsCxb1OGnYggiaO09S → yNZEFRSjP9BLUfdf96Eol}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The three contracts every Vinaya Log reader codes against
|
|
3
|
+
* (`apps/cli/specs/log-sync.md`):
|
|
4
|
+
*
|
|
5
|
+
* - a **source** — where pages of stored lines come from (a log folder, a
|
|
6
|
+
* log server), each page with the cursor to resume from and every gap
|
|
7
|
+
* the source knows it cannot fill;
|
|
8
|
+
* - a **cache** — where normalised rows live, with each source's cursor,
|
|
9
|
+
* the gaps, the quarantined lines and the edits a re-read revealed;
|
|
10
|
+
* - a **dataset** — what a query reads: the rows, and the gaps and
|
|
11
|
+
* quarantine it must account for before calling an answer known.
|
|
12
|
+
*
|
|
13
|
+
* These are types only. The sender's own queue contract (`LogStore`,
|
|
14
|
+
* `../store.ts`) is a different thing and stays separate.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { Measured } from './measured'
|
|
18
|
+
import type { DatasetRow, NormalizedLine, QuarantineRecord, RowOrigin } from './row'
|
|
19
|
+
|
|
20
|
+
/** A source's opaque resume point. Only the source that issued it interprets it. */
|
|
21
|
+
export type SourceCursor = string
|
|
22
|
+
|
|
23
|
+
/** One stored line as a source hands it over, with its position inside that source. */
|
|
24
|
+
export type SourceLine = {
|
|
25
|
+
raw: string
|
|
26
|
+
/** Opaque position within the source — becomes `RowOrigin.position`. */
|
|
27
|
+
position: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A stretch of a source's history that can no longer be read — rotated
|
|
32
|
+
* away, expired from a server's retention, rejected on receipt. A gap is
|
|
33
|
+
* reported, never skipped silently. `from`/`to` are opaque source positions
|
|
34
|
+
* bounding it, `null` where the bound is itself unknown.
|
|
35
|
+
*/
|
|
36
|
+
export type SourceGap = {
|
|
37
|
+
source: string
|
|
38
|
+
from: string | null
|
|
39
|
+
to: string | null
|
|
40
|
+
reason: string
|
|
41
|
+
/** How many lines the gap lost, when the source can count them. */
|
|
42
|
+
lost: Measured<number>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** One page read from a source. `next` is `null` when the source had nothing after this page when read. */
|
|
46
|
+
export type SourcePage = {
|
|
47
|
+
lines: readonly SourceLine[]
|
|
48
|
+
next: SourceCursor | null
|
|
49
|
+
gaps: readonly SourceGap[]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Where stored lines come from. Reading never writes to the source. */
|
|
53
|
+
export interface LogSource {
|
|
54
|
+
/** Stable across runs for the same place (for example `folder:<path>`, `server:<url>`) — the key its cursor and gaps are stored under. */
|
|
55
|
+
readonly id: string
|
|
56
|
+
/** Reads the page after `cursor` (`null` = from the beginning), at most `limit` lines. */
|
|
57
|
+
readPage(cursor: SourceCursor | null, limit: number): Promise<SourcePage>
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A stored row later re-read with the same identity and different content.
|
|
62
|
+
* The first row is kept; the difference is recorded here, once per distinct
|
|
63
|
+
* content.
|
|
64
|
+
*/
|
|
65
|
+
export type RowEdit = {
|
|
66
|
+
identity: string
|
|
67
|
+
/** `contentHash` of the row the cache keeps. */
|
|
68
|
+
keptHash: string
|
|
69
|
+
/** `contentHash` of the differing content that was offered. */
|
|
70
|
+
editedHash: string
|
|
71
|
+
/** Where the differing content was read from. */
|
|
72
|
+
origin: RowOrigin | null
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** What storing one normalised line did. */
|
|
76
|
+
export type PutOutcome =
|
|
77
|
+
| { type: 'row'; result: 'inserted' | 'duplicate' | 'edited' }
|
|
78
|
+
| { type: 'quarantine'; result: 'inserted' | 'duplicate' }
|
|
79
|
+
|
|
80
|
+
/** What a query reads. Every list is deterministic, so two backends holding the same content answer identically. */
|
|
81
|
+
export interface Dataset {
|
|
82
|
+
/** Every row exactly once, ordered by `time`, then `identity`. */
|
|
83
|
+
rows(): readonly DatasetRow[]
|
|
84
|
+
/** Every recorded gap, in the order recorded. */
|
|
85
|
+
gaps(): readonly SourceGap[]
|
|
86
|
+
/** Every quarantined line, in the order first stored. */
|
|
87
|
+
quarantined(): readonly QuarantineRecord[]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Where normalised rows live between syncs. Idempotent by identity: storing
|
|
92
|
+
* a row whose identity is already held adds nothing — the same content is a
|
|
93
|
+
* duplicate, different content is recorded as an edit against the kept row.
|
|
94
|
+
* A quarantine record is keyed by its `contentHash`.
|
|
95
|
+
*/
|
|
96
|
+
export interface LogCache {
|
|
97
|
+
put(line: NormalizedLine): PutOutcome
|
|
98
|
+
/** The cursor last stored for `source`, or `null` when none was. */
|
|
99
|
+
cursor(source: string): SourceCursor | null
|
|
100
|
+
setCursor(source: string, cursor: SourceCursor): void
|
|
101
|
+
/** Records a gap; recording the same gap (same source, bounds and reason) twice keeps one. */
|
|
102
|
+
recordGap(gap: SourceGap): void
|
|
103
|
+
edits(): readonly RowEdit[]
|
|
104
|
+
dataset(): Dataset
|
|
105
|
+
}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sync engine (`apps/cli/specs/log-sync.md`, "The sync run"): the one
|
|
3
|
+
* algorithm that moves a source's stored lines into a cache and is honest
|
|
4
|
+
* about what it could not see. It is pure — a function over a `LogSource` and
|
|
5
|
+
* a `LogCache` handed to it, with the clock and the bounds passed in, no I/O
|
|
6
|
+
* and no clock read of its own.
|
|
7
|
+
*
|
|
8
|
+
* The stored cursor is the **look-back anchor**: it trails the furthest point
|
|
9
|
+
* synced by at most `lookback` lines, so a run reads from it both to resume
|
|
10
|
+
* after a failure (O2) and to re-read the look-back span every run (O3) — the
|
|
11
|
+
* two are the same read. Overlap is deduplicated by identity in the cache
|
|
12
|
+
* (O1), a changed identity is recorded as an edit beside the first row (O3), an
|
|
13
|
+
* identity the cache held at a source position inside the span the run
|
|
14
|
+
* re-read that the source no longer returns is a deletion (O3), and a span the source itself reports lost is a
|
|
15
|
+
* gap, never a deletion (O4).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type { LogCache, LogSource, SourceCursor, SourceGap, SourcePage } from './contracts'
|
|
19
|
+
import { unknownBecause } from './measured'
|
|
20
|
+
import { normalizeStoredLine } from './normalize'
|
|
21
|
+
import type { RowOrigin } from './row'
|
|
22
|
+
|
|
23
|
+
/** The default look-back span: how many trailing positions a run re-reads to find edits and deletions. */
|
|
24
|
+
export const DEFAULT_SYNC_LOOKBACK = 1000
|
|
25
|
+
/** The default page bound: how many pages one run reads before it stops and reports more is available. */
|
|
26
|
+
export const DEFAULT_SYNC_MAX_PAGES = 50
|
|
27
|
+
/** The default page size: how many lines a single `readPage` asks for. */
|
|
28
|
+
export const DEFAULT_SYNC_PAGE_LIMIT = 1000
|
|
29
|
+
|
|
30
|
+
/** The bounds and clock one sync run is given. The engine never reads the clock itself. */
|
|
31
|
+
export type SyncOptions = {
|
|
32
|
+
/** The run's wall-clock instant, passed in so the engine stays pure. */
|
|
33
|
+
now: Date
|
|
34
|
+
/** At most this many pages this run (default {@link DEFAULT_SYNC_MAX_PAGES}). */
|
|
35
|
+
maxPages?: number
|
|
36
|
+
/** At most this many lines per `readPage` (default {@link DEFAULT_SYNC_PAGE_LIMIT}). */
|
|
37
|
+
pageLimit?: number
|
|
38
|
+
/** The trailing span re-read every run to find edits and deletions (default {@link DEFAULT_SYNC_LOOKBACK}). */
|
|
39
|
+
lookback?: number
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** One identity the cache held in the look-back window that the source no longer returns. The stored row is kept; this is where the loss is reported. */
|
|
43
|
+
export type RowDeletion = {
|
|
44
|
+
identity: string
|
|
45
|
+
/** Where the row was last read from, as the cache holds it. */
|
|
46
|
+
origin: RowOrigin | null
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** What one sync run did. Every count is of this run alone; the cache holds the running totals. */
|
|
50
|
+
export type SyncSummary = {
|
|
51
|
+
/** The source's stable id. */
|
|
52
|
+
source: string
|
|
53
|
+
/** The `now` the run was given, as an ISO instant — the engine's only use of the clock it was handed. */
|
|
54
|
+
ranAt: string
|
|
55
|
+
/** Pages read from the source this run. */
|
|
56
|
+
pagesRead: number
|
|
57
|
+
/** Rows newly inserted this run. */
|
|
58
|
+
rowsStored: number
|
|
59
|
+
/** Rows offered whose identity and content the cache already held. */
|
|
60
|
+
duplicates: number
|
|
61
|
+
/** Distinct edits recorded this run: a held identity re-read with different content. */
|
|
62
|
+
edits: number
|
|
63
|
+
/** Identities found deleted this run — detailed in {@link SyncSummary.deleted}. */
|
|
64
|
+
deletions: number
|
|
65
|
+
/** Gaps recorded this run: a span the source reported it could not fill. */
|
|
66
|
+
gaps: number
|
|
67
|
+
/** Lines quarantined this run: an unknown schema version or a line that failed validation. */
|
|
68
|
+
quarantined: number
|
|
69
|
+
/** `true` when the run reached the end of the source without a failure. */
|
|
70
|
+
completed: boolean
|
|
71
|
+
/** `true` when the run stopped on its page bound with more still to read. */
|
|
72
|
+
moreAvailable: boolean
|
|
73
|
+
/** The failure that ended the run early, or `null` when none. The pages stored before it are kept. */
|
|
74
|
+
failure: string | null
|
|
75
|
+
/** Every deletion this run found. The cache keeps no deletion record, so the run's summary is where a deletion is reported. */
|
|
76
|
+
deleted: readonly RowDeletion[]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type Boundary = { cursor: SourceCursor | null; linesBefore: number }
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Runs one sync of `source` into `cache`.
|
|
83
|
+
*
|
|
84
|
+
* Reads pages from the stored look-back anchor, storing every page's rows and
|
|
85
|
+
* quarantine records before advancing anything (O1), until the source ends, a
|
|
86
|
+
* page bound is hit, or a read fails (O2). The overlap with already-stored
|
|
87
|
+
* data deduplicates by identity and surfaces edits; a held identity gone from
|
|
88
|
+
* the re-read window and not covered by a reported gap is a deletion (O3, O4).
|
|
89
|
+
* The run returns a summary and never reads the clock.
|
|
90
|
+
*/
|
|
91
|
+
export async function syncSource(source: LogSource, cache: LogCache, options: SyncOptions): Promise<SyncSummary> {
|
|
92
|
+
const maxPages = options.maxPages ?? DEFAULT_SYNC_MAX_PAGES
|
|
93
|
+
const pageLimit = options.pageLimit ?? DEFAULT_SYNC_PAGE_LIMIT
|
|
94
|
+
const lookback = options.lookback ?? DEFAULT_SYNC_LOOKBACK
|
|
95
|
+
const id = source.id
|
|
96
|
+
|
|
97
|
+
const startCursor = cache.cursor(id)
|
|
98
|
+
const editsBefore = cache.edits().length
|
|
99
|
+
const gapsBefore = cache.dataset().gaps().length
|
|
100
|
+
|
|
101
|
+
// What the cache held for this source before the run, each row with the
|
|
102
|
+
// source position it was last read from — used to tell a deletion from an
|
|
103
|
+
// untouched row.
|
|
104
|
+
const priorRows = new Map<string, RowOrigin>()
|
|
105
|
+
for (const row of cache.dataset().rows()) {
|
|
106
|
+
if (row.origin?.source === id) priorRows.set(row.identity, row.origin)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let pagesRead = 0
|
|
110
|
+
let rowsStored = 0
|
|
111
|
+
let duplicates = 0
|
|
112
|
+
let quarantined = 0
|
|
113
|
+
let failure: string | null = null
|
|
114
|
+
let completed = false
|
|
115
|
+
let sawGap = false
|
|
116
|
+
|
|
117
|
+
// Identities the source returned this run, and the span of source
|
|
118
|
+
// positions the run re-read — the window within which an absent held
|
|
119
|
+
// identity is a deletion. Never a span of event times: lines written by
|
|
120
|
+
// many machines arrive out of event-time order, so a time window would take
|
|
121
|
+
// in rows the run never re-read.
|
|
122
|
+
const seen = new Set<string>()
|
|
123
|
+
const span = new Map<string, SpanBounds>()
|
|
124
|
+
|
|
125
|
+
const boundaries: Boundary[] = []
|
|
126
|
+
let totalLines = 0
|
|
127
|
+
let cursor: SourceCursor | null = startCursor
|
|
128
|
+
let lastNext: SourceCursor | null = null
|
|
129
|
+
|
|
130
|
+
while (pagesRead < maxPages) {
|
|
131
|
+
boundaries.push({ cursor, linesBefore: totalLines })
|
|
132
|
+
let page: SourcePage
|
|
133
|
+
try {
|
|
134
|
+
page = await source.readPage(cursor, pageLimit)
|
|
135
|
+
} catch (error) {
|
|
136
|
+
failure = error instanceof Error ? error.message : String(error)
|
|
137
|
+
break
|
|
138
|
+
}
|
|
139
|
+
pagesRead++
|
|
140
|
+
|
|
141
|
+
// Store every row and quarantine record on the page before advancing the
|
|
142
|
+
// cursor (O1): a failure between the store and the advance would skip
|
|
143
|
+
// lines forever, so the store comes first and the advance is the last act.
|
|
144
|
+
for (const sourceLine of page.lines) {
|
|
145
|
+
const normalized = normalizeStoredLine(sourceLine.raw, { source: id, position: sourceLine.position })
|
|
146
|
+
const outcome = cache.put(normalized)
|
|
147
|
+
const reread = normalized.type === 'row' && priorRows.has(normalized.row.identity)
|
|
148
|
+
if (normalized.type === 'row') seen.add(normalized.row.identity)
|
|
149
|
+
widenSpan(span, sourceLine.position, reread)
|
|
150
|
+
if (outcome.type === 'row') {
|
|
151
|
+
if (outcome.result === 'inserted') rowsStored++
|
|
152
|
+
else if (outcome.result === 'duplicate') duplicates++
|
|
153
|
+
// 'edited' is counted from the cache's own edit log below.
|
|
154
|
+
} else if (outcome.result === 'inserted') {
|
|
155
|
+
quarantined++
|
|
156
|
+
}
|
|
157
|
+
totalLines++
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
for (const gap of page.gaps) {
|
|
161
|
+
cache.recordGap(gap)
|
|
162
|
+
sawGap = true
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
lastNext = page.next
|
|
166
|
+
cursor = page.next
|
|
167
|
+
if (page.next === null) {
|
|
168
|
+
completed = true
|
|
169
|
+
break
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// A non-null stored cursor that returns nothing is a source whose head has
|
|
174
|
+
// fallen behind what the cache already consumed — a gap, not a silent reset
|
|
175
|
+
// (O4).
|
|
176
|
+
if (failure === null && startCursor !== null && totalLines === 0 && !sawGap && priorRows.size > 0) {
|
|
177
|
+
const headBehind: SourceGap = {
|
|
178
|
+
source: id,
|
|
179
|
+
from: startCursor,
|
|
180
|
+
to: null,
|
|
181
|
+
reason: 'the source head is behind the stored cursor',
|
|
182
|
+
lost: unknownBecause<number>('the source retained nothing from the stored cursor')
|
|
183
|
+
}
|
|
184
|
+
cache.recordGap(headBehind)
|
|
185
|
+
sawGap = true
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const deleted = deriveDeletions({ priorRows, seen, span, sawGap })
|
|
189
|
+
|
|
190
|
+
// Advance the stored cursor to the new look-back anchor only on a clean run:
|
|
191
|
+
// a failure leaves it where it was, so the next run re-reads from the last
|
|
192
|
+
// safe point rather than past the lines it never stored (O2).
|
|
193
|
+
if (failure === null) {
|
|
194
|
+
const anchor = nextAnchor(boundaries, totalLines, lookback)
|
|
195
|
+
if (anchor !== null) cache.setCursor(id, anchor)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const moreAvailable = failure === null && !completed && lastNext !== null
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
source: id,
|
|
202
|
+
ranAt: options.now.toISOString(),
|
|
203
|
+
pagesRead,
|
|
204
|
+
rowsStored,
|
|
205
|
+
duplicates,
|
|
206
|
+
edits: cache.edits().length - editsBefore,
|
|
207
|
+
deletions: deleted.length,
|
|
208
|
+
gaps: cache.dataset().gaps().length - gapsBefore,
|
|
209
|
+
quarantined,
|
|
210
|
+
completed,
|
|
211
|
+
moreAvailable,
|
|
212
|
+
failure,
|
|
213
|
+
deleted
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* A source position split into its stream and its ordinal within that stream:
|
|
219
|
+
* the text before its trailing run of digits, and those digits as a number —
|
|
220
|
+
* a server's sequence number (`"1042"`), a folder stream's byte offset
|
|
221
|
+
* (`"<stream>:live:8192"`). Positions are ordered only within one stream; a
|
|
222
|
+
* position with no trailing ordinal is ordered against nothing, so it never
|
|
223
|
+
* lies inside a re-read span.
|
|
224
|
+
*/
|
|
225
|
+
function splitPosition(position: string): { stream: string; ordinal: number } | null {
|
|
226
|
+
const match = /^(.*?)(\d+)$/.exec(position)
|
|
227
|
+
if (match === null) return null
|
|
228
|
+
const ordinal = Number(match[2])
|
|
229
|
+
if (!Number.isSafeInteger(ordinal)) return null
|
|
230
|
+
return { stream: match[1] as string, ordinal }
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* One stream's re-read span: from the earliest position at which the run
|
|
235
|
+
* re-read a row the cache already held (`null` until it has), to the furthest
|
|
236
|
+
* position the run read at all.
|
|
237
|
+
*/
|
|
238
|
+
type SpanBounds = { from: number | null; to: number }
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Widens the run's re-read span, per stream, to take in one position the
|
|
242
|
+
* source returned. Only a re-read of a row the cache already held can open
|
|
243
|
+
* the span: lines past the stored cursor are new, so a run that re-read
|
|
244
|
+
* nothing before its cursor has an empty span — and a stream whose positions
|
|
245
|
+
* restarted (a rotated folder stream's fresh live file) opens none on its new
|
|
246
|
+
* lines alone.
|
|
247
|
+
*/
|
|
248
|
+
function widenSpan(span: Map<string, SpanBounds>, position: string, reread: boolean): void {
|
|
249
|
+
const split = splitPosition(position)
|
|
250
|
+
if (split === null) return
|
|
251
|
+
const from = reread ? split.ordinal : null
|
|
252
|
+
const bounds = span.get(split.stream)
|
|
253
|
+
if (bounds === undefined) {
|
|
254
|
+
span.set(split.stream, { from, to: split.ordinal })
|
|
255
|
+
return
|
|
256
|
+
}
|
|
257
|
+
if (from !== null && (bounds.from === null || from < bounds.from)) bounds.from = from
|
|
258
|
+
if (split.ordinal > bounds.to) bounds.to = split.ordinal
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* The cached identities the source no longer returns whose own source
|
|
263
|
+
* position lies inside the span of positions the run re-read — its
|
|
264
|
+
* deletions. A run that saw any gap derives none: the source reported what it
|
|
265
|
+
* lost, and a reported loss is a gap, never a deletion (O4). A row whose
|
|
266
|
+
* position lies before or after the span, or in a stream the run re-read
|
|
267
|
+
* nothing of, was not re-read and is left untouched; a run that re-read
|
|
268
|
+
* nothing has an empty span and derives none.
|
|
269
|
+
*/
|
|
270
|
+
function deriveDeletions(input: {
|
|
271
|
+
priorRows: Map<string, RowOrigin>
|
|
272
|
+
seen: Set<string>
|
|
273
|
+
span: Map<string, SpanBounds>
|
|
274
|
+
sawGap: boolean
|
|
275
|
+
}): RowDeletion[] {
|
|
276
|
+
const { priorRows, seen, span, sawGap } = input
|
|
277
|
+
if (sawGap) return []
|
|
278
|
+
const deleted: RowDeletion[] = []
|
|
279
|
+
for (const [identity, origin] of priorRows) {
|
|
280
|
+
if (seen.has(identity)) continue
|
|
281
|
+
const split = splitPosition(origin.position)
|
|
282
|
+
if (split === null) continue
|
|
283
|
+
const bounds = span.get(split.stream)
|
|
284
|
+
if (bounds === undefined || bounds.from === null) continue
|
|
285
|
+
if (split.ordinal < bounds.from || split.ordinal > bounds.to) continue
|
|
286
|
+
deleted.push({ identity, origin })
|
|
287
|
+
}
|
|
288
|
+
return deleted
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* The cursor to store as the next run's look-back anchor: the earliest page
|
|
293
|
+
* boundary that still leaves at most `lookback` lines ahead of it, so the next
|
|
294
|
+
* run re-reads that trailing span and no more (O6). `null` keeps the anchor
|
|
295
|
+
* where it was — at the start of the source — when the whole read fit inside
|
|
296
|
+
* the span.
|
|
297
|
+
*/
|
|
298
|
+
function nextAnchor(boundaries: Boundary[], totalLines: number, lookback: number): SourceCursor | null {
|
|
299
|
+
const floor = totalLines - lookback
|
|
300
|
+
let chosen: Boundary | null = null
|
|
301
|
+
for (const boundary of boundaries) {
|
|
302
|
+
if (boundary.linesBefore >= floor) {
|
|
303
|
+
chosen = boundary
|
|
304
|
+
break
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return chosen?.cursor ?? null
|
|
308
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type { CacheContractCase } from './cache-contract'
|
|
2
|
+
export { cacheContractCases } from './cache-contract'
|
|
3
|
+
export type {
|
|
4
|
+
Dataset,
|
|
5
|
+
LogCache,
|
|
6
|
+
LogSource,
|
|
7
|
+
PutOutcome,
|
|
8
|
+
RowEdit,
|
|
9
|
+
SourceCursor,
|
|
10
|
+
SourceGap,
|
|
11
|
+
SourceLine,
|
|
12
|
+
SourcePage
|
|
13
|
+
} from './contracts'
|
|
14
|
+
export {
|
|
15
|
+
DEFAULT_SYNC_LOOKBACK,
|
|
16
|
+
DEFAULT_SYNC_MAX_PAGES,
|
|
17
|
+
DEFAULT_SYNC_PAGE_LIMIT,
|
|
18
|
+
syncSource
|
|
19
|
+
} from './engine'
|
|
20
|
+
export type { RowDeletion, SyncOptions, SyncSummary } from './engine'
|
|
21
|
+
export type { Measured } from './measured'
|
|
22
|
+
export { known, unknownBecause } from './measured'
|
|
23
|
+
export { createMemoryCache } from './memory-cache'
|
|
24
|
+
export { isLowTrustVersion, normalizeStoredLine } from './normalize'
|
|
25
|
+
export type {
|
|
26
|
+
DatasetRow,
|
|
27
|
+
JsonObject,
|
|
28
|
+
NormalizedLine,
|
|
29
|
+
QuarantineRecord,
|
|
30
|
+
RowOrigin,
|
|
31
|
+
RowTrust,
|
|
32
|
+
UnknownableField
|
|
33
|
+
} from './row'
|
|
34
|
+
export { LOW_TRUST_BELOW_VERSION } from './row'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Measured<T>` — the answer type every Vinaya Log reader returns: a known
|
|
3
|
+
* value, or unknown with the reason it cannot be stated
|
|
4
|
+
* (`apps/cli/specs/log-sync.md`). An unknown is never collapsed into a
|
|
5
|
+
* default such as `0`, `''` or `false`: a question the log cannot answer
|
|
6
|
+
* says so, and says why.
|
|
7
|
+
*/
|
|
8
|
+
export type Measured<T> =
|
|
9
|
+
| { readonly known: true; readonly value: T }
|
|
10
|
+
| { readonly known: false; readonly reason: string }
|
|
11
|
+
|
|
12
|
+
/** A value the log states. */
|
|
13
|
+
export function known<T>(value: T): Measured<T> {
|
|
14
|
+
return { known: true, value }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** A value the log cannot state, and why. */
|
|
18
|
+
export function unknownBecause<T = never>(reason: string): Measured<T> {
|
|
19
|
+
return { known: false, reason }
|
|
20
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An in-memory `LogCache` (`apps/cli/specs/log-sync.md`): no I/O, no clock,
|
|
3
|
+
* so every later reader can be tested against it, and the shared contract
|
|
4
|
+
* cases (`cache-contract.ts`) fix what a durable backend must match.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { Dataset, LogCache, RowEdit, SourceCursor, SourceGap } from './contracts'
|
|
8
|
+
import type { DatasetRow, QuarantineRecord } from './row'
|
|
9
|
+
|
|
10
|
+
function gapKey(gap: SourceGap): string {
|
|
11
|
+
return JSON.stringify([gap.source, gap.from, gap.to, gap.reason])
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function createMemoryCache(): LogCache {
|
|
15
|
+
const rows = new Map<string, DatasetRow>()
|
|
16
|
+
const quarantine = new Map<string, QuarantineRecord>()
|
|
17
|
+
const cursors = new Map<string, SourceCursor>()
|
|
18
|
+
const gaps = new Map<string, SourceGap>()
|
|
19
|
+
const edits = new Map<string, RowEdit>()
|
|
20
|
+
|
|
21
|
+
const dataset: Dataset = {
|
|
22
|
+
rows() {
|
|
23
|
+
return [...rows.values()].sort((a, b) =>
|
|
24
|
+
a.time === b.time ? (a.identity < b.identity ? -1 : a.identity > b.identity ? 1 : 0) : a.time < b.time ? -1 : 1
|
|
25
|
+
)
|
|
26
|
+
},
|
|
27
|
+
gaps() {
|
|
28
|
+
return [...gaps.values()]
|
|
29
|
+
},
|
|
30
|
+
quarantined() {
|
|
31
|
+
return [...quarantine.values()]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
put(line) {
|
|
37
|
+
if (line.type === 'quarantine') {
|
|
38
|
+
const key = line.record.contentHash
|
|
39
|
+
if (quarantine.has(key)) return { type: 'quarantine', result: 'duplicate' }
|
|
40
|
+
quarantine.set(key, line.record)
|
|
41
|
+
return { type: 'quarantine', result: 'inserted' }
|
|
42
|
+
}
|
|
43
|
+
const incoming = line.row
|
|
44
|
+
const kept = rows.get(incoming.identity)
|
|
45
|
+
if (kept === undefined) {
|
|
46
|
+
rows.set(incoming.identity, incoming)
|
|
47
|
+
return { type: 'row', result: 'inserted' }
|
|
48
|
+
}
|
|
49
|
+
if (kept.contentHash === incoming.contentHash) return { type: 'row', result: 'duplicate' }
|
|
50
|
+
const editKey = JSON.stringify([incoming.identity, incoming.contentHash])
|
|
51
|
+
if (!edits.has(editKey)) {
|
|
52
|
+
edits.set(editKey, {
|
|
53
|
+
identity: incoming.identity,
|
|
54
|
+
keptHash: kept.contentHash,
|
|
55
|
+
editedHash: incoming.contentHash,
|
|
56
|
+
origin: incoming.origin
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
return { type: 'row', result: 'edited' }
|
|
60
|
+
},
|
|
61
|
+
cursor(source) {
|
|
62
|
+
return cursors.get(source) ?? null
|
|
63
|
+
},
|
|
64
|
+
setCursor(source, cursor) {
|
|
65
|
+
cursors.set(source, cursor)
|
|
66
|
+
},
|
|
67
|
+
recordGap(gap) {
|
|
68
|
+
const key = gapKey(gap)
|
|
69
|
+
if (!gaps.has(key)) gaps.set(key, gap)
|
|
70
|
+
},
|
|
71
|
+
edits() {
|
|
72
|
+
return [...edits.values()]
|
|
73
|
+
},
|
|
74
|
+
dataset() {
|
|
75
|
+
return dataset
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|