@codyn06/cboard 0.3.4 → 0.3.5

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/README.md CHANGED
@@ -61,7 +61,7 @@ Runtime: web-tree-sitter **0.27.1** (MIT), with @vscode/tree-sitter-wasm **0.3.1
61
61
 
62
62
  Repository, modules/directories, files, symbols, manifest configs and dependencies carry repository/commit/path/line provenance. Symbol bodies contain bounded source excerpts, with explicit truncation metadata; no semantic/model summaries are generated. Relative file imports are extracted. Same-file lexical calls, type references and implements relationships are deterministic name heuristics labelled `inferred`; unresolved calls, package aliases, CommonJS and dynamic imports are omitted.
63
63
 
64
- Stable repository-scoped keys reconcile against server state. A same-commit rerun creates no revisions. New commits update source metadata; absent nodes and owned relationships are superseded, never deleted. Overload implementations are traversed. Node and edge pagination must complete before reconciliation. Every batch fits the 50-item/200KB budget (batches are cut at 50 items or 180KB, leaving room for the defaults the server's schema adds) and is atomic; a batch that fails with a server error or statement timeout is retried once as two half-size batches, after the server confirms it never recorded the original; successful earlier batches remain if a later batch conflicts. A rerun resumes reconciliation without trusting local receipt state. Reads use the `/v1/graph` HTTP routes; batches are submitted through the `/mcp` `submit_contribution` tool as base64 (`contribution_b64`), because the CDN firewall in front of the hosted service blocks some code-sync payloads (source excerpts that look like attacks). A server without `contribution_b64` support rejects these calls, so release the server before syncing with a newer client.
64
+ Stable repository-scoped keys reconcile against server state. A same-commit rerun creates no revisions. New commits update source metadata; absent nodes and owned relationships are superseded, never deleted. Overload implementations are traversed. Node and edge pagination must complete before reconciliation. Node batches are capped at 50 items and relationship batches at 200. Both are cut at 180 KB to leave room for server defaults and are atomic; a batch that fails with a server error or statement timeout is retried once as two half-size batches, after the server confirms it never recorded the original; successful earlier batches remain if a later batch conflicts. A rerun resumes reconciliation without trusting local receipt state. Reads use the `/v1/graph` HTTP routes; batches are submitted through the `/mcp` `submit_contribution` tool as base64 (`contribution_b64`), because the CDN firewall in front of the hosted service blocks some code-sync payloads (source excerpts that look like attacks). A server without `contribution_b64` support rejects these calls, so release the server before syncing with a newer client.
65
65
 
66
66
  The local marker in Git metadata (`--state PATH` overrides) records the last successful snapshot without storing a token. The server remains authoritative. Scripts/migrate-cboard.ts reuses the reviewed pure Phase A parser, reading committed documentation blobs and translating acceptance rows and scoped amendments to the approved vocabulary. It never imports prototype application/server code or writes a store directly.
67
67
 
package/dist/api.d.ts CHANGED
@@ -55,12 +55,8 @@ export declare class ContextApi {
55
55
  */
56
56
  edgeHeads(namespace: string, fresh?: boolean): Promise<Result["edges"]>;
57
57
  }
58
- /**
59
- * Each contribution is one SERIALIZABLE transaction with pairwise similarity() queries, so cost
60
- * grows roughly quadratically with batch size; 50 stays under the 5 s statement timeout (#43).
61
- */
62
58
  export declare const BATCH_ITEMS = 50;
63
- export declare function chunks<T>(items: T[], make: (items: T[]) => Contribution): T[][];
59
+ export declare function chunks<T>(items: T[], make: (items: T[]) => Contribution, maxItems?: number): T[][];
64
60
  /**
65
61
  * Submits one batch. On a server error or statement timeout the batch is retried once as two
66
62
  * halves, but only after the server confirms it never recorded the original contribution. A
package/dist/api.js CHANGED
@@ -213,25 +213,17 @@ export class ContextApi {
213
213
  return read.rows;
214
214
  }
215
215
  }
216
- /**
217
- * Batch sizing: the server accepts 200 items and 200,000 bytes per contribution. The item cap
218
- * stays at 50 (below) because server cost per contribution is roughly quadratic in items; raising
219
- * it risks the statement timeout for little gain. Write requests scale as nodes/50, reads as pages.
220
- * The server allows 200,000 bytes, measured after the MCP tool schema fills defaults (aliases,
221
- * namespace, properties…). Batches leave 20,000 bytes for those.
222
- */
216
+ // Leave room for defaults filled by the server before it checks the 200,000-byte limit.
223
217
  const BATCH_BYTES = 180_000;
224
- /**
225
- * Each contribution is one SERIALIZABLE transaction with pairwise similarity() queries, so cost
226
- * grows roughly quadratically with batch size; 50 stays under the 5 s statement timeout (#43).
227
- */
218
+ // Node writes run pairwise similarity checks (#43); relationship-only writes skip those checks.
228
219
  export const BATCH_ITEMS = 50;
229
- export function chunks(items, make) {
220
+ const EDGE_BATCH_ITEMS = 200;
221
+ export function chunks(items, make, maxItems = BATCH_ITEMS) {
230
222
  const result = [];
231
223
  let current = [];
232
224
  for (const item of items) {
233
225
  const candidate = [...current, item];
234
- if (candidate.length > BATCH_ITEMS ||
226
+ if (candidate.length > maxItems ||
235
227
  Buffer.byteLength(JSON.stringify(make(candidate))) > BATCH_BYTES) {
236
228
  if (!current.length)
237
229
  throw new Error("Single contribution item exceeds 200KB");
@@ -309,8 +301,9 @@ const edgeKey = (e) => stable([
309
301
  e.properties.contextNamespace ?? null,
310
302
  e.type === "amends" ? (e.properties.scope ?? null) : null,
311
303
  ]);
312
- /** Up to this many absent keys are looked up one by one; more use the project-wide types scan. */
304
+ /** Up to this many absent keys get individual lookups; more use the project-wide types scan. */
313
305
  const KEY_LOOKUP_MAX = 50;
306
+ const KEY_LOOKUP_CONCURRENCY = 5;
314
307
  /**
315
308
  * The head cache is a mirror refreshed from the server by revision, and the server stays
316
309
  * authoritative: a doubtful cache is dropped for a full read, never trusted.
@@ -331,9 +324,16 @@ anchors = new Map()) {
331
324
  if (absent.has(n.clientKey))
332
325
  candidates.set(n.clientKey, [...(candidates.get(n.clientKey) ?? []), n]);
333
326
  };
334
- if (absent.size <= KEY_LOOKUP_MAX)
335
- for (const client_key of absent)
336
- (await api.all({ client_key, include_inactive: "true" })).nodes.forEach(offer);
327
+ if (absent.size <= KEY_LOOKUP_MAX) {
328
+ const keys = [...absent];
329
+ for (let start = 0; start < keys.length; start += KEY_LOOKUP_CONCURRENCY) {
330
+ const results = await Promise.all(keys
331
+ .slice(start, start + KEY_LOOKUP_CONCURRENCY)
332
+ .map((client_key) => api.all({ client_key, include_inactive: "true" })));
333
+ for (const { nodes } of results)
334
+ nodes.forEach(offer);
335
+ }
336
+ }
337
337
  else {
338
338
  const types = [...new Set(snapshot.nodes.map((n) => n.type))].join(",");
339
339
  (await api.all({ types, include_inactive: "true" })).nodes.forEach(offer);
@@ -446,7 +446,8 @@ anchors = new Map()) {
446
446
  const active = new Set([...currentEdges.values()].filter((e) => e.lifecycle === "active").map(edgeKey));
447
447
  const wanted = new Set(edges.map(edgeKey));
448
448
  const missing = edges.filter((e) => !active.has(edgeKey(e)));
449
- for (const batch of chunks(missing, (edges) => ({ ...empty(), edges })))
449
+ // The server serializes contributions for a project. Keep dependent writes and retries ordered.
450
+ for (const batch of chunks(missing, (edges) => ({ ...empty(), edges }), EDGE_BATCH_ITEMS))
450
451
  contributions += (await submitBatch(api, batch, (edges) => ({ ...empty(), edges }))).length;
451
452
  const activeByKey = new Map();
452
453
  const duplicateIds = new Set();
@@ -489,7 +490,7 @@ anchors = new Map()) {
489
490
  : "Absent from repository snapshot",
490
491
  }))
491
492
  .concat(updated);
492
- for (const batch of chunks(edgeRevisions, (edgeRevisions) => ({ ...empty(), edgeRevisions })))
493
+ for (const batch of chunks(edgeRevisions, (edgeRevisions) => ({ ...empty(), edgeRevisions }), EDGE_BATCH_ITEMS))
493
494
  contributions += (await submitBatch(api, batch, (edgeRevisions) => ({ ...empty(), edgeRevisions }))).length;
494
495
  return {
495
496
  contributions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codyn06/cboard",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Client for cboard project graphs: connect a repository, sync its code layer, check the connection.",
5
5
  "keywords": [
6
6
  "cboard",