@zhin.js/harness 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +8 -2
- package/lib/authority.d.ts +37 -0
- package/lib/authority.js +161 -0
- package/lib/budget.d.ts +48 -0
- package/lib/budget.js +154 -0
- package/lib/contracts.d.ts +643 -0
- package/lib/contracts.js +86 -0
- package/lib/guard.d.ts +25 -0
- package/lib/guard.js +213 -0
- package/lib/harness.d.ts +197 -0
- package/lib/harness.js +731 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +8 -0
- package/lib/journal.d.ts +86 -0
- package/lib/journal.js +712 -0
- package/lib/mailbox.d.ts +6 -0
- package/lib/mailbox.js +422 -0
- package/lib/policies/admission.d.ts +48 -0
- package/lib/policies/admission.js +118 -0
- package/lib/policies/groups.d.ts +47 -0
- package/lib/policies/groups.js +91 -0
- package/lib/policies/index.d.ts +5 -0
- package/lib/policies/index.js +5 -0
- package/lib/policies/live.d.ts +28 -0
- package/lib/policies/live.js +44 -0
- package/lib/policies/markers.d.ts +23 -0
- package/lib/policies/markers.js +42 -0
- package/lib/policies/merge.d.ts +49 -0
- package/lib/policies/merge.js +101 -0
- package/package.json +39 -3
- package/src/authority.ts +194 -0
- package/src/budget.ts +181 -0
- package/src/contracts.ts +762 -0
- package/src/guard.ts +305 -0
- package/src/harness.ts +975 -0
- package/src/index.ts +8 -0
- package/src/journal.ts +833 -0
- package/src/mailbox.ts +467 -0
- package/src/policies/admission.ts +164 -0
- package/src/policies/groups.ts +137 -0
- package/src/policies/index.ts +5 -0
- package/src/policies/live.ts +68 -0
- package/src/policies/markers.ts +58 -0
- package/src/policies/merge.ts +121 -0
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
package/lib/journal.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engagement journal implementations (ADR 0048 §3.5).
|
|
3
|
+
*
|
|
4
|
+
* Depends on `contracts.ts` only. The database store targets a narrow query
|
|
5
|
+
* interface (`EngagementJournalDatabase`) that `@zhin.js/database` satisfies,
|
|
6
|
+
* so the host registers `ENGAGEMENT_EVENT_MODEL` and passes its database in.
|
|
7
|
+
*/
|
|
8
|
+
import { type BoardEntry, type BoardReadFilter, type EngagementEvent, type EngagementId, type EngagementJournal, type EngagementSummary, type JournalRecord, type JournalRetention } from './contracts.js';
|
|
9
|
+
export interface JournalOptions {
|
|
10
|
+
readonly retention?: JournalRetention;
|
|
11
|
+
}
|
|
12
|
+
type AppendInput = Omit<EngagementEvent, 'seq'>;
|
|
13
|
+
/** Reconstructs blackboard entries from a sequence of journal records. */
|
|
14
|
+
export declare function reconstructBoardFromEvents(records: readonly JournalRecord[], filter?: BoardReadFilter): readonly BoardEntry[];
|
|
15
|
+
/** Pure helper that summarizes an engagement's journal records into a collaboration graph and metrics. */
|
|
16
|
+
export declare function summarizeEngagementEvents(engagementId: EngagementId, records: readonly JournalRecord[]): EngagementSummary;
|
|
17
|
+
export declare class InMemoryEngagementJournal implements EngagementJournal {
|
|
18
|
+
#private;
|
|
19
|
+
constructor(options?: JournalOptions);
|
|
20
|
+
append(event: AppendInput): Promise<EngagementEvent>;
|
|
21
|
+
read(engagementId: EngagementId): Promise<readonly EngagementEvent[]>;
|
|
22
|
+
prune(now: number): Promise<number>;
|
|
23
|
+
listEngagements(limit?: number): Promise<readonly EngagementId[]>;
|
|
24
|
+
summarize(engagementId: EngagementId): Promise<EngagementSummary | undefined>;
|
|
25
|
+
compact(engagementId: EngagementId): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export declare const ENGAGEMENT_EVENTS_TABLE = "engagement_events";
|
|
28
|
+
/**
|
|
29
|
+
* Table schema. `id` (`<engagement_id>:<seq>`) is the primary key and therefore
|
|
30
|
+
* the unique (engagement_id, seq) constraint: `@zhin.js/database` column
|
|
31
|
+
* definitions have no composite unique key.
|
|
32
|
+
*/
|
|
33
|
+
export declare const ENGAGEMENT_EVENT_MODEL: {
|
|
34
|
+
id: {
|
|
35
|
+
type: "text";
|
|
36
|
+
primary: boolean;
|
|
37
|
+
nullable: boolean;
|
|
38
|
+
};
|
|
39
|
+
engagement_id: {
|
|
40
|
+
type: "text";
|
|
41
|
+
nullable: boolean;
|
|
42
|
+
};
|
|
43
|
+
seq: {
|
|
44
|
+
type: "integer";
|
|
45
|
+
nullable: boolean;
|
|
46
|
+
};
|
|
47
|
+
at: {
|
|
48
|
+
type: "bigint";
|
|
49
|
+
nullable: boolean;
|
|
50
|
+
};
|
|
51
|
+
type: {
|
|
52
|
+
type: "text";
|
|
53
|
+
nullable: boolean;
|
|
54
|
+
};
|
|
55
|
+
data: {
|
|
56
|
+
type: "text";
|
|
57
|
+
nullable: boolean;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/** Registers the table on a `@zhin.js/database` instance. */
|
|
61
|
+
export declare function defineEngagementEventModel(database: Readonly<{
|
|
62
|
+
define(name: string, definition: unknown): unknown;
|
|
63
|
+
}>): void;
|
|
64
|
+
/** The slice of `@zhin.js/database`'s `Database` the journal uses. */
|
|
65
|
+
export interface EngagementJournalDatabase {
|
|
66
|
+
select(table: string, fields: string[]): {
|
|
67
|
+
where(condition: Record<string, unknown>): PromiseLike<Record<string, unknown>[]>;
|
|
68
|
+
};
|
|
69
|
+
insert(table: string, row: Record<string, unknown>): PromiseLike<unknown>;
|
|
70
|
+
delete(table: string, condition: Record<string, unknown>): PromiseLike<unknown>;
|
|
71
|
+
}
|
|
72
|
+
export interface DatabaseJournalOptions extends JournalOptions {
|
|
73
|
+
/** Bounded retries when another process wins a seq (default 5). */
|
|
74
|
+
readonly maxConflictRetries?: number;
|
|
75
|
+
}
|
|
76
|
+
export declare class DatabaseEngagementJournal implements EngagementJournal {
|
|
77
|
+
#private;
|
|
78
|
+
constructor(database: EngagementJournalDatabase, options?: DatabaseJournalOptions);
|
|
79
|
+
append(event: AppendInput): Promise<EngagementEvent>;
|
|
80
|
+
read(engagementId: EngagementId): Promise<readonly EngagementEvent[]>;
|
|
81
|
+
prune(now: number): Promise<number>;
|
|
82
|
+
listEngagements(limit?: number): Promise<readonly EngagementId[]>;
|
|
83
|
+
summarize(engagementId: EngagementId): Promise<EngagementSummary | undefined>;
|
|
84
|
+
compact(engagementId: EngagementId): Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
export {};
|