Skip to content

build02: compare the two clause headers as clauses, as the instruction says - #16

Merged
hongdy22 merged 1 commit into
mainfrom
fix/build02-osgi-clause-comparison
Sep 14, 2026
Merged

hongdy22 merged 1 commit into
mainfrom
fix/build02-osgi-clause-comparison

Conversation

@hongdy22

Copy link
Copy Markdown
Collaborator

Fixes #13.

The instruction publishes State A's manifest and then states the contract: Export-Package and Import-Package are compared clause by clause, so ordering and whitespace do not matter, but the packages, versions, uses:= sets and resolution:=optional do. test_required_header_exact compared all thirteen required headers as whole strings, so a jar whose only difference was uses:= written before version= rather than after — a choice that belongs to bnd's version, that OSGi gives no meaning and that no resolver can observe — failed a scored check. Under the stage's all-pass gate that one check took the stage, with 2,668 behavioural checks passing beside it.

What changed

  • The quote-aware parser was already here. osgi_header_meaning() normalises on top of it, and only Export-Package and Import-Package route through it; the other eleven headers are untouched and still byte-exact.
  • parse_osgi_header() stopped folding a:=b into a=b. OSGi reads the first as an instruction to the resolver and the second as an attribute a consumer may match on, and only the first makes an import optional; stripping the colon let a clause that declared one answer a check written for the other.
  • tests/verification/lib/jarinspect.py is kept in step with the behavioural copy.

Regression — infra/tests/test_build02_osgi_clauses.py, 20 checks against the real module with a manifest dict in place of a jar. The half that matters is the second one:

  • four reorderings pass — attributes within a clause, the uses:= set, the clauses themselves, whitespace — and one test proves each really is a reordering of State A and not some other header;
  • ten differences still fail: a dropped uses:=, a uses set with a package added or missing, a wrong version, a package not exported, an internal package exported, a version with no value, resolution:=optional dropped or changed to mandatory, an import that is not there, and resolution=optional written as an attribute;
  • a scalar header (Bundle-RequiredExecutionEnvironment) is asserted to be still byte-exact, which is what would notice the routing widening by accident.

Fails on main (19 of 20).

…n says

The instruction publishes State A's manifest and then states the contract:
Export-Package and Import-Package are compared clause by clause, so ordering
and whitespace do not matter, but the packages, versions, `uses:=` sets and
`resolution:=optional` do.  `test_required_header_exact` compared all thirteen
required headers as whole strings, so a jar whose only difference was `uses:=`
written before `version=` rather than after -- a choice that belongs to bnd's
version, that OSGi gives no meaning and that no resolver can observe -- failed
a scored check.  Under the stage's all-pass gate that one check took the stage,
with 2,668 behavioural checks passing beside it.

The parser this needed was already here and already quote-aware;
`osgi_header_meaning` normalises on top of it and the two headers route through
it.  The other eleven are untouched and still byte-exact.

`parse_osgi_header` also stopped folding `a:=b` into `a=b`.  OSGi reads the
first as an instruction to the resolver and the second as an attribute a
consumer may match on, and only the first makes an import optional; stripping
the colon let a clause that declared one answer a check written for the other.

The regression test is the half that matters: four reorderings must pass, and
ten differences the instruction calls graded must still fail -- a dropped
`uses:=`, a changed uses set, a wrong version, a package added or missing, and
`resolution=optional` in place of `resolution:=optional`.
@hongdy22
hongdy22 force-pushed the fix/build02-osgi-clause-comparison branch from d5eff0d to b4530e0 Compare September 14, 2026 06:19
@hongdy22
hongdy22 merged commit 0d5d731 into main Sep 14, 2026
5 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.

build02: Export-Package byte comparison contradicts the order-insensitive contract

1 participant