@dsh-ray/assistant-growth-contract 0.0.1-seed.0 → 0.2.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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +68 -1
  3. package/lib/automation.d.ts +21 -0
  4. package/lib/automation.d.ts.map +1 -0
  5. package/lib/automation.js +336 -0
  6. package/lib/automation.js.map +1 -0
  7. package/lib/canonical.d.ts +44 -0
  8. package/lib/canonical.d.ts.map +1 -0
  9. package/lib/canonical.js +541 -0
  10. package/lib/canonical.js.map +1 -0
  11. package/lib/creation-verification.d.ts +111 -0
  12. package/lib/creation-verification.d.ts.map +1 -0
  13. package/lib/creation-verification.js +150 -0
  14. package/lib/creation-verification.js.map +1 -0
  15. package/lib/index.d.ts +16 -0
  16. package/lib/index.d.ts.map +1 -0
  17. package/lib/index.js +16 -0
  18. package/lib/index.js.map +1 -0
  19. package/lib/memory-learning.d.ts +91 -0
  20. package/lib/memory-learning.d.ts.map +1 -0
  21. package/lib/memory-learning.js +162 -0
  22. package/lib/memory-learning.js.map +1 -0
  23. package/lib/native-model-messages.d.ts +11 -0
  24. package/lib/native-model-messages.d.ts.map +1 -0
  25. package/lib/native-model-messages.js +39 -0
  26. package/lib/native-model-messages.js.map +1 -0
  27. package/lib/plugin-protection.d.ts +28 -0
  28. package/lib/plugin-protection.d.ts.map +1 -0
  29. package/lib/plugin-protection.js +77 -0
  30. package/lib/plugin-protection.js.map +1 -0
  31. package/lib/preferences.d.ts +13 -0
  32. package/lib/preferences.d.ts.map +1 -0
  33. package/lib/preferences.js +19 -0
  34. package/lib/preferences.js.map +1 -0
  35. package/lib/promotion.d.ts +192 -0
  36. package/lib/promotion.d.ts.map +1 -0
  37. package/lib/promotion.js +442 -0
  38. package/lib/promotion.js.map +1 -0
  39. package/lib/revision-benefit.d.ts +106 -0
  40. package/lib/revision-benefit.d.ts.map +1 -0
  41. package/lib/revision-benefit.js +135 -0
  42. package/lib/revision-benefit.js.map +1 -0
  43. package/lib/revision-regression.d.ts +83 -0
  44. package/lib/revision-regression.d.ts.map +1 -0
  45. package/lib/revision-regression.js +169 -0
  46. package/lib/revision-regression.js.map +1 -0
  47. package/lib/revision-verification.d.ts +80 -0
  48. package/lib/revision-verification.d.ts.map +1 -0
  49. package/lib/revision-verification.js +114 -0
  50. package/lib/revision-verification.js.map +1 -0
  51. package/lib/source-owner.d.ts +17 -0
  52. package/lib/source-owner.d.ts.map +1 -0
  53. package/lib/source-owner.js +19 -0
  54. package/lib/source-owner.js.map +1 -0
  55. package/lib/source-run.d.ts +190 -0
  56. package/lib/source-run.d.ts.map +1 -0
  57. package/lib/source-run.js +410 -0
  58. package/lib/source-run.js.map +1 -0
  59. package/lib/types.d.ts +246 -0
  60. package/lib/types.d.ts.map +1 -0
  61. package/lib/types.js +26 -0
  62. package/lib/types.js.map +1 -0
  63. package/lib/version.d.ts +2 -0
  64. package/lib/version.d.ts.map +1 -0
  65. package/lib/version.js +2 -0
  66. package/lib/version.js.map +1 -0
  67. package/package.json +37 -4
@@ -0,0 +1,135 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { types as utilTypes } from 'node:util';
3
+ const RATE_EPSILON = 1e-9;
4
+ function finiteRate(numerator, denominator) {
5
+ return denominator <= 0 ? 0 : numerator / denominator;
6
+ }
7
+ function isGrowthRecord(value) {
8
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
9
+ }
10
+ /** Structural validation for one window; numbers must be non-negative safe integers. */
11
+ export function validateRevisionBenefitWindowStats(value) {
12
+ if (!isGrowthRecord(value) || utilTypes.isProxy(value))
13
+ throw new Error('benefit window must be a plain record');
14
+ const required = ['protocol', 'artifactSha256', 'windowStart', 'windowEnd', 'taskRevisions',
15
+ 'correctedOrWithdrawn', 'failed', 'reworked', 'latencyMsTotal', 'tokensTotal', 'inputTokensTotal', 'outputTokensTotal'];
16
+ for (const key of required)
17
+ if (!(key in value))
18
+ throw new Error(`benefit window missing ${key}`);
19
+ if (value.protocol !== 'assistant-growth/revision-benefit-window/v1')
20
+ throw new Error('benefit window protocol mismatch');
21
+ if (typeof value.artifactSha256 !== 'string' || !/^[a-f0-9]{64}$/u.test(value.artifactSha256))
22
+ throw new Error('benefit window artifact digest invalid');
23
+ const windowStart = value.windowStart, windowEnd = value.windowEnd, taskRevisions = value.taskRevisions;
24
+ const correctedOrWithdrawn = value.correctedOrWithdrawn, failed = value.failed, reworked = value.reworked;
25
+ for (const item of [windowStart, windowEnd, taskRevisions, correctedOrWithdrawn, failed, reworked,
26
+ value.latencyMsTotal, value.tokensTotal, value.inputTokensTotal, value.outputTokensTotal]) {
27
+ if (typeof item !== 'number' || !Number.isSafeInteger(item) || item < 0)
28
+ throw new Error('benefit window counter invalid');
29
+ }
30
+ if (windowEnd <= windowStart)
31
+ throw new Error('benefit window must be nonempty');
32
+ if (failed + reworked > Math.max(0, taskRevisions - correctedOrWithdrawn)) {
33
+ throw new Error('benefit window counters exceed the included set');
34
+ }
35
+ }
36
+ export function validateRevisionBenefitContract(value) {
37
+ if (!isGrowthRecord(value) || utilTypes.isProxy(value))
38
+ throw new Error('benefit contract must be a plain record');
39
+ if (value.protocol !== 'assistant-growth/revision-benefit-contract/v1')
40
+ throw new Error('benefit contract protocol mismatch');
41
+ const model = value.model;
42
+ if (!isGrowthRecord(model) || typeof model.provider !== 'string' || !model.provider
43
+ || typeof model.model !== 'string' || !model.model
44
+ || model.reasoningEffort !== undefined && (typeof model.reasoningEffort !== 'string' || !model.reasoningEffort)) {
45
+ throw new Error('benefit contract model invalid');
46
+ }
47
+ const budget = value.budget;
48
+ if (!isGrowthRecord(budget) || typeof budget.budgetId !== 'string' || !budget.budgetId
49
+ || typeof budget.amount !== 'number' || !Number.isSafeInteger(budget.amount) || budget.amount < 1) {
50
+ throw new Error('benefit contract budget invalid');
51
+ }
52
+ const thresholds = value.thresholds;
53
+ if (!isGrowthRecord(thresholds))
54
+ throw new Error('benefit contract thresholds missing');
55
+ for (const key of ['maxFailureRateDelta', 'maxReworkRateDelta', 'maxCorrectionRateDelta']) {
56
+ const item = thresholds[key];
57
+ if (typeof item !== 'number' || !Number.isFinite(item) || item < 0 || item > 1)
58
+ throw new Error(`benefit threshold ${key} invalid`);
59
+ }
60
+ for (const key of ['maxLatencyRatio', 'maxCostRatio']) {
61
+ const item = thresholds[key];
62
+ if (typeof item !== 'number' || !Number.isFinite(item) || item < 1 || item > 100)
63
+ throw new Error(`benefit threshold ${key} invalid`);
64
+ }
65
+ if (typeof value.minimumTaskRevisions !== 'number' || !Number.isSafeInteger(value.minimumTaskRevisions)
66
+ || value.minimumTaskRevisions < 1 || value.minimumTaskRevisions > 1_000)
67
+ throw new Error('benefit contract minimumTaskRevisions invalid');
68
+ if (typeof value.createdAt !== 'number' || !Number.isSafeInteger(value.createdAt)
69
+ || typeof value.expiresAt !== 'number' || !Number.isSafeInteger(value.expiresAt)
70
+ || value.expiresAt <= value.createdAt)
71
+ throw new Error('benefit contract lifetime invalid');
72
+ }
73
+ export function revisionBenefitContractDigest(value) {
74
+ validateRevisionBenefitContract(value);
75
+ return createHash('sha256').update(JSON.stringify(value)).digest('hex');
76
+ }
77
+ function summarize(stats) {
78
+ const included = Math.max(0, stats.taskRevisions - stats.correctedOrWithdrawn);
79
+ return {
80
+ included,
81
+ failureRate: finiteRate(stats.failed, included),
82
+ reworkRate: finiteRate(stats.reworked, included),
83
+ correctionRate: finiteRate(stats.correctedOrWithdrawn, stats.taskRevisions),
84
+ meanLatencyMs: finiteRate(stats.latencyMsTotal, included),
85
+ meanTokens: finiteRate(stats.tokensTotal, included),
86
+ };
87
+ }
88
+ /**
89
+ * Deterministic non-inferiority evaluation. The candidate is compared against
90
+ * the parent under the contract thresholds; every metric violation names
91
+ * itself in the inferior reason, and sample-short windows stay insufficient.
92
+ */
93
+ export function evaluateRevisionBenefit(contract, parent, candidate, now) {
94
+ validateRevisionBenefitContract(contract);
95
+ validateRevisionBenefitWindowStats(parent);
96
+ validateRevisionBenefitWindowStats(candidate);
97
+ const parentSummary = summarize(parent);
98
+ const candidateSummary = summarize(candidate);
99
+ const evaluation = {
100
+ verdict: { status: 'insufficient', reason: 'below-minimum-samples' },
101
+ parent: parentSummary,
102
+ candidate: candidateSummary,
103
+ };
104
+ if (now >= contract.expiresAt) {
105
+ return { ...evaluation, verdict: { status: 'insufficient', reason: 'contract-expired' } };
106
+ }
107
+ if (parentSummary.included < contract.minimumTaskRevisions
108
+ || candidateSummary.included < contract.minimumTaskRevisions) {
109
+ return evaluation;
110
+ }
111
+ // Cost and latency must be measurable on both windows before any quality
112
+ // claim: an unmeasured axis never passes non-inferiority by default.
113
+ if (parentSummary.meanTokens <= 0 || candidateSummary.meanTokens <= 0
114
+ || parentSummary.meanLatencyMs <= 0 || candidateSummary.meanLatencyMs <= 0) {
115
+ return { ...evaluation, verdict: { status: 'insufficient', reason: 'cost-or-latency-unmeasured' } };
116
+ }
117
+ const thresholds = contract.thresholds;
118
+ if (candidateSummary.failureRate > parentSummary.failureRate + thresholds.maxFailureRateDelta + RATE_EPSILON) {
119
+ return { ...evaluation, verdict: { status: 'inferior', reason: 'failure-rate' } };
120
+ }
121
+ if (candidateSummary.reworkRate > parentSummary.reworkRate + thresholds.maxReworkRateDelta + RATE_EPSILON) {
122
+ return { ...evaluation, verdict: { status: 'inferior', reason: 'rework-rate' } };
123
+ }
124
+ if (candidateSummary.correctionRate > parentSummary.correctionRate + thresholds.maxCorrectionRateDelta + RATE_EPSILON) {
125
+ return { ...evaluation, verdict: { status: 'inferior', reason: 'correction-rate' } };
126
+ }
127
+ if (candidateSummary.meanLatencyMs > parentSummary.meanLatencyMs * thresholds.maxLatencyRatio + RATE_EPSILON) {
128
+ return { ...evaluation, verdict: { status: 'inferior', reason: 'latency' } };
129
+ }
130
+ if (candidateSummary.meanTokens > parentSummary.meanTokens * thresholds.maxCostRatio + RATE_EPSILON) {
131
+ return { ...evaluation, verdict: { status: 'inferior', reason: 'cost' } };
132
+ }
133
+ return { ...evaluation, verdict: { status: 'non-inferior', reason: 'all-metrics-within-thresholds' } };
134
+ }
135
+ //# sourceMappingURL=revision-benefit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revision-benefit.js","sourceRoot":"","sources":["../src/revision-benefit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAA;AAoF9C,MAAM,YAAY,GAAG,IAAI,CAAA;AAEzB,SAAS,UAAU,CAAC,SAAiB,EAAE,WAAmB;IACxD,OAAO,WAAW,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,WAAW,CAAA;AACvD,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,kCAAkC,CAAC,KAAc;IAC/D,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;IAChH,MAAM,QAAQ,GAAG,CAAC,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe;QACzF,sBAAsB,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAA;IACzH,KAAK,MAAM,GAAG,IAAI,QAAQ;QAAE,IAAI,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,GAAG,EAAE,CAAC,CAAA;IACjG,IAAI,KAAK,CAAC,QAAQ,KAAK,6CAA6C;QAAE,MAAM,IAAI,KAAK,C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ACtH,OAAO,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,EAAE,EAAE,CAAA;IACtF,CAAC;IACD,IAAI,gBAAgB,CAAC,aAAa,GAAG,aAAa,CAAC,aAAa,GAAG,UAAU,CAAC,eAAe,GAAG,YAAY,EAAE,CAAC;QAC7G,OAAO,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,CAAA;IAC9E,CAAC;IACD,IAAI,gBAAgB,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,GAAG,UAAU,CAAC,YAAY,GAAG,YAAY,EAAE,CAAC;QACpG,OAAO,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAA;IAC3E,CAAC;IACD,OAAO,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,+BAA+B,EAAE,EAAE,CAAA;AACxG,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { type PluginRevisionParentBinding, type PluginRevisionVerificationCertificate } from './revision-verification.js';
2
+ /** Independent owner policy for testing retained parent behavior before any version switch. */
3
+ export interface RevisionRegressionAcceptanceAuthorityRef {
4
+ protocol: 'assistant-growth/revision-regression-acceptance-authority/v1';
5
+ authorityId: string;
6
+ keyId: string;
7
+ authorityDigest: string;
8
+ namePrefix: string;
9
+ expiresAt: number;
10
+ }
11
+ /** Linux observation provenance shared by the paired parent/candidate runs. */
12
+ export interface PluginRevisionRegressionLinuxExecution {
13
+ boundary: 'linux-native-process-seccomp-v1';
14
+ /** Fixed behavior runtime descriptor that produced both paired observations. */
15
+ runtimeDigest: string;
16
+ /** Validated private observer preparation receipt shared by both sides. */
17
+ observerPreparationDigest: string;
18
+ }
19
+ export interface PluginRevisionRegressionCertificate {
20
+ protocol: 'assistant-growth/revision-regression/v1' | 'assistant-growth/revision-regression/v2';
21
+ verificationId: string;
22
+ authority: RevisionRegressionAcceptanceAuthorityRef;
23
+ plan: PluginRevisionVerificationCertificate['plan'];
24
+ parent: PluginRevisionParentBinding;
25
+ source: PluginRevisionVerificationCertificate['source'];
26
+ /** Digest of the actual retained, independent parent cases; consumers check it against the parent certificate. */
27
+ contractDigest: string;
28
+ schemaDigest: string;
29
+ environment: PluginRevisionVerificationCertificate['environment'];
30
+ model: PluginRevisionVerificationCertificate['model'];
31
+ candidateVerificationDigest: string;
32
+ sourceDigest: string;
33
+ schemaCompatibilityDigest: string;
34
+ budget: {
35
+ maxCases: number;
36
+ maxDurationMs: number;
37
+ maxRuns: number;
38
+ };
39
+ observations: readonly {
40
+ caseId: string;
41
+ parent: {
42
+ jobId: string;
43
+ operationDigest: string;
44
+ observationDigest: string;
45
+ };
46
+ candidate: {
47
+ jobId: string;
48
+ operationDigest: string;
49
+ observationDigest: string;
50
+ };
51
+ }[];
52
+ verifiedAt: number;
53
+ expiresAt: number;
54
+ signature: string;
55
+ /** Required exactly for v2: the Linux native runtime of both paired observations; rejected for v1. */
56
+ execution?: PluginRevisionRegressionLinuxExecution;
57
+ }
58
+ export type PluginRevisionRegressionCertificateV1 = PluginRevisionRegressionCertificate & {
59
+ protocol: 'assistant-growth/revision-regression/v1';
60
+ execution?: never;
61
+ };
62
+ export type PluginRevisionRegressionCertificateV2 = PluginRevisionRegressionCertificate & {
63
+ protocol: 'assistant-growth/revision-regression/v2';
64
+ execution: PluginRevisionRegressionLinuxExecution;
65
+ };
66
+ export interface PluginRevisionRegressionRequest {
67
+ protocol: 'assistant-growth/revision-regression-request/v1';
68
+ planId: string;
69
+ }
70
+ export type PluginRevisionRegressionResult = {
71
+ status: 'verified';
72
+ certificate: PluginRevisionRegressionCertificate;
73
+ } | {
74
+ status: 'rejected' | 'unknown';
75
+ reason: string;
76
+ };
77
+ export declare function validateRevisionRegressionAcceptanceAuthorityRef(value: unknown): asserts value is RevisionRegressionAcceptanceAuthorityRef;
78
+ export declare function validatePluginRevisionRegressionRequest(value: unknown): asserts value is PluginRevisionRegressionRequest;
79
+ export declare function validatePluginRevisionRegressionCertificate(value: unknown): asserts value is PluginRevisionRegressionCertificate;
80
+ export declare function pluginRevisionRegressionSigningPayload(value: Omit<PluginRevisionRegressionCertificate, 'signature'>): string;
81
+ /** Signature and authority equality only; consumers must recheck parent certificate bindings, provenance and source currency. */
82
+ export declare function verifyPluginRevisionRegressionCertificate(value: unknown, authority: RevisionRegressionAcceptanceAuthorityRef, publicKey: string, now?: number): value is PluginRevisionRegressionCertificate;
83
+ //# sourceMappingURL=revision-regression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revision-regression.d.ts","sourceRoot":"","sources":["../src/revision-regression.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuC,KAAK,2BAA2B,EAC5E,KAAK,qCAAqC,EAAE,MAAM,4BAA4B,CAAA;AAEhF,+FAA+F;AAC/F,MAAM,WAAW,wCAAwC;IACvD,QAAQ,EAAE,8DAA8D,CAAA;IACxE,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,+EAA+E;AAC/E,MAAM,WAAW,sCAAsC;IACrD,QAAQ,EAAE,iCAAiC,CAAA;IAC3C,gFAAgF;IAChF,aAAa,EAAE,MAAM,CAAA;IACrB,2EAA2E;IAC3E,yBAAyB,EAAE,MAAM,CAAA;CAClC;AAED,MAAM,WAAW,mCAAmC;IAClD,QAAQ,EAAE,yCAAyC,GAAG,yCAAyC,CAAA;IAC/F,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,wCAAwC,CAAA;IACnD,IAAI,EAAE,qCAAqC,CAAC,MAAM,CAAC,CAAA;IACnD,MAAM,EAAE,2B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CAAA;IAC3D,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,8BAA8B,GACtC;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,mCAAmC,CAAA;CAAE,GACxE;IAAE,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AA8CtD,wBAAgB,gDAAgD,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,wCAAwC,CAO1I;AAED,wBAAgB,uCAAuC,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,+BAA+B,CAIxH;AAED,wBAAgB,2CAA2C,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,mCAAmC,CA6DhI;AAED,wBAAgB,sCAAsC,CAAC,KAAK,EAAE,IAAI,CAAC,mCAAmC,EAAE,WAAW,CAAC,GAAG,MAAM,CAI5H;AAED,iIAAiI;AACjI,wBAAgB,yCAAyC,CAAC,KAAK,EAAE,OAAO,EACtE,SAAS,EAAE,wCAAwC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG,KAAK,IAAI,mCAAmC,CAWxI"}
@@ -0,0 +1,169 @@
1
+ import { createPublicKey, verify } from 'node:crypto';
2
+ import { canonicalGrowthJson } from './canonical.js';
3
+ import { validatePluginRevisionParentBinding } from './revision-verification.js';
4
+ const domainV1 = 'assistant-growth/revision-regression/v1\0';
5
+ const domainV2 = 'assistant-growth/revision-regression/v2\0';
6
+ const digest = /^[a-f0-9]{64}$/u;
7
+ const identifier = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,199}$/u;
8
+ const keys = ['protocol', 'verificationId', 'authority', 'plan', 'parent', 'source', 'contractDigest',
9
+ 'schemaDigest', 'environment', 'model', 'candidateVerificationDigest', 'sourceDigest',
10
+ 'schemaCompatibilityDigest', 'budget', 'observations', 'verifiedAt', 'expiresAt'];
11
+ function certificateKeysFor(value) {
12
+ const protocol = value && typeof value === 'object' ? Object.getOwnPropertyDescriptor(value, 'protocol')?.value : undefined;
13
+ return protocol === 'assistant-growth/revision-regression/v2' ? [...keys, 'execution'] : keys;
14
+ }
15
+ function fail(label) { throw new Error(`invalid plugin revision regression ${label}`); }
16
+ function record(value, expected, label) {
17
+ if (!value || typeof value !== 'object' || Array.isArray(value)
18
+ || Object.getPrototypeOf(value) !== Object.prototype || Object.getOwnPropertySymbols(value).length
19
+ || !Object.values(Object.getOwnPropertyDescriptors(value)).every(item => item.enumerable && 'value' in item)
20
+ || Object.keys(value).sort().join('\0') !== [...expected].sort().join('\0'))
21
+ fail(label);
22
+ return value;
23
+ }
24
+ function id(value, label) {
25
+ if (typeof value !== 'string' || !identifier.test(value) || value.normalize('NFC') !== value)
26
+ fail(label);
27
+ }
28
+ function sha(value, label) {
29
+ if (typeof value !== 'string' || !digest.test(value))
30
+ fail(label);
31
+ }
32
+ function integer(value, label, min, max) {
33
+ if (!Number.isSafeInteger(value) || Number(value) < min || Number(value) > max)
34
+ fail(label);
35
+ }
36
+ function text(value, label, maximum = 500) {
37
+ if (typeof value !== 'string' || !value || !value.isWellFormed() || value.normalize('NFC').trim() !== value
38
+ || Buffer.byteLength(value) > maximum || /[\p{Cc}]/u.test(value))
39
+ fail(label);
40
+ }
41
+ function rows(value) {
42
+ if (!Array.isArray(value) || value.length < 2 || value.length > 8
43
+ || Object.getPrototypeOf(value) !== Array.prototype || Object.getOwnPropertySymbols(value).length
44
+ || Object.getOwnPropertyNames(value).length !== value.length + 1
45
+ || !Object.entries(Object.getOwnPropertyDescriptors(value)).every(([key, entry]) => key === 'length'
46
+ || /^(0|[1-9][0-9]*)$/u.test(key) && entry.enumerable && 'value' in entry)
47
+ || !Array.from({ length: value.length }, (_, index) => Object.hasOwn(value, index)).every(Boolean))
48
+ fail('observation array');
49
+ return value;
50
+ }
51
+ export function validateRevisionRegressionAcceptanceAuthorityRef(value) {
52
+ const ref = record(value, ['protocol', 'authorityId', 'keyId', 'authorityDigest', 'namePrefix', 'expiresAt'], 'authority');
53
+ if (ref.protocol !== 'assistant-growth/revision-regression-acceptance-authority/v1')
54
+ fail('authority protocol');
55
+ id(ref.authorityId, 'authorityId');
56
+ id(ref.keyId, 'keyId');
57
+ sha(ref.authorityDigest, 'authorityDigest');
58
+ if (typeof ref.namePrefix !== 'string' || ref.namePrefix.length < 2 || ref.namePrefix.length > 48
59
+ || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*-$/u.test(ref.namePrefix))
60
+ fail('namePrefix');
61
+ integer(ref.expiresAt, 'authority expiry', 1, 8_640_000_000_000_000);
62
+ }
63
+ export function validatePluginRevisionRegressionRequest(value) {
64
+ const request = record(value, ['protocol', 'planId'], 'request');
65
+ if (request.protocol !== 'assistant-growth/revision-regression-request/v1')
66
+ fail('request protocol');
67
+ id(request.planId, 'request planId');
68
+ }
69
+ export function validatePluginRevisionRegressionCertificate(value) {
70
+ const protocol = value && typeof value === 'object' ? Object.getOwnPropertyDescriptor(value, 'protocol')?.value : undefined;
71
+ const linux = protocol === 'assistant-growth/revision-regression/v2';
72
+ const item = record(value, [...certificateKeysFor(value), 'signature'], 'certificate');
73
+ if (!linux && item.protocol !== 'assistant-growth/revision-regression/v1')
74
+ fail('protocol');
75
+ if (linux) {
76
+ const execution = record(item.execution, ['boundary', 'runtimeDigest', 'observerPreparationDigest'], 'execution');
77
+ if (execution.boundary !== 'linux-native-process-seccomp-v1')
78
+ fail('execution boundary');
79
+ sha(execution.runtimeDigest, 'runtimeDigest');
80
+ sha(execution.observerPreparationDigest, 'observerPreparationDigest');
81
+ }
82
+ id(item.verificationId, 'verificationId');
83
+ validateRevisionRegressionAcceptanceAuthorityRef(item.authority);
84
+ const authority = item.authority;
85
+ const plan = record(item.plan, ['id', 'digest', 'name', 'sourceTreeDigest', 'sourcePatchDigest', 'artifactSha256',
86
+ 'artifactBytes', 'generatorDigest'], 'plan');
87
+ id(plan.id, 'plan id');
88
+ if (typeof plan.name !== 'string' || plan.name.length > 64 || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(plan.name)
89
+ || !plan.name.startsWith(authority.namePrefix))
90
+ fail('plan name');
91
+ for (const key of ['digest', 'sourceTreeDigest', 'sourcePatchDigest', 'artifactSha256', 'generatorDigest'])
92
+ sha(plan[key], key);
93
+ integer(plan.artifactBytes, 'artifact bytes', 1, 512 * 1024);
94
+ validatePluginRevisionParentBinding(item.parent);
95
+ const source = record(item.source, ['referenceDigest', 'ownerDigest', 'growthRunDigest'], 'source');
96
+ for (const key of ['referenceDigest', 'ownerDigest', 'growthRunDigest'])
97
+ sha(source[key], key);
98
+ for (const key of ['contractDigest', 'schemaDigest', 'candidateVerificationDigest', 'sourceDigest',
99
+ 'schemaCompatibilityDigest'])
100
+ sha(item[key], key);
101
+ const environment = record(item.environment, ['node', 'cordis', 'tools', 'systemPrompt'], 'environment');
102
+ for (const key of ['node', 'cordis', 'tools', 'systemPrompt']) {
103
+ if (typeof environment[key] !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9.+-]{0,63}$/u.test(environment[key]))
104
+ fail(key);
105
+ }
106
+ const model = record(item.model, ['provider', 'model',
107
+ ...(item.model && typeof item.model === 'object' && Object.hasOwn(item.model, 'reasoningEffort') ? ['reasoningEffort'] : [])], 'model');
108
+ text(model.provider, 'provider');
109
+ text(model.model, 'model');
110
+ if (Object.hasOwn(model, 'reasoningEffort'))
111
+ text(model.reasoningEffort, 'reasoningEffort');
112
+ const budget = record(item.budget, ['maxCases', 'maxDurationMs', 'maxRuns'], 'budget');
113
+ integer(budget.maxCases, 'cases', 2, 8);
114
+ integer(budget.maxDurationMs, 'duration', 1_000, 1_800_000);
115
+ integer(budget.maxRuns, 'runs', 2 + 2 * Number(budget.maxCases), 64);
116
+ const observations = rows(item.observations);
117
+ if (observations.length > Number(budget.maxCases))
118
+ fail('observations exceed budget');
119
+ const cases = new Set(), jobs = new Set();
120
+ for (const entry of observations) {
121
+ const observation = record(entry, ['caseId', 'parent', 'candidate'], 'observation');
122
+ id(observation.caseId, 'caseId');
123
+ if (cases.has(String(observation.caseId)))
124
+ fail('duplicate case');
125
+ cases.add(String(observation.caseId));
126
+ for (const side of ['parent', 'candidate']) {
127
+ const result = record(observation[side], ['jobId', 'operationDigest', 'observationDigest'], `${side} observation`);
128
+ id(result.jobId, `${side} jobId`);
129
+ sha(result.operationDigest, `${side} operationDigest`);
130
+ sha(result.observationDigest, `${side} observationDigest`);
131
+ if (jobs.has(String(result.jobId)))
132
+ fail('duplicate observation job');
133
+ jobs.add(String(result.jobId));
134
+ }
135
+ }
136
+ integer(item.verifiedAt, 'verifiedAt', 1, 8_640_000_000_000_000);
137
+ integer(item.expiresAt, 'expiresAt', 1, 8_640_000_000_000_000);
138
+ if (Number(item.expiresAt) <= Number(item.verifiedAt) || Number(item.expiresAt) > authority.expiresAt)
139
+ fail('certificate expiry');
140
+ if (typeof item.signature !== 'string' || !/^[A-Za-z0-9_-]{86}$/u.test(item.signature)
141
+ || Buffer.from(item.signature, 'base64url').length !== 64
142
+ || Buffer.from(item.signature, 'base64url').toString('base64url') !== item.signature)
143
+ fail('signature');
144
+ if (Buffer.byteLength(canonicalGrowthJson(item)) > 65_536)
145
+ fail('certificate bytes');
146
+ }
147
+ export function pluginRevisionRegressionSigningPayload(value) {
148
+ const body = record(value, certificateKeysFor(value), 'signing body');
149
+ validatePluginRevisionRegressionCertificate({ ...body, signature: 'A'.repeat(86) });
150
+ return (body.protocol === 'assistant-growth/revision-regression/v2' ? domainV2 : domainV1) + canonicalGrowthJson(body);
151
+ }
152
+ /** Signature and authority equality only; consumers must recheck parent certificate bindings, provenance and source currency. */
153
+ export function verifyPluginRevisionRegressionCertificate(value, authority, publicKey, now = Date.now()) {
154
+ try {
155
+ validateRevisionRegressionAcceptanceAuthorityRef(authority);
156
+ validatePluginRevisionRegressionCertificate(value);
157
+ if (!Number.isSafeInteger(now) || value.verifiedAt > now || value.expiresAt <= now
158
+ || canonicalGrowthJson(value.authority) !== canonicalGrowthJson(authority))
159
+ return false;
160
+ const { signature, ...body } = value;
161
+ const key = createPublicKey(publicKey);
162
+ return key.asymmetricKeyType === 'ed25519'
163
+ && verify(null, Buffer.from(pluginRevisionRegressionSigningPayload(body)), key, Buffer.from(signature, 'base64url'));
164
+ }
165
+ catch {
166
+ return false;
167
+ }
168
+ }
169
+ //# sourceMappingURL=revision-regression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revision-regression.js","sourceRoot":"","sources":["../src/revision-regression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,mCAAmC,EACE,MAAM,4BAA4B,CAAA;AA+DhF,MAAM,QAAQ,GAAG,2CAA2C,CAAA;AAC5D,MAAM,QAAQ,GAAG,2CAA2C,CAAA;AAC5D,MAAM,MAAM,GAAG,iBAAiB,CAAA;AAChC,MAAM,UAAU,GAAG,uCAAuC,CAAA;AAC1D,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB;IACnG,cAAc,EAAE,aAAa,EAAE,OAAO,EAAE,6BAA6B,EAAE,cAAc;IACrF,2BAA2B,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,CAAU,CAAA;AAE5F,SAAS,kBAAkB,CAAC,KAAc;IACxC,MAAM,QAAQ,GAAG,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;IAC3H,OAAO,QAAQ,KAAK,yCAAyC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,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QAAC,OAAO,KAAK,CAAA;IAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,80 @@
1
+ import { type PluginCreationVerificationCertificate, type PluginCreationVerificationLinuxExecution } from './creation-verification.js';
2
+ /** Owner policy frozen before a revision candidate can be written. */
3
+ export interface RevisionAcceptanceAuthorityRef {
4
+ protocol: 'assistant-growth/revision-acceptance-authority/v1';
5
+ authorityId: string;
6
+ keyId: string;
7
+ authorityDigest: string;
8
+ namePrefix: string;
9
+ expiresAt: number;
10
+ }
11
+ /** Exact adopted version and retained source on which the revision is based. */
12
+ export interface PluginRevisionParentBinding {
13
+ planId: string;
14
+ certificateDigest: string;
15
+ artifactSha256: string;
16
+ sourceArchiveDigest: string;
17
+ sourceDigest: string;
18
+ }
19
+ /**
20
+ * Task-failure revisions bind the frozen growth run that authorized them.
21
+ * Owner-instruction revisions have no growth run: their signed source instead
22
+ * binds the exact instruction row that authenticated the revision, while the
23
+ * parent binding already names the adopted plan.
24
+ */
25
+ export type PluginRevisionVerificationTaskSource = {
26
+ referenceDigest: string;
27
+ ownerDigest: string;
28
+ growthRunDigest: string;
29
+ };
30
+ export type PluginRevisionVerificationInstructionSource = {
31
+ instructionDigest: string;
32
+ ownerDigest: string;
33
+ };
34
+ export type PluginRevisionVerificationSource = PluginRevisionVerificationTaskSource | PluginRevisionVerificationInstructionSource;
35
+ export declare function isPluginRevisionTaskSource(value: PluginRevisionVerificationSource): value is PluginRevisionVerificationTaskSource;
36
+ export declare function isPluginRevisionInstructionSource(value: PluginRevisionVerificationSource): value is PluginRevisionVerificationInstructionSource;
37
+ export type PluginRevisionVerificationCertificate = Omit<PluginCreationVerificationCertificate, 'protocol' | 'authority' | 'execution' | 'source'> & {
38
+ protocol: 'assistant-growth/revision-verification/v1' | 'assistant-growth/revision-verification/v2' | 'assistant-growth/revision-verification/v3';
39
+ authority: RevisionAcceptanceAuthorityRef;
40
+ parent: PluginRevisionParentBinding;
41
+ source: PluginRevisionVerificationSource;
42
+ /** Required exactly for v2 with the Linux native boundary; rejected for v1 and v3. */
43
+ execution?: PluginCreationVerificationLinuxExecution;
44
+ };
45
+ export type PluginRevisionVerificationCertificateV1 = PluginRevisionVerificationCertificate & {
46
+ protocol: 'assistant-growth/revision-verification/v1';
47
+ execution?: never;
48
+ };
49
+ export type PluginRevisionVerificationCertificateV2 = PluginRevisionVerificationCertificate & {
50
+ protocol: 'assistant-growth/revision-verification/v2';
51
+ execution: PluginCreationVerificationLinuxExecution;
52
+ };
53
+ /** Owner-instruction revision: no task reference and no growth run anywhere in the signed body. */
54
+ export type PluginRevisionVerificationCertificateV3 = PluginRevisionVerificationCertificate & {
55
+ protocol: 'assistant-growth/revision-verification/v3';
56
+ execution?: never;
57
+ source: {
58
+ instructionDigest: string;
59
+ ownerDigest: string;
60
+ };
61
+ };
62
+ /** Host-only request; the producer must reread the current parent and candidate. */
63
+ export interface PluginRevisionVerificationRequest {
64
+ protocol: 'assistant-growth/revision-verification-request/v1';
65
+ planId: string;
66
+ }
67
+ export type PluginRevisionVerificationResult = {
68
+ status: 'verified';
69
+ certificate: PluginRevisionVerificationCertificate;
70
+ } | {
71
+ status: 'rejected' | 'unknown';
72
+ reason: string;
73
+ };
74
+ export declare function validateRevisionAcceptanceAuthorityRef(value: unknown): asserts value is RevisionAcceptanceAuthorityRef;
75
+ export declare function validatePluginRevisionParentBinding(value: unknown): asserts value is PluginRevisionParentBinding;
76
+ export declare function validatePluginRevisionVerificationCertificate(value: unknown): asserts value is PluginRevisionVerificationCertificate;
77
+ export declare function pluginRevisionVerificationSigningPayload(value: Omit<PluginRevisionVerificationCertificate, 'signature'>): string;
78
+ /** Signature and authority equality only; consumers must also recheck provenance and parent currency. */
79
+ export declare function verifyPluginRevisionVerificationCertificate(value: unknown, authority: RevisionAcceptanceAuthorityRef, publicKey: string, now?: number): value is PluginRevisionVerificationCertificate;
80
+ //# sourceMappingURL=revision-verification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revision-verification.d.ts","sourceR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AAgB,wCAAwC,CAAC,KAAK,EAAE,IAAI,CAAC,qCAAqC,EAAE,WAAW,CAAC,GAAG,MAAM,CAKhI;AAED,yGAAyG;AACzG,wBAAgB,2CAA2C,CAAC,KAAK,EAAE,OAAO,EACxE,SAAS,EAAE,8BAA8B,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG,KAAK,IAAI,qCAAqC,CAWhI"}
@@ -0,0 +1,114 @@
1
+ import { createPublicKey, verify } from 'node:crypto';
2
+ import { canonicalGrowthJson } from './canonical.js';
3
+ import { validatePluginCreationVerificationCertificate } from './creation-verification.js';
4
+ export function isPluginRevisionTaskSource(value) {
5
+ return Object.hasOwn(value, 'growthRunDigest');
6
+ }
7
+ export function isPluginRevisionInstructionSource(value) {
8
+ return Object.hasOwn(value, 'instructionDigest');
9
+ }
10
+ const domainV1 = 'assistant-growth/revision-verification/v1\0';
11
+ const domainV2 = 'assistant-growth/revision-verification/v2\0';
12
+ const domainV3 = 'assistant-growth/revision-verification/v3\0';
13
+ const digest = /^[a-f0-9]{64}$/u;
14
+ const identifier = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,199}$/u;
15
+ const certificateKeys = ['protocol', 'verificationId', 'authority', 'plan', 'parent', 'source', 'contractDigest',
16
+ 'schemaDigest', 'environment', 'model', 'budget', 'sessions', 'observations', 'reviewDigest', 'verifiedAt', 'expiresAt'];
17
+ function certificateKeysFor(value) {
18
+ const protocol = value && typeof value === 'object' ? Object.getOwnPropertyDescriptor(value, 'protocol')?.value : undefined;
19
+ return protocol === 'assistant-growth/revision-verification/v2' ? [...certificateKeys, 'execution'] : certificateKeys;
20
+ }
21
+ function fail(label) { throw new Error(`invalid plugin revision verification ${label}`); }
22
+ function record(value, keys, label) {
23
+ if (!value || typeof value !== 'object' || Array.isArray(value)
24
+ || Object.getPrototypeOf(value) !== Object.prototype || Object.getOwnPropertySymbols(value).length
25
+ || !Object.values(Object.getOwnPropertyDescriptors(value)).every(item => item.enumerable && 'value' in item)
26
+ || Object.keys(value).sort().join('\0') !== [...keys].sort().join('\0'))
27
+ fail(label);
28
+ return value;
29
+ }
30
+ export function validateRevisionAcceptanceAuthorityRef(value) {
31
+ const ref = record(value, ['protocol', 'authorityId', 'keyId', 'authorityDigest', 'namePrefix', 'expiresAt'], 'authority');
32
+ if (ref.protocol !== 'assistant-growth/revision-acceptance-authority/v1')
33
+ fail('authority protocol');
34
+ for (const key of ['authorityId', 'keyId']) {
35
+ if (typeof ref[key] !== 'string' || !identifier.test(ref[key]) || ref[key].normalize('NFC') !== ref[key])
36
+ fail(key);
37
+ }
38
+ if (typeof ref.authorityDigest !== 'string' || !digest.test(ref.authorityDigest))
39
+ fail('authorityDigest');
40
+ if (typeof ref.namePrefix !== 'string' || ref.namePrefix.length < 2 || ref.namePrefix.length > 48
41
+ || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*-$/u.test(ref.namePrefix))
42
+ fail('namePrefix');
43
+ if (!Number.isSafeInteger(ref.expiresAt) || Number(ref.expiresAt) < 1
44
+ || Number(ref.expiresAt) > 8_640_000_000_000_000)
45
+ fail('authority expiry');
46
+ }
47
+ export function validatePluginRevisionParentBinding(value) {
48
+ const parent = record(value, ['planId', 'certificateDigest', 'artifactSha256', 'sourceArchiveDigest', 'sourceDigest'], 'parent');
49
+ if (typeof parent.planId !== 'string' || !identifier.test(parent.planId)
50
+ || parent.planId.normalize('NFC') !== parent.planId)
51
+ fail('parent planId');
52
+ for (const key of ['certificateDigest', 'artifactSha256', 'sourceArchiveDigest', 'sourceDigest']) {
53
+ if (typeof parent[key] !== 'string' || !digest.test(parent[key]))
54
+ fail(`parent ${key}`);
55
+ }
56
+ }
57
+ export function validatePluginRevisionVerificationCertificate(value) {
58
+ const protocol = value && typeof value === 'object' ? Object.getOwnPropertyDescriptor(value, 'protocol')?.value : undefined;
59
+ const linux = protocol === 'assistant-growth/revision-verification/v2';
60
+ const instruction = protocol === 'assistant-growth/revision-verification/v3';
61
+ const item = record(value, [...certificateKeysFor(value), 'signature'], 'certificate');
62
+ if (!linux && item.protocol !== 'assistant-growth/revision-verification/v1'
63
+ && item.protocol !== 'assistant-growth/revision-verification/v3')
64
+ fail('protocol');
65
+ const authority = item.authority;
66
+ validateRevisionAcceptanceAuthorityRef(authority);
67
+ validatePluginRevisionParentBinding(item.parent);
68
+ // The instruction source is validated in full here; the delegated creation
69
+ // shape check only re-verifies the shared fields, so it receives a mapped
70
+ // pseudo-source with the exact triple shape it always required.
71
+ if (instruction) {
72
+ const source = record(item.source, ['instructionDigest', 'ownerDigest'], 'source');
73
+ for (const key of ['instructionDigest', 'ownerDigest']) {
74
+ if (typeof source[key] !== 'string' || !digest.test(source[key]))
75
+ fail(`source ${key}`);
76
+ }
77
+ }
78
+ const { parent: _parent, ...creationShape } = item;
79
+ validatePluginCreationVerificationCertificate({ ...creationShape,
80
+ protocol: linux ? 'assistant-growth/creation-verification/v3' : 'assistant-growth/creation-verification/v1',
81
+ authority: { ...authority, protocol: 'assistant-growth/creation-acceptance-authority/v1' },
82
+ ...(instruction ? { source: instructionSourceForShapeCheck(item.source) } : {}) });
83
+ if (Buffer.byteLength(canonicalGrowthJson(item)) > 65_536)
84
+ fail('certificate bytes');
85
+ }
86
+ /** Maps a validated v3 instruction source onto the shared creation shape for field checks only. */
87
+ function instructionSourceForShapeCheck(source) {
88
+ const item = source;
89
+ return { referenceDigest: item.instructionDigest, ownerDigest: item.ownerDigest, growthRunDigest: item.instructionDigest };
90
+ }
91
+ export function pluginRevisionVerificationSigningPayload(value) {
92
+ const body = record(value, certificateKeysFor(value), 'signing body');
93
+ validatePluginRevisionVerificationCertificate({ ...body, signature: 'A'.repeat(86) });
94
+ return (body.protocol === 'assistant-growth/revision-verification/v2' ? domainV2
95
+ : body.protocol === 'assistant-growth/revision-verification/v3' ? domainV3 : domainV1) + canonicalGrowthJson(body);
96
+ }
97
+ /** Signature and authority equality only; consumers must also recheck provenance and parent currency. */
98
+ export function verifyPluginRevisionVerificationCertificate(value, authority, publicKey, now = Date.now()) {
99
+ try {
100
+ validateRevisionAcceptanceAuthorityRef(authority);
101
+ validatePluginRevisionVerificationCertificate(value);
102
+ if (!Number.isSafeInteger(now) || value.verifiedAt > now || value.expiresAt <= now
103
+ || canonicalGrowthJson(value.authority) !== canonicalGrowthJson(authority))
104
+ return false;
105
+ const { signature, ...body } = value;
106
+ const key = createPublicKey(publicKey);
107
+ return key.asymmetricKeyType === 'ed25519'
108
+ && verify(null, Buffer.from(pluginRevisionVerificationSigningPayload(body)), key, Buffer.from(signature, 'base64url'));
109
+ }
110
+ catch {
111
+ return false;
112
+ }
113
+ }
114
+ //# sourceMappingURL=revision-verification.js.map