@orangepro/orangepro-mcp 0.2.2 → 0.2.4

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
@@ -2,33 +2,50 @@
2
2
 
3
3
  **Find the behaviors your tests miss. Generate grounded tests that actually run.**
4
4
 
5
- `opro` builds a knowledge graph from your local checkout, maps every behavior in your code, shows which ones are tested and which aren't, and generates integration-level tests grounded in real symbols — not hallucinated imports. Runs as a CLI and an MCP server.
5
+ `opro` builds a knowledge graph from your local checkout, maps every behavior in your code, shows which ones are tested and which aren't, and generates integration-level tests grounded in real symbols — not hallucinated imports. It runs as a CLI and a local stdio MCP server.
6
+
7
+ Install the target repository's dependencies first, then run OrangePro from that repository:
6
8
 
7
9
  ```bash
8
- npx @orangepro/mcp-server
9
10
  cd /path/to/your/repo
10
- opro
11
+ npm install # or pnpm install / bun install / the repository's package manager
12
+
13
+ # Optional: enables AI candidate links, candidate flows, and test generation.
14
+ export ANTHROPIC_API_KEY="..." # or OPENAI_API_KEY / OLLAMA_BASE_URL
15
+
16
+ npx -y @orangepro/mcp-server@latest start . --prompt-version v5
17
+ open .orangepro/behavior-coverage.html
11
18
  ```
12
19
 
13
- That's it. You get:
20
+ With no model key, the same command still performs deterministic analysis, renders the report, and dynamically proves eligible behaviors using existing tests. With a key, it also discovers AI candidate flows and drafts grounded tests for the highest-risk gaps. AI output never changes evidence tiers; only the mutation-kill oracle can mint **Dynamically Proven**.
21
+
22
+ The command writes:
14
23
 
15
24
  ```
16
25
  .orangepro/
17
26
  ├── behavior-coverage.html ← open this: interactive gap report
27
+ ├── graph.json ← deterministic evidence graph
28
+ ├── COVERAGE_REPORT.md ← coverage and gap summary
18
29
  ├── rtm.md ← requirements traceability matrix
19
- └── evidence-pack.json machine-readable metadata export
30
+ └── ai/ candidate AI links/flows when a provider is configured
31
+
32
+ orangepro_generated/ ← contained generated tests; existing source files are untouched
20
33
  ```
21
34
 
35
+ Run `opro export` when you want a machine-readable evidence pack.
36
+ <img width="895" height="960" alt="Screenshot 2026-07-08 at 1 18 01 AM" src="https://github.com/user-attachments/assets/73b8a812-2eab-43a1-8aed-4289545e630b" />
37
+
22
38
  ---
23
39
 
24
40
  ## Install
25
41
 
26
42
  ```bash
27
- # No install needed (npx)
28
- npx @orangepro/mcp-server
43
+ # No install needed: run the full local workflow in the current repository
44
+ npx -y @orangepro/mcp-server@latest start . --prompt-version v5
29
45
 
30
46
  # Or global install
31
47
  npm install -g @orangepro/orangepro-mcp
48
+ opro start . --prompt-version v5
32
49
 
33
50
  # Or from source
34
51
  git clone https://github.com/OrangeproAI/orangepro-mcp.git
@@ -41,7 +58,38 @@ cd orangepro-mcp && npm ci && npm run build && npm link
41
58
 
42
59
  OrangePro runs as an MCP server. Any MCP-compatible agent (Cursor, Claude Code, Codex, Copilot, OpenCode) can drive it.
43
60
 
44
- ### Setup
61
+ ### Quick agent setup
62
+
63
+ If you already have `opro` on your PATH, print the exact config for your client:
64
+
65
+ ```bash
66
+ opro agent --client codex
67
+ opro agent --client claude-code
68
+ opro agent --client cursor
69
+ opro agent --client opencode
70
+ opro agent --client generic
71
+ ```
72
+
73
+ No global install is required. These commands use the published package:
74
+
75
+ ```bash
76
+ # Codex
77
+ npx -y @orangepro/mcp-server@latest agent --client codex
78
+
79
+ # Claude Code
80
+ npx -y @orangepro/mcp-server@latest agent --client claude-code
81
+
82
+ # Cursor
83
+ npx -y @orangepro/mcp-server@latest agent --client cursor
84
+
85
+ # OpenCode
86
+ npx -y @orangepro/mcp-server@latest agent --client opencode
87
+
88
+ # Generic MCP clients, including VS Code/Copilot-style MCP settings
89
+ npx -y @orangepro/mcp-server@latest agent --client generic
90
+ ```
91
+
92
+ ### Manual MCP config
45
93
 
46
94
  Add to your client's MCP config:
47
95
 
@@ -57,11 +105,12 @@ Add to your client's MCP config:
57
105
  ```
58
106
 
59
107
  | Client | Config location |
60
- |--------|----------------|
108
+ | --- | --- |
61
109
  | Claude Code | `.mcp.json` or `~/.claude.json` |
62
110
  | Cursor | `~/.cursor/mcp.json` or Settings → MCP |
63
- | Codex | MCP config printed by `opro agent --client codex`; plugin install after OrangePro is listed in a configured marketplace |
64
- | VS Code / Copilot | MCP settings |
111
+ | Codex | Config printed by `opro agent --client codex` or `npx -y @orangepro/mcp-server@latest agent --client codex` |
112
+ | VS Code / Copilot | MCP settings; use the `generic` config if your client accepts raw MCP server JSON |
113
+ | OpenCode | Config printed by `opro agent --client opencode` |
65
114
 
66
115
  ### The workflow
67
116
 
@@ -111,6 +160,7 @@ opro rtm # traceability matrix
111
160
  opro export # metadata-only evidence pack
112
161
  opro mcp # run as MCP server (stdio)
113
162
  opro doctor # what evidence to add next
163
+ opro doctor --proof # explain why dynamic proof could not close
114
164
  opro coverage # ingest runtime coverage
115
165
  ```
116
166
 
@@ -161,6 +211,8 @@ Every behavior gets exactly one tier. Nothing is labeled "tested" on faith.
161
211
 
162
212
  > **"Dynamically Proven 0" is normal on first run.** Static analysis always runs. Dynamic proof requires running tests against targeted mutations. That's the trust model — nothing is Dynamically Proven until a real test kills a real mutant.
163
213
 
214
+ When runtime coverage is available, `opro start` also compares Runtime-covered and Dynamically Proven behaviors over the same deterministic denominator. It never compares source-line coverage with behavior proof or folds off-denominator proofs into that percentage.
215
+
164
216
  ---
165
217
 
166
218
  ## Language support
@@ -237,9 +289,10 @@ OrangePro separates **analysis** (what your code does) from **proof** (whether t
237
289
  ## Privacy
238
290
 
239
291
  - **No stored source.** Reads code in-process. Never uploads to an OrangePro server.
240
- - **No source mutation.** Never edits your existing files. Writes metadata to `.orangepro/`.
292
+ - **No existing-source mutation.** Never edits existing source or test files. Writes metadata to `.orangepro/`; keyed auto-drive may write new, reviewable tests under `orangepro_generated/`.
241
293
  - **Metadata-only exports.** File paths, names, hashes, scores — not raw source.
242
294
  - **Your keys stay yours.** Read from env at call time, never persisted.
295
+ - **BYOK is direct.** When AI lanes are enabled, grounded code context is sent directly to the model provider you configure; OrangePro's hosted service is not in that path.
243
296
 
244
297
  ---
245
298
 
@@ -1534,6 +1534,40 @@ export function analyzeRepo(root, opts = {}) {
1534
1534
  const symId = `sym:${targetRel}#${name}`;
1535
1535
  return codeSymbolIds.has(symId) ? symId : null;
1536
1536
  };
1537
+ /**
1538
+ * ALL package method symbols whose bare name is `bareName` — receiver-qualified
1539
+ * `Recv.M` hits plus bare-named ones (underivable receiver). Go method symbols
1540
+ * are minted qualified (engine `goReceiverBaseName`), so a bare test callee maps
1541
+ * back through this. Same-named FREE functions never appear (kind-filtered):
1542
+ * the mutator's receiver-exact `--recv` match means a free fn can never be
1543
+ * mutated in a method attempt.
1544
+ */
1545
+ const goPackageMethodHits = (dir, bareName) => {
1546
+ const suffix = `.${bareName}`;
1547
+ const hits = [];
1548
+ for (const f of goFilesByDir.get(dir) ?? []) {
1549
+ if (isNonProductFile(f))
1550
+ continue;
1551
+ for (const n of symbolsByFile.get(f) ?? []) {
1552
+ if ((n === bareName || n.endsWith(suffix)) && symbolKind(f, n) === "method")
1553
+ hits.push({ file: f, qualified: n });
1554
+ }
1555
+ }
1556
+ return hits;
1557
+ };
1558
+ /**
1559
+ * Receiver type pinned from a constructor's DECLARED result: `p := New(...)` →
1560
+ * New's single `T`/`*T` result base name (engine `goCtorResults`, structurally
1561
+ * capturable results only). Undefined — never a guess — when the ctor is not
1562
+ * package-unique or its result was not capturable (multi-return, interface,
1563
+ * qualified, generic): receiver pinning must fail closed.
1564
+ */
1565
+ const goCtorResultType = (dir, ctorName) => {
1566
+ const ctorFile = uniqueGoPackageSymbol(dir, ctorName);
1567
+ if (!ctorFile)
1568
+ return undefined;
1569
+ return nonTsStructureByFile.get(ctorFile)?.structure.goCtorResults?.[ctorName];
1570
+ };
1537
1571
  const eligiblePythonSymbol = (targetRel, name) => {
1538
1572
  if (!targetRel || !(proofEligibleSymbolsByFile.get(targetRel) ?? []).includes(name))
1539
1573
  return null;
@@ -1554,13 +1588,38 @@ export function analyzeRepo(root, opts = {}) {
1554
1588
  const symId = `sym:${targetRel}#${name}`;
1555
1589
  return codeSymbolIds.has(symId) ? symId : null;
1556
1590
  };
1557
- const resolveGoProofTarget = (testRel, structure, qualifier, callee, shadowed) => {
1591
+ const resolveGoProofTarget = (testRel, structure, qualifier, callee, shadowed, receiverLocal, receiverCtor) => {
1558
1592
  if (!qualifier) {
1559
1593
  if (shadowed.has(callee) || structure.packageName?.endsWith("_test"))
1560
1594
  return null;
1561
1595
  return eligibleGoSymbol(uniqueGoPackageSymbol(dirOf(testRel), callee), callee);
1562
1596
  }
1563
1597
  const rootQualifier = qualifier.split(".")[0];
1598
+ // Receiver-local METHOD call `p.M()`: the qualifier `p` is a LOCAL by design
1599
+ // (declared `p := New(...)`), so this must be checked BEFORE the qualifier-shadow
1600
+ // guard (which exists to reject package-func names shadowed by locals, not receivers).
1601
+ // Resolve the bare callee among the package's receiver-qualified method symbols
1602
+ // (`Recv.M`):
1603
+ // - ONE method named M package-wide → take it (the #212 unique-name behavior;
1604
+ // the mutator's `--recv` exact match keeps the mutation on that receiver).
1605
+ // - MULTIPLE methods named M → pin the receiver TYPE from the constructor's
1606
+ // DECLARED result (`p := New(...)` → goCtorResultType, structurally provable
1607
+ // results only) and require exactly one `pin.M` hit; no provable pin → refuse
1608
+ // (the pre-pinning fail-closed behavior).
1609
+ // The pin SELECTS only — it never rejects the unique candidate (an interface- or
1610
+ // alias-returning ctor would name an abstraction, not a receiver, and a wrong
1611
+ // selection is fail-safe anyway: the frozen oracle only fails closed in the
1612
+ // survive direction). Callee and ctor both honor shadowing.
1613
+ if (receiverLocal && !shadowed.has(callee) && !structure.packageName?.endsWith("_test")) {
1614
+ const hits = goPackageMethodHits(dirOf(testRel), callee);
1615
+ if (hits.length === 1)
1616
+ return eligibleGoSymbol(hits[0].file, hits[0].qualified);
1617
+ const pinned = receiverCtor && !shadowed.has(receiverCtor) ? goCtorResultType(dirOf(testRel), receiverCtor) : undefined;
1618
+ if (!pinned)
1619
+ return null;
1620
+ const match = hits.filter((h) => h.qualified === `${pinned}.${callee}`);
1621
+ return match.length === 1 ? eligibleGoSymbol(match[0].file, match[0].qualified) : null;
1622
+ }
1564
1623
  if (shadowed.has(rootQualifier))
1565
1624
  return null;
1566
1625
  const binding = structure.imports.find((i) => i.local === rootQualifier && i.kind === "module");
@@ -1730,7 +1789,7 @@ export function analyzeRepo(root, opts = {}) {
1730
1789
  const testExternalId = `test:${testRel}`;
1731
1790
  for (const proof of structure.goProofCalls ?? []) {
1732
1791
  goProofAttempted++;
1733
- const symId = resolveGoProofTarget(testRel, structure, proof.qualifier, proof.callee, new Set(proof.shadowed));
1792
+ const symId = resolveGoProofTarget(testRel, structure, proof.qualifier, proof.callee, new Set(proof.shadowed), proof.receiverLocal, proof.receiverCtor);
1734
1793
  if (!symId)
1735
1794
  continue;
1736
1795
  const edgeKey = `${testExternalId}|${symId}`;
@@ -54,7 +54,7 @@
54
54
  // Swift protocol methods, and Rust trait signatures while dropping Rust aliases.
55
55
  // v16: symbol extraction now carries source line spans for runtime coverage
56
56
  // report ingestion; warm v15 entries lack the ranges and cannot be mapped.
57
- export const PARSER_VERSION = 16;
57
+ export const PARSER_VERSION = 17; // 17: Go method symbols receiver-qualified (Recv.M + member_of)
58
58
  const SYMBOL_KINDS = new Set(["function", "class", "const", "method"]);
59
59
  /** Strict structural validation — persisted data is untrusted FOR SHAPE; reject anything off-shape. */
60
60
  function validSymbols(v) {
@@ -252,8 +252,12 @@ export function extractTreeSitterSymbols(content, language) {
252
252
  if (kind && shouldEmitSymbol(node, language)) {
253
253
  const name = symbolName(node, cfg);
254
254
  if (name && !RESERVED_SYMBOL_NAMES.has(name)) {
255
+ // Go methods mint receiver-qualified names (`Recv.M`, mirroring TS/JS
256
+ // `Class.method` + member_of) so same-named methods on different receivers
257
+ // stay distinct symbols; an underivable receiver falls back to the bare name.
258
+ const recv = kind === "method" && language === "go" ? goReceiverBaseName(node) : undefined;
255
259
  add(kind === "method"
256
- ? { name, symbol_kind: kind, trivial_accessor: isTrivialAccessorBody(node, language), ...nodeLines(node) }
260
+ ? { name: recv ? `${recv}.${name}` : name, ...(recv ? { member_of: recv } : {}), symbol_kind: kind, trivial_accessor: isTrivialAccessorBody(node, language), ...nodeLines(node) }
257
261
  : { name, symbol_kind: kind, ...nodeLines(node) });
258
262
  }
259
263
  }
@@ -381,6 +385,20 @@ function functionName(node, language) {
381
385
  return name;
382
386
  return name;
383
387
  }
388
+ /**
389
+ * Base receiver type name for a Go method declaration — `(p *Parser)` → "Parser",
390
+ * `(g Generic[T])` → "Generic". Undefined when the receiver shape is underivable,
391
+ * in which case callers fall back to the bare method name (the pre-qualified
392
+ * behavior). NOT used for test-name extraction — suite test names must stay bare
393
+ * (`^Test` gate at extractGoProofCalls).
394
+ */
395
+ function goReceiverBaseName(node) {
396
+ const param = node.childForFieldName("receiver")?.namedChild(0);
397
+ let t = param?.childForFieldName("type") ?? undefined;
398
+ if (t && (t.type === "pointer_type" || t.type === "generic_type"))
399
+ t = t.namedChild(0) ?? undefined;
400
+ return t?.type === "type_identifier" ? t.text : undefined;
401
+ }
384
402
  function javaPackage(root) {
385
403
  const pkg = namedChildren(root).find((n) => n.type === "package_declaration");
386
404
  return pkg ? namedChildren(pkg).find((n) => n.type.endsWith("identifier"))?.text : undefined;
@@ -389,6 +407,29 @@ function goPackage(root) {
389
407
  const pkg = namedChildren(root).find((n) => n.type === "package_clause");
390
408
  return pkg ? namedChildren(pkg).find((n) => n.type === "package_identifier")?.text : undefined;
391
409
  }
410
+ /**
411
+ * Top-level Go function name → base name of its single declared result type
412
+ * (`func New(n int) *Parser` → "Parser"). ONLY a bare `type_identifier` (optionally
413
+ * behind one `*`) is captured; multi-return (`parameter_list`), interface, qualified
414
+ * (`pkg.T`), and generic results are omitted — constructor-based receiver pinning
415
+ * must fail closed on any result it cannot prove structurally.
416
+ */
417
+ function extractGoCtorResults(root) {
418
+ const out = {};
419
+ for (const child of namedChildren(root)) {
420
+ if (child.type !== "function_declaration")
421
+ continue;
422
+ const name = child.childForFieldName("name")?.text;
423
+ if (!name)
424
+ continue;
425
+ let r = child.childForFieldName("result") ?? undefined;
426
+ if (r?.type === "pointer_type")
427
+ r = r.namedChild(0) ?? undefined;
428
+ if (r?.type === "type_identifier")
429
+ out[name] = r.text;
430
+ }
431
+ return out;
432
+ }
392
433
  function kotlinPackage(root) {
393
434
  const pkg = namedChildren(root).find((n) => n.type === "package_header");
394
435
  return pkg ? namedChildren(pkg).find((n) => n.type === "identifier")?.text : undefined;
@@ -766,6 +807,17 @@ function goAssertionCalls(node, assertLocals, dotAssertMethods, shadowed) {
766
807
  return Boolean(fn?.type === "identifier" && !shadowed.has(fn.text) && dotAssertMethods.has(fn.text));
767
808
  });
768
809
  }
810
+ function goAssertionIdentifierArgs(assertion, testingParams) {
811
+ const sel = callFunctionSelector(assertion);
812
+ const name = sel?.name ?? assertion.childForFieldName("function")?.text;
813
+ const args = namedChildren(assertion.childForFieldName("arguments") ?? assertion).filter((n) => n.type !== "comment");
814
+ if (!name || args.length < 2)
815
+ return [];
816
+ if (!testingParams.has(args[0]?.text ?? ""))
817
+ return [];
818
+ const slots = name === "Equal" || name === "NotEqual" ? [args[1], args[2]] : [args[1]];
819
+ return slots.filter((n) => n?.type === "identifier").map((n) => n.text);
820
+ }
769
821
  function goAssertionSubject(assertion, testingParams) {
770
822
  const sel = callFunctionSelector(assertion);
771
823
  const name = sel?.name ?? assertion.childForFieldName("function")?.text;
@@ -849,6 +901,11 @@ function goShortVarCalls(stmt) {
849
901
  function extractGoProofCalls(root, imports) {
850
902
  const out = [];
851
903
  const seen = new Set();
904
+ // Var name → constructor name for locals declared in the CURRENT test func by a
905
+ // bare same-package `x := New(...)` (single unqualified call). Reset per top-level
906
+ // test func; marks a qualified proof-call `p.M()` as receiver-local AND carries
907
+ // the ctor name so the analyzer can pin p's receiver type from New's result.
908
+ let receiverLocals = new Map();
852
909
  const assertLocals = goAssertLocals(imports);
853
910
  const dotAssertMethods = goDotAssertMethods(root);
854
911
  const suiteTypes = goCanonicalSuiteTypes(root, goSuiteLocals(imports));
@@ -858,13 +915,41 @@ function extractGoProofCalls(root, imports) {
858
915
  if (seen.has(key))
859
916
  continue;
860
917
  seen.add(key);
861
- out.push({ caller: testName, testName, ...c, shadowed: [...shadowed], assertion, ...(assertionLine ? { assertionLine } : {}) });
918
+ const receiverCtor = c.via === "qualified" && !!c.qualifier && !c.qualifier.includes(".") ? receiverLocals.get(c.qualifier) : undefined;
919
+ out.push({ caller: testName, testName, ...c, shadowed: [...shadowed], assertion, ...(assertionLine ? { assertionLine } : {}), ...(receiverCtor ? { receiverLocal: true, receiverCtor } : {}) });
862
920
  }
863
921
  };
864
922
  const processBlock = (block, testName, testingParams, shadowed) => {
923
+ // ONE-HOP block-local dataflow: a standalone `x, err := F(...)` statement is
924
+ // credited when a LATER statement in the SAME block checks a declared name
925
+ // (if-fail condition or assert subject). This covers the dominant real-Go
926
+ // idiom the if-initializer shape misses. Discipline kept: single product
927
+ // call per statement (goShortVarCalls), last write wins, plain reassignment
928
+ // invalidates, never crosses block boundaries. Metadata only — the dynamic
929
+ // oracle still re-verifies every edge before anything is Proven.
930
+ const pending = new Map();
931
+ // Deferred pending credits: witness lines are collected per call and flushed
932
+ // after the block — one witness keeps its exact line (subtest binding),
933
+ // several witnesses drop the line (the oracle's frame-line gate must never
934
+ // refuse a real kill firing at a sibling check).
935
+ const pendingHits = new Map();
936
+ const hitPending = (assertion, calls, line) => {
937
+ for (const c of calls) {
938
+ const key = `${assertion}|${c.qualifier ?? ""}|${c.callee}`;
939
+ const hit = pendingHits.get(key) ?? { assertion, calls: [c], lines: new Set() };
940
+ if (line !== undefined)
941
+ hit.lines.add(line);
942
+ pendingHits.set(key, hit);
943
+ }
944
+ };
865
945
  for (const stmt of blockStatements(block)) {
866
946
  for (const assertion of goAssertionCalls(stmt, assertLocals, dotAssertMethods, shadowed)) {
867
- add(testName, shadowed, "assert_helper", singleGoProductCallIn(goAssertionSubject(assertion, testingParams)), assertion.startPosition.row + 1);
947
+ const subject = goAssertionSubject(assertion, testingParams);
948
+ add(testName, shadowed, "assert_helper", singleGoProductCallIn(subject), assertion.startPosition.row + 1);
949
+ for (const argName of goAssertionIdentifierArgs(assertion, testingParams)) {
950
+ if (pending.has(argName))
951
+ hitPending("assert_helper", pending.get(argName), assertion.startPosition.row + 1);
952
+ }
868
953
  }
869
954
  if (stmt.type === "if_statement" && hasGoTestingFailure(stmt.childForFieldName("consequence"), testingParams)) {
870
955
  const condition = stmt.childForFieldName("condition");
@@ -876,6 +961,10 @@ function extractGoProofCalls(root, imports) {
876
961
  const initCalls = init ? goShortVarCalls(init) : null;
877
962
  if (initCalls && containsIdentifier(condition, initCalls.names))
878
963
  add(testName, shadowed, "testing_fail", initCalls.calls, failLine);
964
+ for (const [name, calls] of pending) {
965
+ if (containsIdentifier(condition, new Set([name])))
966
+ hitPending("testing_fail", calls, failLine);
967
+ }
879
968
  }
880
969
  for (const child of namedChildren(stmt)) {
881
970
  if (child.type === "block")
@@ -886,6 +975,45 @@ function extractGoProofCalls(root, imports) {
886
975
  const subTestName = subtest.subName ? `${testName}/${subtest.subName}` : testName;
887
976
  processBlock(subtest.body, subTestName, subtest.testingParams, shadowed);
888
977
  }
978
+ // Record declarations AFTER uses: a declaration is never its own check.
979
+ const sv = stmt.type === "short_var_declaration" ? goShortVarCalls(stmt) : null;
980
+ if (sv) {
981
+ for (const name of sv.names)
982
+ pending.set(name, sv.calls);
983
+ }
984
+ if (stmt.type === "short_var_declaration") {
985
+ // A lone `x := New(...)` makes x a receiver-local: its type comes from a
986
+ // same-package constructor, so `x.M()` targets a same-package method. This
987
+ // check inspects the TOP-LEVEL RHS call directly (not goShortVarCalls, whose
988
+ // single-product-call rule drops `New(strings.NewReader(...))` for its nested
989
+ // arg — the real phcparser shape). Refuses composite literals, qualified/
990
+ // imported calls, and multi-assign — none are receiver-locals.
991
+ const rhsNames = new Set();
992
+ collectNames(stmt.childForFieldName("left") ?? stmt.namedChild(0), rhsNames);
993
+ const rhs = stmt.childForFieldName("right");
994
+ const rhsCalls = rhs ? namedChildren(rhs).filter((n) => n.type === "call_expression") : [];
995
+ if (rhsNames.size === 1 && rhsCalls.length === 1) {
996
+ const cp = callParts(rhsCalls[0], "go");
997
+ if (cp && cp.via === "free")
998
+ receiverLocals.set([...rhsNames][0], cp.callee);
999
+ }
1000
+ }
1001
+ else if (stmt.type === "assignment_statement") {
1002
+ // Reassigning a receiver-local invalidates it too.
1003
+ const reassignedRl = new Set();
1004
+ collectNames(stmt.childForFieldName("left") ?? stmt.namedChild(0), reassignedRl);
1005
+ for (const name of reassignedRl)
1006
+ receiverLocals.delete(name);
1007
+ // Plain reassignment kills the binding — the checked value is no longer F's.
1008
+ const reassigned = new Set();
1009
+ collectNames(stmt.childForFieldName("left") ?? stmt.namedChild(0), reassigned);
1010
+ for (const name of reassigned)
1011
+ pending.delete(name);
1012
+ }
1013
+ }
1014
+ for (const hit of pendingHits.values()) {
1015
+ const line = hit.lines.size === 1 ? [...hit.lines][0] : undefined;
1016
+ add(testName, shadowed, hit.assertion, hit.calls, line);
889
1017
  }
890
1018
  };
891
1019
  const processSuiteBlock = (block, testName, receiver, shadowed) => {
@@ -920,6 +1048,7 @@ function extractGoProofCalls(root, imports) {
920
1048
  const body = child.childForFieldName("body");
921
1049
  if (!testingParams.size || !body)
922
1050
  continue;
1051
+ receiverLocals = new Map();
923
1052
  processBlock(body, name, testingParams, localBindings(child, "go"));
924
1053
  }
925
1054
  return out;
@@ -1383,7 +1512,14 @@ export function extractTreeSitterStructure(content, language) {
1383
1512
  nextInsideFunction = true;
1384
1513
  }
1385
1514
  else {
1386
- const name = functionName(node, language);
1515
+ let name = functionName(node, language);
1516
+ // Go method symbols are receiver-qualified — attribute calls to the
1517
+ // qualified caller so Layer-1 edges keep matching the emitted symbol.
1518
+ if (name && language === "go" && node.type === "method_declaration") {
1519
+ const recv = goReceiverBaseName(node);
1520
+ if (recv)
1521
+ name = `${recv}.${name}`;
1522
+ }
1387
1523
  if (name) {
1388
1524
  nextCaller = name;
1389
1525
  nextShadowed = localBindings(node, language);
@@ -1402,7 +1538,7 @@ export function extractTreeSitterStructure(content, language) {
1402
1538
  const imports = extractImports(root, language);
1403
1539
  const result = {
1404
1540
  ...(language === "java" ? { packageName: javaPackage(root), javaClasses: javaClassInfos(root), javaProofCalls: extractJavaProofCalls(root, imports) } : {}),
1405
- ...(language === "go" ? { packageName: goPackage(root) } : {}),
1541
+ ...(language === "go" ? { packageName: goPackage(root), goCtorResults: extractGoCtorResults(root) } : {}),
1406
1542
  ...(language === "kotlin" ? { packageName: kotlinPackage(root), topLevelSymbols: kotlinTopLevelSymbols(root) } : {}),
1407
1543
  ...(language === "php" ? { moduleName: phpNamespace(root) } : {}),
1408
1544
  ...(language === "csharp" ? { moduleName: csharpNamespace(root) } : {}),
@@ -108,15 +108,18 @@ function pytestNodeidsForTarget(sourceRoot, testRel, testName) {
108
108
  * `behavior_surface === "entrypoint_adjacent"`, and carrying NO `denominator_reason_code`
109
109
  * (infra_behavior_surface / not_entry_point_adjacent).
110
110
  *
111
- * Language: TS/JS (unchanged), Go (G-INT-2), OR Java (J-INT-2). Go dynamic proof
112
- * (G-1) proves FREE FUNCTIONS ONLY a Go method classifies `unrunnable` and never
113
- * mints, so admitting one is safe (never a false Proven) but wastes an attempt; when
114
- * the clean `symbol_kind === "method"` signal is present we exclude it up front. Java
115
- * dynamic proof (J-1) is the INVERSE it proves single-top-level-return METHODS, so
116
- * we admit Java methods; a non-J-1-shape method (void/constructor/nested/generic) just
117
- * classifies `unrunnable` and never mints, safe by construction. Everything downstream
118
- * of `closed`/the cert is language-agnostic and mints Go/Java only through the
119
- * unchanged G-INT-1/J-INT-1 gates.
111
+ * Language: TS/JS (unchanged), Go (G-INT-2), OR Java (J-INT-2). This STRICT predicate
112
+ * keeps Go to FREE FUNCTIONS ONLY. The Go oracle can also prove receiver METHODS, but
113
+ * a method's no-false-Proven story rests entirely on the analyzer-minted hard
114
+ * receiver-local TESTED_BY/COVERS edge (package-unique method-name gating) so Go
115
+ * methods are admitted solely by `isEligibleHardExistingTarget` on the hard-edge lane,
116
+ * never here: this predicate also feeds PR/changed-scope selection, weak MAY_*
117
+ * expansion, and generation candidate filtering, where no hard edge backs the pick.
118
+ * Java dynamic proof (J-1) is the INVERSE it proves single-top-level-return METHODS,
119
+ * so we admit Java methods; a non-J-1-shape method (void/constructor/nested/generic)
120
+ * just classifies `unrunnable` and never mints, safe by construction. Everything
121
+ * downstream of `closed`/the cert is language-agnostic and mints Go/Java only through
122
+ * the unchanged G-INT-1/J-INT-1 gates.
120
123
  */
121
124
  export function isEligibleProvableTarget(node) {
122
125
  if (!node || node.kind !== "CodeSymbol")
@@ -133,18 +136,27 @@ export function isEligibleProvableTarget(node) {
133
136
  * The LANGUAGE + oracle-SHAPE half of eligibility, factored out so both the strict
134
137
  * `isEligibleProvableTarget` (which layers the entry-point-adjacent SCOPE guards on top)
135
138
  * and the relaxed hard-edge existing-tests path share ONE definition of "a shape the
136
- * oracle can prove". CodeSymbol + a TS/JS file, a Go free function, a Java method, or a
137
- * Python function/method.
139
+ * oracle can prove". CodeSymbol + a TS/JS file, a Go free function (a receiver method
140
+ * only when the caller opts in via `allowGoMethod`), a Java method, or a Python
141
+ * function/method.
138
142
  */
139
- function matchesProvableLanguageShape(node) {
143
+ function matchesProvableLanguageShape(node, opts) {
140
144
  if (node.kind !== "CodeSymbol")
141
145
  return false;
142
146
  const file = codeSymbolFile(node);
143
147
  if (isTsJsFile(file))
144
148
  return true;
145
- // Go: free functions only. A method is out of scope for the Go oracle (G-1 refuses it).
146
- if (isGoFile(file))
147
- return node.properties.symbol_kind !== "method";
149
+ // Go: free functions only, unless the caller opts into methods (`allowGoMethod`).
150
+ // Only the hard-edge lane opts in: a method's no-false-Proven story rests on the
151
+ // analyzer's uniqueness-gated receiver-local TESTED_BY/COVERS edge, which the strict
152
+ // callers (changed-scope selection, weak MAY_* expansion, generation candidates)
153
+ // do not have — admitting methods there would break the invariant that a Go method
154
+ // only ever becomes a proof attempt via a hard receiver-local edge.
155
+ if (isGoFile(file)) {
156
+ if (node.properties.symbol_kind === "function")
157
+ return true;
158
+ return opts?.allowGoMethod === true && node.properties.symbol_kind === "method";
159
+ }
148
160
  // Java: METHODS only (J-1 proves single-top-level-return methods). A non-J-1-shape
149
161
  // method classifies `unrunnable` and never mints, so admitting all Java methods is
150
162
  // safe (never a false Proven); a non-method Java symbol (a class container) is out
@@ -173,7 +185,11 @@ function matchesProvableLanguageShape(node) {
173
185
  * by the frozen oracle, never false-Proven. Guards deliberately KEPT:
174
186
  * - `infra_behavior_surface` still excludes plumbing (getters/registry accessors) — a
175
187
  * hard edge does not buy an infra symbol an attempt (waste, and preserves the #4 bar);
176
- * - the language + oracle-shape filter (never hand a class container / Go method down).
188
+ * - the language + oracle-shape filter (never hand a class container down).
189
+ * This is also the ONLY caller that admits Go receiver METHODS (`allowGoMethod`): it is
190
+ * reached solely behind a hard TESTED_BY/COVERS edge, and the analyzer mints a method
191
+ * edge only for the uniqueness-gated receiver-local shape — the strict predicate keeps
192
+ * Go methods out of every other selection path.
177
193
  * Used solely on the hard lane; weak MAY_* fan-out stays strict.
178
194
  */
179
195
  function isEligibleHardExistingTarget(node) {
@@ -181,7 +197,7 @@ function isEligibleHardExistingTarget(node) {
181
197
  return false;
182
198
  if (node.properties.denominator_reason_code === "infra_behavior_surface")
183
199
  return false;
184
- return matchesProvableLanguageShape(node);
200
+ return matchesProvableLanguageShape(node, { allowGoMethod: true });
185
201
  }
186
202
  /** Go `_test.go` top-level test-name regex (matches `extractTestNames`'s Go pattern). */
187
203
  const GO_TEST_NAME_RE = /^Test[A-Za-z0-9_]+$/;
@@ -206,9 +222,10 @@ function anchorGoTestRun(name) {
206
222
  * its target test BY NAME (`go test -run ^TestX$`), so auto-drive must derive that
207
223
  * name — G-INT-1 took it as an explicit input.
208
224
  *
209
- * The link is the analyzer's HARD `TESTED_BY`/`COVERS` proof edge (Go free-fn sym ↔
210
- * `test:<file>_test.go`), emitted only for an eligible Go symbol whose test genuinely
211
- * asserts on it. PRIMARY: the edge carries `properties.test_name` — the EXACT enclosing
225
+ * The link is the analyzer's HARD `TESTED_BY`/`COVERS` proof edge (Go sym — free fn,
226
+ * or receiver-local method — ↔ `test:<file>_test.go`), emitted only for an eligible Go
227
+ * symbol whose test genuinely asserts on it. PRIMARY: the edge carries
228
+ * `properties.test_name` — the EXACT enclosing
212
229
  * `func TestXxx` where the assertion witnessed THIS target (structural metadata, never
213
230
  * proof) — which disambiguates even a `_test.go` file with many tests. FALLBACK (old
214
231
  * graphs / no edge metadata): the linked TestCase node's file-level `test_names[]`,
@@ -519,7 +536,8 @@ export function existingAssociatedTests(graph, nodeById) {
519
536
  };
520
537
  // `hard` = TESTED_BY/COVERS (the confirmer's structural links); weak = MAY_* candidate
521
538
  // edges. Hard is recorded before weak (graph.edges scanned first), so a test already
522
- // linked hard is never downgraded; a later weak dup only upgrades an existing weak to hard.
539
+ // linked hard is never downgraded, and a later weak dup of the same pair is a no-op —
540
+ // the hard flag can only ever originate from a genuine TESTED_BY/COVERS edge.
523
541
  const add = (symId, testRel, hard, testName) => {
524
542
  // A HARD TESTED_BY/COVERS edge is a real derivable test; admit it even when the symbol
525
543
  // is not_entry_point_adjacent (relaxed shape-only guard). Weak MAY_* fan-out stays strict.
package/dist/local/cli.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { parseArgs, collectSetupCommands } from "./cliArgs.js";
3
3
  import { opAnalyze, opAiFlows, opAiLinks, opChanged, opCompare, opDoctor, opProofDoctor, opDynamicProof, opExplain, opGaps, opGenerate, opBehaviorCoverageHtml, opCoverageReport, opInit, opProveLoop, opRuntimeCoverage, opScore, opRecordRun, opRtm, opStats, opStatus, opUpdate, opSetModelDefault, opStart, getModelDefault, resolveDiffTargets, resolvePrCheckout, writeCompareReport } from "./operations.js";
4
4
  import { dominantBlockReason } from "./viz/behaviorReportData.js";
5
+ import { coverageRevealLine } from "./viz/coverageReveal.js";
5
6
  import { autoProve, isRoastSurvivor } from "./autoProve.js";
6
7
  import { opRecipeDbSqljs } from "./recipe/dbSqljs.js";
7
8
  import { runExportCli } from "./exportCli.js";
@@ -106,7 +107,7 @@ Usage:
106
107
  opro ai-links [--all] [--apply] [--provider openai|anthropic|ollama] [--model <name>] [--max-behaviors <n>] [--symbols-per-behavior <n>] [--max-prompt-tokens <n>] [--json]
107
108
  # opt-in AI lane: stage weak candidate behavior↔code links in .orangepro/ai/links.json; --apply merges them into candidate_edges only
108
109
  opro ai-flows [--apply] [--provider openai|anthropic|ollama] [--model <name>] [--json]
109
- # opt-in AI lane: stage candidate behavior flows (closed anchor set) in .orangepro/ai/flows.json; --apply stores them under analysis.candidate_flows only — a verify-these worklist, never evidence
110
+ # opt-in AI lane: stage candidate behavior flows (closed anchor set) in .orangepro/flows.json; --apply stores them under analysis.candidate_flows only — a verify-these worklist, never evidence
110
111
  opro generate [--target REQ-001] [--base <ref>] [--pr <n> [--yes]] [--changed] [--framework playwright] [--limit 3] [--prompt-version v2|v5] [--provider openai|anthropic|ollama|deterministic] [--model <name>] [--single [--raw]] [--background] [--json]
111
112
  # default: A/B both arms (prompt-only vs Local KG, same model) scored side by side + writes a fresh report; --single generates one arm only
112
113
  # --base <ref>: NON-MUTATING default for PR/branch review — generate only for the behaviors the diff vs <ref> touches (e.g. --base main); read-only \`git diff\`, no checkout
@@ -236,6 +237,11 @@ async function main() {
236
237
  out(` skipped: ${skip.target_symbol ?? skip.title} — ${skip.reason}`);
237
238
  }
238
239
  out(` Runtime-covered: ${res.rtm.summary.runtime_covered}`);
240
+ // G6: same-denominator coverage-vs-proof reveal — renders only when runtime
241
+ // coverage was ingested; percentages share summary.total (never mixed scopes).
242
+ const reveal = coverageRevealLine(res.rtm.summary);
243
+ if (reveal)
244
+ out(` ${reveal}`);
239
245
  out(` Statically Linked: ${res.rtm.summary.associated} (static test link, not dynamic proof)`);
240
246
  out(` No integration signal: ${res.rtm.summary.no_link}`);
241
247
  out(` AI-linked: ${res.ai_linked.behaviors} behavior(s), ${res.ai_linked.symbols} symbol(s), ${res.ai_linked.links} weak link(s) — not coverage`);