@tiinex/core 0.25.0 → 0.26.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.25.0",
3
+ "version": "0.26.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": "387532b237387d95bd1a491eba1190b57ed73051",
176
+ "gitHead": "7a4c0e1eab27559eef417cf5eb1c15d47483d199",
177
177
  "tiinexRelease": {
178
178
  "policy": "tiinex.master-npm-release.v1",
179
- "sourceCommit": "387532b237387d95bd1a491eba1190b57ed73051",
180
- "sourceTree": "e1a4ae2d3cc2fa91b1a734890d09af3758826617",
179
+ "sourceCommit": "7a4c0e1eab27559eef417cf5eb1c15d47483d199",
180
+ "sourceTree": "bb24af76e471a711fff58602ac0dc879c016f3a5",
181
181
  "repository": "Tiinex/core",
182
- "previousVersion": "0.24.0"
182
+ "previousVersion": "0.25.0"
183
183
  }
184
184
  }
@@ -0,0 +1,70 @@
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 bootstrapPath = String(inspection.packageContract?.bootstrapPath || '').trim();
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: bootstrapPath }),
19
+ ignoredFindingCodes: Object.freeze([]),
20
+ blockingFindingCodes: Object.freeze([]),
21
+ boundary: boundary()
22
+ });
23
+
24
+ const bootstrapArtifact = bootstrapPath ? findFile(bundle, bootstrapPath) : null;
25
+ const bootstrapMarkdown = bootstrapArtifact ? decodeUtf8(packageFileBytes(bootstrapArtifact)) : '';
26
+ const payloadPath = bootstrapMarkdown ? recoveryPayloadPath(bootstrapMarkdown) : '';
27
+ const bootstrapOwnedPaths = new Set([bootstrapPath, payloadPath].filter(Boolean));
28
+ const ignored = [];
29
+ const blocking = [];
30
+ for (const item of errors) {
31
+ const code = String(item?.code || '');
32
+ const findingPath = String(item?.path || item?.packagePath || '').trim();
33
+ const bootstrapScoped = BOOTSTRAP_CODE_PREFIXES.some((prefix) => code.startsWith(prefix)) || (findingPath && bootstrapOwnedPaths.has(findingPath));
34
+ (bootstrapScoped ? ignored : blocking).push(item);
35
+ }
36
+
37
+ const packageStructurePresent = Boolean(inspection.rootArtifact && inspection.readArtifact && inspection.carrierProjection);
38
+ const carrierReady = String(inspection.carrierProjection?.status || '') === 'ready';
39
+ const eligible = packageStructurePresent && carrierReady && ignored.length > 0 && blocking.length === 0;
40
+ return freeze({
41
+ schema: 'tiinex.portable.bootstrap-recovery.v1',
42
+ state: eligible ? 'eligible' : 'ineligible',
43
+ eligibleWithQualifiedHostBootstrap: eligible,
44
+ packageBootstrap: Object.freeze({
45
+ state: bootstrapPath ? (bootstrapArtifact ? 'unqualified' : 'missing') : 'undeclared',
46
+ artifactPath: bootstrapPath,
47
+ payloadPath
48
+ }),
49
+ ignoredFindingCodes: Object.freeze(ignored.map((item) => String(item?.code || '')).filter(Boolean)),
50
+ blockingFindingCodes: Object.freeze(blocking.map((item) => String(item?.code || '')).filter(Boolean)),
51
+ boundary: boundary()
52
+ });
53
+ }
54
+
55
+ function recoveryPayloadPath(markdown = '') {
56
+ const lines = String(markdown || '').split(/\r?\n/);
57
+ for (const line of lines) {
58
+ if (!/(?:payload|location)/i.test(line)) continue;
59
+ const link = line.match(/\[[^\]]+\]\(([^)]+\.zip)\)/i);
60
+ if (link?.[1]) return link[1].trim();
61
+ const field = line.match(/(?:Payload Path|Payload|Location|Bootstrap Payload)\s*:\s*`?([^`\s]+\.zip)`?/i);
62
+ if (field?.[1]) return field[1].trim();
63
+ }
64
+ return '';
65
+ }
66
+
67
+ function findFile(bundle = {}, path = '') { return (bundle.files || []).find((file) => String(file.path || '') === String(path || '')) || null; }
68
+ function decodeUtf8(data) { try { return new TextDecoder('utf-8', { fatal: true }).decode(data); } catch { return ''; } }
69
+ 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.'; }
70
+ 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);