@sigloch/graph-view-edit 0.12.0 → 0.14.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/dist/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>graph-view-edit</title>
7
- <script type="module" crossorigin src="/assets/index-pGjKUwK5.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-B6MGO4N_.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-Cf27gkg2.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigloch/graph-view-edit",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "React/Vite viewer+editor over @sigloch/graphcode — 12 graph-views + 16 doc-views via a declarative View-Registry, plus an SE-Dashboard sibling route. Reads docs/graph/<member>.graph.json client-side (no 2nd Kuzu handle).",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,7 +22,7 @@
22
22
  "comment:deps": "Runtime = what vite.config.js + bin/gve.mjs load at Node level when serving the prebuilt dist/. The UI libs (react, react-dom, elkjs, @tanstack/react-table, zustand) are bundled INTO dist/ by vite and must stay devDependencies — shipping them would make consumers download the whole UI stack twice.",
23
23
  "dependencies": {
24
24
  "@sigloch/contracts": ">=10.2 <11",
25
- "@sigloch/graph-api-core": ">=5.4 <6",
25
+ "@sigloch/graph-api-core": ">=5.10.1 <6",
26
26
  "@sigloch/graphcode-client": ">=1.3 <2",
27
27
  "@sigloch/se-engine": ">=1.4 <2",
28
28
  "@vitejs/plugin-react": "^4.3.4",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@playwright/test": "^1.58.2",
34
- "@sigloch/graphcode": ">=0.20 <1",
34
+ "@sigloch/graphcode": ">=0.25 <1",
35
35
  "@tanstack/react-table": "^8.20.5",
36
36
  "@testing-library/react": "^16.0.1",
37
37
  "elkjs": "^0.11.1",
package/vite.config.js CHANGED
@@ -5,7 +5,7 @@ import { createRequire } from 'node:module';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { defineConfig } from 'vite';
7
7
  import react from '@vitejs/plugin-react';
8
- import { DefaultRuleEngine, SE_DESCRIPTOR, fromOntologyGraph } from '@sigloch/graph-api-core';
8
+ import { DefaultRuleEngine, SE_DESCRIPTOR, fromOntologyGraph, commandsToFormatE } from '@sigloch/graph-api-core';
9
9
  // CR-GVE-262: `moduleMetrics` ist DIESELBE Funktion, auf die graphcodes
10
10
  // graph_metrics ein dünnes Binding ist ("KEINE Rechnung hier", tools/metrics.ts)
11
11
  // — die Kohäsions-Karte rechnet also nichts selbst, sie ruft die eine Referenz.
@@ -20,6 +20,7 @@ import {
20
20
  moduleMetrics,
21
21
  MetricPolicySchema,
22
22
  DEFAULT_METRIC_POLICY,
23
+ RULE_TO_DIMENSION,
23
24
  } from '@sigloch/contracts/se';
24
25
  // CR-GC-265: these eight come from the read-side client, not the substrate.
25
26
  // They are pure projection plus a node:net socket call — depending on
@@ -1052,6 +1053,11 @@ export function nextMovePayload(nextStep, suggest) {
1052
1053
  elementId: top.elementId,
1053
1054
  message: top.message,
1054
1055
  score: top.score,
1056
+ // CR-GVE-297: die Dimension des Zuges, aus DERSELBEN Abbildung, aus der auch
1057
+ // `dimension_readiness` und der Hygiene-Kanal ihre Themen nehmen
1058
+ // (RULE_TO_DIMENSION in @sigloch/contracts). Keine zweite Zuordnung im Viewer:
1059
+ // sonst koennte derselbe Zug hier unter einem anderen Thema stehen als dort.
1060
+ dimension: RULE_TO_DIMENSION[top.ruleId] ?? null,
1055
1061
  applicable: top.applicable === true,
1056
1062
  // Der konkrete Zug, nicht nur der Fund. `retire` gesetzt heißt Umhängen:
1057
1063
  // anwenden als EIN graph_mutate-Batch (CR-GC-435), `codeImpact` benennt
@@ -1352,8 +1358,14 @@ function dashboardApiPlugin() {
1352
1358
  */
1353
1359
  export async function handleMutateRequest(body, { repoRoot = process.cwd(), callHostImpl = callHost } = {}) {
1354
1360
  const socketPath = join(repoRoot, '.graphcode', HOST_SOCK_BASENAME);
1355
- const result = await callHostImpl(socketPath, 'graph_mutate', body);
1356
- if (result.success && result.mutations > 0) {
1361
+ const { commands, ...rest } = body ?? {};
1362
+ // ITEM-2026-604: graph_mutate nimmt nur Format-E. Die Edit-Oberflaeche baut MutateCommands —
1363
+ // HIER, an der einen Stelle vor dem Gate, werden sie Text (`commandsToFormatE`, graph-api-core).
1364
+ const payload = commands ? { ...rest, formatE: await alsFormatE(commands, socketPath, callHostImpl) } : body;
1365
+ const result = await callHostImpl(socketPath, 'graph_mutate', payload);
1366
+ // Ein Probelauf schreibt nichts — ein erzwungener Export danach waere ungefragt (Smoke 2026-09-27:
1367
+ // der dryRun meldete mutations 34 und loeste graph_export force:true aus).
1368
+ if (result.success && result.mutations > 0 && body?.dryRun !== true) {
1357
1369
  try {
1358
1370
  await callHostImpl(socketPath, 'graph_export', { force: true });
1359
1371
  } catch (err) {
@@ -1364,23 +1376,64 @@ export async function handleMutateRequest(body, { repoRoot = process.cwd(), call
1364
1376
  }
1365
1377
 
1366
1378
  /**
1367
- * POST /api/realize (CR-GVE-135 / REQ-real-bind) — same host.sock transport
1368
- * and post-write export rationale as handleMutateRequest, but for the
1369
- * graph_realize tool: binds FUNC↔codeRef (R-20) and optionally TEST↔testRef
1370
- * (R-19) through the same Apply-Gate (graph_realize composes
1371
- * harness.mutate, no parallel write path).
1379
+ * MutateCommands → Format-E. Den Typabschnitt eines Knotens, den der Batch nicht anlegt (update-node
1380
+ * ohne `type`, delete-node), kennt nur der Bestand — der Host liefert ihn (`graph_get_node`).
1381
+ */
1382
+ export async function alsFormatE(commands, socketPath, callHostImpl) {
1383
+ const offen = [...new Set(commands.flatMap((c) =>
1384
+ c.op === 'delete-node' ? [c.uid] : c.op === 'update-node' && !c.node.type ? [c.node.uid] : []))];
1385
+ const typen = new Map();
1386
+ for (const uid of offen) {
1387
+ const read = await callHostImpl(socketPath, 'graph_get_node', { uid });
1388
+ if (read?.node?.type) typen.set(uid, read.node.type);
1389
+ }
1390
+ return commandsToFormatE(commands, (uid) => typen.get(uid));
1391
+ }
1392
+
1393
+ /**
1394
+ * POST /api/realize (CR-GVE-135 / REQ-real-bind) — binds FUNC↔realRef (R-20)
1395
+ * and optionally TEST↔testRefs (R-19). Since CR-GVE-299 this is a Format-E
1396
+ * batch through graph_mutate (`~ FUNC-x` + `@realRef {…}`), sent via
1397
+ * handleMutateRequest — the same gate and the same post-write export as every
1398
+ * edit; graph_realize is gone from the graphcode surface (CR-GC-685).
1399
+ *
1400
+ * `@testRefs` is a PATCH of the whole list, so the endpoint reads the TEST's
1401
+ * current testRefs first and sends existing + new (1:n since CR-SM-231 — a
1402
+ * unit and a visual run must not overwrite each other). The same file+case
1403
+ * bound again replaces its entry; a non-array value is replaced, not extended.
1404
+ * The graphVersion of that read is the OCC baseVersion unless the caller
1405
+ * supplied one.
1372
1406
  */
1373
1407
  export async function handleRealizeRequest(body, { repoRoot = process.cwd(), callHostImpl = callHost } = {}) {
1408
+ const { funcUid, file, symbol, lang, testUid, testFile, testCase, tool, consumerId, baseVersion } = body ?? {};
1409
+ if (!funcUid || !file || !symbol) {
1410
+ return { success: false, error: 'realize: funcUid, file and symbol are required.' };
1411
+ }
1412
+ if (testUid && !testFile) {
1413
+ return { success: false, error: 'realize: testFile is required when testUid is given.' };
1414
+ }
1374
1415
  const socketPath = join(repoRoot, '.graphcode', HOST_SOCK_BASENAME);
1375
- const result = await callHostImpl(socketPath, 'graph_realize', body);
1376
- if (result.success !== false) {
1377
- try {
1378
- await callHostImpl(socketPath, 'graph_export', { force: true });
1379
- } catch (err) {
1380
- return { ...result, exportWarning: `graph_export failed after a successful realize: ${err.message}` };
1381
- }
1416
+ const read = await callHostImpl(socketPath, 'graph_get_node', { uid: funcUid });
1417
+ if (!read.node) return { success: false, error: `realize: unknown funcUid '${funcUid}'.` };
1418
+ const patches = [{ op: 'update-node', node: { uid: read.node.uid, type: read.node.type, attributes: { realRef: { file, symbol, ...(lang ? { lang } : {}) } } } }];
1419
+
1420
+ if (testUid) {
1421
+ const testRead = await callHostImpl(socketPath, 'graph_get_node', { uid: testUid });
1422
+ if (!testRead.node) return { success: false, error: `realize: unknown testUid '${testUid}'.` };
1423
+ const current = testRead.node.attributes?.testRefs;
1424
+ const kept = Array.isArray(current) ? current.filter((r) => r.file !== testFile || r.case !== testCase) : [];
1425
+ const added = { file: testFile, tool: tool ?? 'vitest', ...(testCase ? { case: testCase } : {}) };
1426
+ patches.push({ op: 'update-node', node: { uid: testRead.node.uid, type: testRead.node.type, attributes: { testRefs: [...kept, added] } } });
1382
1427
  }
1383
- return result;
1428
+
1429
+ return handleMutateRequest(
1430
+ {
1431
+ formatE: commandsToFormatE(patches),
1432
+ baseVersion: baseVersion ?? read.graphVersion,
1433
+ ...(consumerId !== undefined ? { consumerId } : {}),
1434
+ },
1435
+ { repoRoot, callHostImpl },
1436
+ );
1384
1437
  }
1385
1438
 
1386
1439
  /**
@@ -1415,7 +1468,7 @@ function mutateApiPlugin() {
1415
1468
  res.end(JSON.stringify(result));
1416
1469
  } catch (err) {
1417
1470
  // A dead/absent socket is a 503 "start a session"; a tool-level
1418
- // rejection (e.g. graph_realize: unknown funcUid) is the tool's own
1471
+ // rejection (e.g. a Format-E decode error) is the tool's own
1419
1472
  // message, not a host problem (CR-GVE-135).
1420
1473
  const hostDown = /ENOENT|ECONNREFUSED|ECONNRESET|EPIPE|socket/i.test(err.message);
1421
1474
  res.statusCode = hostDown ? 503 : 422;