Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(semantic): read standalone featuring declarations as featuring types - #2804

Open
HuiJun wants to merge 123 commits into
developfrom
fix/standalone-featuring-types
Open

HuiJun wants to merge 123 commits into
developfrom
fix/standalone-featuring-types

Conversation

@HuiJun

@HuiJun HuiJun commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

A featuring type can be stated on the feature (feature g featured by T;) or by a declaration of its own (featuring g by T;, featuring tf of g by T;). Model.FeaturingTypes read only the first, so Feature::featuringType was missing the second and nothing that depends on it saw T.

The semantic model now gathers the standalone featuring declarations of each document and indexes their resolved ends by the featured feature, in a shared frame dropped when a contributing document changes. Model.FeaturingTypes adds those types to the inline ones.

The reflective reads of Feature::featuringType agree with it: GetElementProperties (the metamodel evaluator over the model's symbols) and the api-json element form read every TypeFeaturing of the feature. The evaluator takes the standalone declarations from the semantic model's own index (Model.StandaloneTypeFeaturings), and the api-json writer from the graph's TypeFeaturing elements; the stated featured by clauses stay in sysx:mappingValues.

Effect on diagnostics, for a feature g featured by T through a standalone declaration and used from a type that does not conform to T:

Position Before After
feature v subsets g; accepted subsetting-featuring-types
feature v redefines g; accepted redefinition-no-inherited
feature v = g; (reference) accepted accepted
connector c from g to h; accepted accepted

Fixes #2790

Pilot divergence

The pinned pilot (0.63.1) accepts the standalone form in all four positions and rejects the inline form in all four.

  • Subsetting and redefinition: this PR diverges from the pilot, on purpose. KerML 8.3.3.3.4 deriveFeatureFeaturingType derives featuringType from typeFeaturing.type, every TypeFeaturing of the feature and not only ownedTypeFeaturing. KerML 8.3.3.3.10 validateSubsettingFeaturingTypes is a normative constraint over featuringType, and a Redefinition is a Subsetting. So both are rejected here where the pilot is permissive. The two shapes are recorded in the rejection oracle as semantic/k80-subsets-feature-featured-by-standalone-featuring.kerml and semantic/k81-redefines-feature-featured-by-standalone-featuring.kerml, bucket ours-only-rejects (358 cases, 346 both reject, 12 only we reject).

  • Reference and connector end: kept pilot-aligned. The accessibility of a feature reference is the pilot's FeatureUtil.canAccess applied to a reference, not a normative KerML constraint, and the pilot does not apply it to a standalone featuring. constraintChecker.featuringOwners is unchanged from develop, so these two positions read the inline clause alone. The connector-end rule (8.3.4.5.3) is normative, so that position is a known inconsistency left for the reviewer to rule on.

  • api-json featuringType: diverges from the pilot's export, on purpose. For feature g; featuring g by T; and feature h; featuring tf of h by T; the pilot's export states the TypeFeaturing element with featureOfType and featuringType set, and answers featuringType = [] on the feature. For feature i featured by U; featuring i by T; it answers [U], and for a nested A::m with featuring A::m by T; it answers [A]. Under 8.3.3.3.4 the feature's featuringType includes T in each case, and that is what this PR writes. One row of the committed differential moves, re-recorded with pilot-apijson-diff -update: Feature.featuringType in kerml-examples/Simple Tests/Features.kerml (feature y; featuring F of y by C;), absent-both 13 → 12 and pilot-missing 0 → 1; overall absent-both 2642516 → 2642515 and pilot-missing 92358 → 92359. No element match moved. docs/project/api-json-differential.md records the reason.

  • Combined with the member-feature accessibility rule already on develop: pilot-aligned. A reference or connector end naming a feature a type holds as a member, where a standalone featuring also names that feature, is accepted as the pilot accepts it; a standalone control still reports only the one feature-reference-featuring-types diagnostic the pilot reports. TestMemberFeatureWithStandaloneFeaturing* in internal/check/passes/member_feature_standalone_featuring_test.go fail without the change.

Read surfaces

  • api-json across documents. The writer works from the written graph. A standalone featuring of n by Lib::T; in a written document writes Lib::T by id even when Lib is not written, as an inline featured by Lib::T does, and a feature with both forms writes both. A feature whose only featuring declaration sits in an unwritten document has no featuringType: the declaration is no part of the graph, the same rule as an annotation from an unwritten document. No RDF predicate was added. A featuring naming a feature of an unwritten document no longer drops featuringType from the written features. docs/reference/rdf-mapping.md states the rule beside the featuringType row.
  • Against the external-form featuringType derivation that landed on develop meanwhile. The merge has no textual conflict. The standalone fallback is entered only for Feature::featuringType when the derived read is unavailable, and adds only the types of standalone TypeFeaturing elements present in the graph; develop's external-graph and interchange tests pass unchanged. On a model with the four standalone shapes the only difference from develop's export is the added standalone types (g: [T], h: [U], C::c: [U, C], k: [U, T]).
  • Owning type of a nested feature. When a nested feature's featuring type, stated inline (feature h featured by Lib::T;) or standalone (featuring K::g by Lib::T;), is in an unwritten document, api-json wrote [Lib::T] without the owning classifier; it now writes [Lib::T, K] for both forms, as it does when the whole model is written. When the type does not resolve at all (the using file converted alone), featuringType was empty for both forms, where develop wrote [K] for the standalone one; both now write [K], and the unresolved type is left out as its TypeFeaturing leaves it out. The corpus round-trip, pilot-apijson-diff and derived-census baselines did not move.
  • Excluded documents. GetElementProperties leaves out a featuring declaration of a document the model is read without, for model and library features alike.
  • Library features. A standard-library element is answered from its library document's form. GetElementProperties now adds to a library feature's featuringType the types the model's own featuring declarations give it (featuring Base::things by T; reads [P::T], was [], whether the property is read by name or among every property), from the index the checker reads; no other library state is overlaid. A model's api-json writes no element for the library feature, and writes the TypeFeaturing with the library feature's id and P::T.
  • REPL. %eval (Base::things meta KerML::Feature).featuringType answered [] because an expression naming only library elements was evaluated against an empty library-only runtime. With declarations in the session, a reflective expression (x meta T, x.metadata) is evaluated against the session, so it reads [P::T]; x.metadata of a library element likewise now includes the session's about annotations. With no declarations, or unrelated ones, the answers are unchanged and pinned.

Two older answers fixed here

Both were on develop before this change and were found while qualifying it.

  • One order of featuringType on every read. For a nested feature with a featured by, the reflective read (%eval, metadata) listed the owning type first while GetElementProperties and api-json listed the declared types first ([A, U] against [U, A]). Every read now answers the declared types first and the owning type after, the order DerivedFeaturingTypes already derived. TestReflectiveOwnershipAndFeaturingTypes pinned the old order and fails without the fix; TestElementPropertiesFeaturingTypeReadsStandaloneFeaturing now compares the two reads in order rather than sorted.
  • A feature held as a member. KerML.xtext TypeFeatureMember owns the feature through an OwningMembership, so it has no FeatureMembership, no owningType, and its holder is not one of its featuring types (KerML 8.3.3.3.4). api-json answered that; GetElementProperties, %eval and the metadata reads classified the membership as a FeatureMembership and added the holder. The membership is now classified once, in membershipMetaclassName and the evaluator's membershipKind. TestElementPropertiesFeaturingTypeLeavesOutTheHolderOfAMemberFeature, TestEvalFeaturingTypeLeavesOutTheHolderOfAMemberFeature fail without the fix; TestAPIJSONFeaturingTypeLeavesOutTheHolderOfAMemberFeature pins the answer the other two now share.

The recorded baselines moved toward agreement only, each re-recorded with its tool: the structure differential (pilot corpora Feature::featuringType 160 → 30 different, Feature::owningType 84 → 5, Type::ownedFeature 124 → 62; Connector::defaultFeaturingType now fully equal), the agreement ratchet (thirteen rows removed, five lowered, none raised) and the derived census (kerml-examples and spec-examples rows for FeatureMembership, owningType, featuringType and the Type feature lists).

The issue's first model stays accepted: the pilot accepts it and the reference-accessibility rule is not normative; see docs/project/spec-compliance/02-detailed-semantic-compliance-map/30-kerml-rules-not-reported.md. Nothing remains on the issue after this merges.

Why the pilot accepts the standalone form was not established from its source.

Specification basis

KerML 8.3.3.3.4 deriveFeatureFeaturingType; KerML 8.3.3.3.10 validateSubsettingFeaturingTypes. Compliance rows edited: 02-detailed-semantic-compliance-map/10-redefinition-in-a-specialization.md and 30-kerml-rules-not-reported.md. The clause numbers are taken from the repository's constraint manifest.

How it was verified

Fail-first tests, each failing with its part of the change removed:

  • TestFeaturingTypesReadStandaloneFeaturing and TestW8CStandaloneFeaturing: three standalone forms across the four positions, with conforming and inline controls.
  • TestElementPropertiesFeaturingTypeReadsStandaloneFeaturing (gRPC) and TestAPIJSONFeaturingTypeReadsStandaloneFeaturing (export): plain, tf of, declared-before-the-feature, inline plus standalone, and nested forms, each compared with Model.FeaturingTypes.
  • TestAPIJSONFeaturingTypeAcrossAnUnwrittenDocument and TestAPIJSONFeaturingTypeBesideAFeaturingOfAnUnwrittenFeature; the omission for a declaration in an unwritten document is pinned in the first.
  • TestElementPropertiesLibraryFeatureReadsTheModelsFeaturing (gRPC) and TestEvalReflectsOnALibraryElementInTheSession (REPL, on the exact expression above). TestEvalReflectsOnALibraryElementAsTheLibraryStates pins the library-only answers and passes with and without the REPL change.
  • TestAPIJSONFeaturingTypeOfANestedFeatureAcrossAnUnwrittenDocument, TestAPIJSONFeaturingTypeOfANestedFeatureWithAnUnresolvedType (export) and TestConvertDocumentsKeepsANestedFeaturesOwningType (Convert with only the using document written): both forms.
  • TestElementPropertiesFeaturingTypeLeavesOutAnExcludedDocument.
  • The member-feature tests named above.

Baselines, each regenerated with its tool:

  • pilot-apijson-diff: one row, described under Pilot divergence.
  • derived-census -update -recorded-pilot: one row, Feature::featuringType in kerml-examples, 1754 → 1755 equal and 999 → 998 differing, the same feature y; featuring F of y by C;. -check passes.
  • pilot-reject: the two cases under Pilot divergence.

Gates on the pushed head, which merges develop 1b4266551e and, ahead of it in the merge order, the head of #2771 (94b2354444); the diff against develop therefore shows #2771's changes until it lands.

  • gofmt -l ., go build ./..., go vet ./..., the same for tools, doc-counts -check, scripts/changelog.py check, scripts/check-doc-ids.py.
  • go test -count=1 without -race, with the corpora present, over internal/semantic, internal/check, internal/frontend/grpc, internal/frontend/repl, internal/translate/export, internal/workspace, internal/syntax, internal/exec/runtime, tests/parser, tests/hygiene, tests/resolve, tests/grpc and tests/export, plus tests/corpus -run TestExamplesSweep: all pass.
  • pilot-apijson-diff -check passes unchanged: 955 files, 120678 elements matched. derived-census -check -recorded-pilot passes on the re-recorded rows.
  • Not run locally on this head: -race, make lint, make test, and the full go test ./....

Checklist

  • make test and make lint pass locally
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (see CONTRIBUTING.md)
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md
  • baselines regenerated and make docs-counts run if a gate count moved (compliance rows need nothing: the census is counted at docs build)
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

👀 1 finding for you to triage · Follow Devin's work

Devin Review

devin-ai-integration Bot and others added 9 commits November 29, 2026 19:34
…in a branch body

An assignment may end in a body, as the grammar gives it, so an unnamed one
states its ElementId there; an about annotation in an if branch or loop body
now annotates the element it names, and an unnamed member of such a body has
an identity of its own.

Fixes #2713

Co-Authored-By: jason.han <hanhuijun@gmail.com>
A name path before the body was read as a chained name, which lost the
receiver of a feature chain and took an invocation's body expression for
the assignment's body.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
The members are not performed, so a nested step was dropped without a
diagnostic; a body that only annotates the assignment still runs.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
The refusal counted a rep annotation as a declared member.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
A `featuring g by T;` or `featuring tf of g by T;` declaration states the
same TypeFeaturing as a `featured by T` clause on the feature, but neither
Model.FeaturingTypes nor the constraint checker's featuring contexts read it,
so a reference to g from a type outside T was accepted.

The semantic model now gathers the standalone featuring declarations of each
document and indexes their resolved ends by the featured feature, in a shared
frame dropped when a contributing document changes. Model.FeaturingTypes and
constraintChecker.featuringOwners both add those types to the inline ones.

Fixes #2790

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ine clause

The pinned pilot does not read a standalone `featuring f by T;` for the
accessibility of a feature reference or a connector end, a rule that is the
pilot's own for a reference. constraintChecker.featuringOwners reads the inline
`featured by` clause alone again.

Model.FeaturingTypes keeps the standalone declarations (KerML 8.3.3.3.4
deriveFeatureFeaturingType), so the subsetting and redefinition rules
(8.3.3.3.10), which ask Model.CanAccess, judge the feature against them.

Refs #2790

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ition divergence

Two reject-oracle cases, a feature that subsets and one that redefines a feature
whose featuring type a `featuring g by T;` declaration states. The pinned pilot
accepts both; KerML 8.3.3.3.10 validateSubsettingFeaturingTypes over 8.3.3.3.4
deriveFeatureFeaturingType rejects them, so they land in ours-only-rejects.

Refs #2790

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration

devin-ai-integration Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

QA: pass

Tested head 8ddeaeef445f6ec75ad2075a92fbcb7d668db418 against base 729ec119b8aac91f31e15a10d0b8791684cf574c (merge base with develop, which was at the same commit). Both built from clean worktrees; nothing on the branch was changed. This replaces the earlier verdict on b61c37bee2f5.

Recorded run: CLI base vs head, REPL, VS Code diagnostics, hover, go-to-definition, live invalidation, nested-feature api-json

Base: VS Code, no problems Head: the two new diagnostics
base head

Four positions, non-conforming user (CLI, REPL, LSP and gRPC GetDiagnostics agree)

Position inline, base = head standalone, base standalone, head
feature v subsets g; subsetting-featuring-types accepted subsetting-featuring-types
feature v redefines g; redefinition-no-inherited accepted redefinition-no-inherited
feature v = g; feature-reference-featuring-types accepted accepted
connector c from g to h; connector-type-featuring accepted accepted

featuring tf of g by T; and a declaration written before its feature behave like the plain standalone form. A user that specializes T is accepted in every form on both builds.

featuringType on the reflective surfaces

The gap reported on the earlier head is closed: gRPC GetElementProperties and -convert api-json (plain and -interchange) now answer T for a feature featured only by a standalone declaration, plain or identified, in one file or across files. Base answers empty. Turtle is byte-identical on both builds, and the inline fixtures are byte-identical in every format.

Nested feature featured by a type of another document, classifier K { feature g; } with featuring K::g by Lib::T; or feature g featured by Lib::T; (CLI -convert api-json, gRPC Convert with documents, GetElementProperties):

g.featuringType base head
standalone, Lib written [K] [Lib::T, K]
standalone, Lib loaded but not written [K] [Lib::T, K]
standalone, Lib::T unresolved [K] [K]
inline, Lib written [Lib::T] [Lib::T, K]
inline, Lib loaded but not written [Lib::T] [Lib::T, K]
inline, Lib::T unresolved [] [K]

Where head differs from base it follows KerML 8.3.3.3.4 (the owning type together with every TypeFeaturing's type), and the two forms now agree with each other and with GetElementProperties. Head matches base only in the standalone unresolved row. On the intermediate head e4a646d39b the standalone unresolved row was empty; that is fixed here.

What else passed

One failure, same on base and head

After the declaring file is deleted and recreated on disk, its open VS Code diagram view keeps showing "no such document" until the file is reopened. Diagnostics refresh correctly. Base behaves the same, so this is not from this PR and does not change the verdict.

Base after recreating the file Head after recreating the file
base stale diagram head stale diagram

Not run

  • Full make test, make lint, -race, and the runtime, codegen, translate and client shards locally. CI did not run on this head: the run was cancelled at start, so the red "Build and test" only aggregates cancelled jobs and nothing here is backed by CI.
  • pilot-diff and the pilot validator on hand-written probes.

devin-ai-integration Bot and others added 8 commits November 30, 2026 02:21
…ve featuringType

GetElementProperties and the api-json element form answer Feature::featuringType
from every TypeFeaturing of the feature (KerML 8.3.3.3.4), the standalone
`featuring f by T;` declarations included, so they agree with Model.FeaturingTypes.
The metamodel evaluator reads the declarations from the semantic model's own index.

The api-json differential moves one row: Feature.featuringType in
kerml-examples/Simple Tests/Features.kerml, absent-both to pilot-missing, since the
pilot's export leaves a standalone declaration out of the derived property.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ten feature

A standalone featuring declaration naming a feature of a document that is not
written stopped the graph index, so every written feature lost its derived
featuringType. Such a declaration now only marks that a feature outside the
graph may be featured.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
One kerml-examples feature now answers the featuring type a standalone
featuring declaration states (KerML 8.3.3.3.4); re-recorded with
derived-census -update -recorded-pilot.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…g context

The member-feature path of the accessibility check read the derived featuring
types, which include standalone featuring declarations (KerML 8.3.3.3.4), so a
reference or a connector end naming a member feature with such a declaration was
rejected from an unrelated type. It now reads the types the feature and its
chained features own, as the pilot does; the derived property is unchanged.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…en feature

Co-Authored-By: jason.han <hanhuijun@gmail.com>
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration Bot and others added 9 commits November 30, 2026 03:18
…nt by its id

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ment's

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…aturing declarations

Co-Authored-By: jason.han <hanhuijun@gmail.com>
%eval answered `(Base::things meta KerML::Feature).featuringType` from the
empty library runtime, so the session's `featuring Base::things by T;` and
its `about` annotations of library elements were not read. A reflective
expression is now evaluated against the session when it has declarations.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…turing-types

Co-Authored-By: jason.han <hanhuijun@gmail.com>

# Conflicts:
#	docs/project/api-json-differential.md
#	docs/project/api-json-differential/index.json
#	internal/semantic/metamodel/derived_census_records.tsv
devin-ai-integration Bot and others added 23 commits December 1, 2026 18:19
… references

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…element count

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ce and members with no kind as the pilot does

A member's own body inside a body written as an argument reads its sibling members, a directed
attribute bound to a feature keeps its warning, the attribute typing rule reads through a
reference bound in between, and a body argument declares a feature with no kind keyword.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…pilot does

A member of a body argument written with no kind keyword was read as the shorthand parameter when a type was followed by a default, an initial value, a specialization or a further type, and as the result when the name or its multiplicity was followed by ordered or nonunique. The pilot parses each as a feature of the body.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…member as the pilot does

`a : T;` opening a body argument is its shorthand parameter; after a parameter or another member the same text declares a feature, so `F({ a : T; b : T; a + b })` parses as the pilot parses it.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…he converter's spelling

Co-Authored-By: jason.han <hanhuijun@gmail.com>
… with the two spellings 0.13.0 accepted

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…3.0 bare-body graph

`in k {}` in a body argument came back as `in k;` from a graph without source text, while a
usage's empty body is kept. The parser now records the body and the graph states it.

The graph release 0.13.0 wrote for `assign x := F { in i; i };` and `attribute z = F { in i; i };`
is committed as a fixture and reads back as `F({ in i; i })`, with and without its source text.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
A parameter of an assignment is bound when the assignment starts, as an action's is, so its
default does not see a write an earlier step of the same body makes; a binding does.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…e action starts

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…turing-types

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
… every schedule agrees

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…the attribute typing rule now requires

`attribute scaler = holder.scale;` in the function fixture is refused by the rule this branch adds, as the
pilot refuses it, so the six scenarios over that fixture stopped at a model that no longer analyses clean.
`ref scaler = holder.scale;` reads the same function value. The changelog states the break.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…e client test models

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…igures after merging develop

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…est models

Co-Authored-By: jason.han <hanhuijun@gmail.com>
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

…d calculation output

Also order a library feature's featuringType on GetElementProperties as the reflective
read does, the declared types first and the owning type after.

Co-Authored-By: jason.han <hanhuijun@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A standalone featuring declaration is not read as a featuring type

1 participant