@tiinex/core 0.20.0 → 0.21.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.20.0",
3
+ "version": "0.21.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,
@@ -172,12 +172,12 @@
172
172
  "type": "git",
173
173
  "url": "git+https://github.com/Tiinex/core.git"
174
174
  },
175
- "gitHead": "75e2e1e324fbe2e652a5c94f877ce6bf68e4a521",
175
+ "gitHead": "f27d38feae89ffc12999d288c769e5c488217412",
176
176
  "tiinexRelease": {
177
177
  "policy": "tiinex.master-npm-release.v1",
178
- "sourceCommit": "75e2e1e324fbe2e652a5c94f877ce6bf68e4a521",
179
- "sourceTree": "3138e1fdb8c064ec3417a55a731310aa8efd66b8",
178
+ "sourceCommit": "f27d38feae89ffc12999d288c769e5c488217412",
179
+ "sourceTree": "bb04bd577b9880d88648d1750a5244b7db509afe",
180
180
  "repository": "Tiinex/core",
181
- "previousVersion": "0.19.0"
181
+ "previousVersion": "0.20.0"
182
182
  }
183
183
  }
@@ -15,12 +15,18 @@ export function projectGroundingDelegationArtifactAuthority({ authority = null,
15
15
  const sender = qualifiedRole(senderRole, handoff.fromReference || '');
16
16
  if (!sender) unresolved.push('exact-sender-role-authority-not-established');
17
17
 
18
+ const delegateSelection = transferSelection ? selectForwardDelegate(transferSelection.record, authority) : null;
19
+ if (transferSelection && !delegateSelection?.selector) unresolved.push('forward-delegate-selector-not-established');
20
+ if (delegateSelection?.selector && !delegateSelection?.role) unresolved.push('exact-forward-selected-delegate-role-authority-not-established');
21
+
18
22
  const taskRecord = transferSelection?.record || null;
19
23
  const targetWorkspaceId = String(taskRecord?.path || '').split('/')[0] || '';
20
24
  const workspaceSource = (sourceEvidence?.workspaces || []).find((item) => String(item.workspace || '') === targetWorkspaceId && ['qualified', 'explicit-profile'].includes(String(item.state || ''))) || null;
21
25
  if (!workspaceSource?.repository) unresolved.push('exact-target-repository-authority-not-established');
22
26
 
23
- const delegateCapabilityAuthority = recipient && transferSelection ? delegateProjection(recipient, handoff, transferSelection) : null;
27
+ const delegateCapabilityAuthority = delegateSelection?.role && delegateSelection?.selector && transferSelection
28
+ ? delegateProjection(delegateSelection.role, handoff, transferSelection, delegateSelection.selector)
29
+ : null;
24
30
  if (!delegateCapabilityAuthority) unresolved.push('delegate-capability-artifact-projection-not-established');
25
31
 
26
32
  const processApplicability = sender && transferSelection ? processProjection(sender, handoff, transferSelection) : null;
@@ -56,9 +62,11 @@ export function projectGroundingDelegationArtifactAuthority({ authority = null,
56
62
  controllingTask: taskRecord ? sourceArtifactFromRecord(taskRecord) : null,
57
63
  senderRole: sender ? sender.sourceArtifact : null,
58
64
  recipientRole: recipient ? recipient.sourceArtifact : null,
59
- boundary: 'Projection only. Exact Handoff transfer, exact endpoint Role authority, exact controlling Task and exact Workspace source identity are composed mechanically; Role/cache inventory, filenames, adjacency and arbitrary prose are never searched for delegation meaning.'
65
+ delegateSelector: delegateSelection?.selector || null,
66
+ delegateRole: delegateSelection?.role?.sourceArtifact || null,
67
+ boundary: 'Projection only. The inbound Handoff recipient/current holder and downstream specialist are independent claims. The downstream Role is resolved only after one exact explicit selector declaration on the controlling current Task; route-bounded Role material then qualifies that already-selected Role. Role/cache inventory, endpoint identity, filenames, adjacency and arbitrary prose are never used to choose a delegate.'
60
68
  }),
61
- boundary: 'Artifact-derived delegation closure is available only from the exact selected forward chain. It does not select a delegate, invent a process, create source permission, or treat an endpoint alone as delegation authority.'
69
+ boundary: 'Artifact-derived delegation closure is available only from the exact selected forward chain. The current-work declaration selects the downstream Role; exact Role material qualifies capability. Inbound recipient/holder identity, Role-cache carriage, process applicability, source permission and return authority remain separate.'
62
70
  });
63
71
  }
64
72
 
@@ -96,7 +104,85 @@ function qualifiedRole(role, declaredReference = '') {
96
104
  });
97
105
  }
98
106
 
99
- function delegateProjection(role, handoff, selected) {
107
+ function selectForwardDelegate(taskRecord, authority = {}) {
108
+ const selector = explicitTaskSpecialistSelector(taskRecord);
109
+ if (!selector) return Object.freeze({ selector: null, role: null, candidates: Object.freeze([]) });
110
+ const candidates = exactRouteRoleMaterials(authority).filter((role) => normalize(role.label) === normalize(selector.roleLabel));
111
+ const unique = dedupeRoles(candidates);
112
+ return Object.freeze({ selector, role: unique.length === 1 ? unique[0] : null, candidates: Object.freeze(unique) });
113
+ }
114
+
115
+ function explicitTaskSpecialistSelector(taskRecord = {}) {
116
+ if (String(taskRecord.schemaId || '') !== 'tiinex.task.v1' || !taskRecord.hasContinuityContext || !taskRecord.hasIntegrity) return null;
117
+ const objective = section(taskRecord.markdown || '', 'Objective');
118
+ if (!objective) return null;
119
+ const declarations = objective
120
+ .split(/\r?\n\s*\r?\n/u)
121
+ .map((item) => item.trim())
122
+ .filter(Boolean)
123
+ .flatMap((paragraph) => {
124
+ if (/\r|\n/u.test(paragraph)) return [];
125
+ const match = paragraph.match(/^(.{1,80}?) is the explicitly selected specialist for this (.{1,120}?)\.$/u);
126
+ if (!match) return [];
127
+ const roleLabel = match[1].trim();
128
+ const scope = match[2].trim();
129
+ if (!roleLabel || !scope || /[\r\n]/u.test(roleLabel)) return [];
130
+ return [Object.freeze({
131
+ state: 'explicit-current-work-selector',
132
+ roleLabel,
133
+ selectorKind: 'explicit-specialist-declaration-paragraph',
134
+ section: 'Objective',
135
+ declaration: paragraph,
136
+ scope,
137
+ sourceArtifact: sourceArtifactFromRecord(taskRecord),
138
+ boundary: 'Closed lexical declaration paragraph only. Core does not interpret surrounding prose: no Role label is searched for, guessed from inventory, inferred from endpoint identity, or recovered from near-match text.'
139
+ })];
140
+ });
141
+ return declarations.length === 1 ? declarations[0] : null;
142
+ }
143
+
144
+ function exactRouteRoleMaterials(authority = {}) {
145
+ const roles = [];
146
+ const recipient = qualifiedRole(authority?.role || null, authority?.handoff?.toReference || '');
147
+ const sender = qualifiedRole(authority?.senderRole || null, authority?.handoff?.fromReference || '');
148
+ if (recipient) roles.push(recipient);
149
+ if (sender) roles.push(sender);
150
+ for (const item of authority?.participation?.packageRoleGrounding || []) {
151
+ const role = qualifiedPackageGroundingRole(item);
152
+ if (role) roles.push(role);
153
+ }
154
+ return Object.freeze(dedupeRoles(roles));
155
+ }
156
+
157
+ function qualifiedPackageGroundingRole(entry = {}) {
158
+ const artifact = entry?.roleArtifact || null;
159
+ if (!entry?.groundingOnly || String(entry?.materialQualification || '') !== 'qualified' || !artifact) return null;
160
+ const sha256 = String(artifact.sha256 || '').trim().toLowerCase();
161
+ if (!/^[0-9a-f]{64}$/iu.test(sha256)) return null;
162
+ const reference = String(artifact.reference || artifact.path || '').trim();
163
+ const label = String(artifact.roleLabel || entry.label || '').trim();
164
+ if (!reference || !label || String(artifact.schemaId || '') !== 'tiinex.party.role.v1') return null;
165
+ return Object.freeze({
166
+ label,
167
+ kind: 'role',
168
+ roleKind: String(artifact.roleKind || ''),
169
+ boundary: Object.freeze({ ...(entry.exactBoundaryLoaded || {}) }),
170
+ authority: Object.freeze({ ...(entry.authorityBoundaryLoaded || {}) }),
171
+ sourceArtifact: sourceArtifactFromReference(reference, sha256, String(artifact.schemaId || 'tiinex.party.role.v1')),
172
+ materialResolution: Object.freeze({ pointerPath: String(entry.pointerPath || ''), groundingOnly: true })
173
+ });
174
+ }
175
+
176
+ function dedupeRoles(roles = []) {
177
+ const map = new Map();
178
+ for (const role of roles) {
179
+ const key = `${normalize(role?.label)}\u0000${String(role?.sourceArtifact?.path || '')}\u0000${String(role?.sourceArtifact?.sha256 || '')}`;
180
+ if (!map.has(key)) map.set(key, role);
181
+ }
182
+ return [...map.values()];
183
+ }
184
+
185
+ function delegateProjection(role, handoff, selected, selector) {
100
186
  const capabilities = [
101
187
  role.roleKind ? Object.freeze({ kind: 'role-kind', value: role.roleKind }) : null,
102
188
  role.boundary.inScope ? Object.freeze({ kind: 'role-in-scope', value: role.boundary.inScope }) : null,
@@ -111,10 +197,18 @@ function delegateProjection(role, handoff, selected) {
111
197
  selection: Object.freeze({ state: 'explicit-forward-selected', forwardSelected: true }),
112
198
  sourceArtifact: role.sourceArtifact,
113
199
  facts: Object.freeze([
114
- Object.freeze({ kind: 'selected-handoff-transfer', handoff: qualifiedHandoffPath(handoff), transferId: String(selected.transfer.id || ''), transferKind: String(selected.transfer.transferKind || ''), controllingArtifact: selected.resolvedPath }),
115
- Object.freeze({ kind: 'exact-recipient-role-authority', role: role.label, roleKind: role.roleKind })
200
+ Object.freeze({ kind: 'current-work-forward-delegate-selector', role: selector.roleLabel, section: selector.section, selectorKind: selector.selectorKind, controllingArtifact: selected.resolvedPath }),
201
+ Object.freeze({ kind: 'exact-forward-selected-role-authority', role: role.label, roleKind: role.roleKind }),
202
+ Object.freeze({ kind: 'selected-handoff-current-work-transfer', handoff: qualifiedHandoffPath(handoff), transferId: String(selected.transfer.id || ''), transferKind: String(selected.transfer.transferKind || ''), controllingArtifact: selected.resolvedPath })
116
203
  ]),
117
- provenance: Object.freeze({ source: role.sourceArtifact.path, basis: 'selected-handoff-transfer-to-exact-recipient-role-and-controlling-task', forwardSelector: Object.freeze({ handoff: qualifiedHandoffPath(handoff), transferId: String(selected.transfer.id || ''), controllingArtifact: selected.resolvedPath }) })
204
+ provenance: Object.freeze({
205
+ source: role.sourceArtifact.path,
206
+ basis: 'exact-controlling-task-explicit-specialist-selector-plus-exact-selected-role-material',
207
+ forwardSelector: selector,
208
+ roleSourceArtifact: role.sourceArtifact,
209
+ materialResolution: role.materialResolution || null,
210
+ currentWorkTransfer: Object.freeze({ handoff: qualifiedHandoffPath(handoff), transferId: String(selected.transfer.id || ''), controllingArtifact: selected.resolvedPath })
211
+ })
118
212
  });
119
213
  }
120
214
 
@@ -422,7 +422,18 @@ function resolvePackageParticipantRoles(bundle = {}, orientation = null, selecte
422
422
  packageDeclared: true,
423
423
  groundingOnly: true,
424
424
  semanticParticipant: false,
425
- roleArtifact: Object.freeze({ path: parsed.path, sha256: parsed.sha256, schemaId: parsed.schemaId, roleLabel: parsed.label, roleKind: parsed.roleKind }),
425
+ materialQualification: 'qualified',
426
+ roleArtifact: Object.freeze({
427
+ path: parsed.path,
428
+ reference: String(facts.referenceTarget || parsed.path || ''),
429
+ sha256: parsed.sha256,
430
+ schemaId: parsed.schemaId,
431
+ roleLabel: parsed.label,
432
+ roleKind: parsed.roleKind
433
+ }),
434
+ exactBoundaryLoaded: parsed.boundary,
435
+ authorityBoundaryLoaded: parsed.authorityBoundary,
436
+ interpretationLimitsLoaded: parsed.interpretationLimits,
426
437
  pointerPath
427
438
  }));
428
439
  }