mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-16 23:43:12 +00:00
Extract the SemanticModel reconciliation pass (previously inline in
`pipeline/run.ts`) into a dedicated module with:
* `reconcileOwnership(parsedFiles, model)` — pure function returning
stats (methodsRegistered / fieldsRegistered / skippedAlreadyPresent).
Idempotent; safe to re-run.
* `validateOwnershipParity(parsedFiles, model, onWarn)` — dev-mode
runtime validator for Contract Invariant I9. Walks every def with
an `ownerId` and asserts it is reachable via
`model.methods.lookupAllByOwner` or `model.fields.lookupFieldByOwner`.
Soft-fails via `onWarn`; never throws.
Validator is gated on both `NODE_ENV !== 'production'` and
`VALIDATE_SEMANTIC_MODEL !== '0'` so production incurs zero cost but
development surfaces any drift between `parsed.localDefs` ownership and
the registries.
12 new unit tests cover:
* happy path: method, property, Variable registration
* edge case: defs without ownerId are skipped
* idempotency: second call is a no-op
* coexistence: defs the legacy extractor already registered (via
`model.symbols.add`) are skipped on reconcile
* overloads: multiple methods under the same (owner, name)
* validator: no warnings after reconciliation
* validator: warns on drift
* validator: no-op under NODE_ENV=production
* validator: no-op when VALIDATE_SEMANTIC_MODEL=0
* validator: warns on missing Property same as missing Method
Verified:
- npx tsc --noEmit clean
- reconcile-ownership unit tests 12/12 passing
- C# + Python integration 393/393 passing
|
||
|---|---|---|
| .. | ||
| fixtures | ||
| helpers | ||
| integration | ||
| unit | ||
| utils | ||
| global-setup.ts | ||
| vitest.d.ts | ||