Repository navigation
refactor(vba): replace the positional extractor parameters with an options object - #271
Merged
Merged
Conversation
…tions object The VBA extraction knobs travelled as positional parameters through five files (project-config -> extraction/index -> parse-pool -> parse-worker -> tree-sitter -> vba-extractor). Adding one knob meant editing every signature and every call site. Introduce the leaf module `src/extraction/vba/options.ts` exporting `VbaExtractionOptions` (`targets`, `maxRaiseFanout`, `sqlWrappers`) and thread that ONE object end to end: - `VbaExtractor` takes `options` as its 3rd parameter. The positional 3rd/4th form is kept working through a `@deprecated` overload for one release; every in-repo call site moves to the object form. - `extractFromSource` gains a trailing `vbaOptions`; the legacy positionals merge into it per field, with the object winning. - `ParseTask` and the worker message carry `vbaOptions` as one field. `sqlWrappers` is declared and threaded now; the SQL-wrapper task consumes it. The object stays plain structured-cloneable data because it crosses the `structuredClone`-based parse-worker boundary — no functions, no RegExp, no Map. A compiled matcher belongs on the extractor context. Pure refactor: the VBA coverage probe over 00_EXPEDIENTES and 00_GESTION_RIESGOS is byte-identical to main.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #243
What
The VBA extraction knobs travelled as positional parameters through five files:
Adding
vba.sqlWrappersas the next knob meant touching all five again. This collapses the chain onto one object.src/extraction/vba/options.tsexportingVbaExtractionOptionswithtargets,maxRaiseFanout,sqlWrappers. It imports nothing, so the config layer, the pool, the worker and the extractor can all depend on it without a cycle.VbaExtractortakesoptions: VbaExtractionOptions = {}as its 3rd parameter. The positional 3rd/4th form still works through a@deprecatedoverload for one release; every in-repo call site moved to the object form in this PR (including__tests__/extraction-vba-event-fanout.test.ts).extractFromSourcegains a trailingvbaOptions?: VbaExtractionOptions. The legacyvbaTargets/maxRaiseFanoutpositionals merge into it per field, object wins on conflict.ParseTaskand the worker message carryvbaOptionsas ONE field, replacing the two separate ones.sqlWrappersis declared and threaded end to end now; the SQL-wrapper task is its consumer.Overload disambiguation
The implementation signature receives either an options object or a legacy
Record<string, boolean>targets map as its 3rd argument. The runtime discriminator is the value types, not the key names: a targets map has only boolean values;VbaExtractionOptionsnever does (targetsis an object,maxRaiseFanouta number,sqlWrappersan array). So a project that happens to name a#Consttargetsis still read correctly.{}is vacuously "all booleans" and is read as an empty legacy targets map — which is behaviourally identical to empty options, because an empty targets map andundefinedboth mean "no project overrides" topreprocessConditionalCompilation, and an absentmaxRaiseFanoutfalls back toDEFAULT_MAX_RAISE_FANOUTeither way.Worker-boundary constraint
The
parse-pool->parse-workerhop isstructuredClone-based, soVbaExtractionOptionsis plain data: no functions, noRegExp, noMap, no class instances. The module docstring states the rule for whoever adds field four; a compiled wrapper matcher belongs on the extractor context, built inside the extractor from the plain strings insqlWrappers.No CHANGELOG entry
This is a pure refactor with no user-visible change: no new config key is read, no output differs, no CLI surface moves. Per the repo's CHANGELOG discipline there is deliberately no entry.
Tests
New
__tests__/extraction-vba-options.test.ts— 13 tests, real files, real extractor, a realworker_threads.Worker, no mocking:ExtractionResult(ignoring only the wall-clockdurationMsandNode.updatedAt), for bothVbaExtractorandextractFromSourcetargetsis verified to actually do something in the same assertion (#If DEVgates aDevOnlySub), so an equal-and-both-wrong result cannot pass{}, no arguments, and explicit-undefinedpositionals are pinned as the same runmaxRaiseFanoutregression guard for fix(vba): fanout cap for generic event names (Change/Click/AfterUpdate/etc.) to suppress graph noise #152: over the threshold drops everyraises-eventedge and flagshighFanout/raiseCount; at the threshold every edge survives (strict>); object and positional forms gate identicallystructuredClone(options)round-trips unchangedworker_threads.Workerspeaking the pool's{load-grammars -> grammars-loaded}/{parse -> parse-result}protocol echoes thevbaOptionsit received back across the boundary. Both hops are genuinestructuredClones, so this fails the moment a non-cloneable value is added to the interface. An omittedvbaOptionsis pinned as arrivingundefined, not as a mangled object.Verification
45 files is the 44-file baseline on
mainplus the one file this PR adds. Nothing else moved.__tests__/extraction.test.tshas 2 pre-existing failures in the "Git Submodules" / "Nested gitlink repos" blocks. They reproduce identically on a cleanmaincheckout and are unrelated to this change.Zero behaviour change: identical probe output
The committed probe was run over the same two real Access source trees from a clean
maincheckout and from this branch:The two reports are byte-identical —
diffis empty and the SHA-256 of both files is6e8084ded2a4901fb5efaceffe7ac5ff4e761d9beb7a3115fbb52b8f39832f86.classnodescallsedgescontainsedgesreferencesedgesevent-handleredgescallsEvery other field in the report (files by extension, all 15 node kinds, edges by synthesizer, the top-30 stub targets, SQL tables, forms, errors) is identical too — that is what byte-identical means here.