@codyn06/cboard 0.3.3 → 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,
@@ -422,6 +422,10 @@ export function connect(options = {}) {
422
422
  " items, duplicate active handoffs). Claude Code prompts: `/mcp__cboard__orient`,",
423
423
  " `/mcp__cboard__record`. Older servers may lack these; the rules above still apply.",
424
424
  "",
425
+ "Record one `claim` per independently useful finding, with its question and evidence. This applies",
426
+ "to research-only projects and sessions covering several questions. Before building, search the",
427
+ "`research` layer for the feature and fetch relevant findings with `get_graph_node`.",
428
+ "",
425
429
  `Empty project? \`.cboard.json\` may name a \`goalNodeId\`: the project goal (a ${researchOnly ? "`question`" : "`requirement`"} node). Link the first`,
426
430
  "decisions to it with `answers`, then create the first `status_update`. No goal yet: ask the owner for one line and",
427
431
  `run \`${syncCommand} connect --goal "<text>"\`.`,
@@ -18,6 +18,20 @@ tables directly; contribute with `submit_contribution`. Never print or read the
18
18
  what moved recently. The session brief names the current status node: read it first.
19
19
  - In repositories with code sync, code nodes can lag `HEAD`. Read files for exact code.
20
20
 
21
+ ## Research
22
+
23
+ - Use one `question` per distinct research question and one `claim` per independently useful finding.
24
+ A session can produce several questions and findings, including in research-only folders.
25
+ - Give each finding a searchable title and a body that explains what you found, why it matters,
26
+ when it applies, and how certain it is. Cite evidence in provenance, link the claim with `answers`
27
+ to its question, and link relevant evidence with `supports` or `contradicts`. Group evidence for
28
+ the same finding. A full report can cite those nodes for people reading end to end.
29
+ - Record each `source` with URL provenance. Link quoted `excerpt` nodes with `part_of` to the source
30
+ and cite them with `excerpt` provenance. Use `hypothesis` for untested explanations and `idea` for
31
+ loose leads. If you write a report as a `document_page`, cite the findings with `[[cite:<uuid>]]`.
32
+ - Before building, `query_graph` with `layers: ["research"]` and search terms for the feature.
33
+ Read the relevant nodes with `get_graph_node`. Open the report when broader context is needed.
34
+
21
35
  ## 2. Contribute with links
22
36
 
23
37
  Every node you add must link to at least one existing node with the most specific relation that is
@@ -26,6 +40,8 @@ true. A node with no relation cannot be found by traversal.
26
40
  | New node | Relation | Target |
27
41
  | --- | --- | --- |
28
42
  | decision | `answers` | the `question` or `open_issue` it resolves |
43
+ | claim | `answers` | the research `question` it addresses |
44
+ | question | `part_of` | a broader research `question` |
29
45
  | decision | `amends` / `supersedes` / `qualifies` | an earlier decision it changes, replaces or narrows |
30
46
  | task | `implements` | the requirement or decision it carries out |
31
47
  | task, plan | `part_of` / `depends_on` / `blocks` | its milestone, plan or other tasks |
@@ -137,14 +153,6 @@ project's goal, one `requirement` node whose id is `goalNodeId` in `.cboard.json
137
153
  names it). Link the first decisions to it with `answers`, then create the first `status_update`. With
138
154
  no goal, ask the owner for one line first. Rerunning with a different text revises the node.
139
155
 
140
- ### Research projects
141
-
142
- Start from a `question` (the goal in a folder without Git). Add each `source` (`url` provenance) and
143
- its `excerpt` nodes `part_of` the source. Record a `claim` or `hypothesis` that `supports` or
144
- `contradicts` another, or `answers` the question, citing excerpts in provenance (kind `excerpt`). Use
145
- `idea` for loose leads. Revise statuses instead of duplicating. When findings settle, write a
146
- `document_page` that cites nodes with `[[cite:<uuid>]]`.
147
-
148
156
  ## 3. Read the warnings
149
157
 
150
158
  `submit_contribution` returns `warnings: [{ code, message, item? }]` on newer servers. Fix them with
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codyn06/cboard",
3
- "version": "0.3.3",
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",