pubid 2.0.33 → 2.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pubid/iec/CLAUDE.md +2 -0
- data/lib/pubid/iec/identifier.rb +74 -0
- data/lib/pubid/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 25950246723409f8462f360040d4f4d10778b2c0891cd73584e3fd114a6eba52
|
|
4
|
+
data.tar.gz: 6978f1e00c74ac6c3acdeb743dded123f9df8aca3464056e88be14c68d45ed5c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1193aa950c2deaca9748f0c1bbfa2e6cd2533d07537ce33dac075593054da549dfad7463ae6b26541abc95cfbc3fee3d6d8e1c90e39ad39dd474ec1d26e2cb2f
|
|
7
|
+
data.tar.gz: f94436ddc84215ab53864298422303d1a74b2e468014362cb56254d00232779f90edd5ed73982e19611b6eb921073c1514ebd32a4ac856033f77cd04cba08a6d
|
data/lib/pubid/iec/CLAUDE.md
CHANGED
|
@@ -49,6 +49,8 @@ These notes were part of the root `CLAUDE.md`. Read them before you change `lib/
|
|
|
49
49
|
|
|
50
50
|
- **The standalone no-part dotted face is rejected at parse (issue #727).** `IEC/AMD 1.2:2017` parsed and then LOST the dot at render: `render_supplement_standalone` prints the base number and the supplement's own number only, so the stored `stage_iteration` was dropped and `parse(to_s) != parse` — the URN (`amd:1.2:2017`) and `to_hash` carried a facet the canonical face cannot print. No IEC source prints a no-part standalone face with a dotted number (the facet is attested only on the on-base draft faces; 0 rows in the gem fixtures, the testsuite ledger or `relaton-data-iec`), so the shape is **rejected at parse** — the #726 ruling for unattested dotted shapes — rather than built unrenderable. **The crash the issue reported does not reproduce on the Ruby side, and that finding shaped the fix**: the Ruby renderer nil-guards `copublishers` (`copublishers&.any?`) and the parse path always materializes the publisher (the attribute default fills it; the only `publisher_portion` crash needs a hand-set `publisher = nil`, unreachable from parse and from_hash — verified at 2.0.29, the released 2.0.31 and main over a ~40-shape probe matrix); the crash in the issue came from pubid-ts#184's note, where the TS `publisherPortion` reads `copublishers` off a supplement whose table does not materialize the empty collection. So the nil-guard branch of the issue's suggested direction had nothing to guard, and the live Ruby defect was the lossy render on the same face. **The check is the SHAPE, not a grammar route**: `Identifier.parse` walks the built object's `base` chain after `ensure_base` and raises `ParseError` (with `input:`/`flavor:` set, `parse_failure_cause` nil — the synthetic-raise shape) when a `SupplementIdentifier` layer holds both a `stage_iteration` and a synthetic self-base. One condition covers all three parse routes — the `supp_*` standalone branch (`IEC/AMD 1.2:2017`), the publisher-less plain route (`AMD 1.2:2017`, bound as `type_with_stage` + `stage_iteration`, no `supp_` keys) and a dotted layer under an undotted second supplement (`IEC/AMD 1.2:2017/COR 1:2018`) — and none of the neighbours that keep the dot on a printable layer: the single-document draft faces (`IEC CD 1.2:2017`, `IEC/DTR 1.2:2017` — not supplements, the dot rides the base and `parse(to_s) == parse` holds), the DAM-family decodes (`IEC/DAM 1.2` → `IEC 1.2/DAM 1`, dot on the base designation) and the on-base faces (a real base, `synthetic_base?` false). The undotted standalone faces keep parsing with their #693 residue renders (`IEC/AMD 1:2017` → `IEC Amd 1-1:2017`). BSI's delegation (`bsi/single_identifier.rb` → `Pubid::Iec.parse`) and `Pubid.parse` routing raise through the same entry. **`from_hash` deliberately still deserializes the shape** (rendering the undotted face as it always did): parse can no longer produce the hash, no stored row carries it, and rejecting deserialization would hard-break a consumer cache holding a pre-#727 parse — the residue is pinned, not chased. **No corpus round follows** (the shape is unattested; nothing moves to `pass/`). Locked by the new blocks in `spec/pubid/iec/dot_subnumber_spec.rb`: the 11 raising rows with the message, the input/flavor/cause shape of the synthetic raise, the keep-parsing rows (render + `from_hash(to_hash) ==` + re-parse idempotence), the undotted residue rows, and the deserialization residue. (hand-off: iec-standalone-dotted-reject.)
|
|
51
51
|
|
|
52
|
+
- **The fragment-ladder spellings are rejected at parse (issue #731).** `CDFRAG`, `DFRAG`, `FDFRAG`, `PRF Frag`, `PWI Frag` (and the `NP`/`ANW`/`WD` " Frag" siblings from the same `FragmentIdentifier::TYPED_STAGES` ladder) parsed into broken shapes, and **one condition on the BUILT object covers every route** (`reject_unrenderable_fragment`, the #727 shape-not-grammar-route ruling, called from `Identifier.parse` after the dotted check): a fragment whose `base` is nil — the ladder token, and even the published `FRAG` token, in the primary type position builds a `FragmentIdentifier` with no base (the builder captures the designation into a local `fragment_number` but never reaches `wrap_with_fragment`, since the `:base` grammar key is absent, and `assign_attributes` cannot store number/date/edition on the fragment — they delegate to the missing base), which renders bare `/FRAG` (itself unparseable — the render is not a fixed point), carries a nil official URN, keys the empty index string, and silently drops the input's designation/date/edition; or a fragment whose `typed_stage.stage_code` is not `published` — the ladder token in a SUPPLEMENT layer (`IEC 60038/CDFRAG 1`) builds a base-carrying fragment whose stage has no printed face (`render_fragment` prints `/FRAG<n>` unconditionally), so the stage was dropped at render and `parse(to_s) != parse`. **Attestation searched before rejecting** (the issue's stop condition): gem fixtures (`spec/fixtures/iec/identifiers/full/` — only `…/AMDn/FRAGn EDn`, `…/FRAGn EDn` and the tracked-debt `…/COR1/FRAGC1 ED1`, which does not parse at main), the testsuite ledger (`tests/iec/fragment_identifier.yaml` — 16 rows, all base-carrying; the "ANW Frag"/"PRF Frag"/"PWI Frag" strings in `_debt.yaml` are parslet expected-token lists inside error-message notes, not identifiers), the stage-codes SSOT (`data/iec/stage-codes.md` — only "MERGED | Fragment merged" and "SPLIT | Project Fragmented", no ladder rows) and the IEC/ISO Harmonized APIs PDFs in `reference-docs/iec/` (an empty `<FRAG/>` presence element plus `<stdFragment>1</stdFragment>` for the number, and the bilingual-fragment workflow — no ladder token). So parse-reject is the direction; the TS side already rejects these spellings (pubid-ts#193 pinned them as a recorded gem divergence), so the two engines now AGREE with no TS change. **One message covers both facets** (`FRAGMENT_LADDER_MESSAGE`); the walk descends through `base` AND the `identifiers` members (AllParts/Consolidated), so `IEC DFRAG 60038 (all parts)` rejects too while `IEC 60038/FRAG1 CSV` (a Vap over a sound fragment) passes. **`from_hash` stays open** (stored-data compatibility): a stored `{"_type" => "pubid:iec:fragment-identifier", "stage" => "dfrag"}` still deserializes to the degenerate fragment it always built — pinned with what the residue hashes contain. **The registry is untouched**: `Pubid::Iec.locate_stage` still answers every ladder abbreviation (metanorma-iec stage lookups and the URN stage slot resolve through the rows), and the #727-era TYPED_STAGES registration specs keep passing. **Neighbours pinned byte-identical**: the eight attested `/FRAG<n>` faces (IS/amendment/corrigendum bases, copublishers, dated, multi-digit), the Vap-over-fragment and all-parts forms. No corpus round follows (nothing attested). (hand-off: iec-frag-ladder-reject.)
|
|
53
|
+
|
|
52
54
|
## pubid-scheme URN (issue #670; gaps closed by #687)
|
|
53
55
|
|
|
54
56
|
`lib/pubid/iec/pubid_urn_schema.rb` completes the partial schema the IEEE
|
data/lib/pubid/iec/identifier.rb
CHANGED
|
@@ -276,6 +276,7 @@ module Pubid
|
|
|
276
276
|
# (SupplementIdentifier#number).
|
|
277
277
|
id.ensure_base if id.is_a?(SupplementIdentifier)
|
|
278
278
|
reject_standalone_dotted_supplement(id, string)
|
|
279
|
+
reject_unrenderable_fragment(id, string)
|
|
279
280
|
id
|
|
280
281
|
end
|
|
281
282
|
|
|
@@ -313,6 +314,79 @@ module Pubid
|
|
|
313
314
|
end
|
|
314
315
|
end
|
|
315
316
|
|
|
317
|
+
# pubid#731: the fragment-ladder spellings ("CDFRAG", "DFRAG",
|
|
318
|
+
# "FDFRAG", "PRF Frag", "PWI Frag" and the NP/ANW/WD " Frag" siblings)
|
|
319
|
+
# parse into broken shapes, and one condition on the BUILT object
|
|
320
|
+
# covers every route (the check is the shape, not a grammar route —
|
|
321
|
+
# the same ruling as reject_standalone_dotted_supplement above):
|
|
322
|
+
#
|
|
323
|
+
# * a fragment built WITHOUT its base designation — the ladder token
|
|
324
|
+
# (or even the published "FRAG" token) in the primary type position.
|
|
325
|
+
# The input's designation, date and edition are dropped (the
|
|
326
|
+
# fragment delegates number/date to a base that is not there), the
|
|
327
|
+
# fragment renders bare "/FRAG" — which is itself unparseable — and
|
|
328
|
+
# the official URN is nil, so the shape silently corrupts
|
|
329
|
+
# downstream.
|
|
330
|
+
# * a fragment carrying a NON-PUBLISHED ladder stage — the token in a
|
|
331
|
+
# supplement layer ("IEC 60038/CDFRAG 1"). The renderer prints the
|
|
332
|
+
# published "/FRAG<n>" face only, so the stage facet is dropped at
|
|
333
|
+
# render and parse(to_s) != parse.
|
|
334
|
+
#
|
|
335
|
+
# No IEC source prints either shape: the gem fixtures, the testsuite
|
|
336
|
+
# ledger and the IEC/ISO Harmonized APIs data feeds (which carry an
|
|
337
|
+
# empty <FRAG/> element plus <stdFragment> for the number) attest only
|
|
338
|
+
# the on-base "/FRAG<n>" notation of the published fragment, and the
|
|
339
|
+
# stage-codes extract (data/iec/stage-codes.md) has no ladder rows. So
|
|
340
|
+
# the ladder spellings are rejected at parse — the #726/#727 ruling
|
|
341
|
+
# for unattested, un-renderable faces. from_hash stays open
|
|
342
|
+
# (stored-data compatibility): parse can no longer produce the shape,
|
|
343
|
+
# and no stored row carries it. The walk reaches a broken fragment
|
|
344
|
+
# under the wrappers ("IEC DFRAG 60038 (all parts)" is an AllParts
|
|
345
|
+
# over one; "IEC 60038/FRAG1 CSV" a Vap over a sound one — which
|
|
346
|
+
# passes).
|
|
347
|
+
FRAGMENT_LADDER_MESSAGE =
|
|
348
|
+
"the fragment-ladder spellings (\"CDFRAG\", \"DFRAG\", \"FDFRAG\", " \
|
|
349
|
+
"\"PRF Frag\", \"PWI Frag\" and the NP/ANW/WD \" Frag\" siblings) " \
|
|
350
|
+
"build a fragment identifier that cannot render or round-trip: no " \
|
|
351
|
+
"IEC source prints a fragment-ladder token (the attested fragment " \
|
|
352
|
+
"face is the on-base \"/FRAG<n>\" notation), and the built fragment " \
|
|
353
|
+
"either holds no base designation — rendering bare \"/FRAG\" with " \
|
|
354
|
+
"nothing attached and an empty official URN — or carries a " \
|
|
355
|
+
"non-published fragment stage with no printed token"
|
|
356
|
+
|
|
357
|
+
def self.reject_unrenderable_fragment(id, input)
|
|
358
|
+
node = id
|
|
359
|
+
while node
|
|
360
|
+
reject_fragment_ladder_shape(node, input)
|
|
361
|
+
node = descend_wrapper(node)
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
# The rejected fragment shape: either facet of the ladder spellings.
|
|
366
|
+
# A sound fragment (a base AND the published stage) passes; a nil
|
|
367
|
+
# stage also fails the check, defensively — no parse route builds one.
|
|
368
|
+
def self.reject_fragment_ladder_shape(node, input)
|
|
369
|
+
return unless node.is_a?(Identifiers::FragmentIdentifier)
|
|
370
|
+
return if node.base && node.typed_stage&.stage_code.to_s == "published"
|
|
371
|
+
|
|
372
|
+
raise Pubid::Errors::ParseError.new(
|
|
373
|
+
FRAGMENT_LADDER_MESSAGE, nil,
|
|
374
|
+
input: input, flavor: "iec"
|
|
375
|
+
)
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
# The next node the walk reaches: a wrapper's child. Supplements,
|
|
379
|
+
# Vap, Sheet and Fragment carry it in `base`; the AllParts and
|
|
380
|
+
# Consolidated members in `identifiers`. A leaf resolves neither and
|
|
381
|
+
# ends the walk.
|
|
382
|
+
def self.descend_wrapper(node)
|
|
383
|
+
if node.class.attributes.key?(:base)
|
|
384
|
+
node.base
|
|
385
|
+
elsif node.class.attributes.key?(:identifiers)
|
|
386
|
+
node.identifiers.first
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
|
|
316
390
|
# from_hash is the shared polymorphic dispatch on Pubid::Identifier.
|
|
317
391
|
# IEC_TYPE_MAP remains as the key_value polymorphic_map.
|
|
318
392
|
end
|
data/lib/pubid/version.rb
CHANGED