archgraph-argo-beta 0.27.0-beta.10 → 0.27.0-beta.12
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.
|
@@ -186,7 +186,7 @@ function diagnose(session, opts = {}) {
|
|
|
186
186
|
const byQueryClass = {};
|
|
187
187
|
const sigCount = {};
|
|
188
188
|
const pathReads = {};
|
|
189
|
-
let toolMs = 0; let humanWaitMs = 0; let errors = 0; let empty = 0;
|
|
189
|
+
let toolMs = 0; let humanWaitMs = 0; let errors = 0; let empty = 0; let emptyOrError = 0;
|
|
190
190
|
for (const c of tc) {
|
|
191
191
|
const isHuman = c.queryClass === 'human-wait' || HUMAN_WAIT_TOOLS.some(t => String(c.tool).includes(t));
|
|
192
192
|
const bt = byTool[c.tool] || (byTool[c.tool] = { calls: 0, ms: 0, tokens: 0, errors: 0 });
|
|
@@ -200,6 +200,9 @@ function diagnose(session, opts = {}) {
|
|
|
200
200
|
}
|
|
201
201
|
if (c.ok === false) { bt.errors += 1; errors += 1; }
|
|
202
202
|
if ((c.outputBytes || 0) < 2) empty += 1;
|
|
203
|
+
// A failed call with empty output is ONE unproductive call, not two — count the
|
|
204
|
+
// union so the hint does not overstate "empty/error" (issue #8 口径).
|
|
205
|
+
if (c.ok === false || (c.outputBytes || 0) < 2) emptyOrError += 1;
|
|
203
206
|
byQueryClass[c.queryClass] = (byQueryClass[c.queryClass] || 0) + 1;
|
|
204
207
|
sigCount[c.signature] = (sigCount[c.signature] || 0) + 1;
|
|
205
208
|
if (c.queryClass === 'file-read' && c.path) pathReads[c.path] = (pathReads[c.path] || 0) + 1;
|
|
@@ -245,12 +248,12 @@ function diagnose(session, opts = {}) {
|
|
|
245
248
|
overSearch: {
|
|
246
249
|
duplicateCalls: duplicates,
|
|
247
250
|
repeatedReads,
|
|
248
|
-
emptyOrError
|
|
251
|
+
emptyOrError,
|
|
249
252
|
noProgressStreak: best,
|
|
250
253
|
},
|
|
251
254
|
topOffendersByTime: topByMs,
|
|
252
255
|
topOffendersByTokens: topByTokens,
|
|
253
|
-
hints: buildHints({ toolCalls: tc.length, duplicates: duplicates.length, emptyOrError
|
|
256
|
+
hints: buildHints({ toolCalls: tc.length, duplicates: duplicates.length, emptyOrError, repeatedReads: repeatedReads.length, noProgressStreak: best, modelMs, mcpMs: byBackend.graph.ms, repoToolMs: byBackend.repo.ms, roundTrips: countRoundTrips(tc), blowups: blowups.length, blowupMax: blowups.length ? blowups[0].input : 0 }),
|
|
254
257
|
};
|
|
255
258
|
}
|
|
256
259
|
|
|
@@ -149,12 +149,18 @@ const TOOLS = [
|
|
|
149
149
|
},
|
|
150
150
|
{
|
|
151
151
|
name: 'addArchitectureElement',
|
|
152
|
-
description: 'Use for one element. Creates a new element or adds an existing element to view_ids. view_ids is required so elements never exist outside views.',
|
|
152
|
+
description: 'Use for one element. Creates a new element or adds an existing element to view_ids. view_ids is required so elements never exist outside views. element.id is OPTIONAL: omit it and the server auto-allocates a unique id (returned in the result); provide it to pin a specific id (must not collide with a different element).',
|
|
153
153
|
inputSchema: {
|
|
154
154
|
type: 'object',
|
|
155
155
|
required: ['element', 'view_ids'],
|
|
156
156
|
properties: {
|
|
157
|
-
element: {
|
|
157
|
+
element: {
|
|
158
|
+
type: 'object',
|
|
159
|
+
properties: {
|
|
160
|
+
id: { type: 'string', description: 'Element id (OPTIONAL). Omit to let the server auto-allocate a unique id (a semantic slug from the name, e.g. "graph-wiki-federation-center", suffixed -002.. if taken). If provided it must not collide with a DIFFERENT element (a same (type,name) match is idempotent reuse).' },
|
|
161
|
+
},
|
|
162
|
+
description: 'The element to create/attach. `id` is optional — omit it and the server allocates one (returned in the result).',
|
|
163
|
+
},
|
|
158
164
|
view_ids: { type: 'array', minItems: 1, items: { type: 'string' } },
|
|
159
165
|
onConflict: { type: 'string', enum: ['reuse', 'allowDuplicate'], description: 'Dedup policy (default reuse). reuse: find-or-create — attach an existing exact (type, name) match; a same-type semantic near-duplicate also blocks creation. allowDuplicate: create anyway (even if a duplicate exists), requires a justification.' },
|
|
160
166
|
justification: { type: 'string', description: 'Required when onConflict is allowDuplicate.' },
|
|
@@ -193,7 +199,7 @@ const TOOLS = [
|
|
|
193
199
|
},
|
|
194
200
|
{
|
|
195
201
|
name: 'addArchitectureRelationship',
|
|
196
|
-
description: 'Use for one relationship. Creates a new relationship or adds an existing relationship to view_ids. relationship.type is the ArchiMate 3.2 relationship type and is validated against endpoint element types.',
|
|
202
|
+
description: 'Use for one relationship. Creates a new relationship or adds an existing relationship to view_ids. relationship.type is the ArchiMate 3.2 relationship type and is validated against endpoint element types. relationship.id is OPTIONAL: omit it and the server auto-allocates a unique id (returned in the result).',
|
|
197
203
|
inputSchema: {
|
|
198
204
|
type: 'object',
|
|
199
205
|
required: ['relationship', 'view_ids'],
|
|
@@ -237,7 +243,7 @@ const TOOLS = [
|
|
|
237
243
|
},
|
|
238
244
|
{
|
|
239
245
|
name: 'addArchitectureView',
|
|
240
|
-
description: 'Use for one view. The graph must have exactly one top-level view named SystemArchitecture; all sub-views must attach to an element with parent_element_id.',
|
|
246
|
+
description: 'Use for one view. The graph must have exactly one top-level view named SystemArchitecture; all sub-views must attach to an element with parent_element_id. view.view_id is OPTIONAL: omit it and the server auto-allocates a unique view_id (returned in the result).',
|
|
241
247
|
inputSchema: {
|
|
242
248
|
type: 'object',
|
|
243
249
|
required: ['view'],
|
|
@@ -247,12 +247,18 @@ const TOOLS = [
|
|
|
247
247
|
},
|
|
248
248
|
{
|
|
249
249
|
name: 'addArchitectureElement',
|
|
250
|
-
description: 'Use for one element. Creates a new element or adds an existing element to view_ids. view_ids is required so elements never exist outside views. Set dryRun to preview without writing.',
|
|
250
|
+
description: 'Use for one element. Creates a new element or adds an existing element to view_ids. view_ids is required so elements never exist outside views. element.id is OPTIONAL: omit it and the server auto-allocates a unique id (returned in the result); provide it to pin a specific id (must not collide with a different element). Set dryRun to preview without writing.',
|
|
251
251
|
inputSchema: {
|
|
252
252
|
type: 'object',
|
|
253
253
|
required: ['element', 'view_ids'],
|
|
254
254
|
properties: {
|
|
255
|
-
element: {
|
|
255
|
+
element: {
|
|
256
|
+
type: 'object',
|
|
257
|
+
properties: {
|
|
258
|
+
id: { type: 'string', description: 'Element id (OPTIONAL). Omit to let the server auto-allocate a unique id (a semantic slug from the name, e.g. "graph-wiki-federation-center", suffixed -002.. if taken). If provided it must not collide with a DIFFERENT element (a same (type,name) match is idempotent reuse).' },
|
|
259
|
+
},
|
|
260
|
+
description: 'The element to create/attach. `id` is optional — omit it and the server allocates one (returned in the result).',
|
|
261
|
+
},
|
|
256
262
|
view_ids: { type: 'array', minItems: 1, items: { type: 'string' } },
|
|
257
263
|
onConflict: { type: 'string', enum: ['reuse', 'allowDuplicate'], description: 'Dedup policy (default reuse). reuse: find-or-create — attach an existing exact (type, name) match; a same-type semantic near-duplicate also blocks creation. allowDuplicate: create anyway (even if a duplicate exists), requires a justification.' },
|
|
258
264
|
justification: { type: 'string', description: 'Required when onConflict is allowDuplicate.' },
|
|
@@ -294,7 +300,7 @@ const TOOLS = [
|
|
|
294
300
|
},
|
|
295
301
|
{
|
|
296
302
|
name: 'addArchitectureRelationship',
|
|
297
|
-
description: 'Use for one relationship. Creates a new relationship or adds an existing relationship to view_ids. relationship.type is the ArchiMate 3.2 relationship type and is validated against endpoint element types. Set dryRun to preview without writing.',
|
|
303
|
+
description: 'Use for one relationship. Creates a new relationship or adds an existing relationship to view_ids. relationship.type is the ArchiMate 3.2 relationship type and is validated against endpoint element types. relationship.id is OPTIONAL: omit it and the server auto-allocates a unique id (returned in the result). Set dryRun to preview without writing.',
|
|
298
304
|
inputSchema: {
|
|
299
305
|
type: 'object',
|
|
300
306
|
required: ['relationship', 'view_ids'],
|
|
@@ -341,7 +347,7 @@ const TOOLS = [
|
|
|
341
347
|
},
|
|
342
348
|
{
|
|
343
349
|
name: 'addArchitectureView',
|
|
344
|
-
description: 'Use for one view. The graph must have exactly one top-level view named SystemArchitecture; all sub-views must attach to an element with parent_element_id. Set dryRun to preview without writing.',
|
|
350
|
+
description: 'Use for one view. The graph must have exactly one top-level view named SystemArchitecture; all sub-views must attach to an element with parent_element_id. view.view_id is OPTIONAL: omit it and the server auto-allocates a unique view_id (returned in the result). Set dryRun to preview without writing.',
|
|
345
351
|
inputSchema: {
|
|
346
352
|
type: 'object',
|
|
347
353
|
required: ['view'],
|
|
@@ -1616,11 +1622,30 @@ function applyMutations(document, mutations, options = {}) {
|
|
|
1616
1622
|
if (mutation.type === 'addElement') {
|
|
1617
1623
|
requireObject(mutation.element, 'mutation.element');
|
|
1618
1624
|
const scopedViews = requireViewScope(nextDocument.views, mutation.view_ids, 'mutation.view_ids');
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
let
|
|
1623
|
-
|
|
1625
|
+
const requestedElementId = typeof mutation.element.id === 'string' && mutation.element.id !== ''
|
|
1626
|
+
? mutation.element.id
|
|
1627
|
+
: null;
|
|
1628
|
+
let targetElementId;
|
|
1629
|
+
let elementCreated = false;
|
|
1630
|
+
let elementReused = false;
|
|
1631
|
+
|
|
1632
|
+
const existingById = requestedElementId ? findById(nextDocument.elements, requestedElementId) : undefined;
|
|
1633
|
+
if (existingById) {
|
|
1634
|
+
// An explicit id that already exists: idempotent ONLY if it is the same
|
|
1635
|
+
// (type,name). Otherwise the caller picked a taken id — fail loudly instead
|
|
1636
|
+
// of silently attaching an unrelated element (issue #8 collision safety).
|
|
1637
|
+
const sameIdentity = existingById.type === mutation.element.type
|
|
1638
|
+
&& normalizeDedupName(existingById.name) === normalizeDedupName(mutation.element.name);
|
|
1639
|
+
if (!sameIdentity) {
|
|
1640
|
+
throw new Error(
|
|
1641
|
+
`addElement id '${requestedElementId}' is already used by a different element `
|
|
1642
|
+
+ `(type '${existingById.type}', name '${existingById.name}'). Choose another id (or omit id to auto-allocate one), `
|
|
1643
|
+
+ `attach the existing element by using its id, or update it with updateArchitectureElement.`,
|
|
1644
|
+
);
|
|
1645
|
+
}
|
|
1646
|
+
targetElementId = requestedElementId;
|
|
1647
|
+
elementReused = true;
|
|
1648
|
+
} else {
|
|
1624
1649
|
const candidates = findDuplicateElements(nextDocument.elements, mutation.element);
|
|
1625
1650
|
const resolution = resolveDuplicateConflict({
|
|
1626
1651
|
onConflict: mutation.onConflict,
|
|
@@ -1629,12 +1654,19 @@ function applyMutations(document, mutations, options = {}) {
|
|
|
1629
1654
|
}, candidates);
|
|
1630
1655
|
if (resolution.action === 'reuse') {
|
|
1631
1656
|
targetElementId = resolution.existing.id;
|
|
1632
|
-
|
|
1657
|
+
elementReused = true;
|
|
1633
1658
|
} else {
|
|
1634
|
-
|
|
1635
|
-
|
|
1659
|
+
targetElementId = requestedElementId || allocateUniqueId(
|
|
1660
|
+
nextDocument.elements.map(entry => entry.id),
|
|
1661
|
+
mutation.element.name,
|
|
1662
|
+
slugifyId(mutation.element.type) || 'element',
|
|
1663
|
+
);
|
|
1664
|
+
nextDocument.elements.push({ ...clone(mutation.element), id: targetElementId });
|
|
1665
|
+
syncViewsToElementSubdiagramViews(nextDocument, findById(nextDocument.elements, targetElementId));
|
|
1666
|
+
elementCreated = true;
|
|
1636
1667
|
}
|
|
1637
1668
|
}
|
|
1669
|
+
|
|
1638
1670
|
for (const view of scopedViews) {
|
|
1639
1671
|
view.included_elements = addUnique(view.included_elements || [], [targetElementId]);
|
|
1640
1672
|
touchedViewIds.add(view.view_id);
|
|
@@ -1645,8 +1677,10 @@ function applyMutations(document, mutations, options = {}) {
|
|
|
1645
1677
|
type: mutation.type,
|
|
1646
1678
|
id: targetElementId,
|
|
1647
1679
|
view_ids: mutation.view_ids,
|
|
1648
|
-
created:
|
|
1649
|
-
...(
|
|
1680
|
+
created: elementCreated,
|
|
1681
|
+
...(elementReused ? { reused: true, reusedId: targetElementId } : {}),
|
|
1682
|
+
...(requestedElementId === null && elementCreated ? { allocatedId: targetElementId } : {}),
|
|
1683
|
+
...(elementReused && requestedElementId && requestedElementId !== targetElementId ? { requestedId: requestedElementId } : {}),
|
|
1650
1684
|
});
|
|
1651
1685
|
continue;
|
|
1652
1686
|
}
|
|
@@ -1745,13 +1779,35 @@ function applyMutations(document, mutations, options = {}) {
|
|
|
1745
1779
|
if (mutation.type === 'addRelationship') {
|
|
1746
1780
|
requireObject(mutation.relationship, 'mutation.relationship');
|
|
1747
1781
|
const scopedViews = requireViewScope(nextDocument.views, mutation.view_ids, 'mutation.view_ids');
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1782
|
+
const requestedRelationshipId = typeof mutation.relationship.id === 'string' && mutation.relationship.id !== ''
|
|
1783
|
+
? mutation.relationship.id
|
|
1784
|
+
: null;
|
|
1785
|
+
let targetRelationshipId;
|
|
1751
1786
|
let sourceElementId = mutation.relationship.source_id;
|
|
1752
1787
|
let targetEndpointId = mutation.relationship.target_id;
|
|
1753
|
-
let
|
|
1754
|
-
|
|
1788
|
+
let relationshipCreated = false;
|
|
1789
|
+
let relationshipReused = false;
|
|
1790
|
+
|
|
1791
|
+
const existingById = requestedRelationshipId ? findById(nextDocument.relationships, requestedRelationshipId) : undefined;
|
|
1792
|
+
if (existingById) {
|
|
1793
|
+
// Explicit id that already exists: idempotent only for the same natural key;
|
|
1794
|
+
// otherwise fail loudly instead of silently attaching an unrelated edge.
|
|
1795
|
+
const sameIdentity = existingById.source_id === mutation.relationship.source_id
|
|
1796
|
+
&& existingById.type === mutation.relationship.type
|
|
1797
|
+
&& existingById.target_id === mutation.relationship.target_id
|
|
1798
|
+
&& normalizeDedupName(existingById.name) === normalizeDedupName(mutation.relationship.name);
|
|
1799
|
+
if (!sameIdentity) {
|
|
1800
|
+
throw new Error(
|
|
1801
|
+
`addRelationship id '${requestedRelationshipId}' is already used by a different relationship `
|
|
1802
|
+
+ `(source '${existingById.source_id}', type '${existingById.type}', target '${existingById.target_id}'). `
|
|
1803
|
+
+ 'Choose another id (or omit id to auto-allocate one), or update it with updateArchitectureRelationship.',
|
|
1804
|
+
);
|
|
1805
|
+
}
|
|
1806
|
+
targetRelationshipId = requestedRelationshipId;
|
|
1807
|
+
sourceElementId = existingById.source_id;
|
|
1808
|
+
targetEndpointId = existingById.target_id;
|
|
1809
|
+
relationshipReused = true;
|
|
1810
|
+
} else {
|
|
1755
1811
|
const candidates = findDuplicateRelationships(nextDocument.relationships, mutation.relationship);
|
|
1756
1812
|
const resolution = resolveDuplicateConflict({
|
|
1757
1813
|
onConflict: mutation.onConflict,
|
|
@@ -1762,9 +1818,15 @@ function applyMutations(document, mutations, options = {}) {
|
|
|
1762
1818
|
targetRelationshipId = resolution.existing.id;
|
|
1763
1819
|
sourceElementId = resolution.existing.source_id;
|
|
1764
1820
|
targetEndpointId = resolution.existing.target_id;
|
|
1765
|
-
|
|
1821
|
+
relationshipReused = true;
|
|
1766
1822
|
} else {
|
|
1767
|
-
|
|
1823
|
+
targetRelationshipId = requestedRelationshipId || allocateUniqueId(
|
|
1824
|
+
nextDocument.relationships.map(entry => entry.id),
|
|
1825
|
+
mutation.relationship.name || `${mutation.relationship.source_id}-${mutation.relationship.type}-${mutation.relationship.target_id}`,
|
|
1826
|
+
'relationship',
|
|
1827
|
+
);
|
|
1828
|
+
nextDocument.relationships.push({ ...clone(mutation.relationship), id: targetRelationshipId });
|
|
1829
|
+
relationshipCreated = true;
|
|
1768
1830
|
}
|
|
1769
1831
|
}
|
|
1770
1832
|
for (const view of scopedViews) {
|
|
@@ -1780,8 +1842,9 @@ function applyMutations(document, mutations, options = {}) {
|
|
|
1780
1842
|
type: mutation.type,
|
|
1781
1843
|
id: targetRelationshipId,
|
|
1782
1844
|
view_ids: mutation.view_ids,
|
|
1783
|
-
created:
|
|
1784
|
-
...(
|
|
1845
|
+
created: relationshipCreated,
|
|
1846
|
+
...(relationshipReused ? { reused: true, reusedId: targetRelationshipId } : {}),
|
|
1847
|
+
...(requestedRelationshipId === null && relationshipCreated ? { allocatedId: targetRelationshipId } : {}),
|
|
1785
1848
|
});
|
|
1786
1849
|
continue;
|
|
1787
1850
|
}
|
|
@@ -1865,38 +1928,65 @@ function applyMutations(document, mutations, options = {}) {
|
|
|
1865
1928
|
|
|
1866
1929
|
if (mutation.type === 'addView') {
|
|
1867
1930
|
requireObject(mutation.view, 'mutation.view');
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
const newView = clone(mutation.view);
|
|
1888
|
-
if (Array.isArray(newView.included_elements)) {
|
|
1889
|
-
newView.included_elements = addUnique([], newView.included_elements);
|
|
1931
|
+
const requestedViewId = typeof mutation.view.view_id === 'string' && mutation.view.view_id !== ''
|
|
1932
|
+
? mutation.view.view_id
|
|
1933
|
+
: null;
|
|
1934
|
+
let targetViewId;
|
|
1935
|
+
let viewCreated = false;
|
|
1936
|
+
let viewReused = false;
|
|
1937
|
+
|
|
1938
|
+
const existingById = requestedViewId ? findView(nextDocument.views, requestedViewId) : undefined;
|
|
1939
|
+
if (existingById) {
|
|
1940
|
+
// Explicit view_id that already exists: idempotent only for the same
|
|
1941
|
+
// (parent,name); otherwise fail loudly.
|
|
1942
|
+
const sameIdentity = (existingById.parent_element_id || '') === (mutation.view.parent_element_id || '')
|
|
1943
|
+
&& normalizeDedupName(existingById.view_name) === normalizeDedupName(mutation.view.view_name);
|
|
1944
|
+
if (!sameIdentity) {
|
|
1945
|
+
throw new Error(
|
|
1946
|
+
`addView view_id '${requestedViewId}' is already used by a different view `
|
|
1947
|
+
+ `(name '${existingById.view_name}', parent '${existingById.parent_element_id || ''}'). `
|
|
1948
|
+
+ 'Choose another view_id (or omit it to auto-allocate one), or update it with updateArchitectureView.',
|
|
1949
|
+
);
|
|
1890
1950
|
}
|
|
1891
|
-
|
|
1892
|
-
|
|
1951
|
+
targetViewId = requestedViewId;
|
|
1952
|
+
viewReused = true;
|
|
1953
|
+
} else {
|
|
1954
|
+
const candidates = findDuplicateViews(nextDocument.views, mutation.view);
|
|
1955
|
+
const resolution = resolveDuplicateConflict({
|
|
1956
|
+
onConflict: mutation.onConflict,
|
|
1957
|
+
justification: mutation.justification,
|
|
1958
|
+
label: `view (name '${mutation.view.view_name}')`,
|
|
1959
|
+
}, candidates);
|
|
1960
|
+
if (resolution.action === 'reuse') {
|
|
1961
|
+
targetViewId = resolution.existing.view_id;
|
|
1962
|
+
viewReused = true;
|
|
1963
|
+
} else {
|
|
1964
|
+
targetViewId = requestedViewId || allocateUniqueId(
|
|
1965
|
+
nextDocument.views.map(entry => entry.view_id),
|
|
1966
|
+
mutation.view.view_name,
|
|
1967
|
+
'view',
|
|
1968
|
+
);
|
|
1969
|
+
const newView = { ...clone(mutation.view), view_id: targetViewId };
|
|
1970
|
+
if (Array.isArray(newView.included_elements)) {
|
|
1971
|
+
newView.included_elements = addUnique([], newView.included_elements);
|
|
1972
|
+
}
|
|
1973
|
+
if (Array.isArray(newView.included_relationships)) {
|
|
1974
|
+
newView.included_relationships = addUnique([], newView.included_relationships);
|
|
1975
|
+
}
|
|
1976
|
+
nextDocument.views.push(newView);
|
|
1977
|
+
upsertSubdiagramViewIntoElement(nextDocument, newView.parent_element_id, newView);
|
|
1978
|
+
touchedViewIds.add(newView.view_id);
|
|
1979
|
+
viewLimitCheckIds.add(newView.view_id);
|
|
1980
|
+
viewCreated = true;
|
|
1893
1981
|
}
|
|
1894
|
-
nextDocument.views.push(newView);
|
|
1895
|
-
upsertSubdiagramViewIntoElement(nextDocument, newView.parent_element_id, newView);
|
|
1896
|
-
touchedViewIds.add(newView.view_id);
|
|
1897
|
-
viewLimitCheckIds.add(newView.view_id);
|
|
1898
|
-
mutationSummaries.push({ type: mutation.type, id: newView.view_id });
|
|
1899
1982
|
}
|
|
1983
|
+
mutationSummaries.push({
|
|
1984
|
+
type: mutation.type,
|
|
1985
|
+
id: targetViewId,
|
|
1986
|
+
created: viewCreated,
|
|
1987
|
+
...(viewReused ? { reused: true, reusedId: targetViewId } : {}),
|
|
1988
|
+
...(requestedViewId === null && viewCreated ? { allocatedId: targetViewId } : {}),
|
|
1989
|
+
});
|
|
1900
1990
|
continue;
|
|
1901
1991
|
}
|
|
1902
1992
|
|
|
@@ -1968,6 +2058,33 @@ function requireObject(value, label) {
|
|
|
1968
2058
|
}
|
|
1969
2059
|
}
|
|
1970
2060
|
|
|
2061
|
+
function slugifyId(seed) {
|
|
2062
|
+
return String(seed == null ? '' : seed)
|
|
2063
|
+
.toLowerCase()
|
|
2064
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
2065
|
+
.replace(/-{2,}/g, '-')
|
|
2066
|
+
.replace(/^-+|-+$/g, '');
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
// One unified id strategy for the whole framework (issue #8): a semantic slug
|
|
2070
|
+
// derived from the entity's human name, made unique within its collection by a
|
|
2071
|
+
// numeric suffix. Callers MAY omit an id; the server allocates one. There is no
|
|
2072
|
+
// per-repository id strategy — ArchGraph has a single one.
|
|
2073
|
+
function allocateUniqueId(existingIds, seed, fallbackBase) {
|
|
2074
|
+
const taken = new Set((Array.isArray(existingIds) ? existingIds : []).map(String));
|
|
2075
|
+
const base = slugifyId(seed) || fallbackBase || 'item';
|
|
2076
|
+
if (!taken.has(base)) {
|
|
2077
|
+
return base;
|
|
2078
|
+
}
|
|
2079
|
+
for (let n = 2; n < 100000; n += 1) {
|
|
2080
|
+
const candidate = `${base}-${String(n).padStart(3, '0')}`;
|
|
2081
|
+
if (!taken.has(candidate)) {
|
|
2082
|
+
return candidate;
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
return `${base}-${Date.now()}`;
|
|
2086
|
+
}
|
|
2087
|
+
|
|
1971
2088
|
function requireId(value, label) {
|
|
1972
2089
|
if (typeof value !== 'string' || value.length === 0) {
|
|
1973
2090
|
throw new Error(`${label} must be a non-empty string`);
|
|
@@ -2862,6 +2979,18 @@ function compactMutationResponse(payload) {
|
|
|
2862
2979
|
status: payload && payload.status,
|
|
2863
2980
|
written: Boolean(payload && payload.written),
|
|
2864
2981
|
};
|
|
2982
|
+
// A successful write must tell the caller which id was used/allocated and whether
|
|
2983
|
+
// it created or reused — otherwise an omitted (auto-allocated) id is invisible
|
|
2984
|
+
// and an id collision would look like a create. Kept to a few fields (issue #8).
|
|
2985
|
+
if (Array.isArray(payload && payload.mutations) && payload.mutations.length > 0) {
|
|
2986
|
+
compact.mutations = payload.mutations.map((entry) => ({
|
|
2987
|
+
type: entry.type,
|
|
2988
|
+
id: entry.id,
|
|
2989
|
+
created: entry.created,
|
|
2990
|
+
...(entry.reused ? { reused: true, reusedId: entry.reusedId } : {}),
|
|
2991
|
+
...(entry.allocatedId ? { allocatedId: entry.allocatedId } : {}),
|
|
2992
|
+
}));
|
|
2993
|
+
}
|
|
2865
2994
|
if (payload && payload.embeddingLifecycle && payload.embeddingLifecycle.state) {
|
|
2866
2995
|
compact.embeddingLifecycle = { state: payload.embeddingLifecycle.state };
|
|
2867
2996
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "archgraph-argo-beta",
|
|
3
|
-
"version": "0.27.0-beta.
|
|
3
|
+
"version": "0.27.0-beta.12",
|
|
4
4
|
"description": "Deploy the ArchGraph ARGO toolchain, skills, and rules (schema, scripts, argo-init skill, global rule) with one command.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|