Repository navigation
feat(irfacts): derive a correlation key for every entity - #1354
Open
OmarAlJarrah wants to merge 8 commits into
Open
OmarAlJarrah wants to merge 8 commits into
OmarAlJarrah wants to merge 8 commits into
Conversation
An ID is a function of where an entity sits in the source, so it holds across revisions only while that position does, and an array index can hand an old ID to a different entity. The golden spec's own history has one: the organization accounts listing's tenth parameter schema is the direction parameter's at one revision and the status parameter's at the next. irfacts.Index.Correlation now answers what an entity of any class is called across revisions, and Correlated the reverse, as docs/ir/derived-facts.md designs it. A named entity is keyed by its name. Everything else is keyed by the least key among the positions naming it, settled in key order as a shortest-path search settles the nearest vertex. A key two entities share keys neither and nothing through them, since a wrong match is what the key exists to prevent. On the golden spec every operation, parameter, group, server and auth scheme gets a key, as do 91% of types, 96% of properties and 92% of enum members. All but two of the rest sit beneath a union variant nothing names. Deriving every key takes about 200 ms.
3 of 4 tasks
4 of 5 tasks
…feat/irfacts-correlation-keys
5 of 6 tasks
Naming correlation keys took the package comment to 106 words.
…feat/irfacts-correlation-keys
5 of 6 tasks
Promoted fields in the test literals, preallocated slices and a slices.Backward loop, as modernize and prealloc ask.
The modernize linter's embedlit check flags each type literal that names its embedded TypeCommon; the fixtures now set ID, Name and Anonymous directly, as the rest of the module does.
17 tasks done
…feat/irfacts-correlation-keys
This was referenced Nov 2, 2026
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.
Summary
An ID is a function of where its entity sits in the source. Across two revisions it therefore holds only while that position holds, and an array index can hand an old ID to a different entity. The golden spec's own history has a case. At revision b7e65ddd,
t/anon/paths/~1organizations~1{organization_id}~1accounts/get/parameters/10/schemais thedirectionparameter's schema; at 319dc756 it is thestatusparameter's. A consumer keying state by ID, such as an emitter's prior manifest, would give one the other's name.This builds the correlation key that
docs/ir/derived-facts.md#correlation-keysdesigns (the design lands in #1351, this PR's base):irfacts.Index.Correlation(id)returns what an entity of any ID class is called across revisions.Correlated(key)returns the reverse, so matching two revisions takes one call on each side.operationId, else its method and route with variables erased (a webhook by its event name). A type by its namespace and name, a primitive by its kind, and a service or auth scheme by its name. A group is keyed by its ID, which is never built from a position.irfactsfact is.Measured on the golden spec (spec @319dc756, IR from morphic @b206dc99):
Building against the golden spec corrected three rows of the design, which went back onto #1351. Its servers share URL templates, so the scope keys a server too. A header carries a property ID of its own. And a wire name declared twice in one composed model keys the declaration the flattening takes, rather than neither.
The docs that cited #679 now link the section:
architecture.md,prior-art.md,reference-learnings.md. So do the consumers page (now "carried"), the package lists inCLAUDE.mdandREADME.md, and the emitter contract'sFactscomment.Closes #679
The second commit replaces a local wire-name helper with
ir.Property.EffectiveWireName; its subject is 78 characters with this PR's number appended. A later commit spelling the test fixtures with promoted fields is 74 with it. The branch has several commits, so the PR lands under its title, which fits.Stack
Base: #1351, itself stacked on the emitter-design stack ending at #1339. Merge in order. GitHub retargets each PR after its base lands, and "Update branch" merges cleanly.
Test plan
go test ./ir/irfacts -run TestCorrelation: each named class, every position class, the depth bound on groups, callbacks under named and unnamed parents, in-place conjuncts, all three variant naming rules, a shared key, and the least-position rule in both declaration orders.morphic compileoutput. The probe also caught headers being keyed only through their types.mainor the base,skills_lintclean; the two subjects past 72 characters with the number are named above.apiRootsnames the two methods), and coverage.