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

fix(export): read a toolkit export back from the element form as its direct read - #2803

Open
HuiJun wants to merge 81 commits into
developfrom
fix/api-json-interchange-readback
Open

HuiJun wants to merge 81 commits into
developfrom
fix/api-json-interchange-readback

Conversation

@HuiJun

@HuiJun HuiJun commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

Fixes #2784. Fixes #2789. A document rewritten with sysml -convert api-json (with or without -interchange) did not always read back as the notation its direct read gives. The causes, fixed at their source:

  • Library stubs (library_identity.full, library_unmatched.full): the writer dropped every ownerless library stub while references to it stayed, so read-back failed with a missing-element error. A stub whose id the bundled standard library lacks (bundledLibraryID) is now kept when no library-reference table carries its name, so it resolves by its stated name, or is refused as an unmatched library element as on the direct read. Under -interchange a kept stub states every property the schema requires of its metaclass: its name from its qualified name, booleans at their defaults, every other property empty. Table-backed output is unchanged: table entries still never become roots.

  • Library stub of several types: a kept stub stating more than one rdf:type (DataType and Classifier) was refused with 2 rdf:type statements. It is now written as its most specific type and reads back as the direct read. A stub whose types are not in one specialization chain (DataType and Package) is still refused.

  • Unnamed usages (qualified_usages.compact): statedNames was collected before normalisation, so the qualifiedName the element form derives for an unnamed usage (perform a1;) placed it as a named member. deriveNormativeGraph now returns the set computed after dropStatedDefaults.

  • Perform type spelling: a toolkit perform's type was written as a qualified expression or a short name depending on whether the name had been derived yet. It is now spelled from its typing, as it resolves. This changes one pinned golden, state_entry.golden.sysml: perform action charge : Behave::Rover::Charge; becomes : Charge; (charge sits inside Behave::Rover, where Charge is declared).

  • Diagnostic order: chooseNames reported the first unread reference by ranging over a map. firstUnreadReference picks the lowest by member, then target.

  • A KerML feature's chains clause (api-json interchange read-back drops a KerML feature's chains clause #2789): -interchange wrote no sysx: key and nothing else carried the clause, so feature chained chains a2.leaf; read back as attribute chained; with exit 0. A feature declared with chains a.b now owns one FeatureChaining per link, in order (<feature>_pfc0, …), beside its sysml:chains; where the element form states the clause by those alone, the clause is read from them. A chain naming an undeclared feature is carried by that name in a TextualRepresentation the FeatureChaining owns, and reads back as written.

  • A KerML feature's metaclass: a feature declared in a KerML document was written to RDF and both element forms as the SysML AttributeUsage; the pilot writes Feature, and KerML has no AttributeUsage. package P { feature f; feature : T; } now states Feature for both members in Turtle, api-json and -interchange, and reads back as feature. A standard-library feature a model references is typed the same way. A SysML feature is still an AttributeUsage.

  • Chain clause spelling and order: a chain's first link is qualified past a nearer feature of the same name, chains stays ahead of inverse of, and an inherited chain gains no featured by of its own.

  • Terminate target: terminate process; and action stop terminate process; keep their target through -interchange, where it had been dropped.

  • A member named by name alone (p10.compact): -interchange left a reference the export states only by name ("memberElement": {"@ref": "kg"}) out of the form, so the document did not read back. The membership now owns a TextualRepresentation holding the name, a schema-valid carrier, and read-back resolves it as the default form does.

  • A nameless chains declaration: feature chains a.b; is KerML only, and -interchange records no grammar. A document recording none is read as SysML first and as KerML where that does not parse, so the nameless forms read back.

  • Declared chains in a library record: a feature loaded from a library record reflected no chainingFeature for its chains clauses. The record now carries each clause's links, so reflection agrees between a source model and its record. The record layout changes, so snapshotFormatVersion goes to 35 (one bump over fix(export): keep a declared element id on an unnamed assignment and in a branch body #2771's 34).

  • Flows and assignments: flow a.v to b.v; and assign a.q.v := n; were refused on read-back from -interchange. A flow's ends are read as parts of the flow rather than as standalone expressions, and an assignment's target and value are reconstructed from what it owns, as that form writes neither sysx: key. A flow's body members are numbered ahead of its payload, as the source naming does, so a flow with a payload and a body reads back too.

Resolver and semantics change

Materializing the chain needs each link resolved, which reaches past the exporter:

  • A chains clause after the first now resolves in the feature the clause before it chains last: feature bfa chains b chains f.a; is the chain b.f.a, whatever else is named f in the declaring scope. Before, every clause resolved in the declaring feature's scope.
  • A chain feature declared without a type takes the type of its last chaining feature. An unresolved or cyclic chain gets no invented type.
  • A qualified link past the first of a chain (chains b.f.F::a, chains b chains f.F::a) the previous feature has no member for reads outward in reflection as it does in validation, so chainingFeature lists it instead of stopping before it. The first name of a later clause is still a member only.
  • A one-link chain (feature c chains b;) writes chainingFeature as a list of one, where it had written a single reference.

Specification basis

KerML 8.2.3.5.2 (feature chaining in a feature declaration) and the FeatureChaining relationship of KerML 7.3.4.6. No row of docs/project/spec-compliance/ moves.

Baselines moved

All regenerated by their recorders on the merge of develop 729ec119b8, and again on the merges of develop 94e992b0c7 and of #2771's head af6ef32e8c; docs/project/api-json-differential.md adjudicates them.

  • docs/project/api-json-differential (144 fragments): 143 more elements match the pilot, 120203 to 120346; ours-only 15826 to 15753, pilot-only 24101 to 23958, type mismatches 1317 to 471.

    Root Matched of which chains of which Feature Type mismatches
    kerml-examples 7142 to 7270 (+128) 48 80 822 to 313
    spec-examples 9784 to 9790 (+6) 6 0 306 to 110
    testdata 2190 to 2192 (+2) 0 2 16 to 3
    examples 42607 to 42614 (+7) 4 3 171 to 43

    The 58 chain rows are FeatureChaining elements of declared chains the pilot writes and this exporter did not (parser_features_demo_relationships.kerml, Annex A A-3-8-ChangingFeatureValues.kerml, Simple Tests/FeatureChains.kerml, spec examples kerml/7.3.4.2/7 and kerml/7.3.4.6/1). The 85 Feature rows are nameless KerML features and what they own, keyed by metaclass and position, which pair with the pilot's for the first time; 60 are in A-3-8-ChangingFeatureValues.kerml, among them the 12 links of its four nameless chains … features. Named features already paired by name and only leave the type-mismatch count.

  • A KerML Feature no longer takes the attribute base Base::dataValues, so with -inherited-members it answers no inherited members from an implied library base, as every other KerML metaclass already does not (ours-missing 196207 to 197647; pilot-missing 92414 to 88756).

  • External-form schema baseline (api_json_normative_schema_external_form_baseline.json, -update-normative-schema): elements 984 to 986 and nothing else moved: invalid elements stay 517, and no missing-required, non-schema-key or invalid-value figure changes. The two elements are the library stubs of library_identity and library_unmatched, the fixtures' own elements copied through, kept only when the id is not a bundled one and no reference table names it. Under -interchange a kept stub states every property of its metaclass (name and declared name from its qualified name, each derived flag by its rule from what the stub states: isReference against isComposite, mayTimeVary with isVariable, isConjugated for a conjugated port definition or an owned conjugator, featureTarget the last stated chaining feature or the feature itself; other booleans at their defaults, every other property empty), so both are schema-valid and add no missing-required row. A stub of one of the 109 metaclasses with a mandatory value it cannot know (a relationship's ends, a function's result) is kept with that value empty, and a test pins that it is schema-invalid on those values alone. A library reference's qualifiedName is now spelled with escaped segments, so a stub named Missing::'it\'s' keeps its name and is refused by it in both forms. Develop drops them and leaves seven dangling references, so read-back fails; the pilot never writes library elements in a user model's element form and cannot hit the case.

  • Schema baselines after the by-name carriers and the chain fix (-update-normative-schema): default form 6710 to 6760 elements and 355 to 352 invalid, external form 986 to 990 elements with 517 invalid unchanged. The 50 are 25 by-name references across nine fixtures, each now a TextualRepresentation and its OwningMembership, all valid; the 4 are the two by-name members of p10.toolkit.compact.json; the 3 fewer invalid are the FeatureChainings of feature_chains_unresolved.sysml, which now state chainingFeature, relatedElement and target. No missing-required row grows.

  • On the merge of develop 94e992b0c7 the corpus recorder wrote ? for the clause keys of eight Feature rows of the agreement ratchet; they were restored to the keys this branch had already recorded for those rows, and the ratchet and both -checks pass on them.

  • Derived census: kerml-examples 8307 to 8367 elements, spec-examples 11912 to 11918, examples 57877 to 57881, all FeatureChainings of declared chains.

  • structure_differential_expected.txt and the corpus agreement ratchet re-recorded: the AttributeUsage rows of KerML features move to Feature rows under the same clauses, and the 333 AttributeUsage::@type metaclass disagreements are gone.

How it was verified

  • tests/export/toolkit_interchange_roundtrip_test.go: TestToolkitExportsReadBack (default and interchange forms of library_identity.full and qualified_usages.compact against the direct read), TestToolkitUnmatchedLibraryStubRefusesReadBack, TestToolkitKeptLibraryStubIsStatedInFull, the table-driven stub tests over all 175 metaclasses in toolkit_library_stub_audit_test.go and internal/translate/export/api_json_library_stub_test.go (every property against its rule, the schema verdict, the derived flags, the quoted name), and the several-types stub read-back and refusal. Each fails before its fix.
  • tests/export/chains_clause_readback_test.go: the example of api-json interchange read-back drops a KerML feature's chains clause #2789 through Turtle, default api-json and -interchange, asserting both clauses and four FeatureChaining elements; the undeclared-feature refusal; and the two-clause chain b.f.a. tests/resolve/chains_clause_test.go covers the resolver rule. The read-back test fails before the chains fix.
  • Two tables over the chains declarations (named and nameless, one link and many, a link qualified at each position, one clause and several, an undeclared name): tests/export/chains_declaration_table_test.go through the -interchange write, its read-back, the default form and the graph alone; internal/semantic/semantics/declared_chains_reflection_test.go through reflection of the source model and of its library record. The qualified-link, one-link, nameless and record rows fail before their fixes.
  • tests/export/api_json_interchange_statement_readback_test.go: flows (plain, nested, named, succession, with a body, with a payload and a body) and assignments (plain, nested, expression-valued, named) read back from the default form under UUID ids and from -interchange. Every row fails before its fix. p10.toolkit.compact.json joins TestToolkitExportsReadBackAsTheirDirectRead in both forms, and TestInterchangeCarriesAMemberNamedByNameAlone pins its carrier.
  • internal/translate/export/names_unread_test.go for the ordered diagnostic.
  • tests/export/kerml_feature_metaclass_test.go: feature f; and feature : T; in a .kerml file through Turtle, api-json and -interchange, and read-back; it fails before the metaclass fix. The pilot comparison is the api-json differential.
  • Gate on the pushed head's tree (the merge of fix(export): keep a declared element id on an unnamed assignment and in a branch body #2771's head af6ef32e8c, format 35): gofmt -l . empty, go build ./..., go vet for the module and tools, every test of internal/translate, tests/export, internal/semantic, tests/resolve, internal/workspace, tests/corpus, tests/hygiene, internal/syntax and internal/check with the training, pilot, spec-example, pilot-library, PSSM and OMG schema inputs required, pilot-apijson-diff -check, derived-census -check -recorded-pilot, make lint, the changelog and doc-id checks and make docs-counts. The p10.compact row of TestToolkitExportsReadBackAsTheirDirectRead was added after that run and run by name.
  • Recorders run on that merge: make stdlib-snapshot, pilot-apijson-diff -update, derived-census -update, the corpus sweep (-update-corpus-roundtrip -update-api-json-roundtrip -update-agreement-ratchet) and -update-structure-differential. The two baselines that conflicted in the merge are their output.
  • The full quick tier (all 23 shards, without -race) passed on the head before that merge; the suite outside the packages above and the -race tiers are left to CI and the merge queue for this head.

Checklist

  • make test and make lint pass locally (make lint yes; the suite passed without -race)
  • 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
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

Triage opened this PR for Jason
Implemented in session Fix toolkit interchange read-back for four fixtures
Review with Devin · Open in Devin Desktop


devin-ai-integration Bot and others added 8 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>
…direct read

A sysml-toolkit export written back as an api-json element document, in the
default form or with -interchange, did not read back as the notation its
direct read gives (#2784):

- A library stub whose id the bundled standard library lacks was dropped, so
  the references to it dangled. It is kept where no library-reference table
  carries its name, and is resolved by its stated name or refused as an
  unmatched library element.
- -interchange dropped a reference held only by name. It is written at its
  own property as {"@ref": <name>}.
- The qualified name the element form derives for an unnamed usage was read
  as a stated name. The stated names are taken after the derived ones are
  dropped.
- A perform's type was written back as a qualified expression only when its
  name happened to be derived already. It is spelled from the typing, as the
  mapping's own graph has it.
- The reference reported when a written reference does not read back was
  picked by map order. It is the first by member, then target.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
The normative schema admits a reference only by id, so {"@ref": <name>}
moved the element form away from it. A reference the graph holds by name
alone stays out of the -interchange form, as before.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
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.

A kept library stub stated with a metaclass and one it specializes was
refused by the element writer, where the notation reader takes it for the
more specific. The writer now states it so; types outside one
specialization chain are still refused.

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

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

Copy link
Copy Markdown
Contributor

QA: PASS

Tested head 9613f24d95cf54e807b389296260582e6f88a8e2 against develop 5e05757b20dd5c6ba953cde4a131dc5d82b1fd45; merge base c379d7b54c3c43023c0bd88a5a1fb2cd5b933cce. The head merges cleanly with that develop. No regression against develop was found and nothing this PR targets fails. This replaces the earlier verdict on cfd7c7f9a3.

CLI run on develop and head

What the head contains

Past the previously tested 358bf902fd, the head adds the flow and assignment read-back, the nameless-chain KerML fallback, the name-alone member carrier that lets p10.compact read back, and the two earlier read-back refusals. It also merges af6ef32e8c (the snapshot-format-34 rebaseline, not yet on develop), bumps the snapshot format 34 to 35, and adds the p10.toolkit.compact read-back row. Two parents on the merge commit, no other merge.

Read-back through the CLI

Each toolkit export under tests/export/testdata/interchange was read directly, rewritten with sysml -convert api-json and with -interchange, and the rewrite read back. "same" means identical notation, warnings and exit status.

Export Develop default Develop -interchange Head default Head -interchange
library_identity.toolkit.full read fails read fails same same
library_unmatched.toolkit.full different refusal different refusal same refusal same refusal
qualified_usages.toolkit.compact read fails read fails same same
p10.toolkit.compact same read fails same same
feature_chains.compact, flow_ends.full, satisfy_by.full (PR 2765) same same same same
p10.full, state_entry.full, states.compact, states.full, successions.full, transitions.full same same same same
Develop Head
Develop matrix Head matrix
  • p10.toolkit.compact with -interchange. Develop: cannot convert the expression …: a feature reference names the feature it reads, exit 2. Head: exit 0, notation identical to the direct read.

    p10.compact from -interchange on develop and head

  • Flows and assignments. 11 statements (flow a.v to b.v;, flow a.q.v to b.v;, named, succession, with a body, with a payload; assign x := n;, assign a.q.v := n;, assign a.q.v := n + 1;, action s assign x := n;). Develop refuses every -interchange read-back; head reads all 11 back in both forms. From -interchange an unnamed flow comes back as flow from a.v to b.v;.

    Flow and assignment rows

  • chains declarations (KerML). 15 declarations, named and nameless, one link to four, qualified links, several clauses. Develop writes no chainingFeature under -interchange and the read-back drops every chain. Head writes the ordered links (a one-link chain is a list) and reads all 15 back, the four nameless ones included; the default form keeps the source spelling.

    Chain rows

  • Kept library stubs. ScalarValues::Real and Missing::MissingType keep name, declaredName, owner: null, boolean defaults and empty lists; the first reads back as the direct read (exit 0), the second is refused with the direct read's message (exit 2). A stub named Missing::'it\'s' gets name it's and the same refusal. Across synthetic stubs of 175 metaclasses, all 1,751 boolean keys are booleans, isReference/isComposite and isVariable/mayTimeVary agree with the writer, isConjugated is true for a ConjugatedPortDefinition or an owned conjugator, and a chained feature's featureTarget is its last link.

  • Table-backed output. With -library-references, elements and table are byte-identical between develop and head for the six fixture/form pairs checked.

  • KerML feature with -inherited-members. Head writes Feature with no inherited members where develop writes AttributeUsage with 2 features and 7 memberships; the document reads back as the same KerML, and a SysML attribute model is byte-identical on both sides.

Records

Record Develop Head Check on head
Normative schema, element form 6,710 elements, 355 invalid 6,760 elements, 352 invalid TestAPIJSONNormativeSchema passes; -update-normative-schema leaves the tree clean
Normative schema, external form 984 elements, 517 invalid 990 elements, 517 invalid same
api-json differential 120,631 matched, 1,317 type mismatches 120,774 matched, 471 type mismatches pilot-apijson-diff -check exit 0 (954 files)
Derived census kerml-examples 8,307, spec-examples 11,912, examples 59,333 8,367, 11,918, 59,337 derived-census -check -recorded-pilot exit 0

The per-property gap counts in the two schema baselines only shrink (chainingFeature 5 to 0, memberElement 3 to 0 and 123 to 121, relatedElement 11 to 8, target 43 to 24). The differential and census deltas (+143 matched, −846 type mismatches; +60, +6, +4 elements) equal the ones measured on 358bf902fd against its own base, so nothing moved beyond this PR's earlier movement. af6ef32e8c carries the same differential, census and schema numbers as develop.

One deviation, not attributed to this PR: derived-census -check -require-exporter with a fresh pilot export exits 1 on a pilotRecords digest difference. The only rows that differ are the pilot's own counts for Feature::featuringType in three roots, a property the tool already marks pilot-nondeterministic; every OpenSysML column reproduces, and the committed digest is the one develop states.

Differential and census

Suites on head

Check Result
go test ./internal/translate/export/... ./tests/export/... (schema gate required) pass
go test ./tests/corpus (training, pilot and spec-example gates required) pass
go test ./internal/semantic/... pass
go test ./internal/workspace/libs/... ./tests/parser/... ./tests/resolve/... ./internal/syntax/... ./internal/translate/convert/... pass
go build ./..., go vet and gofmt -l on the export, resolve and test trees clean

Still refused from -interchange, same on develop

Not in this PR's scope, seen while trying neighbouring statements: action a1; then action a2; (and then assign …) is refused with "it sequences from the member written before the member it introduces", and state s { entry assign x := n; } with "it has no sysx:target and sysx:assignedValue". Both read back in the default form.

Not run

  • make conformance, the full go test ./..., -race, the client suites and the Flexo interop gate.
  • The Go suites, differential and census on develop; develop was exercised through the CLI only.
  • The differential and census on af6ef32e8c itself; its committed records were compared instead.
  • CI: the check runs on this head are cancelled, so no CI result backs this verdict.

devin-ai-integration Bot and others added 16 commits November 30, 2026 03:03
A KerML feature declared `chains a.b` was stated as text alone, so `-convert api-json -interchange` dropped the clause and read back a plain feature. The feature now owns one FeatureChaining per link, and the clause is read from those where the element form states no text. A chain naming an undeclared feature is refused on read-back.

A later `chains` clause resolves in the feature the clause before it chains last (KerML 8.2.3.5.2), and a chain feature with no typing takes the types of its last chaining feature.

Baselines: the api-json differential gains 58 matched FeatureChainings in five fragments (adjudicated in docs/project/api-json-differential.md). The structure differential and the agreement ratchet follow the new elements; two ratchet rows rise, both in classes already recorded: AttributeUsage::ownedRelationship 78 -> 79 (the multiplicity membership is ordered differently on the two readers) and FeatureChaining::relatedElement 299 -> 305 (the six links of the two specification examples whose chain names nothing declared).

Fixes #2789

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

A chains clause the element form states as FeatureChainings alone was read
back with its first link unqualified past a nearer feature of the same
name, after an inverse of clause written behind it, and with a featured by
clause naming the types of an inherited first link.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
The element form keeps the expression a terminate action owns but not the
property naming it, so terminate process; read back as terminate;.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
The merged base reads a featuringType list by its declared featurings, so this
branch's own collapse of the property is dropped; it reversed the list's order.
The interchange read-back refusals lose the two exports that now read back, and
the unmatched library element is refused as one.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
A nameless `feature chains a.b;` is KerML only. The graph and the default
element form keep it; -interchange records no grammar, so its read-back is
refused rather than written as a feature named `chains`.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
A KerML `feature` was written to RDF and the element form as the SysML
AttributeUsage, since the parser files the keyword under the attribute usage
kind. KerML has no AttributeUsage and the pilot implementation writes Feature
for `feature f;` and `feature : T;` alike, so the writer now chooses the
metaclass by the keyword in a KerML document, for a declaration and for a
library element a model references. A SysML `feature` stays an AttributeUsage.

Read back, a named Feature is no longer taken for an implied chain feature, and
a cross feature written with its own keyword keeps its body form.

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

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

A transition's effect assignment ends in a body like any other; cover it with a golden AST, negative controls, a source-text-free RDF and api-json round trip, and execution cases for an annotating body and a refused member-declaring one.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
devin-ai-integration Bot and others added 27 commits November 30, 2026 22:48
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…rchange form

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…in the outline

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

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

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

# Conflicts:
#	tests/corpus/testdata/element_properties_agreement/answered-not-exported.txt
#	tests/corpus/testdata/element_properties_agreement/value.txt
Depths 16, 20 and 40 of both nesting shapes must parse within ten seconds, so a parser that reads each body twice fails the test instead of running until the package times out.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Recorded with -update-agreement-ratchet: the same eight adjudicated classes rise by two, for the two newly compared elements, and the send classes fall by one.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Generated baselines in conflict took develop's side; re-recorded by their tools in the next commit.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
- `docs/project/api-json-differential`: 1 file(s) regenerated
- `internal/semantic/metamodel/derived_census_baseline.json`: 3 record(s) moved; 2 moved by this branch; 1 moved by both sides (the merge's verdict, adjudicate)
- `internal/semantic/metamodel/derived_census_records.tsv`: 87 record(s) moved; 62 moved by this branch; 25 moved by both sides (the merge's verdict, adjudicate)
  - ours.carriers: 7454008 → 7455408 (+1400)
  - ours.empty: 4313851 → 4314567 (+716)
  - ours.notDerived: 130859 → 130877 (+18)
  - ours.value: 3009298 → 3009964 (+666)
- `internal/translate/export/testdata/structure_differential_expected.txt`: 130 record(s) moved; 96 moved by this branch; 34 moved by both sides (the merge's verdict, adjudicate)
  - examples matched: 59181 → 59185 (+4)
  - examples/pilot-corpora matched: 62125 → 62185 (+60)
  - examples/spec-examples matched: 12791 → 12797 (+6)
- `tests/export/testdata/convert`: 1 file(s) regenerated

The agreement ratchet's Feature rows keep the clause keys this branch gave them.

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

A graph stating no positional names had its unnamed members numbered by ownedRelationship order, which lists a flow's payload feature and a connector's unnamed ends first; naming.Table places body members first and the payload after them. A flow with a payload and a body, or with an unnamed body member, was refused from -interchange.

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

Co-Authored-By: jason.han <hanhuijun@gmail.com>
… loop or unnamed transition

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

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

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

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

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

The two conflicting generated baselines (the structure differential and the element-properties agreement ratchet) are the output of their recorders on the merged tree.

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

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

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

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 3 findings. Devin fixed 2 findings; 1 finding is left for you to triage below.

Fixed by Devin (2)
  • Wrong feature in exported chains — Reproduced: feature c chains P::x.missing; beside a nearer x read back from -interchange as chains x.missing. The resolved links ahead of an undeclared one are now spelled by what they reach; new row in TestChainsClauseIsSpelledFromItsLinksFromInterchange fails before the fix.
  • Initialized parameters block assignment import — Reproduced with an interchange document whose assignment body parameter in q = 2 is owned through a ParameterMembership: read-back was refused. A named parameter is no longer counted as a head operand; TestAssignmentWithAnInitializedBodyParameterReadsBackFromInterchange fails before the fix.

View findings in Devin Review · Follow Devin's work

Devin Review

Comment on lines +702 to +707
switch next := p.peekN(end + 1); {
case next.Kind == lexer.Semicolon, next.Kind == lexer.RParen, next.Kind == lexer.Comma, next.Kind == lexer.RBracket,
next.Kind == lexer.Keyword && next.KeywordID == "else":
return true
}
return p.exprEndsAt(afterSemicolon, end) || afterBrace > afterSemicolon && p.exprEndsAt(afterBrace, end)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Assignment expressions rejected after body arguments

When a resultless body argument precedes + in an assignment value, bodyIsArgument mistakes it for the assignment’s own body. The assignment ends before +, leaving the rest of the expression outside the statement.

Devin left this for you to triage: bodyIsArgument in internal/syntax/parser/expr.go is PR 2771's parser change, present here only through the merge of its head af6ef32; this PR's own commits do not touch the file. If real, assign x := f { ... } + 1 would end the assignment before +. Recommend fixing it in PR 2771, where the change and its tests live, not here.

Learn more

The assignment parser enables body lookahead while reading the right-hand side (parseAssignmentAction). When a name is followed by { in … }, the lookahead recognizes several delimiters after the closing brace but does not recognize expression operators. With no result before the closing brace, the expression stops at the name and the braces become the assignment's body. The binary expression parser would have consumed the operator if the invocation had been recognized.

Example: assign x := F { in i : Integer; } + 1; previously parses as an addition with an invocation on the left. It now parses the braces as the assignment body and leaves + 1; behind.

Recommended fix: Check for valid expression continuation tokens after the closing brace, using the same operator and postfix rules as the expression parser. Add a regression case that asserts the addition is the assignment value and that the assignment has no body.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a defect: this is the pilot implementation's reading, and #2771 keeps it.

After :=, braces following the value are the assignment's own body, so the statement ends at their } and an operator after them is refused. The pinned pilot validator (2026-09.1 / 0.63.1) on the reported input:

package K {
    calc def F { in a : ScalarValues::Integer; return : ScalarValues::Integer = a; }
    action def D {
        attribute x : ScalarValues::Integer;
        assign x := F { in a = 1; } + 1;
    }
}
5:37: error: no viable alternative at input '+'
7:1: error: extraneous input '}' expecting EOF
5:21: error: Must be a valid feature

It gives the same no viable alternative at input '+' with an untyped F, and for the attribute-value form attribute y : ScalarValues::Integer = F { in a = 1; } + 1;. #2771 at af6ef32e8c reports 5:37: error[syntax]: expected a body member at the same +. develop accepts the expression, which is the permissive side; #2771 pins the refusal in a parser test (TestAssignmentValueEndsAtItsBody) and declares the difference from develop in its description.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 4 findings. Devin fixed 3 findings; 1 finding is left for you to triage in Devin Review.

Fixed by Devin (3)
  • Unnamed chain declarations block interchange read-back — Fixed since the earlier verdict: an unnamed feature chains a.b; now reads back from -interchange (KerML fallback when the graph records no grammar). Checked on the current head: the declaration reads back as feature chains a.b;; the nameless rows of the chain table cover it.
  • Wrong feature in exported chains — Reproduced: feature c chains P::x.missing; beside a nearer x read back from -interchange as chains x.missing. The resolved links ahead of an undeclared one are now spelled by what they reach; new row in TestChainsClauseIsSpelledFromItsLinksFromInterchange fails before the fix.
  • Initialized parameters block assignment import — Reproduced with an interchange document whose assignment body parameter in q = 2 is owned through a ParameterMembership: read-back was refused. A named parameter is no longer counted as a head operand; TestAssignmentWithAnInitializedBodyParameterReadsBackFromInterchange fails before the fix.

View findings in Devin Review · Follow Devin's work

Devin Review

@devin-ai-integration

devin-ai-integration Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Review finding "Unnamed chain declarations block interchange read-back" (rdf_in_toolkit.go:640-644): fixed in b9c5980, which reads a document recording no grammar as KerML where it does not parse as SysML.

Input (c.kerml):

package K {
    classifier A { feature b; }
    classifier C {
        feature a : A;
        feature chains a.b;
    }
}

sysml -convert api-json -interchange c.kerml > c.json, then sysml -convert kerml -from api-json c.json on the current head:

package K {
    classifier A {
        feature b;
    }
    classifier C {
        feature a : A;
        feature chains a.b;
    }
}

TestNamelessChainsClauseReadsBack and the four nameless rows of chainDeclarationRows cover it.

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

1 participant