@weftlet/toolkit 0.6.1 → 0.7.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/README.md +168 -1
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/application/application.d.ts +10 -0
- package/dist/application/application.js +20 -0
- package/dist/application/document-code-bindings.d.ts +11 -0
- package/dist/application/document-code-bindings.js +25 -0
- package/dist/application/document-obligations.d.ts +8 -0
- package/dist/application/document-obligations.js +11 -0
- package/dist/application/draft-facts.d.ts +3 -0
- package/dist/application/draft-facts.js +37 -0
- package/dist/application/extraction-identity.d.ts +2 -2
- package/dist/application/extraction-identity.js +7 -1
- package/dist/application/extractor-results.d.ts +6 -0
- package/dist/application/extractor-results.js +6 -0
- package/dist/application/hydrator.js +20 -3
- package/dist/application/mapping-proposals.d.ts +108 -0
- package/dist/application/mapping-proposals.js +142 -0
- package/dist/application/mapping-service.d.ts +2 -0
- package/dist/application/mapping-service.js +5 -0
- package/dist/application/overlay.js +36 -22
- package/dist/application/saved-code-coverage.d.ts +40 -0
- package/dist/application/saved-code-coverage.js +20 -0
- package/dist/application/saved-compatibility.d.ts +38 -0
- package/dist/application/saved-compatibility.js +20 -0
- package/dist/application/saved-evidence.d.ts +17 -11
- package/dist/application/saved-evidence.js +44 -40
- package/dist/application/saved-exploration.d.ts +57 -0
- package/dist/application/saved-exploration.js +21 -0
- package/dist/application/saved-paths.d.ts +58 -0
- package/dist/application/saved-paths.js +20 -0
- package/dist/extraction/call-syntax.d.ts +18 -0
- package/dist/extraction/call-syntax.js +61 -0
- package/dist/extraction/canonical-document-links.d.ts +5 -1
- package/dist/extraction/canonical-document-links.js +4 -4
- package/dist/extraction/code-inventory.d.ts +6 -0
- package/dist/extraction/code-inventory.js +26 -0
- package/dist/extraction/document-code-bindings.d.ts +14 -0
- package/dist/extraction/document-code-bindings.js +121 -0
- package/dist/extraction/document-obligations.d.ts +12 -0
- package/dist/extraction/document-obligations.js +112 -0
- package/dist/extraction/mapping-candidates.d.ts +13 -0
- package/dist/extraction/mapping-candidates.js +46 -0
- package/dist/extraction/mapping-output.d.ts +75 -0
- package/dist/extraction/mapping-output.js +53 -0
- package/dist/extraction/mapping-plan.d.ts +7 -0
- package/dist/extraction/mapping-plan.js +117 -0
- package/dist/extraction/mapping-prompt.d.ts +2 -0
- package/dist/extraction/mapping-prompt.js +17 -0
- package/dist/extraction/mapping-provider.d.ts +15 -0
- package/dist/extraction/mapping-provider.js +60 -0
- package/dist/extraction/mapping-request.d.ts +3 -0
- package/dist/extraction/mapping-request.js +32 -0
- package/dist/extraction/routing.js +5 -20
- package/dist/extraction/scip-occurrences.d.ts +3 -0
- package/dist/extraction/scip-occurrences.js +102 -0
- package/dist/extraction/scip-ranges.d.ts +6 -0
- package/dist/extraction/scip-ranges.js +31 -0
- package/dist/extraction/scip-runtime.d.ts +39 -0
- package/dist/extraction/scip-runtime.js +8 -0
- package/dist/extraction/scip-symbols.d.ts +21 -0
- package/dist/extraction/scip-symbols.js +91 -0
- package/dist/extraction/semantic.d.ts +1 -1
- package/dist/extraction/semantic.js +5 -17
- package/dist/extraction/static-calls.d.ts +10 -0
- package/dist/extraction/static-calls.js +133 -0
- package/dist/extraction/static.d.ts +3 -20
- package/dist/extraction/static.js +8 -84
- package/dist/extraction/symbol-resolution.d.ts +12 -0
- package/dist/extraction/symbol-resolution.js +51 -0
- package/dist/extraction/symbol-selectors.d.ts +11 -0
- package/dist/extraction/symbol-selectors.js +51 -0
- package/dist/graph/binding-rdf.d.ts +7 -0
- package/dist/graph/binding-rdf.js +109 -0
- package/dist/graph/call-rdf.d.ts +4 -0
- package/dist/graph/call-rdf.js +94 -0
- package/dist/graph/call-shapes.d.ts +2 -0
- package/dist/graph/call-shapes.js +28 -0
- package/dist/graph/code-coverage-projection.d.ts +9 -0
- package/dist/graph/code-coverage-projection.js +117 -0
- package/dist/graph/code-coverage-renderer.d.ts +2 -0
- package/dist/graph/code-coverage-renderer.js +15 -0
- package/dist/graph/code-coverage-request.d.ts +6 -0
- package/dist/graph/code-coverage-request.js +19 -0
- package/dist/graph/code-coverage.d.ts +6 -0
- package/dist/graph/code-coverage.js +54 -0
- package/dist/graph/code-description.d.ts +4 -0
- package/dist/graph/code-description.js +24 -0
- package/dist/graph/code-rdf.d.ts +5 -0
- package/dist/graph/code-rdf.js +72 -0
- package/dist/graph/compatibility-context.d.ts +2 -0
- package/dist/graph/compatibility-context.js +18 -0
- package/dist/graph/compatibility-renderer.d.ts +2 -0
- package/dist/graph/compatibility-renderer.js +45 -0
- package/dist/graph/compatibility-request.d.ts +3 -0
- package/dist/graph/compatibility-request.js +18 -0
- package/dist/graph/compatibility.d.ts +7 -0
- package/dist/graph/compatibility.js +67 -0
- package/dist/graph/constraint-comparison.d.ts +7 -0
- package/dist/graph/constraint-comparison.js +49 -0
- package/dist/graph/coverage.d.ts +2 -2
- package/dist/graph/coverage.js +8 -3
- package/dist/graph/diagnostics.d.ts +1 -1
- package/dist/graph/diagnostics.js +10 -6
- package/dist/graph/evidence-description.d.ts +3 -0
- package/dist/graph/evidence-description.js +13 -0
- package/dist/graph/identity-preflight.js +1 -1
- package/dist/graph/neighborhood-renderer.d.ts +2 -0
- package/dist/graph/neighborhood-renderer.js +38 -0
- package/dist/graph/neighborhood-request.d.ts +9 -0
- package/dist/graph/neighborhood-request.js +37 -0
- package/dist/graph/neighborhood.d.ts +8 -0
- package/dist/graph/neighborhood.js +100 -0
- package/dist/graph/obligation-rdf.d.ts +5 -0
- package/dist/graph/obligation-rdf.js +67 -0
- package/dist/graph/obligation-shapes.d.ts +2 -0
- package/dist/graph/obligation-shapes.js +32 -0
- package/dist/graph/path-request.d.ts +11 -0
- package/dist/graph/path-request.js +24 -0
- package/dist/graph/path-search.d.ts +45 -0
- package/dist/graph/path-search.js +101 -0
- package/dist/graph/paths-renderer.d.ts +2 -0
- package/dist/graph/paths-renderer.js +36 -0
- package/dist/graph/paths.d.ts +7 -0
- package/dist/graph/paths.js +74 -0
- package/dist/graph/query.js +23 -6
- package/dist/graph/rdf.js +26 -0
- package/dist/graph/shacl-shapes.js +70 -0
- package/dist/graph/snapshot-context.d.ts +3 -0
- package/dist/graph/snapshot-context.js +8 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +22 -0
- package/dist/infrastructure/json-digest.d.ts +2 -0
- package/dist/infrastructure/json-digest.js +3 -0
- package/dist/infrastructure/unique-json.d.ts +2 -0
- package/dist/infrastructure/unique-json.js +20 -0
- package/dist/interfaces/cli.js +33 -1
- package/dist/interfaces/code-coverage.d.ts +46 -0
- package/dist/interfaces/code-coverage.js +18 -0
- package/dist/interfaces/graph-compatibility.d.ts +35 -0
- package/dist/interfaces/graph-compatibility.js +21 -0
- package/dist/interfaces/graph-exploration.d.ts +59 -0
- package/dist/interfaces/graph-exploration.js +27 -0
- package/dist/interfaces/graph-paths.d.ts +77 -0
- package/dist/interfaces/graph-paths.js +31 -0
- package/dist/interfaces/graph-query-args.d.ts +2 -0
- package/dist/interfaces/graph-query-args.js +25 -0
- package/dist/interfaces/mapping-proposals.d.ts +204 -0
- package/dist/interfaces/mapping-proposals.js +74 -0
- package/dist/interfaces/mcp.js +31 -3
- package/dist/storage/mapping-proposals.d.ts +9 -0
- package/dist/storage/mapping-proposals.js +42 -0
- package/dist/visualization/evidence-sources.d.ts +6 -0
- package/dist/visualization/evidence-sources.js +19 -0
- package/dist/visualization/viewer-interaction.d.ts +5 -8
- package/dist/visualization/viewer-interaction.js +46 -44
- package/dist/visualization/visualization.js +14 -5
- package/docs/1.0-WORK-QUEUE.md +38 -0
- package/docs/ADR-029-exact-graph-neighborhoods.md +70 -0
- package/docs/ADR-030-bounded-evidence-paths.md +97 -0
- package/docs/ADR-031-code-extractor-selection.md +91 -0
- package/docs/ADR-032-scip-code-evidence.md +73 -0
- package/docs/ADR-033-document-symbol-bindings.md +83 -0
- package/docs/ADR-034-mapping-gaps.md +80 -0
- package/docs/ADR-035-static-call-evidence.md +78 -0
- package/docs/ADR-036-contract-obligation-declarations.md +124 -0
- package/docs/ADR-037-selected-contract-compatibility.md +93 -0
- package/docs/ADR-038-monorepo-code-coverage.md +105 -0
- package/docs/ADR-039-mapping-proposals.md +119 -0
- package/docs/GRAPHIFY-EVALUATION.md +21 -4
- package/docs/PRE-1.0-BASELINE.md +49 -2
- package/docs/RELEASE-1.0-PLAN.md +14 -2
- package/docs/RELEASING.md +3 -3
- package/docs/ROADMAP.md +27 -6
- package/docs/VALIDATION.md +437 -14
- package/docs/extraction-manifest.json +248 -21
- package/package.json +8 -4
- package/templates/context-graph-development/SKILL.md +30 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Proposed future capabilities are recorded in the [Weftlet 2.0 product plan](docs
|
|
|
14
14
|
## Set up a project
|
|
15
15
|
|
|
16
16
|
<!-- weftlet:release:start -->
|
|
17
|
-
Package versions in this checkout/archive: `@weftlet/toolkit@0.
|
|
17
|
+
Package versions in this checkout/archive: `@weftlet/toolkit@0.7.0` and `@weftlet/core@0.7.0`.
|
|
18
18
|
<!-- weftlet:release:end -->
|
|
19
19
|
|
|
20
20
|
Weftlet uses `@weftlet/toolkit`; its neutral `@weftlet/core` dependency is installed
|
|
@@ -349,6 +349,123 @@ context-graph impact scan --config context-graph.config.json --capability search
|
|
|
349
349
|
context-graph visualize --config context-graph.config.json --capability search --output graph.html
|
|
350
350
|
```
|
|
351
351
|
|
|
352
|
+
**Available starting with 0.7.0:** for precise follow-up, copy the returned
|
|
353
|
+
snapshot ID and a node ID from a cited fact:
|
|
354
|
+
|
|
355
|
+
```sh
|
|
356
|
+
weftlet graph neighbors --snapshot <snapshot-id> --node <node-id> --direction both --max-facts 20 --json
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
MCP exposes the same read-only operation as `graph.neighbors` with `snapshotId` and `nodeId`.
|
|
360
|
+
Use `predicates` (CLI: repeat `--predicate`) to select relations and `direction` for incoming,
|
|
361
|
+
outgoing or both. Follow `selection.continuation` with the same arguments to retrieve more
|
|
362
|
+
assertions. `frontier.neighbors` identifies returned neighbors with other incident evidence;
|
|
363
|
+
query one of those IDs with the same snapshot to investigate another area. These are exact-ID,
|
|
364
|
+
one-hop reads of saved evidence: no model or indexer is invoked. Each assertion retains its own
|
|
365
|
+
citations, authority and review state, including multiple assertions about the same edge.
|
|
366
|
+
Page completion does not establish complete product coverage. See [the query contract](docs/ADR-029-exact-graph-neighborhoods.md).
|
|
367
|
+
|
|
368
|
+
The development checkout now preserves typed `CodeSymbol` definitions and individual SCIP
|
|
369
|
+
references, including local symbols, repeated same-file uses and one-based UTF-16 columns.
|
|
370
|
+
From a physical-file node, request incoming `definedBy` facts to discover its symbols; from a
|
|
371
|
+
symbol, request incoming/outgoing `references` to inspect exact occurrences. Native lexical
|
|
372
|
+
enclosure is not a call graph. Resolution distinguishes indexed definitions, declaration-only
|
|
373
|
+
targets and absent indexed definitions. Local ordinal IDs are scoped to the exact index; refresh
|
|
374
|
+
code evidence before comparing revisions. See [code evidence and limits](docs/ADR-032-scip-code-evidence.md).
|
|
375
|
+
The development checkout also resolves explicit Markdown symbol selectors in selected documents:
|
|
376
|
+
|
|
377
|
+
```md
|
|
378
|
+
[helper](../src/worker.ts#weftlet-symbol=Engine.execute)
|
|
379
|
+
[implementation](../src/worker.ts#weftlet-symbol=execute "weftlet:implementedBy invariant:max-age")
|
|
380
|
+
[check](../test/worker.test.ts#weftlet-symbol=check "weftlet:verifiedBy invariant:max-age")
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
The first link creates a Document→references→CodeSymbol relationship. The annotated forms require
|
|
384
|
+
an exact existing business-node ID from the graph; discover it with `impact.scan`/`graph.neighbors`.
|
|
385
|
+
They declare a mapping and retain its supporting assertions and review state. They do not prove
|
|
386
|
+
that the implementation fulfills the rule or that a test passed. No function name or nearby prose
|
|
387
|
+
automatically creates an implementation mapping. Approved source documents remain distinguishable
|
|
388
|
+
from unreviewed extracted assertions.
|
|
389
|
+
|
|
390
|
+
Selectors match an exact indexed name, symbol ID, or unambiguous native lexical name such as
|
|
391
|
+
`Engine.execute` in the named file. For an alias or a specific occurrence, supply both one-based
|
|
392
|
+
UTF-16 coordinates, for example `#weftlet-symbol=publicAlias&weftlet-line=1&weftlet-column=23`.
|
|
393
|
+
The graph retains both the selected occurrence and all indexed target definitions, with digests
|
|
394
|
+
and commit SHAs. Missing/ambiguous targets produce cited `implementationGaps`, with no guessed link.
|
|
395
|
+
An indexed `.d.ts` declaration stays declaration-only. These links use the existing configured
|
|
396
|
+
semantic/document-traversal scope and SCIP selection; they require no extra provider call.
|
|
397
|
+
Validation documents stay outside intent extraction and can declare `verifiedBy`, not `implementedBy`.
|
|
398
|
+
See [ADR 033](docs/ADR-033-document-symbol-bindings.md) for bounds and draft-overlay behavior.
|
|
399
|
+
|
|
400
|
+
These capabilities are pending the next npm candidate. The development checkout now also derives
|
|
401
|
+
`calls` from actual TypeScript call/new syntax and exact SCIP identities. Query a function's
|
|
402
|
+
incoming/outgoing `calls` to inspect callers/callees, or follow a bounded path using `calls` and
|
|
403
|
+
`implementedBy`. Each assertion retains callsite and endpoint proofs, with explicit bodyless,
|
|
404
|
+
external, optional and member-dispatch limits. Runtime execution is not implied. Values, callbacks
|
|
405
|
+
and dynamic dispatch without a known target remain references and cited gaps. See
|
|
406
|
+
[ADR 035](docs/ADR-035-static-call-evidence.md). The remaining inferred-mapping proposal is
|
|
407
|
+
recorded separately in [ADR 034](docs/ADR-034-mapping-gaps.md).
|
|
408
|
+
|
|
409
|
+
Selected Markdown documents can now declare producer guarantees and consumer requirements in
|
|
410
|
+
optional `weftlet-obligation` JSON fences. Both sides name an exact scoped/versioned queue or
|
|
411
|
+
stored-data contract and a repository endpoint. Agents retrieve these through `emits`/`consumes`
|
|
412
|
+
neighborhoods and paths, with the original statement, citations and any documented domain, stage,
|
|
413
|
+
constraint/unit and consumer revalidation requirement. Missing fields remain unknown. Declarations
|
|
414
|
+
do not establish fulfillment, runtime delivery or compatibility; ordinary prose is not automatically
|
|
415
|
+
converted into this format. See [the declaration format and example](docs/ADR-036-contract-obligation-declarations.md).
|
|
416
|
+
This addition is also pending the next npm candidate.
|
|
417
|
+
|
|
418
|
+
For two retrieved obligation facts, the development checkout also supports:
|
|
419
|
+
|
|
420
|
+
```sh
|
|
421
|
+
weftlet graph compatibility --snapshot <snapshot-id> --producer-fact <fact-id> --consumer-fact <fact-id> --json
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
MCP `graph.compatibility` uses `snapshotId`, `producerFactId` and `consumerFactId`. It compares
|
|
425
|
+
explicit numeric constraints with matching domain, measurement stage, units and contract version.
|
|
426
|
+
Results distinguish compatible limits, an insufficient guarantee, disjoint limits, required
|
|
427
|
+
consumer revalidation and unknowns. Both original citations and source approvals remain visible.
|
|
428
|
+
This advisory assessment does not establish code fulfillment or a CI policy violation. See
|
|
429
|
+
[comparison semantics and limits](docs/ADR-037-selected-contract-compatibility.md). The command
|
|
430
|
+
reads saved evidence during edits without rebuilding it; it is pending the next npm candidate.
|
|
431
|
+
|
|
432
|
+
Saved repository code coverage is separate from the returned-page relationship counts:
|
|
433
|
+
|
|
434
|
+
```sh
|
|
435
|
+
weftlet graph coverage --snapshot <snapshot-id> --max-items 20 --json
|
|
436
|
+
weftlet graph coverage --snapshot <snapshot-id> --project services/api --max-items 50 --json
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
MCP `graph.coverage` accepts the same snapshot and an optional exact `projectRoot`; follow
|
|
440
|
+
`selection.continuation` with identical arguments. It first pages package boundaries, then files
|
|
441
|
+
within a chosen boundary. Reports distinguish `codeRoots`, requested SCIP entries, actual indexed
|
|
442
|
+
documents, omitted files/packages, cross-package code references and unresolved/declaration-only
|
|
443
|
+
targets. A selected directory or an import does not guarantee its files were indexed: configure
|
|
444
|
+
`scip.sourceProject.include` and aliases for the intended code scope. Other indexer invocations
|
|
445
|
+
retain unknown entry selection. Old snapshots without inventory report unknown coverage.
|
|
446
|
+
The overview also appears in agent queries and the viewer; zero observations never prove no
|
|
447
|
+
business impact. This is TypeScript-family source coverage grouped by nearest `package.json`,
|
|
448
|
+
not universal language or compiler-project coverage. See [ADR 038](docs/ADR-038-monorepo-code-coverage.md).
|
|
449
|
+
This feature requires a fresh snapshot from 0.7.0 or later (assembly 12); unchanged semantic
|
|
450
|
+
artifacts remain reusable.
|
|
451
|
+
|
|
452
|
+
The CLI also supports paths between two exact IDs:
|
|
453
|
+
|
|
454
|
+
```sh
|
|
455
|
+
weftlet graph paths --snapshot <snapshot-id> --from <node-id> --to <node-id> --direction both --max-depth 8 --json
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
MCP `graph.paths` takes `snapshotId`, `fromNodeId` and `toNodeId`. Direction defaults to outgoing;
|
|
459
|
+
use `predicates` to select relations. `maxPaths` (default 5, up to 20) bounds page results;
|
|
460
|
+
`maxSteps` (default 1000, up to 10000) bounds new candidate-edge examinations. Depth is 1–32;
|
|
461
|
+
the search's total ceiling is 100,000 examinations. Responses report replay work separately.
|
|
462
|
+
Follow `search.continuation` with identical inputs even if a work page contains no completed
|
|
463
|
+
path. Depth cuts and total-work exhaustion remain explicit without pretending all dependencies
|
|
464
|
+
were checked; inspect `frontier` and restart with greater depth or narrower endpoints/relations.
|
|
465
|
+
Paths are deterministic cited associations, not shortest routes or proof of business compatibility.
|
|
466
|
+
The HTML viewer uses the same engine and continuation on its displayed facts and selected layers.
|
|
467
|
+
See [path semantics and limits](docs/ADR-030-bounded-evidence-paths.md).
|
|
468
|
+
|
|
352
469
|
Semantic hydration requires a working configured provider. Direct RDF is the default;
|
|
353
470
|
Docker/openCAESAR is an optional explicit backend. Run `context-graph doctor` for setup diagnostics.
|
|
354
471
|
Committed indexing and ontology input use disposable archives, preserving the active checkout.
|
|
@@ -413,3 +530,53 @@ for observed gaps and the distinction between retrieval measurements and live se
|
|
|
413
530
|
|
|
414
531
|
Apache-2.0. See [LICENSE](LICENSE), [NOTICE](NOTICE), and the
|
|
415
532
|
[source inventory](docs/SOURCE-INVENTORY.md) for attribution and extraction history.
|
|
533
|
+
|
|
534
|
+
## Optional mapping proposals (0.7.0)
|
|
535
|
+
|
|
536
|
+
When an approved document describes a rule and links implementation files without naming the
|
|
537
|
+
function, Weftlet can propose an exact rule-to-function mapping. This is opt-in, unreviewed
|
|
538
|
+
inference; it never approves intent, proves compliance, or adds edges to the saved graph.
|
|
539
|
+
Live model accuracy and usefulness validation are tentative and deferred to acceptance testing.
|
|
540
|
+
The maintainer authorized including this optional feature in the 0.7.0 acceptance candidate;
|
|
541
|
+
existing Codex hydration results do not establish the quality of these new proposals.
|
|
542
|
+
|
|
543
|
+
Create `mapping-request.json` using a saved snapshot and its exact graph IDs:
|
|
544
|
+
|
|
545
|
+
```json
|
|
546
|
+
{
|
|
547
|
+
"snapshotId": "<saved-snapshot-id>",
|
|
548
|
+
"ruleId": "invariant:freshness",
|
|
549
|
+
"documentPath": "docs/owner.md",
|
|
550
|
+
"files": ["src/observations.ts"],
|
|
551
|
+
"maxCandidates": 8,
|
|
552
|
+
"maxInputBytes": 32768
|
|
553
|
+
}
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
```sh
|
|
557
|
+
weftlet mappings plan --request mapping-request.json
|
|
558
|
+
# Review readiness, source/code proofs, exclusions, input size and expected requests.
|
|
559
|
+
weftlet mappings propose --request mapping-request.json --allow-model
|
|
560
|
+
weftlet mappings read --snapshot <saved-snapshot-id> --key <returned-key>
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
No configuration switch enables automatic inference. The proposal command reuses the existing
|
|
564
|
+
`semantic` model, reasoning and explicit authentication selection: Codex ChatGPT login remains
|
|
565
|
+
the default; configured API-key mode is optional. A compatible module must separately export
|
|
566
|
+
`createMappingProposalProvider(config)` with matching `identity` and
|
|
567
|
+
`propose(input, { signal, timeoutMs })`; an ordinary semantic module is insufficient. There is
|
|
568
|
+
one provider request per invocation, no automatic retry, and cache hits require no `--allow-model`.
|
|
569
|
+
Prompt/schema bytes and candidate count are bounded; these do not represent a dollar/token cap.
|
|
570
|
+
|
|
571
|
+
MCP `mapping.plan` returns the same no-model preview; `mapping.proposals` reads a saved result by
|
|
572
|
+
snapshot/key. Neither MCP tool invokes a provider. Agents must treat rationale as untrusted model
|
|
573
|
+
content and follow the cited rule and exact symbol IDs. The CLI reports progress on stderr using
|
|
574
|
+
opaque IDs; `--quiet` suppresses progress. Provider failures preserve all existing graph evidence.
|
|
575
|
+
|
|
576
|
+
Refresh a committed snapshot using this candidate to record code coverage before proposing.
|
|
577
|
+
Missing indexing/ownership, unresolved document selectors and budget overflow block inference.
|
|
578
|
+
Historical evidence stays labeled historical; working edits are excluded and draft-overlay
|
|
579
|
+
proposal generation is not yet supported. Saved artifacts live in the configured graph storage
|
|
580
|
+
under `artifacts/mapping-proposals`; they may contain private rule/code identities and rationale.
|
|
581
|
+
Keep them with the consumer. See [ADR 039](docs/ADR-039-mapping-proposals.md) for exact scope,
|
|
582
|
+
caching and authority, and [the public evaluation protocol](evaluations/mapping-proposals/README.md).
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -20,7 +20,7 @@ Do not edit this file manually.
|
|
|
20
20
|
| `@sourcegraph/scip-typescript` | 0.4.0 | Apache-2.0 | [link](https://github.com/sourcegraph/scip-typescript#readme) |
|
|
21
21
|
| `@traqula/chevrotain` | 1.1.0 | Apache-2.0 | [link](https://github.com/comunica/traqula#readme) |
|
|
22
22
|
| `canonicalize` | 1.0.8, 2.1.0 | Apache-2.0 | [link](https://github.com/erdtman/canonicalize#readme) |
|
|
23
|
-
| `typescript` | 5.9.3 | Apache-2.0 | [link](https://www.typescriptlang.org/) |
|
|
23
|
+
| `typescript` | 5.5.4, 5.9.3 | Apache-2.0 | [link](https://www.typescriptlang.org/) |
|
|
24
24
|
| `lru-cache` | 11.5.3 | BlueOak-1.0.0 | [link](https://github.com/isaacs/node-lru-cache#readme) |
|
|
25
25
|
| `domelementtype` | 2.3.0 | BSD-2-Clause | [link](https://github.com/fb55/domelementtype#readme) |
|
|
26
26
|
| `domhandler` | 5.0.3 | BSD-2-Clause | [link](https://github.com/fb55/domhandler#readme) |
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { SavedGraphExplorationService } from "./saved-exploration.js";
|
|
2
|
+
import { SavedGraphPathService } from './saved-paths.js';
|
|
3
|
+
import { SavedContractCompatibilityService } from './saved-compatibility.js';
|
|
4
|
+
import { SavedCodeCoverageService } from './saved-code-coverage.js';
|
|
1
5
|
import { SavedEvidenceQueryService } from "./saved-evidence.js";
|
|
2
6
|
import { AgentSemanticScopeResolver } from "./agent-context.js";
|
|
3
7
|
import type { ContextGraphAdapter, ContextGraphRepository } from "@weftlet/core";
|
|
@@ -6,6 +10,7 @@ import { ContextGraphHydrator } from "./hydrator.js";
|
|
|
6
10
|
import { OpenCaesarOntologyCompiler, DirectRdfOntologyCompiler } from "../extraction/ontology.js";
|
|
7
11
|
import { FileSnapshotStore } from "../storage/storage.js";
|
|
8
12
|
import { SnapshotChecks } from "./snapshot-checks.js";
|
|
13
|
+
import { MappingProposalService } from './mapping-proposals.js';
|
|
9
14
|
export declare function loadContextGraphAdapterModule(moduleSpecifier: string | undefined, repository: ContextGraphRepository, repositoryRoot?: string): Promise<ContextGraphAdapter>;
|
|
10
15
|
export declare function createContextGraphApplication(configPath: string): Promise<{
|
|
11
16
|
storageRoot: string;
|
|
@@ -14,9 +19,14 @@ export declare function createContextGraphApplication(configPath: string): Promi
|
|
|
14
19
|
ontologyCompiler: OpenCaesarOntologyCompiler | DirectRdfOntologyCompiler;
|
|
15
20
|
hydrator: ContextGraphHydrator;
|
|
16
21
|
queryService: SavedEvidenceQueryService;
|
|
22
|
+
explorationService: SavedGraphExplorationService;
|
|
23
|
+
pathService: SavedGraphPathService;
|
|
24
|
+
compatibilityService: SavedContractCompatibilityService;
|
|
25
|
+
codeCoverageService: SavedCodeCoverageService;
|
|
17
26
|
snapshotChecks: SnapshotChecks;
|
|
18
27
|
scopeResolver: AgentSemanticScopeResolver | undefined;
|
|
19
28
|
headName: string;
|
|
29
|
+
mappingProposalService: MappingProposalService;
|
|
20
30
|
config: import("../configuration/config.js").ContextGraphConfig;
|
|
21
31
|
configPath: string;
|
|
22
32
|
repositoryRoot: string;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
// Modified for standalone extraction; see docs/extraction-manifest.json.
|
|
2
|
+
import { SavedGraphExplorationService } from "./saved-exploration.js";
|
|
3
|
+
import { SnapshotGraphExplorationService } from "../graph/neighborhood.js";
|
|
4
|
+
import { SnapshotGraphPathService } from '../graph/paths.js';
|
|
5
|
+
import { SavedGraphPathService } from './saved-paths.js';
|
|
6
|
+
import { SnapshotContractCompatibilityService } from '../graph/compatibility.js';
|
|
7
|
+
import { SavedContractCompatibilityService } from './saved-compatibility.js';
|
|
8
|
+
import { SnapshotCodeCoverageService } from '../graph/code-coverage.js';
|
|
9
|
+
import { SavedCodeCoverageService } from './saved-code-coverage.js';
|
|
2
10
|
import { SavedEvidenceQueryService } from "./saved-evidence.js";
|
|
3
11
|
import { sha256, stableJson } from "../infrastructure/util.js";
|
|
4
12
|
import { AgentSemanticScopeResolver, PreparedImpactQueryService } from "./agent-context.js";
|
|
@@ -17,6 +25,9 @@ import { OtlpJsonRuntimeEvidenceProvider } from "../extraction/telemetry.js";
|
|
|
17
25
|
import { SnapshotChecks } from "./snapshot-checks.js";
|
|
18
26
|
import { resolveConsumerModule } from "../infrastructure/module-resolution.js";
|
|
19
27
|
import { requiredSnapshotExtractorVersions } from './extraction-identity.js';
|
|
28
|
+
import { MappingProposalService } from './mapping-proposals.js';
|
|
29
|
+
import { FileMappingProposalStore } from '../storage/mapping-proposals.js';
|
|
30
|
+
import { createMappingProvider, mappingProviderIdentity } from '../extraction/mapping-provider.js';
|
|
20
31
|
const emptyAdapter = {
|
|
21
32
|
factExtractors: [],
|
|
22
33
|
invariantEvaluators: [],
|
|
@@ -87,8 +98,17 @@ export async function createContextGraphApplication(configPath) {
|
|
|
87
98
|
ontologyCompiler,
|
|
88
99
|
hydrator,
|
|
89
100
|
queryService,
|
|
101
|
+
explorationService: new SavedGraphExplorationService(new SnapshotGraphExplorationService(snapshotStore), repository, sha256(stableJson(config)), expectedExtractors),
|
|
102
|
+
pathService: new SavedGraphPathService(new SnapshotGraphPathService(snapshotStore), repository, sha256(stableJson(config)), expectedExtractors),
|
|
103
|
+
compatibilityService: new SavedContractCompatibilityService(new SnapshotContractCompatibilityService(snapshotStore), repository, sha256(stableJson(config)), expectedExtractors),
|
|
104
|
+
codeCoverageService: new SavedCodeCoverageService(new SnapshotCodeCoverageService(snapshotStore), repository, sha256(stableJson(config)), expectedExtractors),
|
|
90
105
|
snapshotChecks: new SnapshotChecks(snapshotStore, repository, hydrator, scopeResolver, sha256(stableJson(config)), expectedExtractors),
|
|
91
106
|
scopeResolver,
|
|
92
107
|
headName,
|
|
108
|
+
mappingProposalService: new MappingProposalService(repository, snapshotStore, new FileMappingProposalStore(storageRoot), {
|
|
109
|
+
repositoryId: config.repositoryId, configurationDigest: sha256(stableJson(config)), expectedExtractors,
|
|
110
|
+
providerIdentity: mappingProviderIdentity(config.semantic), timeoutMs: config.semantic.timeoutMs ?? 120_000,
|
|
111
|
+
provider: () => createMappingProvider(config.semantic, repositoryRoot),
|
|
112
|
+
}),
|
|
93
113
|
};
|
|
94
114
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ExtractionContext, GraphFact } from '@weftlet/core';
|
|
2
|
+
import type { ContextGraphConfig } from '../configuration/config.js';
|
|
3
|
+
import type { GitRepository } from '../repository/git.js';
|
|
4
|
+
import type { HydrationInputs } from './hydration-inputs.js';
|
|
5
|
+
import { type BindingSource } from '../extraction/document-code-bindings.js';
|
|
6
|
+
/** Uses the already selected committed scope; validation documents remain separately classified. */
|
|
7
|
+
export declare function assembleDocumentCodeBindings(repository: GitRepository, context: ExtractionContext, inputs: HydrationInputs, config: ContextGraphConfig, codeFacts: readonly GraphFact[], subjectFacts: readonly GraphFact[]): Promise<{
|
|
8
|
+
facts: readonly GraphFact[];
|
|
9
|
+
diagnostics: readonly import("@weftlet/core").GraphDiagnostic[];
|
|
10
|
+
}>;
|
|
11
|
+
export declare function selectedDocumentSources(repository: GitRepository, context: ExtractionContext, inputs: HydrationInputs, config: ContextGraphConfig): Promise<readonly BindingSource[]>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { extractDocumentCodeBindings } from '../extraction/document-code-bindings.js';
|
|
2
|
+
import { matchesRepositoryGlob } from '../repository/glob.js';
|
|
3
|
+
/** Uses the already selected committed scope; validation documents remain separately classified. */
|
|
4
|
+
export async function assembleDocumentCodeBindings(repository, context, inputs, config, codeFacts, subjectFacts) {
|
|
5
|
+
return extractDocumentCodeBindings(repository, context, await selectedDocumentSources(repository, context, inputs, config), codeFacts, subjectFacts);
|
|
6
|
+
}
|
|
7
|
+
export async function selectedDocumentSources(repository, context, inputs, config) {
|
|
8
|
+
const byPath = new Map(inputs.sources.map(source => [source.path, source]));
|
|
9
|
+
const evidence = inputs.documentEvidence;
|
|
10
|
+
const classified = new Map(evidence?.classification.documents.map(document => [document.path, document]));
|
|
11
|
+
const sources = [];
|
|
12
|
+
const paths = evidence ? evidence.traversal.documents.filter(document => document.status === 'read').map(document => document.path) : [...byPath.keys()];
|
|
13
|
+
for (const path of paths) {
|
|
14
|
+
let source = byPath.get(path);
|
|
15
|
+
if (!source) {
|
|
16
|
+
const document = evidence.traversal.documents.find(document => document.path === path);
|
|
17
|
+
source = { path, content: await repository.readFileAt(context.commitSha, path), digest: document.digest, stableSemanticId: `document:${path}` };
|
|
18
|
+
}
|
|
19
|
+
const classification = classified.get(path);
|
|
20
|
+
sources.push({ ...source, metadata: classification ? { sourceAuthority: classification.sourceAuthority,
|
|
21
|
+
sourceRole: classification.sourceRole, sourceOwnership: classification.ownership, sourcePolicyDigest: evidence.classification.policyDigest }
|
|
22
|
+
: { sourceAuthority: config.approvedIntentSources?.some(pattern => matchesRepositoryGlob(path, pattern)) ? 'declared' : 'inferred' } });
|
|
23
|
+
}
|
|
24
|
+
return sources;
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ExtractionContext } from '@weftlet/core';
|
|
2
|
+
import type { ContextGraphConfig } from '../configuration/config.js';
|
|
3
|
+
import type { GitRepository } from '../repository/git.js';
|
|
4
|
+
import type { HydrationInputs } from './hydration-inputs.js';
|
|
5
|
+
export declare function assembleDocumentObligations(repository: GitRepository, context: ExtractionContext, inputs: HydrationInputs, config: ContextGraphConfig): Promise<{
|
|
6
|
+
facts: readonly import("@weftlet/core").GraphFact[];
|
|
7
|
+
diagnostics: readonly import("@weftlet/core").GraphDiagnostic[];
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { selectedDocumentSources } from './document-code-bindings.js';
|
|
2
|
+
import { matchesRepositoryGlob } from '../repository/glob.js';
|
|
3
|
+
import { extractDocumentObligations } from '../extraction/document-obligations.js';
|
|
4
|
+
export async function assembleDocumentObligations(repository, context, inputs, config) {
|
|
5
|
+
const sources = await selectedDocumentSources(repository, context, inputs, config);
|
|
6
|
+
const validation = (path) => config.evidenceRoots.some(root => root === '.' || path === root ||
|
|
7
|
+
path.startsWith(`${root.replace(/\/$/, '')}/`) || matchesRepositoryGlob(path, root) || matchesRepositoryGlob(path, `${root}/**`));
|
|
8
|
+
return extractDocumentObligations(repository, context, sources.map(source => ({ ...source,
|
|
9
|
+
metadata: { ...source.metadata, sourceRole: source.metadata.sourceRole ?? (validation(source.path) ? 'validation' :
|
|
10
|
+
source.metadata.sourceAuthority === 'declared' ? 'intent' : 'unclassified') } })));
|
|
11
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { GraphFact } from '@weftlet/core';
|
|
2
|
+
/** Rewrite proof references after code facts receive draft identities; never retain disposable Git SHAs. */
|
|
3
|
+
export declare function draftFacts(facts: readonly GraphFact[], snapshotId: string, baseSha: string): readonly GraphFact[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { sha256, stableJson } from '../infrastructure/util.js';
|
|
2
|
+
/** Rewrite proof references after code facts receive draft identities; never retain disposable Git SHAs. */
|
|
3
|
+
export function draftFacts(facts, snapshotId, baseSha) {
|
|
4
|
+
const rewritten = new Map();
|
|
5
|
+
const span = (citation) => ({ ...citation, commitSha: baseSha });
|
|
6
|
+
const make = ({ id: previousId, ...fact }) => {
|
|
7
|
+
const rewrite = (binding) => {
|
|
8
|
+
const proofs = (items) => items.map(item => ({ ...item, factId: rewritten.get(item.factId)?.id ?? item.factId, provenance: span(item.provenance) }));
|
|
9
|
+
return { ...binding, documentCitations: binding.documentCitations.map(span), selectedOccurrences: proofs(binding.selectedOccurrences),
|
|
10
|
+
definitions: proofs(binding.definitions), subjectEvidence: binding.subjectEvidence.map(item => {
|
|
11
|
+
const updated = rewritten.get(item.factId);
|
|
12
|
+
return updated ? { factId: updated.id, provenance: updated.provenance,
|
|
13
|
+
...(updated.authority === undefined ? {} : { authority: updated.authority }),
|
|
14
|
+
...(updated.sourceAuthority === undefined ? {} : { sourceAuthority: updated.sourceAuthority }),
|
|
15
|
+
...(updated.extractionReview === undefined ? {} : { extractionReview: updated.extractionReview }) } : item;
|
|
16
|
+
}) };
|
|
17
|
+
};
|
|
18
|
+
const draft = { ...fact, snapshotId, authority: 'draft',
|
|
19
|
+
...(fact.codeBinding || fact.extractor.id === 'routing-declaration-extractor' || fact.sourceRole !== undefined ? { sourceAuthority: 'draft' } : {}),
|
|
20
|
+
...(fact.codeBinding ? { codeBinding: rewrite(fact.codeBinding) } : {}), provenance: span(fact.provenance) };
|
|
21
|
+
if (draft.codeCall) {
|
|
22
|
+
const proofs = (items) => items.map(item => ({
|
|
23
|
+
factId: rewritten.get(item.factId)?.id ?? item.factId, provenance: span(item.provenance)
|
|
24
|
+
}));
|
|
25
|
+
draft.codeCall = { ...draft.codeCall, callerDefinitions: proofs(draft.codeCall.callerDefinitions),
|
|
26
|
+
targetOccurrences: proofs(draft.codeCall.targetOccurrences), targetDefinitions: proofs(draft.codeCall.targetDefinitions) };
|
|
27
|
+
}
|
|
28
|
+
if (draft.contractObligation)
|
|
29
|
+
draft.contractObligation = { ...draft.contractObligation,
|
|
30
|
+
endpointSource: span(draft.contractObligation.endpointSource) };
|
|
31
|
+
const result = { ...draft, id: sha256(stableJson(draft)) };
|
|
32
|
+
rewritten.set(previousId, result);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
return [...facts.filter(fact => !fact.codeBinding && !fact.codeCall).map(make),
|
|
36
|
+
...facts.filter(fact => fact.codeCall).map(make), ...facts.filter(fact => fact.codeBinding).map(make)];
|
|
37
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContextGraphConfig } from '../configuration/config.js';
|
|
2
|
-
export declare const graphAssemblyVersion =
|
|
3
|
-
export declare const graphAssemblyIdentity = "standalone-graph-
|
|
2
|
+
export declare const graphAssemblyVersion = 12;
|
|
3
|
+
export declare const graphAssemblyIdentity = "standalone-graph-v12";
|
|
4
4
|
export declare function documentExtractionVersions(config?: Pick<ContextGraphConfig, 'documentTraversal'>): Readonly<Record<string, string>>;
|
|
5
5
|
/** Runtime expectations are separate from source/configuration identity and artifact reuse. */
|
|
6
6
|
export declare function requiredSnapshotExtractorVersions(config?: Pick<ContextGraphConfig, 'routingSources' | 'documentTraversal'>): Readonly<Record<string, string>>;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { documentCodeBindingIdentity } from '../extraction/document-code-bindings.js';
|
|
2
|
+
import { staticCallIdentity } from '../extraction/static-calls.js';
|
|
3
|
+
import { documentObligationIdentity } from '../extraction/document-obligations.js';
|
|
1
4
|
import { repositoryContractExtractorIdentity, scipSymbolExtractorIdentity } from '../extraction/static.js';
|
|
2
5
|
import { routingExtractorIdentity } from '../extraction/routing.js';
|
|
3
6
|
import { documentEvidenceExtractorIdentity } from '../extraction/document-evidence.js';
|
|
4
7
|
import { documentSelectionIdentity } from './hydration-inputs.js';
|
|
5
|
-
export const graphAssemblyVersion =
|
|
8
|
+
export const graphAssemblyVersion = 12;
|
|
6
9
|
export const graphAssemblyIdentity = `standalone-graph-v${graphAssemblyVersion}`;
|
|
7
10
|
export function documentExtractionVersions(config) {
|
|
8
11
|
return config?.documentTraversal ? { 'document-selection': documentSelectionIdentity,
|
|
@@ -11,6 +14,9 @@ export function documentExtractionVersions(config) {
|
|
|
11
14
|
/** Runtime expectations are separate from source/configuration identity and artifact reuse. */
|
|
12
15
|
export function requiredSnapshotExtractorVersions(config) {
|
|
13
16
|
return { assembly: graphAssemblyIdentity,
|
|
17
|
+
[documentCodeBindingIdentity.id]: documentCodeBindingIdentity.version,
|
|
18
|
+
[staticCallIdentity.id]: staticCallIdentity.version,
|
|
19
|
+
[documentObligationIdentity.id]: documentObligationIdentity.version,
|
|
14
20
|
...documentExtractionVersions(config),
|
|
15
21
|
[repositoryContractExtractorIdentity.id]: repositoryContractExtractorIdentity.version,
|
|
16
22
|
[scipSymbolExtractorIdentity.id]: scipSymbolExtractorIdentity.version,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExtractionContext, FactExtractor } from '@weftlet/core';
|
|
2
|
+
/** Stateless per-invocation results retain adapter gaps without changing existing adapters. */
|
|
3
|
+
export declare function extractEvidence(extractors: readonly FactExtractor[], context: ExtractionContext): Promise<{
|
|
4
|
+
facts: import("@weftlet/core").GraphFact[];
|
|
5
|
+
diagnostics: import("@weftlet/core").GraphDiagnostic[];
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Stateless per-invocation results retain adapter gaps without changing existing adapters. */
|
|
2
|
+
export async function extractEvidence(extractors, context) {
|
|
3
|
+
const results = await Promise.all(extractors.map(async (extractor) => extractor.extractWithDiagnostics
|
|
4
|
+
? extractor.extractWithDiagnostics(context) : { facts: await extractor.extract(context), diagnostics: [] }));
|
|
5
|
+
return { facts: results.flatMap(result => result.facts), diagnostics: results.flatMap(result => result.diagnostics) };
|
|
6
|
+
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { scipSourcePatterns } from '../configuration/scip-project.js';
|
|
2
|
+
import { buildCodeInventory } from '../extraction/code-inventory.js';
|
|
2
3
|
import { contractPatternRoots } from "../repository/glob.js";
|
|
3
4
|
import { repositoryFileExtractorIdentity, repositoryContractExtractorIdentity, scipSymbolExtractorIdentity } from '../extraction/static.js';
|
|
4
5
|
import { sha256, stableJson } from "../infrastructure/util.js";
|
|
6
|
+
import { assembleDocumentCodeBindings } from './document-code-bindings.js';
|
|
7
|
+
import { documentCodeBindingIdentity } from '../extraction/document-code-bindings.js';
|
|
8
|
+
import { documentObligationIdentity } from '../extraction/document-obligations.js';
|
|
9
|
+
import { assembleDocumentObligations } from './document-obligations.js';
|
|
10
|
+
import { staticCallIdentity } from '../extraction/static-calls.js';
|
|
11
|
+
import { extractEvidence } from './extractor-results.js';
|
|
5
12
|
import { documentLinkerIdentity, linkSemanticDocuments } from "../extraction/document.js";
|
|
6
13
|
import { repositoryNodeIdentityVersion } from '../extraction/repository-nodes.js';
|
|
7
14
|
import { selectHydrationInputs, classifyHydratedFacts, documentSelectionIdentity } from './hydration-inputs.js';
|
|
@@ -114,6 +121,7 @@ export class ContextGraphHydrator {
|
|
|
114
121
|
};
|
|
115
122
|
// Validate committed routing inputs before invoking any provider or indexer.
|
|
116
123
|
const routing = await extractRoutingDeclarations(repository, context, config.routingSources ?? []);
|
|
124
|
+
const obligations = await assembleDocumentObligations(repository, context, selection, config);
|
|
117
125
|
const { hydrated, semanticExtracted, semanticReused } = await hydrateSemanticSources({
|
|
118
126
|
sources, context, config: config.semantic, configurationDigest,
|
|
119
127
|
hydrator: this.dependencies.semanticHydrator, forceRevision,
|
|
@@ -147,7 +155,10 @@ export class ContextGraphHydrator {
|
|
|
147
155
|
checkpoint();
|
|
148
156
|
options.onProgress?.({ phase: 'index-typescript' });
|
|
149
157
|
const scip = await this.dependencies.staticIndexer.index(context);
|
|
150
|
-
const
|
|
158
|
+
const codeInventory = buildCodeInventory(await repository.listEntriesAt(commitSha), await repository.listFilesAt(commitSha, config.codeRoots), config.codeRoots, config.scip.sourceProject, scip);
|
|
159
|
+
const extracted = await extractEvidence(this.dependencies.extractorFactory(scip), context);
|
|
160
|
+
const extractorFacts = extracted.facts;
|
|
161
|
+
diagnostics.push(...extracted.diagnostics);
|
|
151
162
|
const trackedPaths = await repository.listAllFilesAt(commitSha);
|
|
152
163
|
const tracked = new Set(trackedPaths);
|
|
153
164
|
for (const fact of semanticFacts) {
|
|
@@ -163,14 +174,15 @@ export class ContextGraphHydrator {
|
|
|
163
174
|
}
|
|
164
175
|
}
|
|
165
176
|
const documents = linkSemanticDocuments(context, hydrated, trackedPaths, sources.filter((source) => config.approvedIntentSources?.some((pattern) => matchesRepositoryGlob(source.path, pattern))).map((source) => source.path), { canonicalReferences: !config.documentTraversal });
|
|
166
|
-
|
|
177
|
+
const bindings = await assembleDocumentCodeBindings(repository, context, selection, config, extractorFacts, [...semanticFacts, ...extractorFacts, ...routing.facts, ...obligations.facts]);
|
|
178
|
+
diagnostics.push(...documents.diagnostics, ...bindings.diagnostics, ...obligations.diagnostics);
|
|
167
179
|
diagnostics.push(...routing.diagnostics, ...(selection.documentEvidence?.diagnostics ?? []));
|
|
168
180
|
checkpoint();
|
|
169
181
|
const runtimeEvidence = runtimeRevision.references;
|
|
170
182
|
const runtimeFacts = runtimeEvidenceFacts(context, runtimeEvidence);
|
|
171
183
|
const structuralFacts = selection.documentEvidence?.facts.map(fact => ({ ...fact, snapshotId })) ?? [];
|
|
172
184
|
const facts = [...semanticFacts, ...classifyHydratedFacts(documents.facts, selection.documentEvidence),
|
|
173
|
-
...structuralFacts, ...extractorFacts, ...routing.facts, ...runtimeFacts].sort((left, right) => left.id.localeCompare(right.id));
|
|
185
|
+
...structuralFacts, ...extractorFacts, ...bindings.facts, ...routing.facts, ...obligations.facts, ...runtimeFacts].sort((left, right) => left.id.localeCompare(right.id));
|
|
174
186
|
const validationCounts = { factCount: facts.length };
|
|
175
187
|
await measureValidationPhase('validate-identities', validationCounts, options.onProgress, () => {
|
|
176
188
|
const report = assertGraphIdentities(facts, {
|
|
@@ -207,6 +219,7 @@ export class ContextGraphHydrator {
|
|
|
207
219
|
unresolved,
|
|
208
220
|
diagnostics,
|
|
209
221
|
semanticSources: selectedSemanticSources,
|
|
222
|
+
codeInventory,
|
|
210
223
|
...(selection.documentSelection ? { documentSelection: selection.documentSelection } : {}),
|
|
211
224
|
};
|
|
212
225
|
const contentDigest = sha256(stableJson(logical));
|
|
@@ -220,6 +233,7 @@ export class ContextGraphHydrator {
|
|
|
220
233
|
snapshotId,
|
|
221
234
|
configurationDigest,
|
|
222
235
|
scope: scopePaths,
|
|
236
|
+
codeInventory,
|
|
223
237
|
...(selection.documentSelection ? { documentSelection: selection.documentSelection } : {}),
|
|
224
238
|
ontologyVersion: config.semantic.ontologyVersion,
|
|
225
239
|
extractorVersions: {
|
|
@@ -227,8 +241,11 @@ export class ContextGraphHydrator {
|
|
|
227
241
|
...documentExtractionVersions(config),
|
|
228
242
|
[repositoryContractExtractorIdentity.id]: repositoryContractExtractorIdentity.version,
|
|
229
243
|
[scipSymbolExtractorIdentity.id]: scipSymbolExtractorIdentity.version,
|
|
244
|
+
[staticCallIdentity.id]: staticCallIdentity.version,
|
|
230
245
|
'repository-node-identity': String(repositoryNodeIdentityVersion),
|
|
231
246
|
[documentLinkerIdentity.id]: documentLinkerIdentity.version,
|
|
247
|
+
[documentCodeBindingIdentity.id]: documentCodeBindingIdentity.version,
|
|
248
|
+
[documentObligationIdentity.id]: documentObligationIdentity.version,
|
|
232
249
|
...(config.routingSources?.length ? { [routingExtractorIdentity.id]: routingExtractorIdentity.version } : {}),
|
|
233
250
|
semantic: config.semantic.extractorVersion,
|
|
234
251
|
scip: scip.version,
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ContextPack, MappingProposalArtifact, MappingProposalProvider, MappingProposalRequest, MappingProposalStore, SnapshotStore } from '@weftlet/core';
|
|
2
|
+
import type { GitRepository } from '../repository/git.js';
|
|
3
|
+
export interface MappingOperationOptions {
|
|
4
|
+
readonly allowModel?: boolean;
|
|
5
|
+
readonly signal?: AbortSignal;
|
|
6
|
+
readonly onProgress?: (event: {
|
|
7
|
+
phase: 'plan' | 'reuse' | 'provider' | 'validate' | 'saved';
|
|
8
|
+
operationId: string;
|
|
9
|
+
elapsedMs: number;
|
|
10
|
+
}) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare class MappingProposalService {
|
|
13
|
+
private readonly repository;
|
|
14
|
+
private readonly snapshots;
|
|
15
|
+
private readonly artifacts;
|
|
16
|
+
private readonly settings;
|
|
17
|
+
constructor(repository: GitRepository, snapshots: Pick<SnapshotStore, 'read'>, artifacts: MappingProposalStore, settings: {
|
|
18
|
+
repositoryId: string;
|
|
19
|
+
configurationDigest: string;
|
|
20
|
+
expectedExtractors: Readonly<Record<string, string>>;
|
|
21
|
+
providerIdentity: string;
|
|
22
|
+
timeoutMs: number;
|
|
23
|
+
provider: () => MappingProposalProvider;
|
|
24
|
+
});
|
|
25
|
+
private snapshot;
|
|
26
|
+
private evidence;
|
|
27
|
+
private key;
|
|
28
|
+
private validate;
|
|
29
|
+
plan(value: MappingProposalRequest): Promise<{
|
|
30
|
+
evidenceState: {
|
|
31
|
+
readonly currentCommit?: string;
|
|
32
|
+
readonly excludedWorkingChanges: readonly string[];
|
|
33
|
+
readonly capturedWorkingChanges?: readonly string[];
|
|
34
|
+
readonly changedSinceCapture?: readonly string[];
|
|
35
|
+
readonly overlayFreshness?: "current" | "stale" | "unknown";
|
|
36
|
+
readonly stale: boolean;
|
|
37
|
+
readonly configurationMatches: boolean;
|
|
38
|
+
readonly extractionCompatible?: boolean;
|
|
39
|
+
readonly incompatibleExtractors?: readonly string[];
|
|
40
|
+
readonly eligibleForCurrentDiffValidation: false;
|
|
41
|
+
};
|
|
42
|
+
key: string;
|
|
43
|
+
cached: boolean;
|
|
44
|
+
expectedModelRequests: number;
|
|
45
|
+
timeoutMs: number;
|
|
46
|
+
automaticRetries: number;
|
|
47
|
+
markdown: string;
|
|
48
|
+
ready: boolean;
|
|
49
|
+
issues: {
|
|
50
|
+
readonly code: string;
|
|
51
|
+
readonly path?: string;
|
|
52
|
+
}[];
|
|
53
|
+
version: "mapping-proposal-v1";
|
|
54
|
+
request: Required<MappingProposalRequest>;
|
|
55
|
+
snapshot: ContextPack["snapshot"];
|
|
56
|
+
snapshotDigest: string;
|
|
57
|
+
subjectEvidence: readonly import("@weftlet/core").GraphFact[];
|
|
58
|
+
associations: readonly import("@weftlet/core").GraphFact[];
|
|
59
|
+
candidates: readonly import("@weftlet/core").MappingCandidate[];
|
|
60
|
+
candidateEnumeration: {
|
|
61
|
+
readonly complete: boolean;
|
|
62
|
+
readonly observed: number;
|
|
63
|
+
readonly returned: number;
|
|
64
|
+
};
|
|
65
|
+
excluded: readonly {
|
|
66
|
+
readonly path: string;
|
|
67
|
+
readonly reason: string;
|
|
68
|
+
readonly count: number;
|
|
69
|
+
}[];
|
|
70
|
+
inputBytes: number;
|
|
71
|
+
inputDigest: string;
|
|
72
|
+
}>;
|
|
73
|
+
read(snapshotId: string, key: string): Promise<{
|
|
74
|
+
artifact: MappingProposalArtifact;
|
|
75
|
+
reused: boolean;
|
|
76
|
+
evidenceState: {
|
|
77
|
+
readonly currentCommit?: string;
|
|
78
|
+
readonly excludedWorkingChanges: readonly string[];
|
|
79
|
+
readonly capturedWorkingChanges?: readonly string[];
|
|
80
|
+
readonly changedSinceCapture?: readonly string[];
|
|
81
|
+
readonly overlayFreshness?: "current" | "stale" | "unknown";
|
|
82
|
+
readonly stale: boolean;
|
|
83
|
+
readonly configurationMatches: boolean;
|
|
84
|
+
readonly extractionCompatible?: boolean;
|
|
85
|
+
readonly incompatibleExtractors?: readonly string[];
|
|
86
|
+
readonly eligibleForCurrentDiffValidation: false;
|
|
87
|
+
} | undefined;
|
|
88
|
+
markdown: string;
|
|
89
|
+
}>;
|
|
90
|
+
private report;
|
|
91
|
+
propose(value: MappingProposalRequest, options?: MappingOperationOptions): Promise<{
|
|
92
|
+
artifact: MappingProposalArtifact;
|
|
93
|
+
reused: boolean;
|
|
94
|
+
evidenceState: {
|
|
95
|
+
readonly currentCommit?: string;
|
|
96
|
+
readonly excludedWorkingChanges: readonly string[];
|
|
97
|
+
readonly capturedWorkingChanges?: readonly string[];
|
|
98
|
+
readonly changedSinceCapture?: readonly string[];
|
|
99
|
+
readonly overlayFreshness?: "current" | "stale" | "unknown";
|
|
100
|
+
readonly stale: boolean;
|
|
101
|
+
readonly configurationMatches: boolean;
|
|
102
|
+
readonly extractionCompatible?: boolean;
|
|
103
|
+
readonly incompatibleExtractors?: readonly string[];
|
|
104
|
+
readonly eligibleForCurrentDiffValidation: false;
|
|
105
|
+
} | undefined;
|
|
106
|
+
markdown: string;
|
|
107
|
+
}>;
|
|
108
|
+
}
|