@tiinex/core 0.25.0 → 0.27.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiinex/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Shared host-neutral Tiinex implementation core for artifacts, schemas, validation, lineage, grounding, Handoffs, provenance and deterministic workflows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": true,
|
|
@@ -173,12 +173,12 @@
|
|
|
173
173
|
"type": "git",
|
|
174
174
|
"url": "git+https://github.com/Tiinex/core.git"
|
|
175
175
|
},
|
|
176
|
-
"gitHead": "
|
|
176
|
+
"gitHead": "a7e75e17b1b95c022875c2006d2957d8cce580ae",
|
|
177
177
|
"tiinexRelease": {
|
|
178
178
|
"policy": "tiinex.master-npm-release.v1",
|
|
179
|
-
"sourceCommit": "
|
|
180
|
-
"sourceTree": "
|
|
179
|
+
"sourceCommit": "a7e75e17b1b95c022875c2006d2957d8cce580ae",
|
|
180
|
+
"sourceTree": "e86d119618fcd9cdc48bff5b016546f79bb7bcaa",
|
|
181
181
|
"repository": "Tiinex/core",
|
|
182
|
-
"previousVersion": "0.
|
|
182
|
+
"previousVersion": "0.26.0"
|
|
183
183
|
}
|
|
184
184
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { packageFileBytes } from '../../../export/package.bytes.js';
|
|
2
|
+
|
|
3
|
+
const BOOTSTRAP_CODE_PREFIXES = Object.freeze([
|
|
4
|
+
'portable.handoff-package-v1.bootstrap-',
|
|
5
|
+
'portable.handoff-v2-surface.bootstrap.',
|
|
6
|
+
'portable.tooling-bootstrap.'
|
|
7
|
+
]);
|
|
8
|
+
|
|
9
|
+
export function projectPortableBootstrapRecovery(bundle = {}, inspection = {}) {
|
|
10
|
+
const findings = Array.isArray(inspection.findings) ? inspection.findings : [];
|
|
11
|
+
const errors = findings.filter((item) => String(item?.severity || '') === 'error');
|
|
12
|
+
const bootstrapPaths = recoveryBootstrapArtifactPaths(bundle, inspection);
|
|
13
|
+
const packageBootstrapValid = String(inspection.bootstrapInspection?.status || '') === 'valid';
|
|
14
|
+
if (packageBootstrapValid) return freeze({
|
|
15
|
+
schema: 'tiinex.portable.bootstrap-recovery.v1',
|
|
16
|
+
state: 'not-needed',
|
|
17
|
+
eligibleWithQualifiedHostBootstrap: false,
|
|
18
|
+
packageBootstrap: Object.freeze({ state: 'qualified', artifactPath: bootstrapPaths[0] || '' }),
|
|
19
|
+
ignoredFindingCodes: Object.freeze([]),
|
|
20
|
+
blockingFindingCodes: Object.freeze([]),
|
|
21
|
+
boundary: boundary()
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const bootstrapArtifacts = bootstrapPaths.map((artifactPath) => Object.freeze({ artifactPath, file: findFile(bundle, artifactPath) })).filter((item) => item.artifactPath);
|
|
25
|
+
const payloadPaths = [...new Set(bootstrapArtifacts.flatMap((item) => {
|
|
26
|
+
if (!item.file) return [];
|
|
27
|
+
const markdown = decodeUtf8(packageFileBytes(item.file));
|
|
28
|
+
const target = recoveryPayloadPath(markdown);
|
|
29
|
+
return target ? [target] : [];
|
|
30
|
+
}))];
|
|
31
|
+
const bootstrapOwnedPaths = new Set([...bootstrapPaths, ...payloadPaths].filter(Boolean));
|
|
32
|
+
const ignored = [];
|
|
33
|
+
const blocking = [];
|
|
34
|
+
for (const item of errors) {
|
|
35
|
+
const code = String(item?.code || '');
|
|
36
|
+
const findingPath = String(item?.path || item?.packagePath || '').trim();
|
|
37
|
+
const bootstrapScoped = BOOTSTRAP_CODE_PREFIXES.some((prefix) => code.startsWith(prefix)) || (findingPath && bootstrapOwnedPaths.has(findingPath));
|
|
38
|
+
(bootstrapScoped ? ignored : blocking).push(item);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const packageStructurePresent = Boolean(inspection.rootArtifact && inspection.readArtifact && inspection.carrierProjection);
|
|
42
|
+
const carrierReady = String(inspection.carrierProjection?.status || '') === 'ready';
|
|
43
|
+
const eligible = packageStructurePresent && carrierReady && ignored.length > 0 && blocking.length === 0;
|
|
44
|
+
const primaryPath = bootstrapPaths.find((artifactPath) => Boolean(findFile(bundle, artifactPath))) || bootstrapPaths[0] || '';
|
|
45
|
+
return freeze({
|
|
46
|
+
schema: 'tiinex.portable.bootstrap-recovery.v1',
|
|
47
|
+
state: eligible ? 'eligible' : 'ineligible',
|
|
48
|
+
eligibleWithQualifiedHostBootstrap: eligible,
|
|
49
|
+
packageBootstrap: Object.freeze({
|
|
50
|
+
state: primaryPath ? (findFile(bundle, primaryPath) ? 'unqualified' : 'missing') : 'undeclared',
|
|
51
|
+
artifactPath: primaryPath,
|
|
52
|
+
artifactCandidates: Object.freeze([...bootstrapPaths]),
|
|
53
|
+
payloadPath: payloadPaths[0] || '',
|
|
54
|
+
payloadCandidates: Object.freeze([...payloadPaths])
|
|
55
|
+
}),
|
|
56
|
+
ignoredFindingCodes: Object.freeze(ignored.map((item) => String(item?.code || '')).filter(Boolean)),
|
|
57
|
+
blockingFindingCodes: Object.freeze(blocking.map((item) => String(item?.code || '')).filter(Boolean)),
|
|
58
|
+
boundary: boundary()
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function recoveryBootstrapArtifactPaths(bundle = {}, inspection = {}) {
|
|
63
|
+
const out = [];
|
|
64
|
+
const declared = String(inspection.packageContract?.bootstrapPath || '').trim();
|
|
65
|
+
if (declared) out.push(declared);
|
|
66
|
+
|
|
67
|
+
// Recovery may need to operate precisely when the bootstrap External Payload
|
|
68
|
+
// no longer qualifies strongly enough to reach normal package-contract
|
|
69
|
+
// projection. Use only explicit package-local bootstrap references from the
|
|
70
|
+
// already-identified package root/Start artifacts as recovery hints. These
|
|
71
|
+
// hints bound malformed bootstrap bytes; they do not grant bootstrap authority.
|
|
72
|
+
const candidates = [inspection.rootArtifact?.path, inspection.readArtifact?.path]
|
|
73
|
+
.map((value) => String(value || '').trim())
|
|
74
|
+
.filter(Boolean);
|
|
75
|
+
for (const artifactPath of candidates) {
|
|
76
|
+
const file = findFile(bundle, artifactPath);
|
|
77
|
+
if (!file) continue;
|
|
78
|
+
const markdown = decodeUtf8(packageFileBytes(file));
|
|
79
|
+
for (const target of explicitBootstrapMarkdownTargets(markdown)) out.push(target);
|
|
80
|
+
}
|
|
81
|
+
return Object.freeze([...new Set(out.filter(Boolean))]);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function explicitBootstrapMarkdownTargets(markdown = '') {
|
|
85
|
+
const out = [];
|
|
86
|
+
for (const line of String(markdown || '').split(/\r?\n/)) {
|
|
87
|
+
if (!/bootstrap/i.test(line)) continue;
|
|
88
|
+
for (const match of line.matchAll(/\[[^\]]+\]\(([^)]+\.md)\)/ig)) if (match?.[1]) out.push(match[1].trim());
|
|
89
|
+
}
|
|
90
|
+
return [...new Set(out.filter(Boolean))];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function recoveryPayloadPath(markdown = '') {
|
|
94
|
+
const lines = String(markdown || '').split(/\r?\n/);
|
|
95
|
+
for (const line of lines) {
|
|
96
|
+
if (!/(?:payload|location)/i.test(line)) continue;
|
|
97
|
+
const link = line.match(/\[[^\]]+\]\(([^)]+\.zip)\)/i);
|
|
98
|
+
if (link?.[1]) return link[1].trim();
|
|
99
|
+
const field = line.match(/(?:Payload Path|Payload|Location|Bootstrap Payload)\s*:\s*`?([^`\s]+\.zip)`?/i);
|
|
100
|
+
if (field?.[1]) return field[1].trim();
|
|
101
|
+
}
|
|
102
|
+
return '';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function findFile(bundle = {}, path = '') { return (bundle.files || []).find((file) => String(file.path || '') === String(path || '')) || null; }
|
|
106
|
+
function decodeUtf8(data) { try { return new TextDecoder('utf-8', { fatal: true }).decode(data); } catch { return ''; } }
|
|
107
|
+
function boundary() { return 'Host-bootstrap recovery is a read-only execution fallback only. It does not rewrite package bytes, qualify a broken package bootstrap, erase original findings, or create Handoff/Workspace/semantic authority.'; }
|
|
108
|
+
function freeze(value) { if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value; for (const child of Object.values(value)) freeze(child); return Object.freeze(value); }
|
|
@@ -3,6 +3,7 @@ import { inspectHandoffCarrierProjection } from './carrierProjection.js';
|
|
|
3
3
|
import { inspectHandoffPointerEntrypoints } from './pointerEntrypoint.js';
|
|
4
4
|
import { inspectRecipientFacingV2Topology } from './recipientV2.inspect.js';
|
|
5
5
|
import { RECIPIENT_V2_READ_PATH } from './recipientV2.topology.js';
|
|
6
|
+
import { projectPortableBootstrapRecovery } from './bootstrapRecovery.js';
|
|
6
7
|
|
|
7
8
|
export const HANDOFF_COLD_CONSUMER_ENTRYPOINT_PATH = 'tiinex.package/START.md';
|
|
8
9
|
export const HANDOFF_COLD_CONSUMER_PROJECTION_SCHEMA_ID = 'tiinex.portable.handoff-cold-consumer-projection.v1';
|
|
@@ -120,6 +121,7 @@ export function orientColdConsumerFromHandoffPackage(input = {}) {
|
|
|
120
121
|
if ((bundle.files || []).some((file) => String(file.path || '') === RECIPIENT_V2_READ_PATH)) {
|
|
121
122
|
const v2 = inspectRecipientFacingV2Topology(bundle);
|
|
122
123
|
const projection = v2.coldConsumerProjection || null;
|
|
124
|
+
const bootstrapRecovery = projectPortableBootstrapRecovery(bundle, v2);
|
|
123
125
|
const routeMetadata = new Map((v2.routes || []).map((route) => [`${String(route.workspaceId || '')}\u0000${String(route.workspaceRelativeHandoffPath || '')}`, route]));
|
|
124
126
|
const carrierRouteById = new Map((v2.carrierProjection?.routes || []).map((route) => [String(route.id || ''), route]));
|
|
125
127
|
const workspaceArchiveById = new Map((v2.workspaces || []).map((workspace) => {
|
|
@@ -135,7 +137,7 @@ export function orientColdConsumerFromHandoffPackage(input = {}) {
|
|
|
135
137
|
const handoffPath = String(route.workspaceRelativeHandoffPath || '');
|
|
136
138
|
return Object.freeze({ ...route, sha256: handoffSha256, sha256Target: handoffPath, handoffSha256, archiveSha256: String(archive.sha256 || ''), archivePackagePath: String(archive.path || route.packagePath || ''), requiredClosure: carrierRoute.requiredClosure || null, pointerPath: String(metadata.pointerPath || ''), endpointRolePointers: Object.freeze([...(metadata.endpointRolePointers || [])]), participantRolePointers: Object.freeze([...(metadata.participantRolePointers || [])]) });
|
|
137
139
|
}));
|
|
138
|
-
return deepFreeze({ schema: 'tiinex.portable.handoff-cold-consumer-orientation.v1', status: v2.status === 'valid' && projection?.status === 'ready' ? 'ready' : 'blocked', entrypoint: Object.freeze({ schema: 'tiinex.portable.handoff-v2.recipient-orientation.inspection.v1', status: v2.status, path: RECIPIENT_V2_READ_PATH, projection, findings: v2.findings }), pointerEntrypoints: Object.freeze({ schema: 'tiinex.portable.handoff-v2.recipient-pointer.inspection.v1', status: v2.status, entries: v2.routes, findings: v2.findings }), workspaces: projection?.workspaces || Object.freeze([]), carrierLineage: v2.carrierProjection?.lineage || null, routes, endpointRoles: v2.endpointRoles || Object.freeze([]), participantRoles: v2.participantRoles || Object.freeze([]), selection: projection?.selection || null, operationBoundary: orientationOperationBoundary(v2.bootstrapInspection), boundary: 'Read-only recipient-facing v2 orientation from qualified visible Tiinex artifacts and exact payload bytes; no legacy control JSON, filename, or adjacency authority.' });
|
|
140
|
+
return deepFreeze({ schema: 'tiinex.portable.handoff-cold-consumer-orientation.v1', status: v2.status === 'valid' && projection?.status === 'ready' ? 'ready' : 'blocked', entrypoint: Object.freeze({ schema: 'tiinex.portable.handoff-v2.recipient-orientation.inspection.v1', status: v2.status, path: RECIPIENT_V2_READ_PATH, projection, findings: v2.findings }), pointerEntrypoints: Object.freeze({ schema: 'tiinex.portable.handoff-v2.recipient-pointer.inspection.v1', status: v2.status, entries: v2.routes, findings: v2.findings }), workspaces: projection?.workspaces || Object.freeze([]), carrierLineage: v2.carrierProjection?.lineage || null, routes, endpointRoles: v2.endpointRoles || Object.freeze([]), participantRoles: v2.participantRoles || Object.freeze([]), selection: projection?.selection || null, bootstrapRecovery, operationBoundary: orientationOperationBoundary(v2.bootstrapInspection), boundary: 'Read-only recipient-facing v2 orientation from qualified visible Tiinex artifacts and exact payload bytes; no legacy control JSON, filename, or adjacency authority.' });
|
|
139
141
|
}
|
|
140
142
|
const inspection = inspectHandoffColdConsumerEntrypoint(bundle);
|
|
141
143
|
const pointerEntrypoints = inspectHandoffPointerEntrypoints(bundle);
|