@treeseed/sdk 0.13.0-rc.121 → 0.13.0-rc.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-capacity/contracts/capacity/assignments/agent-execution.d.ts +2365 -1275
- package/dist/agent-capacity/contracts/capacity/assignments/agent-execution.js +94 -28
- package/dist/agent-capacity/contracts/capacity/assignments/assignment-context-pack.d.ts +38 -38
- package/dist/agent-capacity/contracts/capacity/assignments/assignment-path.d.ts +2 -0
- package/dist/agent-capacity/contracts/capacity/assignments/assignment-path.js +13 -0
- package/dist/agent-capacity/contracts/capacity/assignments/assignment-records.d.ts +2 -59
- package/dist/agent-capacity/contracts/capacity/providers/supply-policy.d.ts +126 -1
- package/dist/agent-capacity/contracts/capacity/providers/supply-policy.js +35 -1
- package/dist/agent-capacity/contracts/capacity/workdays/assignment-allocation.d.ts +2 -4
- package/dist/agent-capacity/contracts/capacity/workdays/assignment-allocation.js +22 -16
- package/dist/agent-capacity/contracts/capacity/workdays/capability-accounting.d.ts +3 -42
- package/dist/agent-capacity/contracts/capacity/workdays/capability-accounting.js +8 -8
- package/dist/agent-capacity/contracts/capacity/workdays/workday-allocation.d.ts +244 -85
- package/dist/agent-capacity/contracts/capacity/workdays/workday-allocation.js +54 -19
- package/dist/agent-capacity/contracts/capacity/workdays/workday-records.d.ts +216 -70
- package/dist/agent-capacity/contracts/capacity/workdays/workday-records.js +19 -0
- package/dist/agent-capacity/contracts/configuration/configuration.d.ts +1 -1
- package/dist/agent-capacity/contracts/configuration/configuration.js +0 -2
- package/dist/agent-capacity/contracts/operations/agent-team-clone.d.ts +55 -55
- package/dist/agent-capacity/contracts/projects/agents/project-agent-class.d.ts +119 -23
- package/dist/agent-capacity/contracts/projects/agents/project-agent-class.js +16 -0
- package/dist/agent-capacity/contracts/runtime/runtime-observability.d.ts +2 -154
- package/dist/agent-capacity/contracts/support/agent-atlas.d.ts +0 -13
- package/dist/agent-capacity/contracts/support/execution-graph.d.ts +496 -292
- package/dist/agent-capacity/contracts/support/execution-graph.js +21 -19
- package/dist/agent-capacity/contracts/support/financial-records.d.ts +3 -6
- package/dist/agent-capacity/contracts/support/planning-records.d.ts +1 -87
- package/dist/agent-capacity/grant.d.ts +34 -0
- package/dist/agent-capacity/grant.js +4 -0
- package/dist/agent-capacity/validation/agent-definition-schema.d.ts +1178 -1152
- package/dist/agent-capacity/validation/agent-definition-schema.js +21 -28
- package/dist/agent-capacity/validation/agent-lab-forensics-schema.d.ts +10 -10
- package/dist/agent-capacity/validation/agent-lab-forensics-schema.js +0 -1
- package/dist/agent-capacity/validation/assignment-records.d.ts +1 -6
- package/dist/agent-capacity/validation/assignment-records.js +49 -35
- package/dist/agent-capacity/validation/configuration.d.ts +1 -1
- package/dist/agent-capacity/validation/configuration.js +2 -6
- package/dist/agent-capacity/validation/grant.d.ts +11 -0
- package/dist/agent-capacity/validation/grant.js +31 -0
- package/dist/capacity/agents/agent-capacity.d.ts +3 -4
- package/dist/capacity/agents/agent-capacity.js +2 -3
- package/dist/capacity-provider/capability-ontology.d.ts +150 -150
- package/dist/capacity-provider/client.d.ts +15 -9
- package/dist/capacity-provider/client.js +1 -10
- package/dist/capacity-provider/contracts/capacity-facts.d.ts +0 -1
- package/dist/capacity-provider/contracts/environment-profiles.d.ts +44 -44
- package/dist/capacity-provider/contracts/governance.d.ts +2 -17
- package/dist/capacity-provider/contracts/index.d.ts +2 -0
- package/dist/capacity-provider/contracts/index.js +2 -0
- package/dist/capacity-provider/core-capability-catalog.d.ts +7 -7
- package/dist/capacity-provider/environment-catalog.d.ts +188 -188
- package/dist/capacity-provider/environment-catalog.js +1 -1
- package/dist/capacity-provider/install-configuration.d.ts +2 -2
- package/dist/capacity-provider/sandbox-contracts.d.ts +92 -92
- package/dist/capacity-provider/source-workspace.d.ts +166 -68
- package/dist/capacity-provider/source-workspace.js +5 -1
- package/dist/capacity-provider/validation.d.ts +10 -2
- package/dist/capacity-provider/validation.js +52 -22
- package/dist/content/validation/agent-operational-content-schemas.d.ts +144 -142
- package/dist/content/validation/agent-operational-content-schemas.js +2 -0
- package/dist/content/validation/auxiliary-content-schemas.d.ts +158 -158
- package/dist/content/validation/content-model-schemas.d.ts +9105 -5295
- package/dist/content/validation/content-model-schemas.js +192 -115
- package/dist/content/validation/portable-content-data.d.ts +411 -238
- package/dist/content/validation/portable-content-data.js +6 -1
- package/dist/content/validation/schema-constraints.d.ts +78 -0
- package/dist/content/validation/schema-constraints.js +149 -0
- package/dist/deployment/ai/storage.d.ts +24 -24
- package/dist/deployment/ai-hosting.d.ts +18 -18
- package/dist/deployment/ai-instance.d.ts +16 -16
- package/dist/deployment/ai-mode.d.ts +92 -92
- package/dist/deployment/hosted-topology-template.d.ts +44 -44
- package/dist/deployment/hosted-topology.d.ts +335 -335
- package/dist/deployment/postgres/contracts.d.ts +52 -52
- package/dist/deployment/postgres/transfer.d.ts +6 -6
- package/dist/deployment/schemas.d.ts +1114 -1114
- package/dist/development/schemas.d.ts +633 -633
- package/dist/graph/context-query-contracts.js +1 -1
- package/dist/guarantees/index.d.ts +26 -2
- package/dist/identity/contracts.js +6 -1
- package/dist/knowledge/contracts.d.ts +9 -2
- package/dist/knowledge/contracts.js +2 -2
- package/dist/model-registry/discussion-models.js +0 -1
- package/dist/operator-contracts/canonical-command-tree.js +25 -9
- package/dist/operator-contracts/catalog/agents/agent-team-clone-operations.d.ts +29 -29
- package/dist/operator-contracts/catalog/capability-ontology-operations.d.ts +30 -30
- package/dist/operator-contracts/catalog/commands/command-tree-builders.d.ts +15 -13
- package/dist/operator-contracts/catalog/communication-operations.d.ts +176 -158
- package/dist/operator-contracts/catalog/hosted-topology-operations.d.ts +67 -67
- package/dist/operator-contracts/catalog/inbox-operations.d.ts +65 -65
- package/dist/operator-contracts/catalog/infrastructure/ai-instance-operations.d.ts +6 -6
- package/dist/operator-contracts/catalog/infrastructure/ai-instance-operations.js +2 -1
- package/dist/operator-contracts/catalog/knowledge-share-operations.d.ts +10 -10
- package/dist/operator-contracts/catalog/provider-environment-operations.d.ts +3 -3
- package/dist/operator-contracts/catalog/services/secret-operations.d.ts +16 -8
- package/dist/operator-contracts/catalog/services/secret-operations.js +2 -1
- package/dist/operator-contracts/catalog/workdays/profile-operations.d.ts +11 -11
- package/dist/operator-contracts/catalog/workdays/selection-commands.js +3 -0
- package/dist/operator-contracts/communication/contracts.d.ts +537 -395
- package/dist/operator-contracts/communication/contracts.js +6 -1
- package/dist/operator-contracts/control-plane-operation.d.ts +7 -0
- package/dist/operator-contracts/control-plane-operation.js +6 -0
- package/dist/operator-contracts/control-plane-operations.d.ts +631 -610
- package/dist/operator-contracts/control-plane-operations.js +26 -12
- package/dist/operator-contracts/inbox/contracts.d.ts +229 -229
- package/dist/operator-contracts/knowledge/contracts.d.ts +16 -16
- package/dist/operator-contracts/mcp.js +4 -3
- package/dist/operator-contracts/workday-lifecycle.d.ts +192 -0
- package/dist/operator-contracts/workday-lifecycle.js +109 -45
- package/dist/platform/agent-schema-verification.d.ts +3 -0
- package/dist/platform/agent-schema-verification.js +377 -0
- package/dist/platform/contracts.d.ts +72 -72
- package/dist/platform/schemas.d.ts +144 -36
- package/dist/platform/schemas.js +26 -0
- package/dist/platform/verification.js +10 -0
- package/dist/sdk-types/support/planning-policy.d.ts +1 -1
- package/dist/sdk-types/support/sdk-search-request.d.ts +2 -2
- package/dist/secrets-capability/secret-contracts.d.ts +2 -2
- package/dist/secrets-capability/shared-access.d.ts +3 -3
- package/dist/secrets-capability/shared-resources.d.ts +50 -50
- package/dist/secrets-capability/vault-contracts.d.ts +2 -2
- package/dist/security/encrypted-envelope.d.ts +14 -14
- package/dist/treedx/client.d.ts +4 -4
- package/dist/treedx/index.d.ts +1 -1
- package/dist/treedx/index.js +1 -0
- package/dist/treedx/types.d.ts +286 -0
- package/dist/treedx/types.js +44 -0
- package/guarantees/agent/golden/component-boundaries.guarantee.yaml +12 -0
- package/guarantees/agent/golden/product-custody.guarantee.yaml +12 -0
- package/guarantees/agent/golden/product.guarantee.yaml +12 -0
- package/guarantees/agent/golden/scenes/component-boundaries.scene.yaml +837 -0
- package/guarantees/agent/golden/scenes/product-custody.scene.yaml +53 -0
- package/guarantees/agent/golden/scenes/product.scene.yaml +8 -0
- package/guarantees/verifiers/golden.verifiers.yaml +1429 -0
- package/package.json +9 -3
- package/tests/acceptance/golden-product.test.ts +205 -0
- package/tests/acceptance/golden-product.ts +404 -0
- package/tests/acceptance/product/base-red.ts +73 -0
- package/tests/acceptance/product/documentation-examples.ts +68 -0
- package/tests/acceptance/product/intent-runtime.ts +145 -0
- package/tests/acceptance/product/release-output.ts +160 -0
- package/tests/acceptance/product/research-artifact.ts +87 -0
- package/tests/acceptance/product/research-revision.ts +82 -0
- package/tests/acceptance/product/research-source.ts +91 -0
- package/tests/acceptance/product/test-chain.ts +192 -0
- package/treeseed.package.yaml +147 -0
- package/dist/.treeseed-build-complete.json +0 -1
- package/dist/agent-capacity/allocation.d.ts +0 -183
- package/dist/agent-capacity/allocation.js +0 -5
- package/dist/agent-capacity/artifact-mutation-receipt.d.ts +0 -49
- package/dist/agent-capacity/artifact-mutation-receipt.js +0 -36
- package/dist/agent-capacity/artifacts.d.ts +0 -123
- package/dist/agent-capacity/artifacts.js +0 -39
- package/dist/agent-capacity/contracts/support/decision-work.d.ts +0 -227
- package/dist/agent-capacity/contracts/support/decision-work.js +0 -0
- package/dist/agent-capacity/validation/allocation.d.ts +0 -12
- package/dist/agent-capacity/validation/allocation.js +0 -115
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { closeSync, constants, fstatSync, lstatSync, openSync, readFileSync, realpathSync } from 'node:fs';
|
|
3
|
+
import { basename, isAbsolute, resolve } from 'node:path';
|
|
4
|
+
import { exactEntityReferenceSchema, executionEdgeSchema, activityProfileSchema } from '@treeseed/sdk/agent-capacity';
|
|
5
|
+
import { validatePortableContentData } from '@treeseed/sdk/content-validation';
|
|
6
|
+
import { createHash } from 'node:crypto';
|
|
7
|
+
import { parse, parseDocument, visit } from 'yaml';
|
|
8
|
+
import { TREESEED_COMMAND_TREE_V1, type CommandLeafDescriptor } from '@treeseed/sdk/operator-contracts';
|
|
9
|
+
import { isSdkArchiveCommand, sdkReleaseCommands, verifySdkReleaseOutputs } from './product/release-output.ts';
|
|
10
|
+
|
|
11
|
+
type Row = Record<string, any>;
|
|
12
|
+
export function sdkGoldenReadArguments(args: readonly string[], team: string): string[] {
|
|
13
|
+
let nodes = TREESEED_COMMAND_TREE_V1.commands, selected: CommandLeafDescriptor | undefined;
|
|
14
|
+
for (const segment of args) {
|
|
15
|
+
const node = nodes.find(value => value.segment === segment);
|
|
16
|
+
assert.ok(node, 'ACCEPTANCE_SDK_READ: Supported public read command required');
|
|
17
|
+
if (node.nodeType === 'leaf') { selected = node; break; }
|
|
18
|
+
nodes = node.children;
|
|
19
|
+
}
|
|
20
|
+
assert.ok(selected?.kind === 'read', 'ACCEPTANCE_SDK_READ: Supported public read command required');
|
|
21
|
+
const operation = selected.execution.kind === 'operation' ? selected.execution : undefined;
|
|
22
|
+
const scopedTeam = operation?.input.some(input => input.source === 'context' && input.name === 'team');
|
|
23
|
+
assert.ok(!scopedTeam || (typeof team === 'string' && team.trim()), 'ACCEPTANCE_SDK_READ: Exact team required');
|
|
24
|
+
assert.ok(!args.some(value => ['--server', '--team', '--json'].includes(value)),
|
|
25
|
+
'ACCEPTANCE_SDK_READ: Scope selectors must be supplied once by the owning reader');
|
|
26
|
+
return [...args, ...(operation ? ['--server', 'local'] : []), ...(scopedTeam ? ['--team', team] : []), '--json'];
|
|
27
|
+
}
|
|
28
|
+
export type SdkGoldenOriginal = { binding: Row; files: Row; initialProposal: Row; teamLibrary?: Row; referenceFiles?: Row[]; graph?: Row; executionEvents?: Row[] };
|
|
29
|
+
/** The selected scene consumes the existing CLI library-read result. */
|
|
30
|
+
export function sdkGoldenLibraryFiles(readback: Row): Row {
|
|
31
|
+
const result = readback && typeof readback === 'object' && !Array.isArray(readback) ? readback.result : undefined;
|
|
32
|
+
assert.ok(result && typeof result === 'object' && !Array.isArray(result) && result.ok === true
|
|
33
|
+
&& typeof result.repoId === 'string' && result.repoId && typeof result.resolvedRef === 'string'
|
|
34
|
+
&& /^[a-f0-9]{40}$/u.test(result.resolvedRef) && Array.isArray(result.files),
|
|
35
|
+
'ACCEPTANCE_SDK_LIBRARY_READ: Complete supported CLI library-read result required');
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
function measured(record: Row | undefined): boolean {
|
|
39
|
+
return Boolean(record && record.status === 'passed' && record.exitCode === 0
|
|
40
|
+
&& typeof record.outputDigest === 'string' && /^sha256:[a-f0-9]{64}$/u.test(record.outputDigest)
|
|
41
|
+
&& Number.isSafeInteger(record.durationSeconds) && record.durationSeconds >= 0);
|
|
42
|
+
}
|
|
43
|
+
export function sdkGoldenSource(freeze: Row, proposalIds: unknown): string {
|
|
44
|
+
const source = freeze.sourceHeads?.sdk;
|
|
45
|
+
assert.ok(typeof source === 'string' && /^[a-f0-9]{40}$/u.test(source)
|
|
46
|
+
&& typeof freeze.proposal?.id === 'string' && Array.isArray(proposalIds) && proposalIds.includes(freeze.proposal.id),
|
|
47
|
+
'ACCEPTANCE_SDK_FREEZE: Exact current source and matching frozen proposal required');
|
|
48
|
+
return source;
|
|
49
|
+
}
|
|
50
|
+
export function sdkGoldenProposalProvenance(storedProposal: unknown): Row {
|
|
51
|
+
assert.ok(storedProposal && typeof storedProposal === 'object' && !Array.isArray(storedProposal),
|
|
52
|
+
'ACCEPTANCE_SDK_PROPOSAL: Original public proposal record required');
|
|
53
|
+
const governance = storedProposal as Row, provenance = governance.metadata?.contentProvenance;
|
|
54
|
+
assert.ok(provenance && typeof provenance.repositoryId === 'string' && /^repo_[A-Za-z0-9_-]+$/u.test(provenance.repositoryId)
|
|
55
|
+
&& typeof provenance.commitSha === 'string' && /^[a-f0-9]{40}$/u.test(provenance.commitSha)
|
|
56
|
+
&& typeof provenance.digest === 'string' && /^[a-f0-9]{64}$/u.test(provenance.digest)
|
|
57
|
+
&& typeof provenance.contentPath === 'string' && provenance.contentPath.startsWith('proposals/')
|
|
58
|
+
&& !/[\s\\\0]/u.test(provenance.contentPath)
|
|
59
|
+
&& !provenance.contentPath.split('/').some((part: string) => !part || part === '.' || part === '..')
|
|
60
|
+
&& Number.isSafeInteger(governance.activeVersion) && governance.activeVersion > 0
|
|
61
|
+
&& governance.activeContentHash === provenance.digest,
|
|
62
|
+
'ACCEPTANCE_SDK_PROPOSAL: Original exact governed content provenance required');
|
|
63
|
+
return provenance;
|
|
64
|
+
}
|
|
65
|
+
export function sdkGoldenProposalDocument(storedProposal: unknown, original: SdkGoldenOriginal | undefined): Row {
|
|
66
|
+
const provenance = sdkGoldenProposalProvenance(storedProposal), governance = storedProposal as Row;
|
|
67
|
+
assert.ok(original && original.binding?.repositoryId === provenance.repositoryId
|
|
68
|
+
&& original.files?.repoId === provenance.repositoryId && original.files.resolvedRef === provenance.commitSha
|
|
69
|
+
&& Array.isArray(original.files.files) && original.files.files.length === 1,
|
|
70
|
+
'ACCEPTANCE_SDK_PROPOSAL: Independently resolved original library and exact content required');
|
|
71
|
+
const file = original.files.files[0];
|
|
72
|
+
assert.ok(file && file.path === provenance.contentPath && typeof file.content === 'string'
|
|
73
|
+
&& Buffer.byteLength(file.content) <= 1_048_576
|
|
74
|
+
&& createHash('sha256').update(file.content).digest('hex') === provenance.digest,
|
|
75
|
+
'ACCEPTANCE_SDK_PROPOSAL: Original recorded path and raw proposal bytes required');
|
|
76
|
+
const document = file.content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/u);
|
|
77
|
+
assert.ok(document, 'ACCEPTANCE_SDK_PROPOSAL: Original frontmatter required');
|
|
78
|
+
const proposal = parse(document[1], { maxAliasCount: 0 }) as Row;
|
|
79
|
+
const syntax = parseDocument(document[1]);
|
|
80
|
+
assert.equal(syntax.errors.length, 0, 'ACCEPTANCE_SDK_PROPOSAL: Unambiguous original YAML required');
|
|
81
|
+
visit(syntax, (_key, node) => {
|
|
82
|
+
if (node && typeof node === 'object' && 'anchor' in node) assert.ok(!node.anchor,
|
|
83
|
+
'ACCEPTANCE_SDK_PROPOSAL: Stored configuration cannot contain YAML anchors');
|
|
84
|
+
});
|
|
85
|
+
assert.deepEqual(proposal, file.frontmatter, 'ACCEPTANCE_SDK_PROPOSAL: Readback contradicts original bytes');
|
|
86
|
+
assert.ok(proposal && typeof proposal === 'object' && !Array.isArray(proposal)
|
|
87
|
+
&& proposal.id === governance.id && proposal.projectId === governance.projectId
|
|
88
|
+
&& proposal.title === governance.title && proposal.summary === governance.summary && proposal.request === governance.body,
|
|
89
|
+
'ACCEPTANCE_SDK_PROPOSAL: Governance index differs from its original content');
|
|
90
|
+
return proposal;
|
|
91
|
+
}
|
|
92
|
+
function verifySdkGoldenAuthoredWork(proposal: Row, draft = false): void {
|
|
93
|
+
const sourceCode = draft ? 'ACCEPTANCE_SDK_FROZEN_REQUEST' : 'ACCEPTANCE_SDK_PROPOSAL';
|
|
94
|
+
const graphCode = draft ? sourceCode : 'ACCEPTANCE_SDK_GRAPH';
|
|
95
|
+
assert.ok(Array.isArray(proposal.evidenceRefs), `${sourceCode}: Original source issue evidence required`);
|
|
96
|
+
const sourceEvidence = proposal.evidenceRefs.filter((ref: unknown) => ref && typeof ref === 'object'
|
|
97
|
+
&& !Array.isArray(ref) && (ref as Row).url === 'https://github.com/treeseed-ai/sdk/issues/299');
|
|
98
|
+
assert.equal(sourceEvidence.length, 1, `${sourceCode}: One unambiguous original SDK source issue required`);
|
|
99
|
+
const issue = exactEntityReferenceSchema.safeParse(sourceEvidence[0]);
|
|
100
|
+
assert.ok(issue.success && issue.data.store === 'url' && issue.data.model === 'issue',
|
|
101
|
+
`${sourceCode}: Canonical original SDK source issue reference required`);
|
|
102
|
+
const authored = proposal.executionPlan?.workItems;
|
|
103
|
+
const fixedRows = [
|
|
104
|
+
['research-context', 'researcher', 'treedx'], ['architecture-contract', 'architect', 'treedx'],
|
|
105
|
+
['tests-first', 'tester', 'git'], ['implement-change', 'engineer', 'git'],
|
|
106
|
+
['document-change', 'technical-writer', 'git'], ['simulate-release', 'releaser', 'git'],
|
|
107
|
+
] as const;
|
|
108
|
+
assert.ok(Array.isArray(authored) && authored.length === fixedRows.length
|
|
109
|
+
&& authored.every(item => item && typeof item === 'object' && !Array.isArray(item))
|
|
110
|
+
&& new Set(authored.map(item => item.id)).size === fixedRows.length,
|
|
111
|
+
`${graphCode}: Six unique original authored work items required`);
|
|
112
|
+
for (const [id, agentClass, workspace] of fixedRows) {
|
|
113
|
+
const item: Row | undefined = authored.find(row => row.id === id);
|
|
114
|
+
assert.ok(item && item.agentClass === agentClass && item.workspace === workspace
|
|
115
|
+
&& item.activity === 'acting' && item.review === 'required' && item.maximumReviewCycles === 2
|
|
116
|
+
&& Array.isArray(item.dependsOn) && item.dependsOn.length === 0
|
|
117
|
+
&& ['objective', 'contextRefs', 'requestedPermissions', 'requiredCapabilities', 'acceptanceCriteria',
|
|
118
|
+
...(draft ? [] : ['estimate', 'reviewEstimate'])].every(field => Object.hasOwn(item, field)),
|
|
119
|
+
`${graphCode}: Original ${id} class workspace dependencies and review policy required`);
|
|
120
|
+
const permissionCode = `ACCEPTANCE_SDK_PERMISSIONS: ${graphCode}`;
|
|
121
|
+
const permissions = activityProfileSchema.shape.permissions.safeParse(item.requestedPermissions);
|
|
122
|
+
assert.ok(permissions.success, `${permissionCode}: Complete canonical original permission request required`);
|
|
123
|
+
const reads: string[] = ['book', 'knowledge', 'objective', 'proposal', 'decision', 'note', 'question'];
|
|
124
|
+
const writes: string[] = agentClass === 'researcher' ? ['knowledge', 'note', 'question']
|
|
125
|
+
: agentClass === 'architect' ? ['book', 'knowledge', 'note', 'question'] : [];
|
|
126
|
+
const tools: string[] = workspace === 'treedx' ? ['discussion', 'source.read']
|
|
127
|
+
: ['source.read', 'source.write', 'verification', ...(agentClass === 'releaser' ? ['release'] : [])];
|
|
128
|
+
const lists: [readonly string[], readonly string[]][] = [[permissions.data.content.read, reads], [permissions.data.content.write, writes], [permissions.data.tools, tools]];
|
|
129
|
+
for (const [actual, expected] of lists)
|
|
130
|
+
assert.deepEqual([...actual].sort(), [...expected].sort(), `${permissionCode}: Exact ${id} requested content and tools required`);
|
|
131
|
+
if (draft) assert.ok(['estimate', 'reviewEstimate', 'ownerEstimate', 'reviewerEstimate'].every(field => !Object.hasOwn(item, field))
|
|
132
|
+
&& typeof item.objective === 'string' && item.objective.trim()
|
|
133
|
+
&& Array.isArray(item.contextRefs) && item.contextRefs.length > 0
|
|
134
|
+
&& item.contextRefs.every((ref: unknown) => exactEntityReferenceSchema.safeParse(ref).success)
|
|
135
|
+
&& item.requestedPermissions && typeof item.requestedPermissions === 'object' && !Array.isArray(item.requestedPermissions)
|
|
136
|
+
&& Array.isArray(item.requiredCapabilities) && item.requiredCapabilities.every((value: unknown) => typeof value === 'string' && value.trim())
|
|
137
|
+
&& Array.isArray(item.acceptanceCriteria) && item.acceptanceCriteria.length > 0
|
|
138
|
+
&& item.acceptanceCriteria.every((value: unknown) => typeof value === 'string' && value.trim()),
|
|
139
|
+
`${graphCode}: Explicit estimate-free original work required`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function verifySdkGoldenGraph(proposal: Row, attempt: Row, graph: Row | undefined): void {
|
|
144
|
+
const code = 'ACCEPTANCE_SDK_GRAPH_PAIRS';
|
|
145
|
+
assert.ok(graph && graph.teamId === attempt.teamId && Array.isArray(graph.nodes), `${code}: Independent public graph required`);
|
|
146
|
+
assert.ok(graph.nodes.every((node: unknown) => node && typeof node === 'object' && !Array.isArray(node)), `${code}: Malformed graph node`);
|
|
147
|
+
const nodes: Row[] = graph.nodes.filter((node: Row) => node.workdayId === attempt.workdayId && node.pairRole !== null);
|
|
148
|
+
const items: Row[] = proposal.executionPlan.workItems;
|
|
149
|
+
assert.equal(nodes.length, items.length * 2, `${code}: Exactly six authored Actors and six generated Reviewers required`);
|
|
150
|
+
assert.equal(new Set(nodes.map(node => node.id)).size, nodes.length, `${code}: Duplicate node identity`);
|
|
151
|
+
for (const item of items) for (const role of ['actor', 'reviewer']) {
|
|
152
|
+
const pair = nodes.filter(node => node.workItemId === item.id && node.pairRole === role);
|
|
153
|
+
assert.equal(pair.length, 1, `${code}: Each authored work item requires one exact ${role}`);
|
|
154
|
+
const node = pair[0]!;
|
|
155
|
+
assert.ok(typeof node.id === 'string' && node.id && node.teamId === attempt.teamId && node.projectId === proposal.projectId
|
|
156
|
+
&& node.kind === (role === 'actor' ? item.activity : 'reviewing')
|
|
157
|
+
&& node.agentClass === (role === 'actor' ? item.agentClass : 'reviewer')
|
|
158
|
+
&& node.workspace === (role === 'actor' ? item.workspace : 'treedx')
|
|
159
|
+
&& node.maximumReviewCycles === item.maximumReviewCycles && item.review === 'required',
|
|
160
|
+
`${code}: Authored Actor or generated Reviewer authority drifted`);
|
|
161
|
+
assert.deepEqual(node.sourceRef, attempt.sourceRef, `${code}: Pair must represent the exact original authored proposal`);
|
|
162
|
+
if (role === 'actor') assert.deepEqual(node.requestedPermissions, item.requestedPermissions, `${code}: Actor must retain its original authored permission request`);
|
|
163
|
+
}
|
|
164
|
+
const orderCode = 'ACCEPTANCE_SDK_GRAPH_ORDER';
|
|
165
|
+
assert.ok(Array.isArray(graph.edges), `${orderCode}: Independent complete public edges required`);
|
|
166
|
+
const edges = graph.edges.map((edge: unknown) => {
|
|
167
|
+
const checked = executionEdgeSchema.safeParse(edge);
|
|
168
|
+
assert.ok(checked.success, `${orderCode}: Canonical original edge required`); return checked.data;
|
|
169
|
+
});
|
|
170
|
+
assert.equal(new Set(edges.map(edge => edge.id)).size, edges.length, `${orderCode}: Duplicate edge identity`);
|
|
171
|
+
const ids = new Set(nodes.map(node => node.id));
|
|
172
|
+
const scoped = edges.filter(edge => ids.has(edge.fromNodeId) || ids.has(edge.toNodeId));
|
|
173
|
+
const nodeId = (item: string, role: string) => nodes.find(node => node.workItemId === item && node.pairRole === role)!.id;
|
|
174
|
+
const expectedPairs = items.map(item => [nodeId(item.id, 'actor'), nodeId(item.id, 'reviewer')]);
|
|
175
|
+
const engineering = ['architecture-contract', 'tests-first', 'implement-change', 'document-change', 'simulate-release'];
|
|
176
|
+
const expectedProfiles = engineering.slice(1).map((item, index) => [nodeId(engineering[index]!, 'reviewer'), nodeId(item, 'actor')]);
|
|
177
|
+
for (const edge of scoped.filter(edge => ids.has(edge.fromNodeId) && ids.has(edge.toNodeId))) {
|
|
178
|
+
const matches = (pairs: string[][]) => pairs.some(([from, to]) => edge.fromNodeId === from && edge.toNodeId === to);
|
|
179
|
+
assert.ok((edge.provenance === 'review-pair' && matches(expectedPairs))
|
|
180
|
+
|| (edge.provenance === 'profile-agent' && matches(expectedProfiles)),
|
|
181
|
+
`${orderCode}: Fixed work items allow only their generated review pairs and immediate reviewed profile predecessors`);
|
|
182
|
+
}
|
|
183
|
+
for (const [provenance, expected] of [['review-pair', expectedPairs], ['profile-agent', expectedProfiles]] as const) {
|
|
184
|
+
const actual = scoped.filter(edge => edge.provenance === provenance || (provenance === 'profile-agent' && edge.provenance === 'work-item'));
|
|
185
|
+
assert.equal(actual.length, expected.length, `${orderCode}: Exact pairs and immediate standing profile dependencies required`);
|
|
186
|
+
for (const [from, to] of expected) {
|
|
187
|
+
const matching = actual.filter(edge => edge.provenance === provenance && edge.fromNodeId === from && edge.toNodeId === to);
|
|
188
|
+
assert.equal(matching.length, 1, `${orderCode}: Independent research and immediate reviewed predecessor required`);
|
|
189
|
+
assert.equal(matching[0]!.teamId, attempt.teamId, `${orderCode}: Foreign edge owner`);
|
|
190
|
+
assert.equal(matching[0]!.graphRevisionRemoved, undefined, `${orderCode}: Removed edge cannot establish current order`);
|
|
191
|
+
assert.deepEqual(matching[0]!.sourceRef, attempt.sourceRef, `${orderCode}: Edge must retain exact authored source authority`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function verifySdkGoldenProduct(assignments: Row[], sourceBase: string, storedProposal: unknown,
|
|
197
|
+
original?: SdkGoldenOriginal): void {
|
|
198
|
+
const actors = assignments.filter(item => item.status === 'completed'
|
|
199
|
+
&& item.assignmentAttempt?.effectiveProfile?.activity === 'acting');
|
|
200
|
+
const final = (id: string) => actors.filter(item => item.assignmentAttempt.workItemId === id)
|
|
201
|
+
.sort((a, b) => String(a.createdAt).localeCompare(String(b.createdAt))).at(-1);
|
|
202
|
+
const release = final('simulate-release');
|
|
203
|
+
assert.ok(release, 'ACCEPTANCE_SDK_RELEASE: Completed release actor required');
|
|
204
|
+
const proposal = sdkGoldenProposalDocument(storedProposal, original), governance = storedProposal as Row;
|
|
205
|
+
assert.ok(original, 'ACCEPTANCE_SDK_PROPOSAL: Original public evidence required');
|
|
206
|
+
const provenance = sdkGoldenProposalProvenance(governance);
|
|
207
|
+
const sourceRef = release.assignmentAttempt.sourceRef;
|
|
208
|
+
assert.ok(sourceRef?.store === 'treedx' && sourceRef.model === 'proposal' && typeof sourceRef.id === 'string' && sourceRef.id,
|
|
209
|
+
'ACCEPTANCE_SDK_PROPOSAL: Release must retain its original proposal authority');
|
|
210
|
+
assert.equal(proposal.id, sourceRef.id, 'ACCEPTANCE_SDK_PROPOSAL: Public proposal differs from the executed authority');
|
|
211
|
+
assert.equal(proposal.projectId, release.assignmentAttempt.projectId, 'ACCEPTANCE_SDK_PROPOSAL: Public proposal belongs to another project');
|
|
212
|
+
assert.equal(proposal.title, 'Select accepted decisions in portable workday intent',
|
|
213
|
+
'ACCEPTANCE_SDK_PROPOSAL: Stored title differs from the fixed SDK proposal');
|
|
214
|
+
assert.equal(proposal.summary, 'Prove the SDK can express high-level decision-governed execution while keeping all derived execution state API-owned.',
|
|
215
|
+
'ACCEPTANCE_SDK_PROPOSAL: Stored summary differs from the fixed SDK proposal');
|
|
216
|
+
assert.ok(original.initialProposal && original.initialProposal.id === proposal.id
|
|
217
|
+
&& original.initialProposal.projectId === proposal.projectId
|
|
218
|
+
&& typeof original.initialProposal.request === 'string' && original.initialProposal.request.trim()
|
|
219
|
+
&& proposal.request === original.initialProposal.request,
|
|
220
|
+
'ACCEPTANCE_SDK_FROZEN_REQUEST: Ready proposal must retain its original frozen request; source issue is evidence only');
|
|
221
|
+
// Check the original public proposal, not the derived graph node counts.
|
|
222
|
+
// Genuine estimate provenance and generated review readiness have separate gates.
|
|
223
|
+
verifySdkGoldenAuthoredWork(proposal);
|
|
224
|
+
const expanded = validatePortableContentData('proposal', proposal);
|
|
225
|
+
assert.ok(expanded.ok, 'ACCEPTANCE_SDK_GRAPH: Complete original canonical Proposal and WorkItems required');
|
|
226
|
+
assert.deepEqual(expanded.data, proposal, 'ACCEPTANCE_SDK_GRAPH: Original configuration cannot inherit defaults or discard shorthand');
|
|
227
|
+
verifySdkGoldenAuthoredWork(original.initialProposal, true);
|
|
228
|
+
for (const field of ['title', 'summary', 'evidenceRefs']) assert.deepEqual(proposal[field], original.initialProposal[field],
|
|
229
|
+
'ACCEPTANCE_SDK_FROZEN_REQUEST: Fixed original objective and evidence changed');
|
|
230
|
+
for (const item of proposal.executionPlan.workItems) {
|
|
231
|
+
const { estimate, reviewEstimate, ...fixed } = item;
|
|
232
|
+
assert.deepEqual(fixed, original.initialProposal.executionPlan.workItems.find((row: Row) => row.id === item.id),
|
|
233
|
+
'ACCEPTANCE_SDK_FROZEN_REQUEST: Fixed original work changed while becoming ready');
|
|
234
|
+
}
|
|
235
|
+
verifySdkGoldenProposalReferences(proposal, original!, release.assignmentAttempt);
|
|
236
|
+
assert.ok(sourceRef.revision === governance.activeVersion && sourceRef.digest === `sha256:${provenance.digest}`
|
|
237
|
+
&& sourceRef.repository === provenance.repositoryId && sourceRef.commit === provenance.commitSha
|
|
238
|
+
&& sourceRef.path === provenance.contentPath,
|
|
239
|
+
'ACCEPTANCE_SDK_PROPOSAL: Read content differs from original issued proposal authority');
|
|
240
|
+
verifySdkGoldenGraph(proposal, release.assignmentAttempt, original.graph);
|
|
241
|
+
for (const item of actors.filter(item => ['research-context', 'architecture-contract', 'tests-first'].includes(item.assignmentAttempt.workItemId)))
|
|
242
|
+
assert.ok(item.assignmentAttempt.contextRefs?.some((ref: Row) => ref.store === 'git' && ref.commit === sourceBase),
|
|
243
|
+
'ACCEPTANCE_SDK_SOURCE: Early roles must receive exact frozen SDK source');
|
|
244
|
+
const records = release.assignmentResult?.verification as Row[] | undefined;
|
|
245
|
+
assert.ok(Array.isArray(records), 'ACCEPTANCE_SDK_VERIFICATION: Canonical measured verification required');
|
|
246
|
+
// release:verify owns strict build, standards generation/acceptance and the full
|
|
247
|
+
// test:release suite. Separate build/generator/suite receipts duplicate that gate.
|
|
248
|
+
for (const command of sdkReleaseCommands) {
|
|
249
|
+
const record = records.find(item => item.command === command);
|
|
250
|
+
assert.ok(measured(record),
|
|
251
|
+
'ACCEPTANCE_SDK_RELEASE_GATE: Every required release command must have passed with measured exact evidence');
|
|
252
|
+
}
|
|
253
|
+
assert.ok(!records.some(record => record.status === 'failed' || record.exitCode !== 0),
|
|
254
|
+
'ACCEPTANCE_SDK_RELEASE_GATE: A failed candidate cannot pass');
|
|
255
|
+
const archivePassed = (verification: unknown) => Array.isArray(verification) && verification.some(record =>
|
|
256
|
+
isSdkArchiveCommand(record.command)
|
|
257
|
+
&& measured(record));
|
|
258
|
+
assert.ok(archivePassed(records), 'ACCEPTANCE_SDK_RELEASE_GATE: Packed export/type inspection must be independently replayable');
|
|
259
|
+
const review = assignments.filter(item => item.status === 'completed' && item.assignmentAttempt?.workItemId === 'simulate-release'
|
|
260
|
+
&& item.assignmentAttempt.effectiveProfile?.activity === 'reviewing')
|
|
261
|
+
.sort((a, b) => String(a.createdAt).localeCompare(String(b.createdAt))).at(-1);
|
|
262
|
+
assert.ok(review?.lifecycleOutput?.activityCompletion?.reviewDisposition === 'approved'
|
|
263
|
+
&& archivePassed(review.assignmentResult?.verification)
|
|
264
|
+
&& sdkReleaseCommands.every(command => measured(review.assignmentResult?.verification?.find((record: Row) => record.command === command)))
|
|
265
|
+
&& !review.assignmentResult?.verification?.some((record: Row) => record.status === 'failed' || record.exitCode !== 0),
|
|
266
|
+
'ACCEPTANCE_SDK_ARCHIVE_REVIEW: Independent approved replay of every release command required');
|
|
267
|
+
const source = release.lifecycleOutput?.sourceReference;
|
|
268
|
+
assert.ok(source?.kind === 'git' && source.repository === 'treeseed-ai/sdk' && /^[a-f0-9]{40}$/u.test(source.commit),
|
|
269
|
+
'ACCEPTANCE_SDK_CANDIDATE: Exact local SDK candidate required');
|
|
270
|
+
assert.ok(release.assignmentResult.references.some((ref: Row) => ref.kind === 'git' && ref.repository === source.repository && ref.commit === source.commit),
|
|
271
|
+
'ACCEPTANCE_SDK_CANDIDATE: Canonical result must retain the verified candidate');
|
|
272
|
+
const actorAttempt = release.assignmentAttempt, reviewerAttempt = review.assignmentAttempt;
|
|
273
|
+
assert.ok(reviewerAttempt.id !== actorAttempt.id && reviewerAttempt.agentClass !== actorAttempt.agentClass
|
|
274
|
+
&& reviewerAttempt.workdayId === actorAttempt.workdayId && reviewerAttempt.projectId === actorAttempt.projectId
|
|
275
|
+
&& review.assignmentResult?.assignmentId === reviewerAttempt.id && release.assignmentResult.assignmentId === actorAttempt.id
|
|
276
|
+
&& review.assignmentResult.id !== release.assignmentResult.id
|
|
277
|
+
&& Array.isArray(reviewerAttempt.predecessorResultIds)
|
|
278
|
+
&& new Set(reviewerAttempt.predecessorResultIds).size === reviewerAttempt.predecessorResultIds.length
|
|
279
|
+
&& reviewerAttempt.predecessorResultIds.includes(release.assignmentResult.id)
|
|
280
|
+
&& reviewerAttempt.contextRefs?.some((ref: Row) => ref.store === 'git' && ref.repository === source.repository && ref.commit === source.commit),
|
|
281
|
+
'ACCEPTANCE_SDK_ARCHIVE_REVIEW: Independent review must consume this exact Actor result and candidate');
|
|
282
|
+
verifySdkReleaseOutputs(release, review, original.executionEvents, source.commit);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** Resolve the proposal's own exact references against independent native public reads. */
|
|
286
|
+
export function verifySdkGoldenProposalReferences(proposal: Row, original: SdkGoldenOriginal, attempt: Row): void {
|
|
287
|
+
const code = 'ACCEPTANCE_SDK_POPULATED_PROPOSAL';
|
|
288
|
+
assert.equal(proposal.status, 'ready', `${code}: Actual ready proposal required`);
|
|
289
|
+
assert.ok(Array.isArray(proposal.objectiveRefs) && proposal.objectiveRefs.length >= 2
|
|
290
|
+
&& proposal.discussionRef && typeof proposal.discussionRef === 'object', `${code}: Project/team objectives and closed discussion required`);
|
|
291
|
+
assert.deepEqual(proposal.objectiveRefs, original.initialProposal.objectiveRefs, `${code}: Frozen objective authority changed`);
|
|
292
|
+
const team = original.teamLibrary?.project, library = original.teamLibrary?.library;
|
|
293
|
+
assert.ok(team && team.slug === 'team' && team.teamId === attempt.teamId && typeof team.id === 'string' && team.id
|
|
294
|
+
&& team.id !== proposal.projectId && library?.projectId === team.id && library.teamId === attempt.teamId
|
|
295
|
+
&& typeof library.repositoryId === 'string' && library.repositoryId, `${code}: Original owning Team Library lookup required`);
|
|
296
|
+
const refs = [...proposal.objectiveRefs, proposal.discussionRef];
|
|
297
|
+
assert.ok(Array.isArray(original.referenceFiles) && original.referenceFiles.length === refs.length,
|
|
298
|
+
`${code}: Complete independent reference read inventory required`);
|
|
299
|
+
const scopes = new Set<string>(), consumed = new Set<Row>();
|
|
300
|
+
for (const [index, value] of refs.entries()) {
|
|
301
|
+
const ref = exactEntityReferenceSchema.parse(value), model = index < proposal.objectiveRefs.length ? 'objective' : 'discussion';
|
|
302
|
+
assert.ok(ref.store === 'treedx' && ref.model === model && ref.repository && ref.path && ref.commit && ref.digest,
|
|
303
|
+
`${code}: Complete exact governed reference required`);
|
|
304
|
+
const matches: Row[] = original.referenceFiles.filter(read => read.repoId === ref.repository && read.resolvedRef === ref.commit
|
|
305
|
+
&& Array.isArray(read.files) && read.files.length === 1 && read.files[0]?.path === ref.path);
|
|
306
|
+
assert.equal(matches.length, 1, `${code}: One unambiguous native read required`);
|
|
307
|
+
const read = matches[0]!; assert.ok(!consumed.has(read), `${code}: Reused reference read`); consumed.add(read);
|
|
308
|
+
const file = read.files[0], bytes = file.content;
|
|
309
|
+
assert.ok(typeof bytes === 'string' && Buffer.byteLength(bytes) <= 1_048_576
|
|
310
|
+
&& `sha256:${createHash('sha256').update(bytes).digest('hex')}` === ref.digest, `${code}: Original reference bytes and digest required`);
|
|
311
|
+
const document = bytes.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/u); assert.ok(document, `${code}: Native reference frontmatter required`);
|
|
312
|
+
const content = parse(document[1], { maxAliasCount: 0 }) as Row;
|
|
313
|
+
assert.deepEqual(content, file.frontmatter, `${code}: Native parsed view contradicts bytes`);
|
|
314
|
+
assert.ok(validatePortableContentData(model, content).ok && content.id === ref.id, `${code}: Exact canonical referenced entity required`);
|
|
315
|
+
if (model === 'objective') {
|
|
316
|
+
const project = content.projectId;
|
|
317
|
+
assert.ok(project === proposal.projectId ? ref.repository === original.binding.repositoryId
|
|
318
|
+
: project === team.id && ref.repository === library.repositoryId, `${code}: Foreign objective owner`);
|
|
319
|
+
scopes.add(project);
|
|
320
|
+
} else {
|
|
321
|
+
assert.ok(content.status === 'closed' && content.projectId === proposal.projectId && content.teamId === attempt.teamId
|
|
322
|
+
&& content.subjectRef?.store === 'treedx' && content.subjectRef.model === 'proposal' && content.subjectRef.id === proposal.id
|
|
323
|
+
&& content.subjectRef.repository === original.binding.repositoryId && content.subjectRef.path === original.files.files[0]?.path
|
|
324
|
+
&& ref.repository === original.binding.repositoryId, `${code}: Exact closed proposal discussion required`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
assert.deepEqual([...scopes].sort(), [proposal.projectId, team.id].sort(), `${code}: Both original project and team objectives required`);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function retainedBytes(path: string): Buffer {
|
|
331
|
+
assert.ok(isAbsolute(path) && realpathSync(path) === resolve(path) && lstatSync(path).isFile(),
|
|
332
|
+
'ACCEPTANCE_SDK_WORKDAY: Independent regular retained file required');
|
|
333
|
+
const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
334
|
+
try {
|
|
335
|
+
assert.ok(fstatSync(fd).isFile() && (fstatSync(fd).mode & 0o444) !== 0, 'ACCEPTANCE_SDK_WORKDAY: Readable regular file required');
|
|
336
|
+
return readFileSync(fd);
|
|
337
|
+
} finally { closeSync(fd); }
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** Consume the original captured proposal input, not a second proposal authority. */
|
|
341
|
+
export function sdkGoldenFrozenProposal(freeze: Row): Row {
|
|
342
|
+
assert.ok(freeze.receipts && typeof freeze.receipts === 'object' && !Array.isArray(freeze.receipts),
|
|
343
|
+
'ACCEPTANCE_SDK_FROZEN_REQUEST: Original proposal input receipt required');
|
|
344
|
+
const inputs = Object.entries(freeze.receipts).filter(([path]) => basename(path) === 'proposal-input.json');
|
|
345
|
+
assert.equal(inputs.length, 1, 'ACCEPTANCE_SDK_FROZEN_REQUEST: One unambiguous original proposal input required');
|
|
346
|
+
const [path, digest] = inputs[0]!, bytes = retainedBytes(path);
|
|
347
|
+
assert.ok(bytes.length <= 1_048_576 && typeof digest === 'string' && /^sha256:[a-f0-9]{64}$/u.test(digest)
|
|
348
|
+
&& digest === `sha256:${createHash('sha256').update(bytes).digest('hex')}`,
|
|
349
|
+
'ACCEPTANCE_SDK_FROZEN_REQUEST: Original proposal input bytes changed');
|
|
350
|
+
const input: unknown = JSON.parse(bytes.toString('utf8'));
|
|
351
|
+
assert.ok(input && typeof input === 'object' && !Array.isArray(input), 'ACCEPTANCE_SDK_FROZEN_REQUEST: Original proposal object required');
|
|
352
|
+
const proposal = input as Row;
|
|
353
|
+
assert.ok(proposal.status === 'draft' && typeof proposal.id === 'string' && proposal.id.trim() === proposal.id && proposal.id
|
|
354
|
+
&& proposal.id === freeze.proposal?.id
|
|
355
|
+
&& Array.isArray(freeze.request?.body?.projects) && freeze.request.body.projects.length === 1
|
|
356
|
+
&& typeof proposal.projectId === 'string' && proposal.projectId.trim() === proposal.projectId && proposal.projectId
|
|
357
|
+
&& proposal.projectId === freeze.request.body.projects[0]
|
|
358
|
+
&& typeof proposal.request === 'string' && proposal.request.trim(),
|
|
359
|
+
'ACCEPTANCE_SDK_FROZEN_REQUEST: Exact initial draft identity project and request required');
|
|
360
|
+
assert.ok(typeof proposal.title === 'string' && proposal.title.trim() && typeof proposal.summary === 'string' && proposal.summary.trim()
|
|
361
|
+
&& Array.isArray(proposal.objectiveRefs) && proposal.objectiveRefs.length >= 2
|
|
362
|
+
&& proposal.objectiveRefs.every((ref: unknown) => exactEntityReferenceSchema.safeParse(ref).success),
|
|
363
|
+
'ACCEPTANCE_SDK_FROZEN_REQUEST: Complete original objective authority required');
|
|
364
|
+
verifySdkGoldenAuthoredWork(proposal, true);
|
|
365
|
+
assert.deepEqual(retainedBytes(path), bytes, 'ACCEPTANCE_SDK_FROZEN_REQUEST: Original proposal changed during read');
|
|
366
|
+
return proposal;
|
|
367
|
+
}
|
|
368
|
+
/** Product acceptance consumes the original API receipt; proposal discovery is not invocation authority. */
|
|
369
|
+
export function sdkGoldenWorkdayId(read: (args: string[]) => Row, freeze: Row, explicit?: string, freezePath?: string): string {
|
|
370
|
+
assert.ok(freezePath, 'ACCEPTANCE_SDK_WORKDAY: Explicit immutable freeze path required');
|
|
371
|
+
const bytes = retainedBytes(freezePath), receiptPath = `${freezePath}.workday-start.json`, receiptBytes = retainedBytes(receiptPath);
|
|
372
|
+
assert.deepEqual(JSON.parse(bytes.toString('utf8')), freeze, 'ACCEPTANCE_SDK_WORKDAY: Frozen input changed');
|
|
373
|
+
const receipt = JSON.parse(receiptBytes.toString('utf8')) as unknown;
|
|
374
|
+
assert.ok(receipt && typeof receipt === 'object' && !Array.isArray(receipt), 'ACCEPTANCE_SDK_WORKDAY: Original API receipt required');
|
|
375
|
+
const original = receipt as Row, preflight = freeze.preflight, body = freeze.request?.body, id = original.workdayId;
|
|
376
|
+
assert.deepEqual(Object.keys(original).sort(), ['schemaVersion', 'workdayId', 'preflightId', 'preflightDigest', 'startedAt',
|
|
377
|
+
'acceptedExecutionNodeIds', 'assignmentIds', 'reservationIds', 'providerReceiptRefs', 'transactionReceiptId'].sort());
|
|
378
|
+
assert.equal(original.schemaVersion, 'treeseed.workday-start-receipt/v1');
|
|
379
|
+
assert.ok(typeof id === 'string' && /^workday-[a-f0-9-]+$/u.test(id));
|
|
380
|
+
assert.ok(typeof preflight?.id === 'string' && preflight.id.trim() && typeof preflight.teamId === 'string' && preflight.teamId.trim()
|
|
381
|
+
&& typeof preflight.preflightDigest === 'string' && /^sha256:[A-Za-z0-9_-]{43}$/u.test(preflight.preflightDigest));
|
|
382
|
+
assert.equal(original.preflightId, preflight.id); assert.equal(original.preflightDigest, preflight.preflightDigest);
|
|
383
|
+
assert.ok(typeof original.startedAt === 'string' && Number.isFinite(Date.parse(original.startedAt))
|
|
384
|
+
&& typeof original.transactionReceiptId === 'string' && /^workday-start:[A-Za-z0-9_-]{43}$/u.test(original.transactionReceiptId));
|
|
385
|
+
for (const field of ['acceptedExecutionNodeIds', 'assignmentIds', 'reservationIds', 'providerReceiptRefs']) {
|
|
386
|
+
const values: unknown = original[field];
|
|
387
|
+
assert.ok(Array.isArray(values) && values.every(value => typeof value === 'string' && value.trim() === value && value.length > 0)
|
|
388
|
+
&& new Set(values).size === values.length);
|
|
389
|
+
}
|
|
390
|
+
if (explicit) assert.equal(explicit, id, 'ACCEPTANCE_SDK_WORKDAY: Conflicting explicit workday');
|
|
391
|
+
assert.ok(typeof freeze.proposal?.id === 'string' && freeze.proposal.id.trim());
|
|
392
|
+
assert.equal(body?.executionMode, 'simulation'); assert.deepEqual(body.proposalIds, [freeze.proposal.id]);
|
|
393
|
+
assert.ok(Array.isArray(body.projects) && body.projects.length === 1 && typeof body.projects[0] === 'string' && body.projects[0].trim());
|
|
394
|
+
const run = read(['workdays', 'show', id]).run;
|
|
395
|
+
assert.equal(run?.id, id); assert.equal(run.teamId, preflight.teamId); assert.equal(run.executionMode, 'simulation');
|
|
396
|
+
assert.equal(run.status, 'completed'); assert.equal(run.startedAt, original.startedAt);
|
|
397
|
+
assert.deepEqual(run.parameters?.proposalIds, body.proposalIds); assert.deepEqual(run.parameters.scheduledProjectIds, body.projects);
|
|
398
|
+
assert.deepEqual(retainedBytes(freezePath), bytes); assert.deepEqual(retainedBytes(receiptPath), receiptBytes);
|
|
399
|
+
return id;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export{parseSdkResearchCitation,resolveSdkResearchCitation}from'./product/research-source.ts';
|
|
403
|
+
export{sdkResearchArtifact,verifySdkResearchCitations}from'./product/research-artifact.ts';
|
|
404
|
+
export{verifySdkResearchRevision}from'./product/research-revision.ts';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import {execFileSync,spawnSync} from 'node:child_process';
|
|
3
|
+
import {createHash} from 'node:crypto';
|
|
4
|
+
import {existsSync,mkdtempSync,mkdirSync,readFileSync,rmSync,writeFileSync} from 'node:fs';
|
|
5
|
+
import {tmpdir} from 'node:os';
|
|
6
|
+
import {dirname,join,resolve} from 'node:path';
|
|
7
|
+
import {nativePublishedGit,verifySdkCommittedTests} from './test-chain.ts';
|
|
8
|
+
import {nativeTestReport,sdkNativeTestCommand} from './release-output.ts';
|
|
9
|
+
|
|
10
|
+
const label='ACCEPTANCE_SDK_BASE_RED';
|
|
11
|
+
type Observation={commit:string;command:string;processCommand:string[];status:number;startedAt:string;completedAt:string;stdout:string;stderr:string;outputDigest:string};
|
|
12
|
+
/** Replay original committed source and tests independently. Only disposable
|
|
13
|
+
* directories are written; every command comes from the held upstream package. */
|
|
14
|
+
export async function verifySdkBaseRed(repository:string,base:string,tester:string,engineer:string, inspectEngineer?: (cwd:string)=>void|Promise<void>){
|
|
15
|
+
const approved=verifySdkCommittedTests(repository,base,tester,engineer),git=nativePublishedGit(repository);
|
|
16
|
+
const root=mkdtempSync(join(tmpdir(),'sdk-native-base-red-')),observations:Observation[]=[];
|
|
17
|
+
const env:NodeJS.ProcessEnv={PATH:dirname(process.execPath)+':/usr/bin:/bin',HOME:root,LANG:'C',CI:'true',
|
|
18
|
+
NPM_CONFIG_CACHE:join(root,'npm-cache'),NPM_CONFIG_USERCONFIG:join(root,'user.npmrc'),NPM_CONFIG_GLOBALCONFIG:join(root,'global.npmrc'),
|
|
19
|
+
...(process.env.NODE_EXTRA_CA_CERTS?{NODE_EXTRA_CA_CERTS:process.env.NODE_EXTRA_CA_CERTS}:{})};
|
|
20
|
+
const run=(commit:string,cwd:string,args:string[],mayFail=false)=>{
|
|
21
|
+
const startedAt=new Date().toISOString(),result=spawnSync('/usr/bin/setsid',['npm',...args],{cwd,env,encoding:'utf8',timeout:120_000,maxBuffer:32*1024*1024});
|
|
22
|
+
const observation={commit,command:['npm',...args].join(' '),processCommand:['/usr/bin/setsid','npm',...args],status:result.status??-1,startedAt,completedAt:new Date().toISOString(),stdout:result.stdout??'',stderr:result.stderr??'',outputDigest:'sha256:'+createHash('sha256').update(JSON.stringify({stderr:result.stderr??'',stdout:result.stdout??''})).digest('hex')};
|
|
23
|
+
observations.push(observation);
|
|
24
|
+
// Every process group is newly owned by this disposable command. Reap its
|
|
25
|
+
// descendants on success or failure before another phase or directory cleanup.
|
|
26
|
+
if(Number.isInteger(result.pid)&&result.pid>0){try{process.kill(-result.pid,'SIGKILL');}catch(error){if((error as NodeJS.ErrnoException).code!=='ESRCH')throw error;}}
|
|
27
|
+
assert.equal(result.error,undefined,label);assert.equal(result.signal,null,label);
|
|
28
|
+
assert.ok(mayFail?result.status===0||result.status===1:result.status===0,label+': '+observation.command);
|
|
29
|
+
return observation;
|
|
30
|
+
};
|
|
31
|
+
try{
|
|
32
|
+
writeFileSync(join(root,'user.npmrc'),'');writeFileSync(join(root,'global.npmrc'),'');
|
|
33
|
+
const reports=[];
|
|
34
|
+
let baselinePackage:Buffer|undefined,baselineLock:Buffer|undefined,baselineConfig:Buffer|undefined;
|
|
35
|
+
for(const [phase,commit]of [['base',base],['tester',tester],['engineer',engineer]]as const){
|
|
36
|
+
const cwd=join(root,phase);mkdirSync(cwd);
|
|
37
|
+
execFileSync('/usr/bin/tar',['-xf','-','-C',cwd],{input:git(['archive','--format=tar',commit]),timeout:5_000});
|
|
38
|
+
const packageBytes=readFileSync(join(cwd,'package.json')),lock=readFileSync(join(cwd,'package-lock.json')),config=readFileSync(join(cwd,'vitest.contracts.config.ts'));
|
|
39
|
+
if(phase==='base'){baselinePackage=packageBytes;baselineLock=lock;baselineConfig=config;}
|
|
40
|
+
else {assert.deepEqual(packageBytes,baselinePackage,label+': runner package changed');assert.deepEqual(lock,baselineLock,label+': dependency lock changed');assert.deepEqual(config,baselineConfig,label+': assertion discovery changed');}
|
|
41
|
+
const scripts=JSON.parse(packageBytes.toString('utf8')).scripts;assert.ok(typeof scripts?.build==='string'&&typeof scripts?.['test:contracts']==='string',label);
|
|
42
|
+
run(commit,cwd,['ci','--ignore-scripts','--no-audit','--no-fund']);run(commit,cwd,['run','build']);
|
|
43
|
+
if(phase==='engineer')await inspectEngineer?.(cwd);
|
|
44
|
+
const original=run(commit,cwd,['run','test:contracts','--','--reporter=default','--reporter=json'],true);
|
|
45
|
+
assert.equal(original.command,sdkNativeTestCommand,label);
|
|
46
|
+
reports.push(nativeTestReport(original.stdout,original.status===0));
|
|
47
|
+
for(const candidate of [base,tester,engineer])assert.equal(git(['rev-parse','--verify',candidate+'^{commit}']).toString().trim(),candidate,label);
|
|
48
|
+
}
|
|
49
|
+
const [baseline,red,green]=reports;assert.ok(baseline&&red&&green,label);
|
|
50
|
+
const progress=verifySdkBaseAssertionProgress(baseline,red,green,approved);
|
|
51
|
+
return{base,tester,engineer,approved,...progress,redAssertions:red,greenAssertions:green,observations};
|
|
52
|
+
}catch(failure){throw new Error(label+': independent frozen-source replay failed',{cause:{failure,observations}});}
|
|
53
|
+
finally{rmSync(root,{recursive:true,force:true});assert.equal(existsSync(root),false,label+': disposable replay residue');}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
type Assertions=ReadonlyMap<string,{path:string;status:string}>;
|
|
57
|
+
/** Original BASE identities cannot disappear from the approved native suite. */
|
|
58
|
+
export function verifySdkBaseAssertionProgress(baseline:Assertions,red:Assertions,green:Assertions,approved:readonly{path:string}[]){
|
|
59
|
+
assert.ok(baseline.size>0&&red.size>0&&green.size>0,label+': complete original assertion inventories required');
|
|
60
|
+
for(const id of baseline.keys())assert.ok(red.has(id),label+': original BASE assertion omitted');
|
|
61
|
+
|
|
62
|
+
const changed=new Set(approved.map(file=>file.path)),introduced:string[]=[],unrelated:string[]=[];
|
|
63
|
+
for(const[id,test]of baseline)if(test.status==='failed'){unrelated.push(id);assert.equal(red.get(id)?.status,'failed',label+': original BASE failure disappeared');}
|
|
64
|
+
assert.deepEqual([...red.keys()].sort(),[...green.keys()].sort(),label+': Engineer omitted or replaced assertions');
|
|
65
|
+
for(const[id,test]of red){assert.equal(green.get(id)?.status,'passed',label+': exact approved test is not GREEN');
|
|
66
|
+
if(test.status==='failed'&&baseline.get(id)?.status!=='failed'){assert.ok(changed.has(test.path),label+': new failure outside approved tests');introduced.push(id);}
|
|
67
|
+
}
|
|
68
|
+
assert.ok(introduced.length>0,label+': a nonzero command or unchanged BASE failure is not intended test-first RED');
|
|
69
|
+
for(const file of approved.filter(file=>/\.(?:test|spec)\.tsx?$/u.test(file.path)))assert.ok([...red.values()].some(test=>test.path===file.path),label+': committed test omitted');
|
|
70
|
+
|
|
71
|
+
return{introducedFailures:introduced,unrelatedBaseFailures:unrelated};
|
|
72
|
+
}
|
|
73
|
+
export {verifySdkIntentRuntime} from './intent-runtime.ts';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
|
|
4
|
+
const label='ACCEPTANCE_SDK_DOCUMENTATION',unknown=Symbol('not-a-literal');
|
|
5
|
+
type Literal=string|number|boolean|null|typeof unknown|Literal[]|{[key:string]:Literal};
|
|
6
|
+
const object=(value:Literal):value is {[key:string]:Literal}=>Boolean(value&&typeof value==='object'&&!Array.isArray(value));
|
|
7
|
+
|
|
8
|
+
/** Inspect literal reference examples without executing documentation or trusting
|
|
9
|
+
* prose/metadata as proof of normalization and omission. TypeScript is already
|
|
10
|
+
* a production SDK dependency. Unknown expressions never prove an example. */
|
|
11
|
+
function examples(source:string):Array<{[key:string]:Literal}>{
|
|
12
|
+
const observations:Array<{[key:string]:Literal}>=[],bindings=new Map<string,Literal>();
|
|
13
|
+
const literal=(node:ts.Expression):Literal=>{
|
|
14
|
+
if(ts.isStringLiteral(node)||ts.isNoSubstitutionTemplateLiteral(node))return node.text;
|
|
15
|
+
if(ts.isNumericLiteral(node))return Number(node.text);
|
|
16
|
+
if(node.kind===ts.SyntaxKind.TrueKeyword)return true;if(node.kind===ts.SyntaxKind.FalseKeyword)return false;if(node.kind===ts.SyntaxKind.NullKeyword)return null;
|
|
17
|
+
if(ts.isIdentifier(node))return bindings.get(node.text)??unknown;
|
|
18
|
+
if(ts.isParenthesizedExpression(node)||ts.isAsExpression(node)||ts.isSatisfiesExpression(node))return literal(node.expression);
|
|
19
|
+
if(ts.isArrayLiteralExpression(node))return node.elements.map(item=>ts.isSpreadElement(item)?unknown:literal(item));
|
|
20
|
+
if(!ts.isObjectLiteralExpression(node))return unknown;
|
|
21
|
+
const value:{[key:string]:Literal}=Object.create(null);
|
|
22
|
+
for(const property of node.properties){
|
|
23
|
+
if(ts.isSpreadAssignment(property)){const spread=literal(property.expression);if(!object(spread))return unknown;Object.assign(value,spread);continue;}
|
|
24
|
+
if(ts.isShorthandPropertyAssignment(property)){value[property.name.text]=bindings.get(property.name.text)??unknown;continue;}
|
|
25
|
+
if(!ts.isPropertyAssignment(property))return unknown;
|
|
26
|
+
const key=ts.isIdentifier(property.name)||ts.isStringLiteral(property.name)?property.name.text:undefined;if(key===undefined||Object.hasOwn(value,key))return unknown;
|
|
27
|
+
Object.defineProperty(value,key,{value:literal(property.initializer),enumerable:true,configurable:true,writable:true});
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
for(const match of source.matchAll(/(?:^|\n)(`{3,}|~{3,})([^\n]*)\n([\s\S]*?)\n\1(?=\n|$)/gu)){
|
|
32
|
+
const language=match[2]!.trim().split(/\s/u)[0];if(!['ts','typescript','js','javascript','json'].includes(language!))continue;
|
|
33
|
+
const text=language==='json'?'('+match[3]+');':match[3]!;
|
|
34
|
+
const syntax=ts.transpileModule(text,{reportDiagnostics:true,compilerOptions:{target:ts.ScriptTarget.ES2022}});
|
|
35
|
+
assert.ok(!syntax.diagnostics?.some(value=>value.category===ts.DiagnosticCategory.Error),label+': Malformed reference example');
|
|
36
|
+
const file=ts.createSourceFile('reference.ts',text,ts.ScriptTarget.ES2022,true,ts.ScriptKind.TS);
|
|
37
|
+
const visit=(node:ts.Node)=>{
|
|
38
|
+
if(ts.isVariableDeclaration(node)&&ts.isIdentifier(node.name)&&node.initializer)bindings.set(node.name.text,literal(node.initializer));
|
|
39
|
+
if(ts.isObjectLiteralExpression(node)){const value=literal(node);if(object(value))observations.push(value);}
|
|
40
|
+
ts.forEachChild(node,visit);
|
|
41
|
+
};visit(file);
|
|
42
|
+
}
|
|
43
|
+
return observations;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function verifySdkDocumentationExamples(documents:unknown):void{
|
|
47
|
+
assert.ok(Array.isArray(documents)&&documents.length>0&&documents.every(value=>typeof value==='string'&&value.trim()),label+': Visible committed reference pages required');
|
|
48
|
+
const source=documents.join('\n').replace(/^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/gmu,'').replace(/<!--[\s\S]*?-->/gu,'');
|
|
49
|
+
const rows=examples(source),selections=rows.map(row=>row.decisionIds).filter((value):value is string[]=>Array.isArray(value)&&value.length>0&&value.every(id=>typeof id==='string'));
|
|
50
|
+
assert.ok(selections.some(input=>{const trimmed=input.map(id=>id.trim());if(new Set(trimmed).size!==trimmed.length||!trimmed.every(id=>/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,199}$/u.test(id)))return false;
|
|
51
|
+
const normalized=[...trimmed].sort();return JSON.stringify(input)!==JSON.stringify(normalized)&&selections.some(output=>JSON.stringify(output)===JSON.stringify(normalized));
|
|
52
|
+
}),label+': Literal input and exact trimmed case-sensitive sorted outbound selection required');
|
|
53
|
+
for(const planningOnly of [false,true])assert.ok(rows.some(row=>row.planningOnly===planningOnly&&!Object.hasOwn(row,'decisionIds')&&row.schemaVersion==='treeseed.workday-intent/v1'&&Array.isArray(row.projects)&&row.projects.length>0),label+': Omission must preserve both independent planning states');
|
|
54
|
+
const commands=[...source.matchAll(/(?:^|\n)(`{3,}|~{3,})(?:sh|bash|shell|console|text)\s*\n([\s\S]*?)\n\1(?=\n|$)/gu)].flatMap(match=>match[2]!.split('\n'));
|
|
55
|
+
for(const command of ['workdays plan','workdays schedules start'])assert.ok(commands.some(line=>{
|
|
56
|
+
if(!new RegExp('(?:^|\\s)'+command+'(?:\\s|$)','u').test(line)||/^\s*#/u.test(line))return false;
|
|
57
|
+
const ids=[...line.matchAll(/(?:^|\s)--decision(?:=|\s+)([^\s]+)/gu)].flatMap(match=>match[1]!.replace(/^['"]|['"]$/gu,'').split(','));return ids.length>=2&&ids.every(id=>/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,199}$/u.test(id));
|
|
58
|
+
}),label+': Both generated command descriptors need repeatable/CSV selection examples');
|
|
59
|
+
const prose=source.replace(/(?:^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\1(?=\n|$)/gu,' ');
|
|
60
|
+
assert.ok(!/\bSDK\s+(?:also\s+)?(?:computes?|generates?)\s+(?!neither\b|no\b)[^,.;\n]*\b(?:intentDigest|preflightDigest)\b/iu.test(prose),label+': Contradictory SDK digest ownership');
|
|
61
|
+
assert.ok(/\bAPI\b[^.\n]*\b(?:alone|only)\b[^.\n]*\bcomputes?\b[^.\n]*\bintentDigest\b[^.\n]*\bpreflightDigest\b[^.\n]*\b(?:persistence|persisted)\b/iu.test(prose),label+': API-only digest and persistence ownership must be stated');
|
|
62
|
+
assert.ok(/\bSDK\b[^.\n]*\bserializ\w*/iu.test(prose)&&/\bpersisted\s+`?capacityPlanId`?\b/iu.test(prose),label+': Separate SDK serialization and persisted API capacity provenance required');
|
|
63
|
+
for(const field of ['executionPlanId','capacityPlanId','executionInputId','demandSetId']){
|
|
64
|
+
assert.ok(!new RegExp('caller-authored[^.\\n]*\\b'+field+'\\b[^.\\n]*\\b(?:is|are)\\s+(?:accepted|allowed|permitted)\\b','iu').test(prose),label+': Contradictory caller-derived authority');
|
|
65
|
+
assert.ok(rows.some(row=>Object.hasOwn(row,field)),label+': Every prohibited caller field needs an actual input example');
|
|
66
|
+
assert.ok(new RegExp('(?:caller-authored|caller input)[^.\\n]*\\b'+field+'\\b[^.\\n]*\\b(?:rejected|prohibited|invalid)\\b','iu').test(prose),label+': Each caller-authored field must be explicitly denied');
|
|
67
|
+
}
|
|
68
|
+
}
|