@akagilnc/pi-workflow-roles 0.1.3412 → 0.1.3439

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 (67) hide show
  1. package/dist/archivist-record-entry.js +21 -12
  2. package/dist/archivist-record-topology.js +20 -0
  3. package/dist/auditor-dossier-tool.js +67 -76
  4. package/dist/canonical-json.js +66 -69
  5. package/dist/compliance-transport.js +99 -86
  6. package/dist/countersign-contracts.js +23 -25
  7. package/dist/doctor-contracts.js +169 -145
  8. package/dist/engine-detour-tool.js +83 -87
  9. package/dist/engine-detour.js +148 -183
  10. package/dist/evidence-child-executor.js +10 -1
  11. package/dist/exact-utf8.js +11 -10
  12. package/dist/git-object-id.js +10 -5
  13. package/dist/gleaner-left-contracts.js +33 -35
  14. package/dist/grok/production-host.js +229 -118
  15. package/dist/inspector-contracts.js +28 -31
  16. package/dist/institutional-resolution.js +101 -104
  17. package/dist/ledger-session-read.js +241 -0
  18. package/dist/merger-contracts.js +66 -56
  19. package/dist/notary-contracts.js +91 -100
  20. package/dist/open-tool-schema.js +32 -31
  21. package/dist/package-contracts/collector-output.js +56 -43
  22. package/dist/package-contracts/fixer-output.js +52 -50
  23. package/dist/package-contracts/fixer-packet.js +67 -64
  24. package/dist/package-contracts/gatekeeper-output.js +48 -56
  25. package/dist/package-contracts/judge-output.js +23 -20
  26. package/dist/package-contracts/navigator-output.js +35 -40
  27. package/dist/package-contracts/reviewer-output.js +94 -110
  28. package/dist/package-contracts/terminating-infrastructure.js +62 -90
  29. package/dist/package-contracts/worker-output.js +30 -11
  30. package/dist/package-resources/engine-material.js +58 -94
  31. package/dist/public-cli/config.js +420 -484
  32. package/dist/public-cli/main.js +1219 -524
  33. package/dist/public-cli/registry.js +107 -114
  34. package/dist/receipt-delivery-policy.js +74 -76
  35. package/dist/session-opening-materials.js +44 -47
  36. package/dist/sha256.js +5 -3
  37. package/dist/sitian-appender.js +204 -210
  38. package/dist/sitian-contracts.js +15 -19
  39. package/dist/sitian-facade.js +5 -10
  40. package/dist/sitian-reader.js +37 -46
  41. package/dist/stream-idle-guard.js +63 -71
  42. package/dist/ticket-seat-memory.js +244 -0
  43. package/package.json +1 -1
  44. package/scripts/build-package.mjs +41 -0
  45. package/souls/audit-law.md +4 -0
  46. package/souls/countersign.md +1 -1
  47. package/souls/gleaner-left.md +1 -1
  48. package/souls/inspector.md +1 -1
  49. package/souls/notary.md +1 -1
  50. package/souls/reviewer.md +1 -1
  51. package/src/analyst-gate-cycles-read.ts +152 -83
  52. package/src/analyst-ledger.ts +170 -43
  53. package/src/archivist-record-entry.ts +32 -11
  54. package/src/archivist-record-topology.ts +39 -0
  55. package/src/evidence-child-executor.ts +14 -1
  56. package/src/grok/production-host.ts +44 -9
  57. package/src/host-contracts.ts +18 -0
  58. package/src/host-transition-prior-native.ts +8 -1
  59. package/src/ledger-session-read.ts +56 -0
  60. package/src/pi/durable-principal.ts +6 -0
  61. package/src/public-cli/inspector-run.ts +21 -10
  62. package/src/public-cli/invocation.ts +4 -20
  63. package/src/public-cli/notary-run.ts +21 -4
  64. package/src/public-cli/post-admission.ts +333 -42
  65. package/src/public-cli/settlement.ts +266 -81
  66. package/src/session-opening-materials.ts +4 -2
  67. package/src/ticket-seat-memory.ts +454 -0
@@ -2,72 +2,74 @@ import { Type } from "typebox";
2
2
  import { FIXER_PREREQUISITE_ID_PATTERN } from "./fixer-packet.js";
3
3
  import { openToolObjectFromUnion } from "../open-tool-schema.js";
4
4
  import { withInfrastructureFailureDeclaration } from "./terminating-infrastructure.js";
5
- export const FIXER_OUTPUT_TOOL_NAME = "ak_fixer_output";
6
- export const FIXER_ACCEPTED_TEXT = "修内司回执已接受";
5
+ const FIXER_OUTPUT_TOOL_NAME = "ak_fixer_output";
6
+ const FIXER_ACCEPTED_TEXT = "\u4FEE\u5185\u53F8\u56DE\u6267\u5DF2\u63A5\u53D7";
7
7
  const nonblankTransportString = Type.String({ minLength: 1 });
8
8
  const authorityBlockerSchema = Type.Object({ cause: Type.Literal("authority_violation"), evidence: nonblankTransportString });
9
9
  const prerequisiteBlockerSchema = Type.Object({ cause: Type.Literal("prerequisite_unmet"), prerequisiteId: Type.String({ pattern: FIXER_PREREQUISITE_ID_PATTERN }), evidence: nonblankTransportString });
10
10
  const blockerSchema = Type.Union([authorityBlockerSchema, prerequisiteBlockerSchema]);
11
11
  const exceptionSchema = Type.Object({ where: nonblankTransportString, reason: nonblankTransportString });
12
- /** ⑥ test evidence slip — require submit when diff has test changes; machine does not check existence/completeness/coverage. */
13
12
  const testEvidenceSchema = Type.Object({
14
- contract: Type.String({ minLength: 1, description: "测试改动所证明的契约" }),
15
- minimumNecessaryCost: Type.String({ minLength: 1, description: "测试改动的一行最小必要成本" }),
16
- measuredDuration: Type.String({ minLength: 1, description: "聚焦验证实测时长" }),
17
- }, { description: "测试证据条;diff 含测试改动时提交;机器不核验。" });
13
+ contract: Type.String({ minLength: 1, description: "\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6" }),
14
+ minimumNecessaryCost: Type.String({ minLength: 1, description: "\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C" }),
15
+ measuredDuration: Type.String({ minLength: 1, description: "\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F" })
16
+ }, { description: "\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1Bdiff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u63D0\u4EA4\uFF1B\u673A\u5668\u4E0D\u6838\u9A8C\u3002" });
18
17
  const completedClassResultSchema = Type.Object({
19
- name: nonblankTransportString,
20
- disposition: Type.Literal("completed"),
21
- searchScope: nonblankTransportString,
22
- exceptions: Type.Array(exceptionSchema),
23
- commitSha: nonblankTransportString,
18
+ name: nonblankTransportString,
19
+ disposition: Type.Literal("completed"),
20
+ searchScope: nonblankTransportString,
21
+ exceptions: Type.Array(exceptionSchema),
22
+ commitSha: nonblankTransportString
24
23
  });
25
24
  const refusedClassResultSchema = Type.Object({
26
- name: nonblankTransportString,
27
- disposition: Type.Literal("refused"),
28
- remainingScope: nonblankTransportString,
29
- blocker: blockerSchema,
25
+ name: nonblankTransportString,
26
+ disposition: Type.Literal("refused"),
27
+ remainingScope: nonblankTransportString,
28
+ blocker: blockerSchema
30
29
  });
31
30
  const classResultSchema = Type.Union([completedClassResultSchema, refusedClassResultSchema]);
32
31
  const completedClassResultsSchema = Type.Array(completedClassResultSchema, { minItems: 1 });
33
32
  const fixerOutputVariants = Type.Union([
34
- Type.Object({ status: Type.Literal("planned", { description: "planned — 形状指引,非 schema 闸" }), report: Type.String({ minLength: 1, description: "如实结果报告" }) }),
35
- Type.Object({ status: Type.Literal("refused", { description: "refused — 形状指引,非 schema 闸" }), report: Type.String({ minLength: 1, description: "如实结果报告" }), remainingScope: Type.String({ minLength: 1, description: "依法不能完成的工作范围" }), blocker: Type.Unsafe({ ...blockerSchema, description: "合法阻断完成的 blocker" }) }),
36
- Type.Object({ status: Type.Literal("unfinished", { description: "unfinished — 形状指引,非 schema 闸;缺前置或违宪约束致本局未完成时可用。缺待决 owner 决定或答复属缺前置。" }), report: Type.String({ minLength: 1, description: "如实结果报告" }), remainingScope: Type.String({ minLength: 1, description: "本局后剩余工作" }), reason: Type.Optional(Type.String({ minLength: 1, description: "阻断原因:缺前置或违宪约束。缺待决 owner 决定或答复属缺前置。" })), classResults: Type.Optional(Type.Unsafe({ ...completedClassResultsSchema, description: "本局已完成的 class 结算" })), testEvidence: Type.Optional(testEvidenceSchema) }),
37
- Type.Object({ status: Type.Literal("completed", { description: "completed — 形状指引,非 schema 闸" }), report: Type.String({ minLength: 1, description: "如实结果报告" }), classResults: Type.Array(classResultSchema, { minItems: 1, description: "已完成的 class 结算" }), testEvidence: Type.Optional(testEvidenceSchema) }),
38
- Type.Object({ status: Type.Literal("refused", { description: "refused — 形状指引,非 schema 闸" }), report: Type.String({ minLength: 1, description: "如实结果报告" }), classResults: Type.Array(classResultSchema, { minItems: 1, description: "各类拒绝结算" }) }),
39
- Type.Object({ status: Type.Literal("partially_completed", { description: "partially_completed — 形状指引,非 schema 闸" }), report: Type.String({ minLength: 1, description: "如实结果报告" }), classResults: Type.Array(classResultSchema, { minItems: 1, description: "各类完成或拒绝结算" }), testEvidence: Type.Optional(testEvidenceSchema) }),
33
+ Type.Object({ status: Type.Literal("planned", { description: "planned \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }),
34
+ Type.Object({ status: Type.Literal("refused", { description: "refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type.String({ minLength: 1, description: "\u4F9D\u6CD5\u4E0D\u80FD\u5B8C\u6210\u7684\u5DE5\u4F5C\u8303\u56F4" }), blocker: Type.Unsafe({ ...blockerSchema, description: "\u5408\u6CD5\u963B\u65AD\u5B8C\u6210\u7684 blocker" }) }),
35
+ Type.Object({ status: Type.Literal("unfinished", { description: "unfinished \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1B\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type.String({ minLength: 1, description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }), reason: Type.Optional(Type.String({ minLength: 1, description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002" })), classResults: Type.Optional(Type.Unsafe({ ...completedClassResultsSchema, description: "\u672C\u5C40\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" })), testEvidence: Type.Optional(testEvidenceSchema) }),
36
+ Type.Object({ status: Type.Literal("completed", { description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type.Array(classResultSchema, { minItems: 1, description: "\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" }), testEvidence: Type.Optional(testEvidenceSchema) }),
37
+ Type.Object({ status: Type.Literal("refused", { description: "refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type.Array(classResultSchema, { minItems: 1, description: "\u5404\u7C7B\u62D2\u7EDD\u7ED3\u7B97" }) }),
38
+ Type.Object({ status: Type.Literal("partially_completed", { description: "partially_completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type.Array(classResultSchema, { minItems: 1, description: "\u5404\u7C7B\u5B8C\u6210\u6216\u62D2\u7EDD\u7ED3\u7B97" }), testEvidence: Type.Optional(testEvidenceSchema) })
40
39
  ]);
41
- export const fixerOutputSchema = withInfrastructureFailureDeclaration(openToolObjectFromUnion(fixerOutputVariants));
42
- export function validateFixerOutput(value, _phase) {
43
- return value;
40
+ const fixerOutputSchema = withInfrastructureFailureDeclaration(
41
+ openToolObjectFromUnion(fixerOutputVariants)
42
+ );
43
+ function validateFixerOutput(value, _phase) {
44
+ return value;
44
45
  }
45
46
  function safeProperty(value, property) {
46
- if (value === null || typeof value !== "object")
47
- return undefined;
48
- try {
49
- return value[property];
50
- }
51
- catch {
52
- return undefined;
53
- }
47
+ if (value === null || typeof value !== "object") return void 0;
48
+ try {
49
+ return value[property];
50
+ } catch {
51
+ return void 0;
52
+ }
54
53
  }
55
- /** Bind recognizable prerequisite blockers to the packet declaration. */
56
- export function validateFixerOutputForPacket(value, phase, packet) {
57
- const output = validateFixerOutput(value, phase);
58
- const declaredIds = new Set(packet.prerequisites.map((entry) => entry.id));
59
- const topLevelBlocker = safeProperty(output, "blocker");
60
- const classResults = safeProperty(output, "classResults");
61
- const blockers = topLevelBlocker === undefined
62
- ? (Array.isArray(classResults) ? classResults.map((entry) => safeProperty(entry, "blocker")) : [])
63
- : [topLevelBlocker];
64
- for (const blocker of blockers) {
65
- if (safeProperty(blocker, "cause") !== "prerequisite_unmet")
66
- continue;
67
- const prerequisiteId = safeProperty(blocker, "prerequisiteId");
68
- if (typeof prerequisiteId === "string" && !declaredIds.has(prerequisiteId)) {
69
- throw new Error("Fixer output violates blocker.prerequisiteId declared-prerequisite constraint");
70
- }
54
+ function validateFixerOutputForPacket(value, phase, packet) {
55
+ const output = validateFixerOutput(value, phase);
56
+ const declaredIds = new Set(packet.prerequisites.map((entry) => entry.id));
57
+ const topLevelBlocker = safeProperty(output, "blocker");
58
+ const classResults = safeProperty(output, "classResults");
59
+ const blockers = topLevelBlocker === void 0 ? Array.isArray(classResults) ? classResults.map((entry) => safeProperty(entry, "blocker")) : [] : [topLevelBlocker];
60
+ for (const blocker of blockers) {
61
+ if (safeProperty(blocker, "cause") !== "prerequisite_unmet") continue;
62
+ const prerequisiteId = safeProperty(blocker, "prerequisiteId");
63
+ if (typeof prerequisiteId === "string" && !declaredIds.has(prerequisiteId)) {
64
+ throw new Error("Fixer output violates blocker.prerequisiteId declared-prerequisite constraint");
71
65
  }
72
- return output;
66
+ }
67
+ return output;
73
68
  }
69
+ export {
70
+ FIXER_ACCEPTED_TEXT,
71
+ FIXER_OUTPUT_TOOL_NAME,
72
+ fixerOutputSchema,
73
+ validateFixerOutput,
74
+ validateFixerOutputForPacket
75
+ };
@@ -1,77 +1,80 @@
1
1
  import { Type } from "typebox";
2
2
  import { Value } from "typebox/value";
3
- export const FIXER_PREREQUISITE_ID_PATTERN = "^[A-Za-z0-9][A-Za-z0-9._-]*$";
4
- export const fixerPrerequisiteSchema = Type.Object({
5
- id: Type.String({ pattern: FIXER_PREREQUISITE_ID_PATTERN }),
6
- requirement: Type.String({ pattern: "\\S" }),
3
+ const FIXER_PREREQUISITE_ID_PATTERN = "^[A-Za-z0-9][A-Za-z0-9._-]*$";
4
+ const fixerPrerequisiteSchema = Type.Object({
5
+ id: Type.String({ pattern: FIXER_PREREQUISITE_ID_PATTERN }),
6
+ requirement: Type.String({ pattern: "\\S" })
7
7
  }, { additionalProperties: false });
8
- export const fixerPrerequisitesSchema = Type.Array(fixerPrerequisiteSchema);
8
+ const fixerPrerequisitesSchema = Type.Array(fixerPrerequisiteSchema);
9
9
  function causeMessage(cause) {
10
- if (cause instanceof Error)
11
- return cause.message;
12
- if (typeof cause === "string")
13
- return cause;
14
- try {
15
- return JSON.stringify(cause) ?? String(cause);
16
- }
17
- catch {
18
- return String(cause);
19
- }
10
+ if (cause instanceof Error) return cause.message;
11
+ if (typeof cause === "string") return cause;
12
+ try {
13
+ return JSON.stringify(cause) ?? String(cause);
14
+ } catch {
15
+ return String(cause);
16
+ }
20
17
  }
21
- export class FixerPacketValidationError extends Error {
22
- code = "AK_INVALID_FIX_PACKET";
23
- constructor(cause) {
24
- const prefix = "Fixer prerequisites or instructions violate the invocation contract";
25
- super(cause === undefined ? prefix : `${prefix}: ${causeMessage(cause)}`, cause === undefined ? undefined : { cause });
26
- this.name = "FixerPacketValidationError";
27
- }
18
+ class FixerPacketValidationError extends Error {
19
+ code = "AK_INVALID_FIX_PACKET";
20
+ constructor(cause) {
21
+ const prefix = "Fixer prerequisites or instructions violate the invocation contract";
22
+ super(
23
+ cause === void 0 ? prefix : `${prefix}: ${causeMessage(cause)}`,
24
+ cause === void 0 ? void 0 : { cause }
25
+ );
26
+ this.name = "FixerPacketValidationError";
27
+ }
28
28
  }
29
29
  function fail(cause) {
30
- throw new FixerPacketValidationError(cause);
30
+ throw new FixerPacketValidationError(cause);
31
31
  }
32
32
  function parseFailure(value) {
33
- if (!Array.isArray(value))
34
- fail(new Error("Fixer prerequisites must be a JSON array"));
35
- for (const entry of value) {
36
- if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
37
- fail(new Error("Fixer prerequisite entry must be an object with id and requirement fields"));
38
- }
39
- const keys = Object.keys(entry);
40
- if (keys.length !== 2 || !keys.includes("id") || !keys.includes("requirement")) {
41
- fail(new Error("Fixer prerequisite entry fields must be exactly id and requirement"));
42
- }
43
- if (typeof entry.id !== "string" ||
44
- !(new RegExp(FIXER_PREREQUISITE_ID_PATTERN)).test(entry.id)) {
45
- fail(new Error(`Fixer prerequisite id violates pattern ${FIXER_PREREQUISITE_ID_PATTERN}`));
46
- }
47
- if (typeof entry.requirement !== "string" ||
48
- !/\S/.test(entry.requirement)) {
49
- fail(new Error("Fixer prerequisite requirement must be nonblank"));
50
- }
33
+ if (!Array.isArray(value)) fail(new Error("Fixer prerequisites must be a JSON array"));
34
+ for (const entry of value) {
35
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
36
+ fail(new Error("Fixer prerequisite entry must be an object with id and requirement fields"));
51
37
  }
52
- fail(new Error("Fixer prerequisites violate the attachment schema"));
53
- }
54
- export function validateFixerPrerequisites(value) {
55
- if (!Value.Check(fixerPrerequisitesSchema, value))
56
- parseFailure(value);
57
- const entries = value;
58
- const ids = new Set();
59
- const prerequisites = entries.map((entry) => {
60
- if (ids.has(entry.id)) {
61
- fail(new Error(`Fixer prerequisites contain duplicate id: ${entry.id}`));
62
- }
63
- ids.add(entry.id);
64
- return Object.freeze({ id: entry.id, requirement: entry.requirement });
65
- });
66
- return Object.freeze(prerequisites);
67
- }
68
- export function parseFixerPrerequisites(source) {
69
- let decoded;
70
- try {
71
- decoded = JSON.parse(source);
38
+ const keys = Object.keys(entry);
39
+ if (keys.length !== 2 || !keys.includes("id") || !keys.includes("requirement")) {
40
+ fail(new Error("Fixer prerequisite entry fields must be exactly id and requirement"));
72
41
  }
73
- catch (error) {
74
- fail(error);
42
+ if (typeof entry.id !== "string" || !new RegExp(FIXER_PREREQUISITE_ID_PATTERN).test(entry.id)) {
43
+ fail(new Error(`Fixer prerequisite id violates pattern ${FIXER_PREREQUISITE_ID_PATTERN}`));
75
44
  }
76
- return validateFixerPrerequisites(decoded);
45
+ if (typeof entry.requirement !== "string" || !/\S/.test(entry.requirement)) {
46
+ fail(new Error("Fixer prerequisite requirement must be nonblank"));
47
+ }
48
+ }
49
+ fail(new Error("Fixer prerequisites violate the attachment schema"));
50
+ }
51
+ function validateFixerPrerequisites(value) {
52
+ if (!Value.Check(fixerPrerequisitesSchema, value)) parseFailure(value);
53
+ const entries = value;
54
+ const ids = /* @__PURE__ */ new Set();
55
+ const prerequisites = entries.map((entry) => {
56
+ if (ids.has(entry.id)) {
57
+ fail(new Error(`Fixer prerequisites contain duplicate id: ${entry.id}`));
58
+ }
59
+ ids.add(entry.id);
60
+ return Object.freeze({ id: entry.id, requirement: entry.requirement });
61
+ });
62
+ return Object.freeze(prerequisites);
63
+ }
64
+ function parseFixerPrerequisites(source) {
65
+ let decoded;
66
+ try {
67
+ decoded = JSON.parse(source);
68
+ } catch (error) {
69
+ fail(error);
70
+ }
71
+ return validateFixerPrerequisites(decoded);
77
72
  }
73
+ export {
74
+ FIXER_PREREQUISITE_ID_PATTERN,
75
+ FixerPacketValidationError,
76
+ fixerPrerequisiteSchema,
77
+ fixerPrerequisitesSchema,
78
+ parseFixerPrerequisites,
79
+ validateFixerPrerequisites
80
+ };
@@ -1,71 +1,63 @@
1
- /**
2
- * Public Gatekeeper (门下省) terminating receipt contracts (#639).
3
- * Direct public seat shares the province decision shape: dispatch | pass.
4
- * No usable result is infrastructure failure via public settlement, not a judgment status (#475).
5
- */
6
1
  import { Type } from "typebox";
7
2
  import { openToolObject } from "../open-tool-schema.js";
8
3
  import { withInfrastructureFailureDeclaration } from "./terminating-infrastructure.js";
9
- export const GATEKEEPER_OUTPUT_TOOL_NAME = "ak_gatekeeper_output";
10
- export const GATEKEEPER_ACCEPTED_TEXT = "门下省决议已受理";
11
- /** Same open decision shape the province uses inside audit sessions. */
12
- export const gatekeeperDecisionSchema = openToolObject(Type.Object({
4
+ const GATEKEEPER_OUTPUT_TOOL_NAME = "ak_gatekeeper_output";
5
+ const GATEKEEPER_ACCEPTED_TEXT = "\u95E8\u4E0B\u7701\u51B3\u8BAE\u5DF2\u53D7\u7406";
6
+ const gatekeeperDecisionSchema = openToolObject(
7
+ Type.Object({
13
8
  status: Type.Unknown({
14
- description: "dispatch | pass — 形状指引,非 schema 闸",
9
+ description: "dispatch | pass \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
15
10
  }),
16
11
  officer: Type.Unknown({
17
- description: "status 为 dispatch 时为 inspector | notary",
12
+ description: "status \u4E3A dispatch \u65F6\u4E3A inspector | notary"
18
13
  }),
19
14
  findings: Type.Unknown({
20
- description: "status 为 pass 时可选 string[] findings",
21
- }),
22
- }));
23
- export const gatekeeperOutputSchema = withInfrastructureFailureDeclaration(gatekeeperDecisionSchema);
15
+ description: "status \u4E3A pass \u65F6\u53EF\u9009 string[] findings"
16
+ })
17
+ })
18
+ );
19
+ const gatekeeperOutputSchema = withInfrastructureFailureDeclaration(
20
+ gatekeeperDecisionSchema
21
+ );
24
22
  function isRecord(value) {
25
- return typeof value === "object" && value !== null && !Array.isArray(value);
23
+ return typeof value === "object" && value !== null && !Array.isArray(value);
26
24
  }
27
25
  function asStringArray(value) {
28
- if (!Array.isArray(value))
29
- return [];
30
- return value.filter((item) => typeof item === "string");
26
+ if (!Array.isArray(value)) return [];
27
+ return value.filter((item) => typeof item === "string");
31
28
  }
32
- /**
33
- * Project one lawful explicit Gatekeeper decision (dispatch | pass).
34
- * No throw on shape — ADR 0055 / 第 0 条: already-submitted params are retained as-is;
35
- * public-terminal projects non-usable releases via typed failure cause.
36
- */
37
- export function projectLawfulGatekeeperOutput(value) {
38
- if (!isRecord(value))
39
- return undefined;
40
- if (value.status === "pass") {
41
- return Array.isArray(value.findings)
42
- ? { status: "pass", findings: asStringArray(value.findings) }
43
- : { status: "pass" };
44
- }
45
- if (value.status === "dispatch" &&
46
- (value.officer === "inspector" || value.officer === "notary")) {
47
- return { status: "dispatch", officer: value.officer };
48
- }
49
- return undefined;
29
+ function projectLawfulGatekeeperOutput(value) {
30
+ if (!isRecord(value)) return void 0;
31
+ if (value.status === "pass") {
32
+ return Array.isArray(value.findings) ? { status: "pass", findings: asStringArray(value.findings) } : { status: "pass" };
33
+ }
34
+ if (value.status === "dispatch" && (value.officer === "inspector" || value.officer === "notary")) {
35
+ return { status: "dispatch", officer: value.officer };
36
+ }
37
+ return void 0;
50
38
  }
51
- /**
52
- * Settlement/recording path: only lawful recorded dispatch/pass.
53
- * Does not gate role admission — callers must not use this to reject a submission.
54
- */
55
- export function validateRecordedGatekeeperOutput(value) {
56
- const projected = projectLawfulGatekeeperOutput(value);
57
- if (projected === undefined) {
58
- throw new Error("Gatekeeper output has no recognized execution discriminator");
59
- }
60
- return projected;
39
+ function validateRecordedGatekeeperOutput(value) {
40
+ const projected = projectLawfulGatekeeperOutput(value);
41
+ if (projected === void 0) {
42
+ throw new Error("Gatekeeper output has no recognized execution discriminator");
43
+ }
44
+ return projected;
61
45
  }
62
- export function gatekeeperDecisiveFacts(output) {
63
- const facts = { status: output.status };
64
- if (output.status === "dispatch") {
65
- facts.officer = output.officer;
66
- }
67
- else if (Array.isArray(output.findings)) {
68
- facts.findingsCount = output.findings.length;
69
- }
70
- return facts;
46
+ function gatekeeperDecisiveFacts(output) {
47
+ const facts = { status: output.status };
48
+ if (output.status === "dispatch") {
49
+ facts.officer = output.officer;
50
+ } else if (Array.isArray(output.findings)) {
51
+ facts.findingsCount = output.findings.length;
52
+ }
53
+ return facts;
71
54
  }
55
+ export {
56
+ GATEKEEPER_ACCEPTED_TEXT,
57
+ GATEKEEPER_OUTPUT_TOOL_NAME,
58
+ gatekeeperDecisionSchema,
59
+ gatekeeperDecisiveFacts,
60
+ gatekeeperOutputSchema,
61
+ projectLawfulGatekeeperOutput,
62
+ validateRecordedGatekeeperOutput
63
+ };
@@ -1,22 +1,25 @@
1
- /** Package-owned Judge output leaf — no role registration surface. */
2
- export const JUDGE_OUTPUT_TOOL_NAME = "ak_judge_output";
3
- export const JUDGE_ACCEPTED_TEXT = "大理寺回执已接受";
4
- export const JUDGE_ACCEPTED_AUDIT_NO_RECEIPT_TEXT = "大理寺回执已接受;审计无回执";
5
- export function validateAcceptedJudgeDetails(verdict) {
6
- if (verdict === null || typeof verdict !== "object" || Array.isArray(verdict))
7
- throw new Error("Judge verdict has no execution discriminator");
8
- let judgeStatus;
9
- try {
10
- judgeStatus = verdict.judgeStatus;
11
- }
12
- catch {
13
- throw new Error("Judge verdict has no execution discriminator");
14
- }
15
- if (typeof judgeStatus !== "string") {
16
- throw new Error("Judge verdict has no execution discriminator");
17
- }
18
- if (["converged", "continue", "escalate"].includes(judgeStatus)) {
19
- return verdict;
20
- }
1
+ const JUDGE_OUTPUT_TOOL_NAME = "ak_judge_output";
2
+ const JUDGE_ACCEPTED_TEXT = "\u5927\u7406\u5BFA\u56DE\u6267\u5DF2\u63A5\u53D7";
3
+ const JUDGE_ACCEPTED_AUDIT_NO_RECEIPT_TEXT = "\u5927\u7406\u5BFA\u56DE\u6267\u5DF2\u63A5\u53D7\uFF1B\u5BA1\u8BA1\u65E0\u56DE\u6267";
4
+ function validateAcceptedJudgeDetails(verdict) {
5
+ if (verdict === null || typeof verdict !== "object" || Array.isArray(verdict)) throw new Error("Judge verdict has no execution discriminator");
6
+ let judgeStatus;
7
+ try {
8
+ judgeStatus = verdict.judgeStatus;
9
+ } catch {
21
10
  throw new Error("Judge verdict has no execution discriminator");
11
+ }
12
+ if (typeof judgeStatus !== "string") {
13
+ throw new Error("Judge verdict has no execution discriminator");
14
+ }
15
+ if (["converged", "continue", "escalate"].includes(judgeStatus)) {
16
+ return verdict;
17
+ }
18
+ throw new Error("Judge verdict has no execution discriminator");
22
19
  }
20
+ export {
21
+ JUDGE_ACCEPTED_AUDIT_NO_RECEIPT_TEXT,
22
+ JUDGE_ACCEPTED_TEXT,
23
+ JUDGE_OUTPUT_TOOL_NAME,
24
+ validateAcceptedJudgeDetails
25
+ };
@@ -1,48 +1,43 @@
1
- /**
2
- * Public Navigator (游奕使) terminating receipt contracts (#639).
3
- * Direct public seat submits route advice with the same candidate shape the
4
- * attendance prepare tool owns — one shape authority for navigator advice.
5
- * No usable result is infrastructure failure via public settlement, not a judgment status (#475).
6
- */
7
1
  import { Type } from "typebox";
8
2
  import { openToolObject } from "../open-tool-schema.js";
9
3
  import { withInfrastructureFailureDeclaration } from "./terminating-infrastructure.js";
10
- export const NAVIGATOR_OUTPUT_TOOL_NAME = "ak_navigator_output";
11
- export const NAVIGATOR_ACCEPTED_TEXT = "游奕使建议已受理";
12
- export const navigatorOutputSchema = withInfrastructureFailureDeclaration(openToolObject(Type.Object({
13
- status: Type.Unknown({
14
- description: "advice — 形状指引,非 schema 闸",
15
- }),
16
- candidates: Type.Unknown({
17
- description: "排好序的路线建议数组,元素含 next/phase/reason — 形状指引,非 schema 闸",
18
- }),
19
- })));
4
+ const NAVIGATOR_OUTPUT_TOOL_NAME = "ak_navigator_output";
5
+ const NAVIGATOR_ACCEPTED_TEXT = "\u6E38\u5955\u4F7F\u5EFA\u8BAE\u5DF2\u53D7\u7406";
6
+ const navigatorOutputSchema = withInfrastructureFailureDeclaration(
7
+ openToolObject(
8
+ Type.Object({
9
+ status: Type.Unknown({
10
+ description: "advice \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
11
+ }),
12
+ candidates: Type.Unknown({
13
+ description: "\u6392\u597D\u5E8F\u7684\u8DEF\u7EBF\u5EFA\u8BAE\u6570\u7EC4\uFF0C\u5143\u7D20\u542B next/phase/reason \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
14
+ })
15
+ })
16
+ )
17
+ );
20
18
  function isRecord(value) {
21
- return typeof value === "object" && value !== null && !Array.isArray(value);
19
+ return typeof value === "object" && value !== null && !Array.isArray(value);
22
20
  }
23
- /**
24
- * Project one lawful explicit Navigator advice receipt: candidates array,
25
- * each candidate a record. Broken ancillary fields are preserved as submitted —
26
- * shape is not an admission gate (ADR 0055 / 第 0 条).
27
- */
28
- export function projectLawfulNavigatorOutput(value) {
29
- if (!isRecord(value) || !Array.isArray(value.candidates))
30
- return undefined;
31
- if (value.status !== "advice")
32
- return undefined;
33
- return { status: "advice", candidates: value.candidates.filter(isRecord) };
21
+ function projectLawfulNavigatorOutput(value) {
22
+ if (!isRecord(value) || !Array.isArray(value.candidates)) return void 0;
23
+ if (value.status !== "advice") return void 0;
24
+ return { status: "advice", candidates: value.candidates.filter(isRecord) };
34
25
  }
35
- /**
36
- * Settlement/recording path: only lawful recorded candidate arrays.
37
- * Does not gate role admission — callers must not use this to reject a submission.
38
- */
39
- export function validateRecordedNavigatorOutput(value) {
40
- const projected = projectLawfulNavigatorOutput(value);
41
- if (projected === undefined) {
42
- throw new Error("Navigator output has no recognized execution discriminator");
43
- }
44
- return projected;
26
+ function validateRecordedNavigatorOutput(value) {
27
+ const projected = projectLawfulNavigatorOutput(value);
28
+ if (projected === void 0) {
29
+ throw new Error("Navigator output has no recognized execution discriminator");
30
+ }
31
+ return projected;
45
32
  }
46
- export function navigatorDecisiveFacts(output) {
47
- return { status: "advice", candidates: output.candidates };
33
+ function navigatorDecisiveFacts(output) {
34
+ return { status: "advice", candidates: output.candidates };
48
35
  }
36
+ export {
37
+ NAVIGATOR_ACCEPTED_TEXT,
38
+ NAVIGATOR_OUTPUT_TOOL_NAME,
39
+ navigatorDecisiveFacts,
40
+ navigatorOutputSchema,
41
+ projectLawfulNavigatorOutput,
42
+ validateRecordedNavigatorOutput
43
+ };