@tiinex/core 0.24.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.24.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": "c9a902017994156ce1c45f9ea78612875a072a1b",
176
+ "gitHead": "7a4c0e1eab27559eef417cf5eb1c15d47483d199",
177
177
  "tiinexRelease": {
178
178
  "policy": "tiinex.master-npm-release.v1",
179
- "sourceCommit": "c9a902017994156ce1c45f9ea78612875a072a1b",
180
- "sourceTree": "55c92c3bb3f604746613e64bd9adbe14f3fad3a1",
179
+ "sourceCommit": "7a4c0e1eab27559eef417cf5eb1c15d47483d199",
180
+ "sourceTree": "bb24af76e471a711fff58602ac0dc879c016f3a5",
181
181
  "repository": "Tiinex/core",
182
- "previousVersion": "0.23.0"
182
+ "previousVersion": "0.25.0"
183
183
  }
184
184
  }
@@ -198,7 +198,28 @@ async function prepareWorkspaceCarrierCliCommand(flags = {}, workspaceRoot = '.'
198
198
  const workspaceScopeValue = await readOptionalJson(flags['workspace-scopes']);
199
199
  const additionalWorkspaces = [...splitFlag(flags['additional-workspaces']), ...descriptorArray(workspaceDescriptorValue, 'workspaces')];
200
200
  const verifyRoundtrip = !flags['no-roundtrip'];
201
- const carrierProfile = selectCarrierProfile({ operator: operatorCarrierProfile, runtime: runtime.defaultCarrierProfile || null });
201
+ const parentPackagePath = String(flags['package-parent'] || '').trim();
202
+ let carrierLineage = Object.freeze({ ...initialHandoffCarrierLineage(), checkpointKind: 'progression', majorReason: '' });
203
+ let inheritedCarrierProfile = normalizeHandoffCarrierProfile(null);
204
+ if (parentPackagePath) {
205
+ const resolvedParent = path.resolve(parentPackagePath);
206
+ const parentBytes = new Uint8Array(await readFile(resolvedParent));
207
+ const parentBundle = await loadNodePortableInput([resolvedParent], { maxFiles: flags['max-files'], maxTextBytes: flags['max-text-bytes'] });
208
+ inheritedCarrierProfile = parentHandoffCarrierProfileFromBundle(parentBundle);
209
+ const parentLineage = parentHandoffCarrierLineageFromBundle(parentBundle);
210
+ carrierLineage = carrierLineageFromCliParent({
211
+ bundle: parentBundle,
212
+ parentPath: resolvedParent,
213
+ parentBytes,
214
+ qualifiedParentLineage: parentLineage,
215
+ major: Boolean(flags['package-major']),
216
+ majorReason: flags['major-reason'] || '',
217
+ siblingIndex: 1
218
+ });
219
+ } else if (flags['package-major']) {
220
+ throw new Error('portable.cli.workspace-carrier.package-major.parent-required');
221
+ }
222
+ const carrierProfile = selectCarrierProfile({ operator: operatorCarrierProfile, inherited: inheritedCarrierProfile, runtime: runtime.defaultCarrierProfile || null });
202
223
  const projectedFilename = String(flags['projected-filename'] || flags.projectedFilename || '').trim();
203
224
  const input = await prepareNodeWorkspaceCarrierManufacturingInput({
204
225
  workspaceRoot,
@@ -216,7 +237,7 @@ async function prepareWorkspaceCarrierCliCommand(flags = {}, workspaceRoot = '.'
216
237
  verifyRoundtrip,
217
238
  createdAt: flags['built-at'] || undefined,
218
239
  projectedFilename,
219
- carrierLineage: Object.freeze({ ...initialHandoffCarrierLineage(), checkpointKind: 'progression', majorReason: '' }),
240
+ carrierLineage,
220
241
  carrierProfile
221
242
  }, runtime);
222
243
  return { input, options: { verifyRoundtrip, packageInput: { builtAt: flags['built-at'] || undefined } } };
@@ -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);