@pome-sh/checks 0.1.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 +17 -0
- package/README.md +88 -0
- package/dist/_types/sdk/check-discrimination.d.ts +7 -0
- package/dist/_types/sdk/check-state-path.d.ts +71 -0
- package/dist/_types/sdk/checks.d.ts +93 -0
- package/dist/_types/sdk/db.d.ts +44 -0
- package/dist/_types/sdk/failure-injection-rules.d.ts +32 -0
- package/dist/_types/twin-github/src/check-kind.d.ts +3 -0
- package/dist/_types/twin-github/src/check-state.d.ts +77 -0
- package/dist/_types/twin-github/src/checks.d.ts +50 -0
- package/dist/_types/twin-github/src/seed.d.ts +92 -0
- package/dist/_types/twin-github/src/types.d.ts +244 -0
- package/dist/_types/twin-gmail/src/check-kind.d.ts +3 -0
- package/dist/_types/twin-gmail/src/check-state.d.ts +138 -0
- package/dist/_types/twin-gmail/src/checks.d.ts +19 -0
- package/dist/_types/twin-gmail/src/faults.d.ts +21 -0
- package/dist/_types/twin-gmail/src/seed.d.ts +247 -0
- package/dist/_types/twin-gmail/src/types.d.ts +150 -0
- package/dist/_types/twin-linear/src/check-kind.d.ts +3 -0
- package/dist/_types/twin-linear/src/check-state.d.ts +123 -0
- package/dist/_types/twin-linear/src/checks.d.ts +29 -0
- package/dist/_types/twin-linear/src/seed.d.ts +166 -0
- package/dist/_types/twin-linear/src/types.d.ts +366 -0
- package/dist/_types/twin-slack/src/check-kind.d.ts +3 -0
- package/dist/_types/twin-slack/src/check-state.d.ts +107 -0
- package/dist/_types/twin-slack/src/checks.d.ts +14 -0
- package/dist/_types/twin-slack/src/seed.d.ts +62 -0
- package/dist/_types/twin-slack/src/types.d.ts +182 -0
- package/dist/_types/twin-stripe/src/check-kind.d.ts +3 -0
- package/dist/_types/twin-stripe/src/check-state.d.ts +107 -0
- package/dist/_types/twin-stripe/src/checks.d.ts +22 -0
- package/dist/_types/twin-stripe/src/seed.d.ts +213 -0
- package/dist/_types/twin-stripe/src/types.d.ts +252 -0
- package/dist/_types/wire/index.d.ts +23 -0
- package/dist/_types/wire/otel/event-schema.d.ts +424 -0
- package/dist/_types/wire/otel/index.d.ts +25 -0
- package/dist/_types/wire/otel/legacy-shim.d.ts +105 -0
- package/dist/_types/wire/otel/map-span.d.ts +64 -0
- package/dist/_types/wire/otel/nano.d.ts +26 -0
- package/dist/_types/wire/otel/project.d.ts +42 -0
- package/dist/_types/wire/otel/semconv.d.ts +57 -0
- package/dist/_types/wire/otel/span-event.d.ts +198 -0
- package/dist/_types/wire/recorder-events.d.ts +526 -0
- package/dist/_types/wire/redaction.d.ts +2 -0
- package/dist/chunk-4WXX5VPA.js +238 -0
- package/dist/chunk-5SJ4PVO5.js +981 -0
- package/dist/chunk-GYFGMULG.js +1138 -0
- package/dist/chunk-IVENH4KX.js +814 -0
- package/dist/chunk-NORTPYDQ.js +1015 -0
- package/dist/chunk-SJ6SVRAA.js +432 -0
- package/dist/chunk-ZXE6LAM3.js +1 -0
- package/dist/dsl.d.ts +11 -0
- package/dist/dsl.js +2 -0
- package/dist/github.d.ts +2 -0
- package/dist/github.js +2 -0
- package/dist/gmail.d.ts +2 -0
- package/dist/gmail.js +2 -0
- package/dist/index.d.ts +163 -0
- package/dist/index.js +24 -0
- package/dist/linear.d.ts +2 -0
- package/dist/linear.js +2 -0
- package/dist/slack.d.ts +2 -0
- package/dist/slack.js +2 -0
- package/dist/stripe.d.ts +2 -0
- package/dist/stripe.js +2 -0
- package/package.json +93 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @pome-sh/checks
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
First release. Carries the grading vocabulary of all five digital twins so a
|
|
6
|
+
publish + pin bump.
|
|
7
|
+
|
|
8
|
+
- The five check arrays (`GITHUB_CHECKS`, `SLACK_CHECKS`, `STRIPE_CHECKS`,
|
|
9
|
+
`GMAIL_CHECKS`, `LINEAR_CHECKS`), keyed as `TWIN_CHECKS`.
|
|
10
|
+
- Each twin's seed schema, `parseSeed` and default seed, prefixed by twin in the
|
|
11
|
+
barrel and under the twin's own names on the per-twin subpaths.
|
|
12
|
+
- The check DSL from `@pome-sh/sdk/checks`, re-exported whole.
|
|
13
|
+
|
|
14
|
+
`@pome-sh/sdk` and the five `@pome-sh/twin-*` packages stay `private: true`;
|
|
15
|
+
their compiled output is inlined here by tsup, so this package declares zero
|
|
16
|
+
`@pome-sh/*` runtime dependencies. `zod` is a peer dependency, never bundled, so
|
|
17
|
+
a consumer's process holds exactly one zod schema identity.
|
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# `@pome-sh/checks`
|
|
2
|
+
|
|
3
|
+
The grading vocabulary of Pome's five digital twins: the **check declarations**,
|
|
4
|
+
the **seed schemas** and the **default seeds**, plus the **check DSL** they are
|
|
5
|
+
written in.
|
|
6
|
+
|
|
7
|
+
Declarations only. No twin server, no database, no HTTP routes, no tool
|
|
8
|
+
dispatch. If you want to *run* a twin, install
|
|
9
|
+
[`@pome-sh/cli`](https://www.npmjs.com/package/@pome-sh/cli) (`npx @pome-sh/cli
|
|
10
|
+
twin start github`) or pull the twin's container image — this package cannot
|
|
11
|
+
start one and does not try to.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @pome-sh/checks zod
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`zod` is a **peer dependency**, and installing your own copy is the point: the
|
|
18
|
+
seed schemas are zod values, and two copies of zod in one process means two
|
|
19
|
+
schema identities — `instanceof` fails and parsed results stop being
|
|
20
|
+
interchangeable. One zod, one identity.
|
|
21
|
+
|
|
22
|
+
## What it is for
|
|
23
|
+
|
|
24
|
+
A Pome task scores an agent with criteria. A `[code]` criterion is graded by a
|
|
25
|
+
**check**: a declared, templated assertion over the twin's final state, its seed
|
|
26
|
+
compared against its final state, or the recorded tape of tool calls. This
|
|
27
|
+
package is where those declarations live, so the thing that grades a run and the
|
|
28
|
+
twin that produced it agree on the vocabulary rather than each keeping its own
|
|
29
|
+
copy of it.
|
|
30
|
+
|
|
31
|
+
## Use
|
|
32
|
+
|
|
33
|
+
Everything under one specifier, with the seed helpers prefixed by twin:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { GITHUB_CHECKS, TWIN_CHECKS, parseGitHubSeed, renderCheck } from "@pome-sh/checks";
|
|
37
|
+
|
|
38
|
+
const check = GITHUB_CHECKS.find((c) => c.id === "github.issue-closed");
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Or one twin at a time, keeping that twin's own names:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { GITHUB_CHECKS, parseSeed, seedSchema } from "@pome-sh/checks/github";
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Subpaths: `./github`, `./slack`, `./stripe`, `./gmail`, `./linear`, and `./dsl`
|
|
48
|
+
for the DSL alone.
|
|
49
|
+
|
|
50
|
+
| Export | What |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `GITHUB_CHECKS`, `SLACK_CHECKS`, `STRIPE_CHECKS`, `GMAIL_CHECKS`, `LINEAR_CHECKS` | Each twin's declarations, in authoring order |
|
|
53
|
+
| `TWIN_CHECKS` | The five arrays keyed by twin id |
|
|
54
|
+
| `CHECKS_TWIN_NAMES`, `ChecksTwinName` | The five twin ids, and the type derived from them |
|
|
55
|
+
| `parse<Twin>Seed`, `<twin>SeedSchema`, `default<Twin>Seed` | Seed contract per twin |
|
|
56
|
+
| `defineCheck`, `parseCheck`, `renderCheck`, `checkPattern`, `checksDigest`, `templateSlots`, `statePath`, `childStatePath` | The DSL |
|
|
57
|
+
| `GitHubCheck`, `GmailCheck`, `LinearCheck`, `SlackCheck`, `StripeCheck` | Each twin's check element type. Every twin declares its own `Check<TArgs>` over its own state, so the barrel prefixes them; the per-twin subpaths keep the plain name `Check` |
|
|
58
|
+
| `CheckDefinition`, `Check…State` types | The generic declaration type, and each twin's state shape — what you want when the twin is a parameter rather than known |
|
|
59
|
+
| `VACUITY_SENTINEL`, `VACUITY_SENTINEL_NUMBER`, `VACUITY_SENTINEL_SNAKE` | The values that mark an assertion no state can satisfy |
|
|
60
|
+
|
|
61
|
+
`applySeed` and `loadSeedFromEnv` are **not** exported. The first writes rows
|
|
62
|
+
into a live SQLite database and the second reads `process.env`; both are twin
|
|
63
|
+
runtime behaviour, not declarations.
|
|
64
|
+
|
|
65
|
+
## Versioning
|
|
66
|
+
|
|
67
|
+
Pre-1.0, so `^0.x` caret semantics apply and **minor plays the major role**:
|
|
68
|
+
|
|
69
|
+
- **Minor (`0.N+1.0`)** — anything a consumer must act on: a check id renamed or
|
|
70
|
+
removed, a template changed, a polarity flipped, a seed schema tightened, an
|
|
71
|
+
`engines` floor bump.
|
|
72
|
+
- **Patch (`0.N.x`)** — additive checks or exports, wording that does not change
|
|
73
|
+
a pattern, internal implementation swaps behind an unchanged surface.
|
|
74
|
+
|
|
75
|
+
A grading vocabulary is a contract in a stricter sense than a normal library: a
|
|
76
|
+
renamed check id does not break a build, it silently stops binding, and a
|
|
77
|
+
criterion that stops binding scores nothing. Treat every id as public.
|
|
78
|
+
|
|
79
|
+
## Where the source lives
|
|
80
|
+
|
|
81
|
+
Nowhere in this package. Every declaration is re-exported from the twin that
|
|
82
|
+
owns it (`packages/twin-*/src/check-*.ts`) and the DSL from
|
|
83
|
+
`packages/sdk/src/checks.ts`, all in
|
|
84
|
+
[pome-sh/digital-twins](https://github.com/pome-sh/digital-twins). Their
|
|
85
|
+
compiled output is inlined here at build time, so this package declares no
|
|
86
|
+
`@pome-sh/*` dependency and there is no second copy to drift.
|
|
87
|
+
|
|
88
|
+
Licence: Apache-2.0.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CheckDefinition, DiscriminationVerdict } from "./checks.js";
|
|
2
|
+
/**
|
|
3
|
+
* Run a check against the worlds it names and say whether they actually
|
|
4
|
+
* discriminate. Pure: no vitest, no ledger — each twin's contract test owns the
|
|
5
|
+
* ledger half, so an empty ledger cannot silently excuse anything.
|
|
6
|
+
*/
|
|
7
|
+
export declare function probeDiscrimination<TState, TArgs extends Record<string, string>>(def: CheckDefinition<TState, TArgs>, args: TArgs): DiscriminationVerdict;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { CheckDefinition } from "./checks.js";
|
|
2
|
+
/**
|
|
3
|
+
* A pointer from the ROOT of the exported tree.
|
|
4
|
+
*
|
|
5
|
+
* Numbers are array indices and strings are object keys, but this function does
|
|
6
|
+
* not enforce that — the tree decides, at resolution time. Passing no segments
|
|
7
|
+
* returns `""`, which RFC 6901 defines as the whole document; a check with
|
|
8
|
+
* nothing narrower to name must OMIT `evidenceStatePaths` rather than cite the
|
|
9
|
+
* root, for the same reason it must omit rather than send `[]`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function statePath(...segments: readonly (string | number)[]): string;
|
|
12
|
+
/**
|
|
13
|
+
* A pointer relative to one a resolver already built.
|
|
14
|
+
*
|
|
15
|
+
* The twins' `resolve*` helpers walk the tree to find an entity and now hand
|
|
16
|
+
* back the pointer they walked; a check appends the field it went on to read.
|
|
17
|
+
* Written as its own function rather than string concatenation at 37 call sites
|
|
18
|
+
* because the escaping has to happen on the appended segments and NOT on the
|
|
19
|
+
* base, which already contains real `/` separators — concatenating by hand is
|
|
20
|
+
* how a `~1` ends up double-encoded.
|
|
21
|
+
*/
|
|
22
|
+
export declare function childStatePath(base: string, ...segments: readonly (string | number)[]): string;
|
|
23
|
+
/**
|
|
24
|
+
* What a pointer addresses in a tree, or `null` when it addresses nothing.
|
|
25
|
+
*
|
|
26
|
+
* `null` is a NORMAL answer and every caller must handle it: the state blob a
|
|
27
|
+
* report renders can be a different export from the one the check read (a
|
|
28
|
+
* re-run, a truncated upload, a snapshot predating a field). A consumer turns
|
|
29
|
+
* `null` into "no affordance", exactly as `findEventIndexForEvidence` turns an
|
|
30
|
+
* unresolvable event id into one.
|
|
31
|
+
*
|
|
32
|
+
* Wrapped in `{ value }` rather than returned bare because `undefined` and
|
|
33
|
+
* `null` are both legal JSON-ish values a tree can hold at a pointer, and a bare
|
|
34
|
+
* return could not tell "the path is absent" from "the path holds null" — the
|
|
35
|
+
* difference between no evidence and evidence that the field is empty.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveStatePath(tree: unknown, pointer: string): {
|
|
38
|
+
value: unknown;
|
|
39
|
+
} | null;
|
|
40
|
+
export type StateCitationArm = "passing" | "failing";
|
|
41
|
+
export type StateCitationVerdict = {
|
|
42
|
+
kind: "cites";
|
|
43
|
+
} | {
|
|
44
|
+
kind: "declined";
|
|
45
|
+
} | {
|
|
46
|
+
kind: "uncited";
|
|
47
|
+
arm: StateCitationArm;
|
|
48
|
+
} | {
|
|
49
|
+
kind: "unresolvable";
|
|
50
|
+
arm: StateCitationArm;
|
|
51
|
+
pointer: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: "malformed";
|
|
54
|
+
arm: StateCitationArm;
|
|
55
|
+
detail: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Does this state-reading check say WHERE it looked, in a form that resolves?
|
|
59
|
+
*
|
|
60
|
+
* Probes BOTH arms, and that is deliberate. A citation present on the passing
|
|
61
|
+
* world and absent on the failing one is worse than no citation at all: its
|
|
62
|
+
* absence starts reading as a verdict class — "no evidence" would come to mean
|
|
63
|
+
* "this one failed" — and the reader has no way to know that is an accident of
|
|
64
|
+
* how the predicate was written. So a check must be able to say where it looked
|
|
65
|
+
* whether or not it liked what it found there.
|
|
66
|
+
*
|
|
67
|
+
* Only meaningful for `final` / `seed+final` checks. A `tape` check cites
|
|
68
|
+
* `evidenceEventIds` instead and is not this gate's business; callers filter on
|
|
69
|
+
* `substrate` before probing.
|
|
70
|
+
*/
|
|
71
|
+
export declare function probeStateCitation<TState, TArgs extends Record<string, string>>(def: CheckDefinition<TState, TArgs>, args: TArgs): StateCitationVerdict;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export type CheckPolarity = "positive" | "negative";
|
|
2
|
+
export declare const VACUITY_SENTINEL = "pome-vacuity-never";
|
|
3
|
+
export declare const VACUITY_SENTINEL_SNAKE = "pome_vacuity_never";
|
|
4
|
+
export declare const VACUITY_SENTINEL_NUMBER = 987654321;
|
|
5
|
+
export type CheckSubstrateKind = "final" | "seed+final" | "tape";
|
|
6
|
+
export interface CheckParamType {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly pattern: string;
|
|
9
|
+
readonly example: string;
|
|
10
|
+
render(value: string): string;
|
|
11
|
+
parse(raw: string): string;
|
|
12
|
+
}
|
|
13
|
+
export declare const repoRef: CheckParamType;
|
|
14
|
+
export declare function oneOf(name: string, values: readonly string[], example?: string): CheckParamType;
|
|
15
|
+
export interface CheckOutcome {
|
|
16
|
+
passed: boolean;
|
|
17
|
+
reason: string;
|
|
18
|
+
status?: "passed" | "failed" | "unmatched" | "skipped";
|
|
19
|
+
evidenceEventIds?: string[];
|
|
20
|
+
evidenceStatePaths?: string[];
|
|
21
|
+
}
|
|
22
|
+
export interface CheckTapeEvent {
|
|
23
|
+
ts?: string | null;
|
|
24
|
+
twin?: string | null;
|
|
25
|
+
method?: string | null;
|
|
26
|
+
path?: string | null;
|
|
27
|
+
request_body?: unknown;
|
|
28
|
+
request_headers?: Record<string, string>;
|
|
29
|
+
status?: number | null;
|
|
30
|
+
response_body?: unknown;
|
|
31
|
+
latency_ms?: number | null;
|
|
32
|
+
fidelity?: string | null;
|
|
33
|
+
state_mutation?: boolean | null;
|
|
34
|
+
error?: string | null;
|
|
35
|
+
tool?: string | null;
|
|
36
|
+
event_id?: string | null;
|
|
37
|
+
}
|
|
38
|
+
export interface CheckSubstrate<TState> {
|
|
39
|
+
seed: TState | null;
|
|
40
|
+
final: TState;
|
|
41
|
+
tape: readonly CheckTapeEvent[] | null;
|
|
42
|
+
}
|
|
43
|
+
export interface CheckWorlds<TState> {
|
|
44
|
+
passing: CheckSubstrate<TState>;
|
|
45
|
+
failing: CheckSubstrate<TState>;
|
|
46
|
+
}
|
|
47
|
+
export type DiscriminationArm = "passing" | "failing" | "degenerate";
|
|
48
|
+
export type DiscriminationVerdict = {
|
|
49
|
+
kind: "discriminates";
|
|
50
|
+
} | {
|
|
51
|
+
kind: "declined";
|
|
52
|
+
} | {
|
|
53
|
+
kind: "broken";
|
|
54
|
+
arm: DiscriminationArm;
|
|
55
|
+
detail: string;
|
|
56
|
+
};
|
|
57
|
+
export interface CheckDefinition<TState, TArgs extends Record<string, string>> {
|
|
58
|
+
id: string;
|
|
59
|
+
description: string;
|
|
60
|
+
template: string;
|
|
61
|
+
params: {
|
|
62
|
+
[K in keyof TArgs]: CheckParamType;
|
|
63
|
+
};
|
|
64
|
+
substrate: CheckSubstrateKind;
|
|
65
|
+
polarity(args: TArgs): CheckPolarity;
|
|
66
|
+
subject?(args: TArgs): string | null;
|
|
67
|
+
vacuityMutant(args: TArgs): TArgs | null;
|
|
68
|
+
discriminatingWorlds(args: TArgs): CheckWorlds<TState> | null;
|
|
69
|
+
evaluate(args: TArgs, substrate: CheckSubstrate<TState>): CheckOutcome;
|
|
70
|
+
}
|
|
71
|
+
export declare function templateSlots(template: string): {
|
|
72
|
+
literals: string[];
|
|
73
|
+
params: string[];
|
|
74
|
+
};
|
|
75
|
+
type ArgsOfParams<TParams extends Record<string, CheckParamType>> = {
|
|
76
|
+
[K in keyof TParams]: string;
|
|
77
|
+
};
|
|
78
|
+
export declare function defineCheck<TState, TParams extends Record<string, CheckParamType>>(def: Omit<CheckDefinition<TState, ArgsOfParams<TParams>>, "params"> & {
|
|
79
|
+
params: TParams;
|
|
80
|
+
}): CheckDefinition<TState, ArgsOfParams<TParams>>;
|
|
81
|
+
export declare function renderCheck<TState, TArgs extends Record<string, string>>(def: CheckDefinition<TState, TArgs>, args: TArgs): string;
|
|
82
|
+
export interface CheckBindingShape {
|
|
83
|
+
readonly id: string;
|
|
84
|
+
readonly template: string;
|
|
85
|
+
readonly substrate: CheckSubstrateKind;
|
|
86
|
+
readonly params: Readonly<Record<string, CheckParamType>>;
|
|
87
|
+
}
|
|
88
|
+
export declare function checkPattern(def: CheckBindingShape): RegExp;
|
|
89
|
+
export declare function checksDigest(defs: readonly CheckBindingShape[]): string;
|
|
90
|
+
export declare function checkNearMissPattern(def: CheckBindingShape): RegExp;
|
|
91
|
+
export declare function parseCheck<TState, TArgs extends Record<string, string>>(def: CheckDefinition<TState, TArgs>, text: string): TArgs | null;
|
|
92
|
+
export { probeDiscrimination } from "./check-discrimination.js";
|
|
93
|
+
export { statePath, childStatePath, resolveStatePath, probeStateCitation, type StateCitationArm, type StateCitationVerdict, } from "./check-state-path.js";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mutation outcome — the shape both better-sqlite3's `RunResult` and
|
|
3
|
+
* node:sqlite's `StatementResultingChanges` return; `changes` is coerced to
|
|
4
|
+
* number, `lastInsertRowid` may be a bigint for rowids beyond safe-integer
|
|
5
|
+
* range.
|
|
6
|
+
*/
|
|
7
|
+
export interface TwinRunResult {
|
|
8
|
+
changes: number;
|
|
9
|
+
lastInsertRowid: number | bigint;
|
|
10
|
+
}
|
|
11
|
+
export interface TwinStatement {
|
|
12
|
+
run(...params: unknown[]): TwinRunResult;
|
|
13
|
+
get(...params: unknown[]): unknown;
|
|
14
|
+
all(...params: unknown[]): unknown[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A wrapped transaction function (better-sqlite3's shape). The `.immediate`
|
|
18
|
+
* variant takes the write lock up front (BEGIN IMMEDIATE) — github's domain
|
|
19
|
+
* runs its mutations under it.
|
|
20
|
+
*/
|
|
21
|
+
export type TwinTransaction<F extends (...args: never[]) => unknown> = F & {
|
|
22
|
+
immediate: F;
|
|
23
|
+
};
|
|
24
|
+
export interface TwinDatabase {
|
|
25
|
+
prepare(sql: string): TwinStatement;
|
|
26
|
+
exec(sql: string): void;
|
|
27
|
+
pragma(statement: string, options?: {
|
|
28
|
+
simple?: boolean;
|
|
29
|
+
}): unknown;
|
|
30
|
+
/** Same shape as better-sqlite3: wraps `fn` so calling it runs atomically. */
|
|
31
|
+
transaction<F extends (...args: never[]) => unknown>(fn: F): TwinTransaction<F>;
|
|
32
|
+
close(): void;
|
|
33
|
+
}
|
|
34
|
+
export interface OpenTwinDatabaseOptions {
|
|
35
|
+
/** Schema migration hook, run once right after the pragmas are applied. */
|
|
36
|
+
migrate?: (db: TwinDatabase) => void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Open a twin database with the pome pragma set applied:
|
|
40
|
+
* `busy_timeout = 5000`, `journal_mode = WAL` (file-backed), and
|
|
41
|
+
* `foreign_keys = ON` — the exact pragmas every twin's hand-rolled db.ts
|
|
42
|
+
* applied before F-681 centralized them.
|
|
43
|
+
*/
|
|
44
|
+
export declare function openTwinDatabase(path?: string, options?: OpenTwinDatabaseOptions): TwinDatabase;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const FAILURE_INJECTION_OVERRIDE_KEY = "failureInjectionOverride";
|
|
3
|
+
export type FailureInjectionOverride = {
|
|
4
|
+
status: number;
|
|
5
|
+
body: unknown;
|
|
6
|
+
};
|
|
7
|
+
export type FailureInjectionMode = "before_handler" | "after_handler";
|
|
8
|
+
export type FailureInjectionRule = {
|
|
9
|
+
method: string;
|
|
10
|
+
path: string;
|
|
11
|
+
attempt: number;
|
|
12
|
+
mode: FailureInjectionMode;
|
|
13
|
+
status: number;
|
|
14
|
+
body: unknown;
|
|
15
|
+
};
|
|
16
|
+
export declare const failureInjectionRuleSchema: z.ZodObject<{
|
|
17
|
+
method: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
18
|
+
path: z.ZodString;
|
|
19
|
+
attempt: z.ZodNumber;
|
|
20
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
21
|
+
before_handler: "before_handler";
|
|
22
|
+
after_handler: "after_handler";
|
|
23
|
+
}>>;
|
|
24
|
+
status: z.ZodNumber;
|
|
25
|
+
body: z.ZodUnknown;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type FailureInjectionStore = {
|
|
28
|
+
setRules(rules: FailureInjectionRule[]): void;
|
|
29
|
+
clear(): void;
|
|
30
|
+
matchAndConsume(accountId: string, method: string, path: string): FailureInjectionRule | null;
|
|
31
|
+
};
|
|
32
|
+
export declare function createFailureInjectionStore(): FailureInjectionStore;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type CheckOutcome } from "../../sdk/checks.js";
|
|
2
|
+
export interface GitHubCheckStateLabel {
|
|
3
|
+
name?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface GitHubCheckStateComment {
|
|
6
|
+
body?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface GitHubCheckStateIssue {
|
|
9
|
+
number?: number;
|
|
10
|
+
state?: string | null;
|
|
11
|
+
labels?: GitHubCheckStateLabel[] | null;
|
|
12
|
+
assignees?: string[] | null;
|
|
13
|
+
comments?: GitHubCheckStateComment[] | null;
|
|
14
|
+
}
|
|
15
|
+
export interface GitHubCheckStateReview {
|
|
16
|
+
state?: string | null;
|
|
17
|
+
}
|
|
18
|
+
export interface GitHubCheckStatePullRequest {
|
|
19
|
+
number?: number;
|
|
20
|
+
state?: string | null;
|
|
21
|
+
merged?: number | boolean | null;
|
|
22
|
+
reviews?: GitHubCheckStateReview[] | null;
|
|
23
|
+
comments?: GitHubCheckStateComment[] | null;
|
|
24
|
+
}
|
|
25
|
+
export interface GitHubCheckStateCommitStatus {
|
|
26
|
+
context?: string;
|
|
27
|
+
state?: string | null;
|
|
28
|
+
}
|
|
29
|
+
export interface GitHubCheckStateFile {
|
|
30
|
+
path?: string;
|
|
31
|
+
branch?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface GitHubCheckStateRepo {
|
|
34
|
+
owner?: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
full_name?: string;
|
|
37
|
+
labels?: GitHubCheckStateLabel[] | null;
|
|
38
|
+
files?: GitHubCheckStateFile[] | null;
|
|
39
|
+
issues?: GitHubCheckStateIssue[] | null;
|
|
40
|
+
pull_requests?: GitHubCheckStatePullRequest[] | null;
|
|
41
|
+
commit_statuses?: GitHubCheckStateCommitStatus[] | null;
|
|
42
|
+
}
|
|
43
|
+
export interface GitHubCheckState {
|
|
44
|
+
repositories?: GitHubCheckStateRepo[] | null;
|
|
45
|
+
}
|
|
46
|
+
export declare function findRepo(state: GitHubCheckState, ref: string): {
|
|
47
|
+
repo: GitHubCheckStateRepo;
|
|
48
|
+
index: number;
|
|
49
|
+
} | null;
|
|
50
|
+
export declare function issueNumbers(repo: GitHubCheckStateRepo): Set<number>;
|
|
51
|
+
export declare function labelNames(repo: GitHubCheckStateRepo): Set<string>;
|
|
52
|
+
export type Resolved<T> = {
|
|
53
|
+
found: T;
|
|
54
|
+
path: string;
|
|
55
|
+
} | {
|
|
56
|
+
missing: string;
|
|
57
|
+
searched?: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The `failed` outcome a missing entity produces, citing where the lookup
|
|
61
|
+
* looked.
|
|
62
|
+
*
|
|
63
|
+
* One function rather than a conditional spread at every `if ("missing" in …)`
|
|
64
|
+
* site, because the rule it encodes — cite the searched collection, cite nothing
|
|
65
|
+
* when there was none — is one rule, and twelve hand-written copies of it is
|
|
66
|
+
* twelve chances for one to quietly drop the citation.
|
|
67
|
+
*/
|
|
68
|
+
export declare function missOutcome(miss: {
|
|
69
|
+
missing: string;
|
|
70
|
+
searched?: string;
|
|
71
|
+
}): CheckOutcome;
|
|
72
|
+
export declare function resolveRepo(state: GitHubCheckState, ref: string, where: string): Resolved<GitHubCheckStateRepo>;
|
|
73
|
+
export declare function resolveIssue(state: GitHubCheckState, ref: string, number: string): Resolved<GitHubCheckStateIssue>;
|
|
74
|
+
export declare function resolvePullRequest(state: GitHubCheckState, ref: string, number: string): Resolved<GitHubCheckStatePullRequest>;
|
|
75
|
+
export declare function isMerged(pull: GitHubCheckStatePullRequest): boolean;
|
|
76
|
+
export declare function sameLabel(a: string, b: string): boolean;
|
|
77
|
+
export declare function appliedLabelNames(issue: GitHubCheckStateIssue): string[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type { Check } from "./check-kind.js";
|
|
2
|
+
export type { GitHubCheckState, GitHubCheckStateComment, GitHubCheckStateCommitStatus, GitHubCheckStateFile, GitHubCheckStateIssue, GitHubCheckStateLabel, GitHubCheckStatePullRequest, GitHubCheckStateRepo, GitHubCheckStateReview, } from "./check-state.js";
|
|
3
|
+
export declare const GITHUB_CHECKS: readonly [import("./check-kind.js").Check<{
|
|
4
|
+
issue: string;
|
|
5
|
+
repo: string;
|
|
6
|
+
}>, import("./check-kind.js").Check<{
|
|
7
|
+
issue: string;
|
|
8
|
+
repo: string;
|
|
9
|
+
state: string;
|
|
10
|
+
}>, import("./check-kind.js").Check<{
|
|
11
|
+
issue: string;
|
|
12
|
+
repo: string;
|
|
13
|
+
label: string;
|
|
14
|
+
}>, import("./check-kind.js").Check<{
|
|
15
|
+
issue: string;
|
|
16
|
+
repo: string;
|
|
17
|
+
label: string;
|
|
18
|
+
}>, import("./check-kind.js").Check<{
|
|
19
|
+
issue: string;
|
|
20
|
+
repo: string;
|
|
21
|
+
login: string;
|
|
22
|
+
}>, import("./check-kind.js").Check<{
|
|
23
|
+
needle: string;
|
|
24
|
+
issue: string;
|
|
25
|
+
repo: string;
|
|
26
|
+
}>, import("./check-kind.js").Check<{
|
|
27
|
+
repo: string;
|
|
28
|
+
}>, import("./check-kind.js").Check<{
|
|
29
|
+
repo: string;
|
|
30
|
+
}>, import("./check-kind.js").Check<{
|
|
31
|
+
pr: string;
|
|
32
|
+
repo: string;
|
|
33
|
+
state: string;
|
|
34
|
+
}>, import("./check-kind.js").Check<{
|
|
35
|
+
pr: string;
|
|
36
|
+
repo: string;
|
|
37
|
+
}>, import("./check-kind.js").Check<{
|
|
38
|
+
review: string;
|
|
39
|
+
pr: string;
|
|
40
|
+
repo: string;
|
|
41
|
+
}>, import("./check-kind.js").Check<{
|
|
42
|
+
path: string;
|
|
43
|
+
repo: string;
|
|
44
|
+
}>, import("./check-kind.js").Check<{
|
|
45
|
+
context: string;
|
|
46
|
+
repo: string;
|
|
47
|
+
state: string;
|
|
48
|
+
}>, import("./check-kind.js").Check<Record<string, never>>, import("./check-kind.js").Check<{
|
|
49
|
+
tool: string;
|
|
50
|
+
}>];
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { GitHubStateSeed } from "./types.js";
|
|
3
|
+
export declare const seedSchema: z.ZodObject<{
|
|
4
|
+
users: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
5
|
+
login: z.ZodString;
|
|
6
|
+
type: z.ZodDefault<z.ZodEnum<{
|
|
7
|
+
User: "User";
|
|
8
|
+
Organization: "Organization";
|
|
9
|
+
}>>;
|
|
10
|
+
name: z.ZodDefault<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>>>;
|
|
12
|
+
repositories: z.ZodArray<z.ZodObject<{
|
|
13
|
+
owner: z.ZodString;
|
|
14
|
+
name: z.ZodString;
|
|
15
|
+
description: z.ZodDefault<z.ZodString>;
|
|
16
|
+
private: z.ZodDefault<z.ZodBoolean>;
|
|
17
|
+
default_branch: z.ZodDefault<z.ZodString>;
|
|
18
|
+
collaborators: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
19
|
+
labels: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
color: z.ZodDefault<z.ZodString>;
|
|
22
|
+
description: z.ZodDefault<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>>>;
|
|
24
|
+
files: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
25
|
+
path: z.ZodString;
|
|
26
|
+
content: z.ZodString;
|
|
27
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>>>;
|
|
29
|
+
issues: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
30
|
+
number: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
title: z.ZodString;
|
|
32
|
+
body: z.ZodDefault<z.ZodString>;
|
|
33
|
+
state: z.ZodDefault<z.ZodEnum<{
|
|
34
|
+
open: "open";
|
|
35
|
+
closed: "closed";
|
|
36
|
+
}>>;
|
|
37
|
+
labels: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
38
|
+
assignees: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
39
|
+
}, z.core.$strip>>>;
|
|
40
|
+
pull_requests: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
41
|
+
number: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
title: z.ZodString;
|
|
43
|
+
body: z.ZodDefault<z.ZodString>;
|
|
44
|
+
head: z.ZodString;
|
|
45
|
+
base: z.ZodDefault<z.ZodString>;
|
|
46
|
+
state: z.ZodDefault<z.ZodEnum<{
|
|
47
|
+
open: "open";
|
|
48
|
+
closed: "closed";
|
|
49
|
+
}>>;
|
|
50
|
+
author: z.ZodOptional<z.ZodString>;
|
|
51
|
+
reviews: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
52
|
+
author: z.ZodString;
|
|
53
|
+
state: z.ZodDefault<z.ZodEnum<{
|
|
54
|
+
APPROVED: "APPROVED";
|
|
55
|
+
CHANGES_REQUESTED: "CHANGES_REQUESTED";
|
|
56
|
+
COMMENTED: "COMMENTED";
|
|
57
|
+
}>>;
|
|
58
|
+
body: z.ZodDefault<z.ZodString>;
|
|
59
|
+
}, z.core.$strip>>>;
|
|
60
|
+
statuses: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
61
|
+
context: z.ZodDefault<z.ZodString>;
|
|
62
|
+
state: z.ZodDefault<z.ZodEnum<{
|
|
63
|
+
error: "error";
|
|
64
|
+
failure: "failure";
|
|
65
|
+
pending: "pending";
|
|
66
|
+
success: "success";
|
|
67
|
+
}>>;
|
|
68
|
+
description: z.ZodDefault<z.ZodString>;
|
|
69
|
+
}, z.core.$strip>>>;
|
|
70
|
+
}, z.core.$strip>>>;
|
|
71
|
+
}, z.core.$strip>>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
export type ParsedGitHubStateSeed = z.output<typeof seedSchema>;
|
|
74
|
+
export declare function parseSeed(input: unknown): ParsedGitHubStateSeed;
|
|
75
|
+
/**
|
|
76
|
+
* Boot-time seed loader: prefer `POME_SEED_JSON` env (set by the cloud
|
|
77
|
+
* control-plane from the CLI-supplied scenario seed; see FDRS-353) and
|
|
78
|
+
* fall back to `defaultSeedState()` when the env is absent. Throws on
|
|
79
|
+
* malformed JSON or schema-invalid seed, so a misconfigured cloud
|
|
80
|
+
* deploy fails the twin server's healthz instead of silently booting
|
|
81
|
+
* with the default world.
|
|
82
|
+
*/
|
|
83
|
+
/**
|
|
84
|
+
* `Record<string, string | undefined>` rather than `NodeJS.ProcessEnv`, which is
|
|
85
|
+
* structurally the same thing but an AMBIENT global. This signature is vendored
|
|
86
|
+
* into `@pome-sh/checks`'s published declarations, and an ambient reference there
|
|
87
|
+
* makes a consumer's `tsc` fail with TS2503 unless they happen to have
|
|
88
|
+
* `@types/node` installed — a dependency this package should not impose to
|
|
89
|
+
* describe a plain string map.
|
|
90
|
+
*/
|
|
91
|
+
export declare function loadSeedFromEnv(env?: Record<string, string | undefined>): ParsedGitHubStateSeed;
|
|
92
|
+
export declare function defaultSeedState(): GitHubStateSeed;
|