archgraph-argo-beta 0.27.0-beta.10 → 0.27.0-beta.11

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: errors + empty,
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: errors + empty, 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 }),
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,19 @@ 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 REQUIRED: a non-empty, caller-assigned, stable string — there is no auto-id (reuse an existing id, or allocate the next one from the graph).',
153
153
  inputSchema: {
154
154
  type: 'object',
155
155
  required: ['element', 'view_ids'],
156
156
  properties: {
157
- element: { type: 'object' },
157
+ element: {
158
+ type: 'object',
159
+ required: ['id'],
160
+ properties: {
161
+ id: { type: 'string', minLength: 1, description: 'Element id (non-empty, caller-assigned, stable). REQUIRED — the graph is written by id and there is NO auto-id: reuse an existing id (onConflict:"reuse" with the same (type,name)) or allocate the next one (e.g. MATCH (e:Element {graphKey:$graphKey}) RETURN max(toInteger(e.id))).' },
162
+ },
163
+ description: 'The element to create/attach. MUST include a non-empty `id`.',
164
+ },
158
165
  view_ids: { type: 'array', minItems: 1, items: { type: 'string' } },
159
166
  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
167
  justification: { type: 'string', description: 'Required when onConflict is allowDuplicate.' },
@@ -247,12 +247,19 @@ 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 REQUIRED: a non-empty, caller-assigned, stable string — there is no auto-id (reuse an existing id, or allocate the next one from the graph). Set dryRun to preview without writing.',
251
251
  inputSchema: {
252
252
  type: 'object',
253
253
  required: ['element', 'view_ids'],
254
254
  properties: {
255
- element: { type: 'object' },
255
+ element: {
256
+ type: 'object',
257
+ required: ['id'],
258
+ properties: {
259
+ id: { type: 'string', minLength: 1, description: 'Element id (non-empty, caller-assigned, stable). REQUIRED — the graph is written by id and there is NO auto-id: reuse an existing id (onConflict:"reuse" with the same (type,name)) or allocate the next one (e.g. MATCH (e:Element {graphKey:$graphKey}) RETURN max(toInteger(e.id))).' },
260
+ },
261
+ description: 'The element to create/attach. MUST include a non-empty `id`.',
262
+ },
256
263
  view_ids: { type: 'array', minItems: 1, items: { type: 'string' } },
257
264
  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
265
  justification: { type: 'string', description: 'Required when onConflict is allowDuplicate.' },
@@ -1616,7 +1623,15 @@ function applyMutations(document, mutations, options = {}) {
1616
1623
  if (mutation.type === 'addElement') {
1617
1624
  requireObject(mutation.element, 'mutation.element');
1618
1625
  const scopedViews = requireViewScope(nextDocument.views, mutation.view_ids, 'mutation.view_ids');
1619
- requireId(mutation.element.id, 'mutation.element.id');
1626
+ if (typeof mutation.element.id !== 'string' || mutation.element.id === '') {
1627
+ // Actionable: the caller must supply a stable id (issue #8). Not a generic
1628
+ // requireId message — say what is missing and how to get one.
1629
+ throw new Error(
1630
+ "addElement requires element.id: a non-empty, caller-assigned, stable string. There is no auto-id — set `id` explicitly: " +
1631
+ "reuse an existing element's id with onConflict:'reuse' (matched by the same (type,name)), or allocate the next id " +
1632
+ '(e.g. MATCH (e:Element {graphKey:$graphKey}) RETURN max(toInteger(e.id))).',
1633
+ );
1634
+ }
1620
1635
  const existingElement = findById(nextDocument.elements, mutation.element.id);
1621
1636
  let targetElementId = mutation.element.id;
1622
1637
  let reusedElement = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archgraph-argo-beta",
3
- "version": "0.27.0-beta.10",
3
+ "version": "0.27.0-beta.11",
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": {