Skip to content

fix(parser): every hop of a multi-hop @flows gets its line's location and continuation; conformance cases for longer chains - #48

Merged
Animesh-Sri-bugb merged 2 commits into
mainfrom
fm/flows-guardlink-long-chains
Oct 1, 2026
Merged

Animesh-Sri-bugb merged 2 commits into
mainfrom
fm/flows-guardlink-long-chains

Conversation

@Animesh-Sri-bugb

@Animesh-Sri-bugb Animesh-Sri-bugb commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Fix: every hop of a multi-hop @flows gets the whole line

SPEC §3.2 @flows (Chains) says that every hop carries the line's mechanism, description and location. On main the parser did not do that in two cases:

  1. Sidecar chains were sited at the .gal file. In .guardlink/annotations/app/pay.py.gal:

    @source file:app/pay.py line:4 symbol:charge
    @flows #a -> #b -> #c via tok -- "x"
    

    On main, guardlink parse gave the first hop app/pay.py:4 with origin_file pointing at the sidecar. The second hop got .guardlink/annotations/app/pay.py.gal:2 with no origin, so it had no handler or anchor and sent readers to the sidecar instead of the code. parseString now applies the @source location to every record a line produces. All hops share one location object, the same as inline hops.

  2. Continuation lines extended only the last hop. For # @flows #a -> #b -> #c via tok -- "first" followed by # -- "second", main gave hop 1 the description first and hop 2 first second. A continuation now appends to every record the line above produced, so both hops read first second.

The SPEC sentence on chains now names both cases explicitly, and the CHANGELOG has an entry under Unreleased → Fixed.

Longer chains in the conformance corpus

Until now, conformance/flows.json exercised only a three-endpoint chain. This PR adds five parse cases:

  • chain/four-endpoints-via-description: four endpoints become three hops, each with the full mechanism and description.
  • chain/five-endpoints-no-via: five endpoints become four hops, each with a null mechanism. This one chain uses all four endpoint forms: component path (User, Svc.Api), #id, #repo.id and quoted.
  • route/four-endpoint-chain: via PATCH./orders/{id}?fields (json) on four endpoints becomes three hops. Each keeps the full mechanism and the route PATCH /orders/{id}.
  • chain/continuation-every-hop: a continuation line reaches both hops of an inline chain.
  • sidecar/chain-every-hop-sited: both hops of a sidecar chain are sited at app/pay.py:4, with origin_file and origin_line set, and a continuation in the .gal file reaches both.

Only cases are added, so the corpus format version stays at 1. The corpus now has 44 cases, 27 of them parse cases.

Verification

  • With src/parser/parse-file.ts from main swapped in, exactly the two new cases for the fix fail (chain/continuation-every-hop and sidecar/chain-every-hop-sited). With this branch's parser, all 45 corpus tests pass.
  • npm run build, then npm test: 111 files, 1973 passed, 1 skipped.
  • npm run lint: clean.
  • guardlink validate . --artifacts: current and drawable. Re-running sync and artifacts changes nothing, because this repository's own model has no multi-hop @flows affected by the fix.

…xtend every hop's description

A multi-hop @flows in a .gal sidecar sited only its first hop at the
@source block; later hops kept the .gal file as their location, so they
had no handler or anchor. A '-- "..."' continuation line extended only the
last hop's description. Both now apply to every hop, as SPEC §3.2 @flows
(Chains) states. Two conformance cases pin them; both fail on the previous
parser.
@Animesh-Sri-bugb Animesh-Sri-bugb changed the title test(conformance): four- and five-endpoint @flows chains and a route channel on a longer chain fix(parser): every hop of a multi-hop @flows gets its line's location and continuation; conformance cases for longer chains Oct 1, 2026
@Animesh-Sri-bugb
Animesh-Sri-bugb merged commit f9c0595 into main Oct 1, 2026
1 of 3 checks passed
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.

1 participant