@groundnuty/macf-core 0.2.44 → 0.2.46

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.
Files changed (47) hide show
  1. package/dist/discovery.d.ts +59 -0
  2. package/dist/discovery.d.ts.map +1 -0
  3. package/dist/discovery.js +103 -0
  4. package/dist/discovery.js.map +1 -0
  5. package/dist/fleet-driver.d.ts +135 -0
  6. package/dist/fleet-driver.d.ts.map +1 -0
  7. package/dist/fleet-driver.js +44 -0
  8. package/dist/fleet-driver.js.map +1 -0
  9. package/dist/fleet-reconcile.d.ts +180 -0
  10. package/dist/fleet-reconcile.d.ts.map +1 -0
  11. package/dist/fleet-reconcile.js +249 -0
  12. package/dist/fleet-reconcile.js.map +1 -0
  13. package/dist/fleet-upgrade.d.ts +171 -0
  14. package/dist/fleet-upgrade.d.ts.map +1 -0
  15. package/dist/fleet-upgrade.js +177 -0
  16. package/dist/fleet-upgrade.js.map +1 -0
  17. package/dist/guest.d.ts +100 -0
  18. package/dist/guest.d.ts.map +1 -0
  19. package/dist/guest.js +120 -0
  20. package/dist/guest.js.map +1 -0
  21. package/dist/index.d.ts +8 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +8 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/norm.d.ts +2 -2
  26. package/dist/prompt-responses.d.ts +208 -0
  27. package/dist/prompt-responses.d.ts.map +1 -0
  28. package/dist/prompt-responses.js +274 -0
  29. package/dist/prompt-responses.js.map +1 -0
  30. package/dist/registry/local-client.d.ts.map +1 -1
  31. package/dist/registry/local-client.js +15 -9
  32. package/dist/registry/local-client.js.map +1 -1
  33. package/dist/registry/registry.d.ts.map +1 -1
  34. package/dist/registry/registry.js +91 -27
  35. package/dist/registry/registry.js.map +1 -1
  36. package/dist/registry/types.d.ts +57 -12
  37. package/dist/registry/types.d.ts.map +1 -1
  38. package/dist/registry/types.js.map +1 -1
  39. package/dist/stall-signatures.d.ts +139 -0
  40. package/dist/stall-signatures.d.ts.map +1 -0
  41. package/dist/stall-signatures.js +219 -0
  42. package/dist/stall-signatures.js.map +1 -0
  43. package/dist/verify-green.d.ts +62 -0
  44. package/dist/verify-green.d.ts.map +1 -0
  45. package/dist/verify-green.js +53 -0
  46. package/dist/verify-green.js.map +1 -0
  47. package/package.json +1 -1
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Cross-fleet GUEST bindings — DR-036 Amendment A (groundnuty/macf#679).
3
+ *
4
+ * A consumer fleet depends on a specialist agent that lives in ANOTHER fleet
5
+ * (the worked example: `icsoc-2026` depends on `ppam-2026/code-agent`, the
6
+ * `onedata-mcp` specialist). The consumer carries a LOCAL, consumer-side
7
+ * "guest" binding naming that external agent + the perspectival role it plays
8
+ * from the consumer's viewpoint. The external agent neither sees nor agrees to
9
+ * it — topology-autonomy is preserved (a consumer only ANNOTATES its own view;
10
+ * it cannot impose membership on a peer).
11
+ *
12
+ * The load-bearing invariant (DR-036 Amendment A): **visibility is split from
13
+ * supervision**. A guest MAY be SHOWN in the consumer's `macf fleet status` /
14
+ * `/macf-peers`, clearly marked external + unsupervised — but it is NEVER a
15
+ * supervised member (never owned by the consumer's registry, never under its
16
+ * DR-031 liveness / reconciliation / restart / prune machinery). Only the
17
+ * no-supervision half is mandatory; the visibility half is the new capability.
18
+ *
19
+ * The binding lives in the fleet-scope config `.github/macf-fleet.json`
20
+ * (macf#614 — the same file that carries the `routing_fleet` opt-OUT marker),
21
+ * so this schema describes the WHOLE file, not just the guests array. The
22
+ * `routing_fleet` key is preserved here so the one config file has one schema.
23
+ */
24
+ import { z } from 'zod';
25
+ import { MacfError } from './errors.js';
26
+ /**
27
+ * How the consumer reaches the guest (DR-036 §two enabler paths, Amendment A):
28
+ * - `route` — the guest is App-scoped + GitHub-@mention-routable
29
+ * (paths a/b). Cross-reachable → a live `/health` probe is
30
+ * meaningful; the guest shows its live online/offline state.
31
+ * - `operator-relay` — the guest is a local-mode / private-mesh agent (path c):
32
+ * no App, a local-CA mTLS mesh on a host the consumer can't
33
+ * reach. A cross-fleet `/health` probe is NOT meaningful (it
34
+ * would hit the consumer's own localhost or fail), so the
35
+ * guest renders registry-derived state ONLY — never "down".
36
+ */
37
+ export declare const GUEST_DELEGATE_VIA: readonly ["route", "operator-relay"];
38
+ export declare const GuestDelegateViaSchema: z.ZodEnum<{
39
+ route: "route";
40
+ "operator-relay": "operator-relay";
41
+ }>;
42
+ export type GuestDelegateVia = z.infer<typeof GuestDelegateViaSchema>;
43
+ /**
44
+ * One consumer-side guest binding (DR-036 Amendment A). Consumer-LOCAL: the
45
+ * external agent is unaware. Perspectival — `local_role` is the consumer's
46
+ * vocabulary for the role the guest plays here, NOT a role the guest adopts.
47
+ */
48
+ export declare const GuestBindingSchema: z.ZodObject<{
49
+ agent: z.ZodString;
50
+ local_role: z.ZodString;
51
+ purpose: z.ZodString;
52
+ delegate_via: z.ZodEnum<{
53
+ route: "route";
54
+ "operator-relay": "operator-relay";
55
+ }>;
56
+ until: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
57
+ }, z.core.$strip>;
58
+ export type GuestBinding = z.infer<typeof GuestBindingSchema>;
59
+ /**
60
+ * The whole `.github/macf-fleet.json` fleet-scope config (macf#614 + #679).
61
+ * Non-strict: unknown keys are stripped, so a future additive key doesn't
62
+ * reject the file. `guests` defaults to `[]` so a config with no guests (or the
63
+ * plain `routing_fleet`-only marker) parses to an empty guest list.
64
+ */
65
+ export declare const MacfFleetConfigSchema: z.ZodObject<{
66
+ routing_fleet: z.ZodOptional<z.ZodBoolean>;
67
+ guests: z.ZodDefault<z.ZodArray<z.ZodObject<{
68
+ agent: z.ZodString;
69
+ local_role: z.ZodString;
70
+ purpose: z.ZodString;
71
+ delegate_via: z.ZodEnum<{
72
+ route: "route";
73
+ "operator-relay": "operator-relay";
74
+ }>;
75
+ until: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
76
+ }, z.core.$strip>>>;
77
+ }, z.core.$strip>;
78
+ export type MacfFleetConfig = z.infer<typeof MacfFleetConfigSchema>;
79
+ /** Raised when a `.github/macf-fleet.json` value violates the schema. */
80
+ export declare class GuestConfigError extends MacfError {
81
+ constructor(message: string);
82
+ }
83
+ /**
84
+ * Parse + validate a raw `.github/macf-fleet.json` value. Throws
85
+ * `GuestConfigError` (with the first Zod issue path + message) on any schema
86
+ * violation so a malformed binding fails LOUD rather than silently dropping a
87
+ * guest. Callers that must DEGRADE instead (a config read on a hot path) can use
88
+ * `MacfFleetConfigSchema.safeParse` directly and fall back to an empty config.
89
+ */
90
+ export declare function parseMacfFleetConfig(raw: unknown): MacfFleetConfig;
91
+ /**
92
+ * Split a `<home-project>/<name>` guest ref into its two segments. Assumes the
93
+ * ref already passed `GuestBindingSchema` (exactly one `/`); throws
94
+ * `GuestConfigError` defensively for a malformed ref reaching this path.
95
+ */
96
+ export declare function parseGuestAgentRef(agent: string): {
97
+ readonly homeProject: string;
98
+ readonly name: string;
99
+ };
100
+ //# sourceMappingURL=guest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guest.d.ts","sourceRoot":"","sources":["../src/guest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,sCAAuC,CAAC;AACvE,eAAO,MAAM,sBAAsB;;;EAA6B,CAAC;AACjE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAUtE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;iBAgB7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;iBAShC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,yEAAyE;AACzE,qBAAa,gBAAiB,SAAQ,SAAS;gBACjC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,CASlE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG;IACjD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAQA"}
package/dist/guest.js ADDED
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Cross-fleet GUEST bindings — DR-036 Amendment A (groundnuty/macf#679).
3
+ *
4
+ * A consumer fleet depends on a specialist agent that lives in ANOTHER fleet
5
+ * (the worked example: `icsoc-2026` depends on `ppam-2026/code-agent`, the
6
+ * `onedata-mcp` specialist). The consumer carries a LOCAL, consumer-side
7
+ * "guest" binding naming that external agent + the perspectival role it plays
8
+ * from the consumer's viewpoint. The external agent neither sees nor agrees to
9
+ * it — topology-autonomy is preserved (a consumer only ANNOTATES its own view;
10
+ * it cannot impose membership on a peer).
11
+ *
12
+ * The load-bearing invariant (DR-036 Amendment A): **visibility is split from
13
+ * supervision**. A guest MAY be SHOWN in the consumer's `macf fleet status` /
14
+ * `/macf-peers`, clearly marked external + unsupervised — but it is NEVER a
15
+ * supervised member (never owned by the consumer's registry, never under its
16
+ * DR-031 liveness / reconciliation / restart / prune machinery). Only the
17
+ * no-supervision half is mandatory; the visibility half is the new capability.
18
+ *
19
+ * The binding lives in the fleet-scope config `.github/macf-fleet.json`
20
+ * (macf#614 — the same file that carries the `routing_fleet` opt-OUT marker),
21
+ * so this schema describes the WHOLE file, not just the guests array. The
22
+ * `routing_fleet` key is preserved here so the one config file has one schema.
23
+ */
24
+ import { z } from 'zod';
25
+ import { MacfError } from './errors.js';
26
+ /**
27
+ * How the consumer reaches the guest (DR-036 §two enabler paths, Amendment A):
28
+ * - `route` — the guest is App-scoped + GitHub-@mention-routable
29
+ * (paths a/b). Cross-reachable → a live `/health` probe is
30
+ * meaningful; the guest shows its live online/offline state.
31
+ * - `operator-relay` — the guest is a local-mode / private-mesh agent (path c):
32
+ * no App, a local-CA mTLS mesh on a host the consumer can't
33
+ * reach. A cross-fleet `/health` probe is NOT meaningful (it
34
+ * would hit the consumer's own localhost or fail), so the
35
+ * guest renders registry-derived state ONLY — never "down".
36
+ */
37
+ export const GUEST_DELEGATE_VIA = ['route', 'operator-relay'];
38
+ export const GuestDelegateViaSchema = z.enum(GUEST_DELEGATE_VIA);
39
+ /**
40
+ * `<home-project>/<name>` — the guest's home fleet + agent name. One `/`; no
41
+ * whitespace or additional slashes in either segment. Resolves in the shared
42
+ * registry scope as `<HOME_PROJECT>_AGENT_<NAME>` (DR-006 profile scope; the
43
+ * cross-scope union per macf#621 when the guest lives under a different scope).
44
+ */
45
+ const GUEST_AGENT_REF_RE = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;
46
+ /**
47
+ * One consumer-side guest binding (DR-036 Amendment A). Consumer-LOCAL: the
48
+ * external agent is unaware. Perspectival — `local_role` is the consumer's
49
+ * vocabulary for the role the guest plays here, NOT a role the guest adopts.
50
+ */
51
+ export const GuestBindingSchema = z.object({
52
+ /** `<home-project>/<name>` — home fleet + agent (resolves in the shared registry). */
53
+ agent: z
54
+ .string()
55
+ .regex(GUEST_AGENT_REF_RE, 'guest.agent must be "<home-project>/<name>" (one slash, no spaces)'),
56
+ /** The perspectival role the guest plays from the consumer's viewpoint (e.g. `onedata-specialist`). */
57
+ local_role: z.string().min(1, 'guest.local_role must be non-empty'),
58
+ /** Why this dependency exists (e.g. `data-access dependency (onedata-mcp)`). */
59
+ purpose: z.string().min(1, 'guest.purpose must be non-empty'),
60
+ /** How the consumer reaches the guest — decides path-aware reachability rendering. */
61
+ delegate_via: GuestDelegateViaSchema,
62
+ /**
63
+ * Optional expiry → "temporary" membership. `null` (or absent) = open-ended.
64
+ * A consumer-side annotation scoped in time with no change on the guest's side.
65
+ */
66
+ until: z.string().nullable().optional().default(null),
67
+ });
68
+ /**
69
+ * The whole `.github/macf-fleet.json` fleet-scope config (macf#614 + #679).
70
+ * Non-strict: unknown keys are stripped, so a future additive key doesn't
71
+ * reject the file. `guests` defaults to `[]` so a config with no guests (or the
72
+ * plain `routing_fleet`-only marker) parses to an empty guest list.
73
+ */
74
+ export const MacfFleetConfigSchema = z.object({
75
+ /**
76
+ * macf#614 routing-fleet opt-OUT marker: a pinned agent-router-caller repo
77
+ * declares itself non-fleet (`false`) to be excluded from `routing doctor`'s
78
+ * `pins_consistent` verdict. Preserved here so one file has one schema.
79
+ */
80
+ routing_fleet: z.boolean().optional(),
81
+ /** Consumer-side cross-fleet guest bindings (DR-036 Amendment A, #679). */
82
+ guests: z.array(GuestBindingSchema).default([]),
83
+ });
84
+ /** Raised when a `.github/macf-fleet.json` value violates the schema. */
85
+ export class GuestConfigError extends MacfError {
86
+ constructor(message) {
87
+ super('GUEST_CONFIG_ERROR', message);
88
+ this.name = 'GuestConfigError';
89
+ }
90
+ }
91
+ /**
92
+ * Parse + validate a raw `.github/macf-fleet.json` value. Throws
93
+ * `GuestConfigError` (with the first Zod issue path + message) on any schema
94
+ * violation so a malformed binding fails LOUD rather than silently dropping a
95
+ * guest. Callers that must DEGRADE instead (a config read on a hot path) can use
96
+ * `MacfFleetConfigSchema.safeParse` directly and fall back to an empty config.
97
+ */
98
+ export function parseMacfFleetConfig(raw) {
99
+ const result = MacfFleetConfigSchema.safeParse(raw);
100
+ if (!result.success) {
101
+ const first = result.error.issues[0];
102
+ const where = first && first.path.length > 0 ? ` at ${first.path.join('.')}` : '';
103
+ const why = first ? first.message : 'invalid config';
104
+ throw new GuestConfigError(`Invalid .github/macf-fleet.json${where}: ${why}`);
105
+ }
106
+ return result.data;
107
+ }
108
+ /**
109
+ * Split a `<home-project>/<name>` guest ref into its two segments. Assumes the
110
+ * ref already passed `GuestBindingSchema` (exactly one `/`); throws
111
+ * `GuestConfigError` defensively for a malformed ref reaching this path.
112
+ */
113
+ export function parseGuestAgentRef(agent) {
114
+ const slash = agent.indexOf('/');
115
+ if (slash <= 0 || slash !== agent.lastIndexOf('/') || slash === agent.length - 1) {
116
+ throw new GuestConfigError(`guest.agent "${agent}" is not "<home-project>/<name>" (one slash required)`);
117
+ }
118
+ return { homeProject: agent.slice(0, slash), name: agent.slice(slash + 1) };
119
+ }
120
+ //# sourceMappingURL=guest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guest.js","sourceRoot":"","sources":["../src/guest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAU,CAAC;AACvE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AAGjE;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG,oCAAoC,CAAC;AAEhE;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,sFAAsF;IACtF,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,KAAK,CAAC,kBAAkB,EAAE,oEAAoE,CAAC;IAClG,uGAAuG;IACvG,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,oCAAoC,CAAC;IACnE,gFAAgF;IAChF,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,iCAAiC,CAAC;IAC7D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,EAAE,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAI9C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,KAAK,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjF,MAAM,IAAI,gBAAgB,CACxB,gBAAgB,KAAK,uDAAuD,CAC7E,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC"}
package/dist/index.d.ts CHANGED
@@ -17,7 +17,15 @@ export * from './config.js';
17
17
  export * from './token.js';
18
18
  export * from './types.js';
19
19
  export * from './semver.js';
20
+ export * from './discovery.js';
21
+ export * from './fleet-driver.js';
22
+ export * from './fleet-reconcile.js';
23
+ export * from './verify-green.js';
24
+ export * from './fleet-upgrade.js';
20
25
  export * from './reflection.js';
26
+ export * from './prompt-responses.js';
27
+ export * from './stall-signatures.js';
28
+ export * from './guest.js';
21
29
  export * from './norm.js';
22
30
  export * from './protected-invariant-norms.js';
23
31
  export * from './mtls-health-ping.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AAIpC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AAIpC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -17,7 +17,15 @@ export * from './config.js';
17
17
  export * from './token.js';
18
18
  export * from './types.js';
19
19
  export * from './semver.js';
20
+ export * from './discovery.js';
21
+ export * from './fleet-driver.js';
22
+ export * from './fleet-reconcile.js';
23
+ export * from './verify-green.js';
24
+ export * from './fleet-upgrade.js';
20
25
  export * from './reflection.js';
26
+ export * from './prompt-responses.js';
27
+ export * from './stall-signatures.js';
28
+ export * from './guest.js';
21
29
  export * from './norm.js';
22
30
  export * from './protected-invariant-norms.js';
23
31
  export * from './mtls-health-ping.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AAEpC,kEAAkE;AAClE,oEAAoE;AACpE,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AAEpC,kEAAkE;AAClE,oEAAoE;AACpE,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/norm.d.ts CHANGED
@@ -115,8 +115,8 @@ export declare const ConditionSchema: z.ZodPipe<z.ZodTransform<unknown, unknown>
115
115
  export type Condition = (typeof CONDITION_TOKENS)[number];
116
116
  /** The three deontic modalities. */
117
117
  export declare const DeonticSchema: z.ZodEnum<{
118
- obligation: "obligation";
119
118
  permission: "permission";
119
+ obligation: "obligation";
120
120
  prohibition: "prohibition";
121
121
  }>;
122
122
  export type Deontic = z.infer<typeof DeonticSchema>;
@@ -150,8 +150,8 @@ export declare const NormSchema: z.ZodObject<{
150
150
  deployment: "deployment";
151
151
  }>>;
152
152
  deontic: z.ZodEnum<{
153
- obligation: "obligation";
154
153
  permission: "permission";
154
+ obligation: "obligation";
155
155
  prohibition: "prohibition";
156
156
  }>;
157
157
  action: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodEnum<{
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Interactive-prompt auto-responder — config schema, the Inv-2 ceremony-only
3
+ * classifier, and the pure Inv-1/Inv-3 frame matcher (DR-033, groundnuty/macf#645).
4
+ *
5
+ * SAFETY-CRITICAL. This module holds the *pure* logic behind the auto-responder:
6
+ * the config the operator curates in `.claude/.macf/prompt-responses.json`, the
7
+ * rules for what may go on the allowlist, and the frame-matching that decides
8
+ * whether a captured tmux pane is a KNOWN ceremony prompt we may answer. The
9
+ * shell watcher (`scripts/macf-prompt-watcher.sh`) reimplements the SAME
10
+ * algorithm in bash+jq for runtime; this module is the tested reference spec +
11
+ * the validator the CLI runs at `macf init/update/rules refresh`. The two MUST
12
+ * stay in lockstep — a change here is a change there.
13
+ *
14
+ * The three constitutional invariants (DR-033 §Decision):
15
+ *
16
+ * Inv 1 — allowlist-only. Only auto-answer a prompt matching a vetted entry.
17
+ * An unrecognized prompt-like frame → the caller ALERTs and does NOT answer.
18
+ * `matchPromptFrame` returns `unknown-prompt` for that case; the watcher
19
+ * turns it into a loud forensic-log + stderr alert. Silence-on-unknown beats
20
+ * a wrong answer.
21
+ *
22
+ * Inv 2 — ceremony-acks ONLY. The config loader HARD-REFUSES (drops) any entry
23
+ * whose signature material contains an authorization/destructive substring
24
+ * (`delete` / `overwrite` / `trust`) and LOUD-WARNS (keeps, operator-owned
25
+ * risk) on `(y/n)` / `allow` / `permission` / `grant`. This constrains what
26
+ * may go ON the allowlist — the stronger sibling of Inv 1.
27
+ *
28
+ * Inv 3 — the signature GUARANTEES the `send` still means the intended option.
29
+ * A structured signature (`frame_contains` + `option_text` at the `send`
30
+ * ordinal's rendered position) — NOT a fragile substring. A menu reorder /
31
+ * reword / insert breaks the match → falls through to Inv 1 (alert, don't
32
+ * answer) rather than firing a now-wrong ordinal. The signature is not "what
33
+ * prompt is this"; it is "is the world still exactly as the `send` assumes".
34
+ */
35
+ import { z } from 'zod';
36
+ import { MacfError } from './errors.js';
37
+ /** Config schema version. Bump on a breaking shape change. */
38
+ export declare const PROMPT_RESPONSES_SCHEMA_VERSION: "1";
39
+ /**
40
+ * Inv 2 — HARD-REFUSE substrings. An entry whose signature material contains any
41
+ * of these (case-insensitive) is DROPPED at load: the auto-responder must never
42
+ * answer a destructive-confirmation or a folder/tool-trust prompt, even if an
43
+ * operator tries to allowlist it (DR-033 OQ1 lean: hard-refuse the most
44
+ * dangerous). Kept in lockstep with `PROMPT_REFUSE_SUBSTRINGS` in the watcher.
45
+ * `revoke`/`remove` are the security/destructive siblings of `delete`/`trust`
46
+ * ("revoke token?" / "remove collaborator?") — same never-even-if-allowlisted
47
+ * class (science review of macf#645).
48
+ */
49
+ export declare const PROMPT_REFUSE_SUBSTRINGS: readonly ["delete", "overwrite", "trust", "revoke", "remove"];
50
+ /**
51
+ * Inv 2 — LOUD-WARN substrings. An entry whose signature material contains any
52
+ * of these is KEPT (operator-owned risk) but flagged loudly at load: these lean
53
+ * authorization-shaped, so the operator should confirm they meant a ceremony ack
54
+ * and not a permission grant. Kept in lockstep with the watcher.
55
+ */
56
+ export declare const PROMPT_WARN_SUBSTRINGS: readonly ["(y/n)", "allow", "permission", "grant"];
57
+ /** Thrown when the prompt-responses config fails schema validation. */
58
+ export declare class PromptResponderError extends MacfError {
59
+ constructor(message: string);
60
+ }
61
+ /**
62
+ * A single allowlist entry — the STRUCTURED signature that resolves DR-033 OQ2
63
+ * (Inv 3). `frame_contains` identifies WHICH prompt (all substrings must be
64
+ * present); `option_text` is the EXACT rendered text at the `send` ordinal's
65
+ * line, so `send`↔option binding is machine-checkable, not a fragile substring.
66
+ *
67
+ * - `frame_contains` — substrings that MUST ALL be present in the captured
68
+ * frame (Inv 1 identity). Requiring all present also doubles as the
69
+ * "wait for the full frame rendered" gate.
70
+ * - `option_text` — the exact rendered option text at the `send` position
71
+ * (Inv 3 binding). Must appear on a menu line numbered `send`.
72
+ * - `send` — the keystroke(s) to send, typically a menu ordinal ("1" / "2").
73
+ * - `verify_contains` — OPTIONAL expected substring of the POST-answer
74
+ * next-screen (Inv-A "verify the RIGHT outcome"). When set, the watcher
75
+ * asserts it appears after sending; when unset the watcher verifies
76
+ * signature-clearance only + logs that the outcome check was weaker.
77
+ * - `max_fires` — per-prompt fire cap (default 1). An auto-responder that
78
+ * fires repeatedly on a recurring pattern is itself a hazard.
79
+ *
80
+ * `.strict()` so an operator typo in a field name (e.g. `frame_contain`) is a
81
+ * loud validation error, not a silently-ignored field.
82
+ */
83
+ export declare const PromptResponseEntrySchema: z.ZodObject<{
84
+ name: z.ZodString;
85
+ frame_contains: z.ZodArray<z.ZodString>;
86
+ option_text: z.ZodString;
87
+ send: z.ZodString;
88
+ verify_contains: z.ZodOptional<z.ZodString>;
89
+ max_fires: z.ZodDefault<z.ZodNumber>;
90
+ }, z.core.$strict>;
91
+ export type PromptResponseEntry = z.infer<typeof PromptResponseEntrySchema>;
92
+ /**
93
+ * The whole config. Top-level is deliberately NON-strict (unknown keys stripped,
94
+ * not rejected) so the shipped seed can carry a `_comment` operator-note field
95
+ * without failing validation. Entries stay strict.
96
+ */
97
+ export declare const PromptResponsesConfigSchema: z.ZodObject<{
98
+ schema_version: z.ZodLiteral<"1">;
99
+ entries: z.ZodDefault<z.ZodArray<z.ZodObject<{
100
+ name: z.ZodString;
101
+ frame_contains: z.ZodArray<z.ZodString>;
102
+ option_text: z.ZodString;
103
+ send: z.ZodString;
104
+ verify_contains: z.ZodOptional<z.ZodString>;
105
+ max_fires: z.ZodDefault<z.ZodNumber>;
106
+ }, z.core.$strict>>>;
107
+ }, z.core.$strip>;
108
+ export type PromptResponsesConfig = z.infer<typeof PromptResponsesConfigSchema>;
109
+ /** Inv-2 classification of a single entry's signature material. */
110
+ export type SignatureClass = 'refuse' | 'warn' | 'ok';
111
+ /**
112
+ * Classify an entry against the Inv-2 substring lists. `refuse` wins over `warn`
113
+ * (the destructive/trust list is checked first). Substring match is intentional
114
+ * and over-refuse-safe: better to reject a benignly-worded entry than to admit a
115
+ * dangerous one.
116
+ */
117
+ export declare function classifyPromptSignature(entry: PromptResponseEntry): SignatureClass;
118
+ /** One refused/warned entry + the substring that triggered the classification. */
119
+ export interface ClassifiedEntry {
120
+ readonly entry: PromptResponseEntry;
121
+ readonly matched: string;
122
+ }
123
+ /**
124
+ * The result of loading + Inv-2-filtering a config: the `accepted` entries the
125
+ * watcher may act on (refused entries DROPPED per Inv 2 hard-refuse), plus the
126
+ * `refused` + `warned` lists so the caller can surface them loudly.
127
+ */
128
+ export interface LoadedPromptResponses {
129
+ readonly accepted: readonly PromptResponseEntry[];
130
+ readonly refused: readonly ClassifiedEntry[];
131
+ readonly warned: readonly ClassifiedEntry[];
132
+ }
133
+ /**
134
+ * Validate + Inv-2-filter a parsed config object. Throws `PromptResponderError`
135
+ * on a schema-invalid shape (loud — never silently proceed on a malformed
136
+ * config). Refuse-classified entries are dropped from `accepted`; warn-classified
137
+ * entries stay in `accepted` (operator-owned risk) but are also listed in
138
+ * `warned`.
139
+ */
140
+ export declare function loadPromptResponses(raw: unknown): LoadedPromptResponses;
141
+ /**
142
+ * Prompt-like frame detector (Inv 1). A frame that matches no allowlist entry
143
+ * but LOOKS like an interactive prompt (a `❯` selector or a `(y/n)`-style
144
+ * confirmation) is the dangerous case: an unknown prompt we must NOT answer.
145
+ * Broad on purpose — false-positive (alert on a non-prompt) is cheap; a
146
+ * false-negative (miss a real unknown prompt) is the hazard.
147
+ */
148
+ export declare function looksPromptLike(frame: string): boolean;
149
+ /**
150
+ * Inv 3 binding: does `optionText` render on a menu line numbered `send`?
151
+ *
152
+ * For a numeric `send` (the common menu-ordinal case), the line containing
153
+ * `optionText` must, after stripping any leading selector glyph / whitespace
154
+ * (`❯ 1. …`), START with the `send` ordinal followed by a boundary — so a menu
155
+ * reorder that moves `optionText` to a differently-numbered line breaks the
156
+ * match. For a non-numeric `send` there is no ordinal to bind to, so presence of
157
+ * `optionText` is the binding (weaker; the seeds + realistic launch menus are
158
+ * numbered).
159
+ */
160
+ export declare function optionOnSendLine(frame: string, optionText: string, send: string): boolean;
161
+ /**
162
+ * Does the frame match this specific allowlist entry? All `frame_contains`
163
+ * present (Inv 1 identity + full-render gate) AND `option_text` present AND
164
+ * `option_text` on a line numbered `send` (Inv 3 binding).
165
+ */
166
+ export declare function entryMatchesFrame(frame: string, entry: PromptResponseEntry): boolean;
167
+ /** Outcome of matching a captured frame against the accepted allowlist. */
168
+ export type MatchResult = {
169
+ readonly kind: 'match';
170
+ readonly entry: PromptResponseEntry;
171
+ } | {
172
+ readonly kind: 'unknown-prompt';
173
+ } | {
174
+ readonly kind: 'none';
175
+ };
176
+ /**
177
+ * Match a captured tmux frame against the accepted allowlist (Inv 1 + Inv 3).
178
+ * Returns the first matching entry; else `unknown-prompt` when the frame looks
179
+ * prompt-like (→ caller alerts, never answers); else `none` (no prompt / the
180
+ * agent's own output).
181
+ */
182
+ export declare function matchPromptFrame(frame: string, entries: readonly PromptResponseEntry[]): MatchResult;
183
+ /** Per-prompt fire cap (Inv operational guard): may this entry fire again? */
184
+ export declare function canFire(entry: PromptResponseEntry, firedCount: number): boolean;
185
+ /**
186
+ * Outcome verification after a send (DR-033 "verify the RIGHT outcome"):
187
+ * - `not-cleared` — the same signature STILL matches: the send had no effect
188
+ * (the RC typed-but-no-Enter hazard, silent-fallback Instance 3). Retry/alert.
189
+ * - `wrong-outcome` — signature cleared BUT `verify_contains` (the expected
190
+ * next-screen marker) is absent: a *wrong* answer also clears the prompt.
191
+ * - `ok` — signature cleared AND `verify_contains` present.
192
+ * - `weak-ok` — signature cleared, no `verify_contains` configured: the
193
+ * watcher can only confirm clearance, not correctness (logged as weaker).
194
+ */
195
+ export type VerifyResult = 'ok' | 'weak-ok' | 'not-cleared' | 'wrong-outcome';
196
+ export declare function verifyOutcome(afterFrame: string, entry: PromptResponseEntry): VerifyResult;
197
+ /**
198
+ * The canonical seed config `macf init` writes when no `prompt-responses.json`
199
+ * exists yet. Two ceremony-ack entries vetted to Inv 2 (neither signature
200
+ * contains a refuse/warn substring). The exact rendered text of a launch prompt
201
+ * can only be confirmed by an OPERATOR live-verify (the prompts don't render in
202
+ * `-p` mode), so a seed that doesn't exactly match a real prompt fails SAFE —
203
+ * the frame falls through to Inv 1 (unknown-prompt alert), never a wrong answer.
204
+ * Operators tune the exact `frame_contains` / `option_text` against the real
205
+ * pane, then the ceremony auto-clears.
206
+ */
207
+ export declare const PROMPT_RESPONSES_SEED: PromptResponsesConfig;
208
+ //# sourceMappingURL=prompt-responses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-responses.d.ts","sourceRoot":"","sources":["../src/prompt-responses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,8DAA8D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