One parse / one write path + write-path consistency check - #385
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #385 +/- ##
============================================
+ Coverage 98.23% 98.25% +0.02%
- Complexity 1725 1728 +3
============================================
Files 111 111
Lines 4356 4360 +4
============================================
+ Hits 4279 4284 +5
+ Misses 77 76 -1 ☔ View full report in Codecov by Harness. |
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.
Slice
docs/architecture/0002-execution-plan.md)0001-foundational-architecture.md§4.3 (Read/Write Segregation — exactly one write path), §5.2 (SymbolSink write contract)What this does
Collapses the sink's double write into one parse feeding both stores, and adds a
consistency guard so the two structures cannot silently diverge.
Before,
DocumentSymbolSink::write()registered class metadata and indexed symbolsvia two independent code paths, each of which parsed the document (the content-keyed
parse memo made this one actual parse, but two parse calls / two extraction
entries). Now the sink parses once and feeds that single AST to both the class-lookup
registration and the symbol index:
DocumentIndexer::indexParsed(TextDocument, array $ast)indexes a supplied ASTinstead of reparsing;
index()is nowparse()→indexParsed(). The sink drivesthe index through
indexParsed, so the indexer no longer reparses.ClassInfofor lookup, lightweight
Symbols for enumeration/search), but are writtentransactionally from the one AST.
Because the Step P parity harness compares only observable outputs, an internal
divergence between the two structures could pass parity.
assertStoresAgree()guardsthe invariant directly: every class-like registered for lookup must also be present in
the symbol index, so a name is never resolvable through one surface yet invisible to
the other. The check is one-directional — the index is a legitimate superset (it also
records class-likes declared inside conditional/nested statements, which the top-level
lookup registration does not), so the reverse would false-positive on valid PHP. The
divergence branch is an unreachable
LogicException.This discharges the Teardown-ledger row "Step 2 facade hides today's double write
(§5.5) → Step 3a(iv)": the scaffolding was the double write inside the sink (S3.3
already replaced the illustrative
DelegatingSymbolSourcewithDocumentSymbolSink),now collapsed.
Behavior-preserving (Step 3a): the Step P parity goldens (class-like lookup,
childrenOf, prefix-search, write-path symbol state) are unchanged and the full suiteis green. The consistency guard is a new internal invariant, so it carries its own
unit coverage rather than a parity golden.
Acceptance criteria
didOpen/didChangewrite, feeding both stores (the sink parses; the indexer no longer reparses —indexParsed)assertStoresAgree)Candidate closes
None — the manifest lists no
Closesfor S3.4.