codex-workflow-v2 2.0.0-beta.13.15 → 2.0.0-beta.13.16

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 (101) hide show
  1. package/dist/reviewer-runtime-build.json +6 -6
  2. package/dist/src/graph.js +25 -3
  3. package/dist/src/graph.js.map +1 -1
  4. package/dist/src/version.d.ts +1 -1
  5. package/dist/src/version.js +1 -1
  6. package/dist/src/workflow.js +1 -1
  7. package/docs/pdf/codex-workflow-v2-architecture-ru.pdf +0 -0
  8. package/docs/pdf/codex-workflow-v2-chat-only-guide-ru.pdf +0 -0
  9. package/docs/pdf/codex-workflow-v2-technical-reference-ru.pdf +0 -0
  10. package/docs/pdf/sources/codex-workflow-v2-architecture-ru.md +1 -1
  11. package/docs/pdf/sources/codex-workflow-v2-chat-only-guide-ru.md +2 -2
  12. package/docs/pdf/sources/codex-workflow-v2-technical-reference-ru.md +2 -2
  13. package/package.json +2 -1
  14. package/plugins/codex-workflow-gateway/.codex-plugin/plugin.json +1 -1
  15. package/plugins/codex-workflow-gateway/references/codebase-memory-routing.md +16 -13
  16. package/src/alpha6/adoption.ts +1105 -0
  17. package/src/alpha6/captured-check-evidence.ts +126 -0
  18. package/src/alpha6/check-support-anchor.ts +128 -0
  19. package/src/alpha6/component-owner.ts +168 -0
  20. package/src/alpha6/corrective-decision-boundary.ts +39 -0
  21. package/src/alpha6/downstream-proof.ts +732 -0
  22. package/src/alpha6/failed-step-planning-recovery.ts +88 -0
  23. package/src/alpha6/handoff.ts +1443 -0
  24. package/src/alpha6/journal.ts +473 -0
  25. package/src/alpha6/literal-test-invocation.ts +84 -0
  26. package/src/alpha6/mechanical-feasibility.ts +488 -0
  27. package/src/alpha6/milestone.ts +2182 -0
  28. package/src/alpha6/npm-check-contract.ts +47 -0
  29. package/src/alpha6/plan-integrity-update.ts +20 -0
  30. package/src/alpha6/plan-integrity.ts +298 -0
  31. package/src/alpha6/plan-risk.ts +1480 -0
  32. package/src/alpha6/preexecution-replan.ts +187 -0
  33. package/src/alpha6/remediation-cause.ts +98 -0
  34. package/src/alpha6/remediation.ts +2965 -0
  35. package/src/alpha6/review.ts +1198 -0
  36. package/src/alpha6/root-cause-replan-carryover.ts +471 -0
  37. package/src/alpha6/store-sidecars.ts +335 -0
  38. package/src/alpha7/autonomy.ts +411 -0
  39. package/src/alpha7/corrective-recovery.ts +1332 -0
  40. package/src/artifacts.ts +130 -0
  41. package/src/beta1/project-transaction.ts +351 -0
  42. package/src/change-explanation.ts +153 -0
  43. package/src/cli-actions.ts +119 -0
  44. package/src/cli.ts +1583 -0
  45. package/src/contracts.ts +1510 -0
  46. package/src/credential-output.ts +89 -0
  47. package/src/credential-transport.ts +215 -0
  48. package/src/delegation.ts +190 -0
  49. package/src/dependency-provenance.ts +538 -0
  50. package/src/diagnostics.ts +93 -0
  51. package/src/domain/completed-step-carryover.ts +76 -0
  52. package/src/domain/discovery.ts +27 -0
  53. package/src/domain/plan-semantics.ts +58 -0
  54. package/src/domain/validation.ts +177 -0
  55. package/src/errors.ts +23 -0
  56. package/src/fs-utils.ts +61 -0
  57. package/src/gateway-handshake.ts +103 -0
  58. package/src/git.ts +158 -0
  59. package/src/graph.ts +342 -0
  60. package/src/historical-step-provenance.ts +136 -0
  61. package/src/index.ts +21 -0
  62. package/src/lifecycle/canonical-hash.ts +28 -0
  63. package/src/lifecycle/catalog.ts +202 -0
  64. package/src/lifecycle/compiler-inspection.ts +29 -0
  65. package/src/lifecycle/core-static-readiness.ts +132 -0
  66. package/src/lifecycle/corrective-replan-authority.ts +136 -0
  67. package/src/lifecycle/corrective-replan-binding-manifest.ts +51 -0
  68. package/src/lifecycle/corrective-replan-credential-core.ts +408 -0
  69. package/src/lifecycle/corrective-replan-credential-schema.ts +54 -0
  70. package/src/lifecycle/corrective-replan-credentials.ts +48 -0
  71. package/src/lifecycle/corrective-replan.ts +843 -0
  72. package/src/lifecycle/evaluator.ts +48 -0
  73. package/src/lifecycle/fingerprint.ts +488 -0
  74. package/src/lifecycle/immutable.ts +8 -0
  75. package/src/lifecycle/implementation-table.ts +118 -0
  76. package/src/lifecycle/index.ts +8 -0
  77. package/src/lifecycle/schema-artifact.ts +263 -0
  78. package/src/lifecycle/semantic-registry.ts +572 -0
  79. package/src/lifecycle/types.ts +838 -0
  80. package/src/memory.ts +273 -0
  81. package/src/migration.ts +161 -0
  82. package/src/navigation-actions.ts +70 -0
  83. package/src/observation.ts +198 -0
  84. package/src/observed-routes.ts +661 -0
  85. package/src/operational-contract.ts +125 -0
  86. package/src/pending-review-update.ts +191 -0
  87. package/src/repository.ts +99 -0
  88. package/src/reviewer.ts +1876 -0
  89. package/src/state/corrective-replan-executor.ts +818 -0
  90. package/src/state/corrective-replan-public-schema.ts +83 -0
  91. package/src/state/corrective-replan-public.ts +908 -0
  92. package/src/state/corrective-replan-transaction.ts +947 -0
  93. package/src/state/corrective-yield-executor.ts +327 -0
  94. package/src/state/corrective-yield-transaction.ts +728 -0
  95. package/src/state/lock.ts +880 -0
  96. package/src/state/store.ts +567 -0
  97. package/src/transition-core.ts +330 -0
  98. package/src/ulid.ts +24 -0
  99. package/src/version.ts +2 -0
  100. package/src/workflow-blocker-route.ts +109 -0
  101. package/src/workflow.ts +11436 -0
@@ -0,0 +1,83 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { Ajv2020, type ValidateFunction } from 'ajv/dist/2020.js';
3
+ import { WorkflowError } from '../errors.js';
4
+
5
+ const PUBLIC_SCHEMA_ID = 'codex-workflow://schemas/public/corrective-replan/v2';
6
+ const credentialSchema = JSON.parse(readFileSync(
7
+ new URL('../../../schemas/corrective-replan-credentials.private.schema.json', import.meta.url),
8
+ 'utf8',
9
+ )) as object;
10
+ const transitionPayloadSchema = JSON.parse(readFileSync(
11
+ new URL('../../../schemas/transition-payloads.schema.json', import.meta.url),
12
+ 'utf8',
13
+ )) as object;
14
+ const publicSchema = JSON.parse(readFileSync(
15
+ new URL('../../../schemas/corrective-replan-public.schema.json', import.meta.url),
16
+ 'utf8',
17
+ )) as object;
18
+ const ajv = new Ajv2020({ allErrors: true, strict: true, formats: { 'date-time': true } });
19
+ ajv.addSchema(credentialSchema);
20
+ ajv.addSchema(transitionPayloadSchema);
21
+ ajv.addSchema(publicSchema);
22
+
23
+ export type CorrectiveReplanPublicSchemaKind =
24
+ | 'candidate'
25
+ | 'humanGate'
26
+ | 'humanGateResult'
27
+ | 'credential'
28
+ | 'executionResult'
29
+ | 'response';
30
+
31
+ const validators: Readonly<Record<CorrectiveReplanPublicSchemaKind, ValidateFunction>> = {
32
+ candidate: requiredValidator('candidateV1'),
33
+ humanGate: requiredValidator('humanGateV1'),
34
+ humanGateResult: requiredValidator('humanGateResultV1'),
35
+ credential: requiredValidator('credentialV1'),
36
+ executionResult: requiredValidator('executionResultV1'),
37
+ response: requiredValidator('responseV2'),
38
+ };
39
+
40
+ export function validateCorrectiveReplanPublicValue(
41
+ kind: CorrectiveReplanPublicSchemaKind,
42
+ value: unknown,
43
+ ): boolean {
44
+ return validateSchemaView(validators[kind], value);
45
+ }
46
+
47
+ export function assertCorrectiveReplanPublicOutput<T>(
48
+ kind: CorrectiveReplanPublicSchemaKind,
49
+ value: T,
50
+ ): T {
51
+ const validator = validators[kind];
52
+ if (!validateSchemaView(validator, value)) {
53
+ throw new WorkflowError('STATE_CORRUPT', 'Core produced an invalid corrective-replan protocol-v2 response.', {
54
+ responseKind: kind,
55
+ schemaId: PUBLIC_SCHEMA_ID,
56
+ errors: normalizeErrors(validator.errors),
57
+ });
58
+ }
59
+ return value;
60
+ }
61
+
62
+ // Public boundaries seal JSON records with null prototypes. AJV uniqueItems
63
+ // uses fast-deep-equal, which assumes Object.prototype.valueOf exists. A schema
64
+ // view normalizes prototypes without dropping own undefined/unknown keys (as a
65
+ // JSON stringify/parse roundtrip would). The hashed/executed value is untouched.
66
+ function validateSchemaView(validator: ValidateFunction, value: unknown): boolean {
67
+ try {
68
+ return validator(structuredClone(value)) === true;
69
+ } catch {
70
+ // Non-cloneable values and malformed objects remain invalid public JSON.
71
+ return false;
72
+ }
73
+ }
74
+
75
+ function requiredValidator(definition: string): ValidateFunction {
76
+ const validator = ajv.getSchema(`${PUBLIC_SCHEMA_ID}#/$defs/${definition}`);
77
+ if (!validator) throw new TypeError(`Missing corrective-replan public schema definition ${definition}.`);
78
+ return validator;
79
+ }
80
+
81
+ function normalizeErrors(errors: ValidateFunction['errors']): readonly Readonly<{ path: string; keyword: string }>[] {
82
+ return (errors ?? []).map((entry) => ({ path: entry.instancePath || '/', keyword: entry.keyword }));
83
+ }