pubid 2.0.0.pre.alpha.58 → 2.0.0.pre.alpha.60

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.
@@ -30,4 +30,4 @@ These notes were part of the root `CLAUDE.md`. Read them before you change `lib/
30
30
 
31
31
  **Two parent-slot gaps recorded by the cross-flavor `base` survey** (`lib/pubid/bsi/CLAUDE.md` has the measured version). `Identifiers::TestReportForm#cispr_identifier` is a polymorphic `Identifier` parent slot with no `#root` override, so `root` returns the form itself. And `Identifiers::ConsolidatedIdentifier#base_document` returns `identifiers&.first` **without** the recursive `&.base_document` that its BSI, CSA and CEN counterparts use — a one-level peel where the others peel fully, so a consolidated edition of a supplement does not reduce to the bare standard. Neither is chased here; both are pinned by nothing, which is why they are written down.
32
32
 
33
- **Stage codes — the SSOT and what is settled.** The authoritative source for IEC stage abbreviations is committed in this repo: **`data/iec/stage-codes.md`** — the 52-row IEC/ISO stage-code correspondence table transcribed from IEC's official *IEC/ISO Harmonized APIs* documents (v0.0.8 2023-06, api-portal.iec.ch; v0.0.7 2021-05, iec-apiportal.apigee.io — the successors that replace the IEC Data Feeds), the legacy Data-Feeds field examples, and the IS-lifecycle ladder from `StageCodes_IS_v2.pdf` (2023-06). `www.iec.ch` itself is fully WAF-gated to non-browsers and the Wayback Machine holds no snapshots of its PDFs, so the extract — not the unreachable original — is the reference. **`Pubid::Iec.locate_stage` reads `TYPED_STAGES` only** (`lib/pubid/iec.rb`); `PROJECT_STAGES` (AFDIS, TCDV, PRVC…) are not queryable through it. Every one of metanorma-iec's 55 `STAGE_CODES` — the list quoted in pubid#237 — resolves, locked by `spec/pubid/iec/typed_stages_spec.rb` in the issue's own order; aliases are always **appended, never prepended**, so `abbr.first` (what renders) is unchanged. Notable rulings from that pass: **ADIS** is the legacy Data-Feeds spelling of AFDIS ("Approved for FDIS circulation", ISO_LEVEL 40.99) and is an alias on `cdv` (the typed stage claiming 40.99); **CDISH/CDPAS** are the 50.20 rows of the DISH/DPAS deliverables, not "committee draft ISH/PAS" (30.xx); bare **PUB**, and the codes **AWG/CANV**, are defined by no IEC source and are deliberately unregistered (pubid#572, closed — the extract's "absent from every source" section is the standing evidence). **Reconciliation items recorded in the extract, deliberately not applied:** DELPUB sits at 99.60 there while the `is` ladder does not claim 99.60; CAN carries two codes (30.98 IS/TR/TS, 50.98 PAS/ISH/COR); the rows CDISH-table-siblings DECDISH/MERGED/SPLIT/PCC/PRVN/DEL/RPUB/TPUB and the per-deliverable translation/preparation families are not registered as typed-stage abbreviations.
33
+ **Stage codes — the SSOT and what is settled.** The authoritative source for IEC stage abbreviations is committed in this repo: **`data/iec/stage-codes.md`** — the 52-row IEC/ISO stage-code correspondence table transcribed from IEC's official *IEC/ISO Harmonized APIs* documents (v0.0.8 2023-06, api-portal.iec.ch; v0.0.7 2021-05, iec-apiportal.apigee.io — the successors that replace the IEC Data Feeds), the legacy Data-Feeds field examples, and the IS-lifecycle ladder from `StageCodes_IS_v2.pdf` (2023-06). `www.iec.ch` itself is fully WAF-gated to non-browsers and the Wayback Machine holds no snapshots of its PDFs, so the extract — not the unreachable original — is the reference. **`Pubid::Iec.locate_stage` reads `TYPED_STAGES` only** (`lib/pubid/iec.rb`); `PROJECT_STAGES` (AFDIS, TCDV, PRVC…) are not queryable through it. Every one of metanorma-iec's 55 `STAGE_CODES` — the list quoted in pubid#237 — resolves, locked by `spec/pubid/iec/typed_stages_spec.rb` in the issue's own order; aliases are always **appended, never prepended**, so `abbr.first` (what renders) is unchanged. Notable rulings from that pass: **ADIS** is the legacy Data-Feeds spelling of AFDIS ("Approved for FDIS circulation", ISO_LEVEL 40.99) and is an alias on `cdv` (the typed stage claiming 40.99); **CDISH/CDPAS** are the 50.20 rows of the DISH/DPAS deliverables, not "committee draft ISH/PAS" (30.xx); **Reconciliation items recorded in the extract, deliberately not applied:** DELPUB sits at 99.60 there while the `is` ladder does not claim 99.60; CAN carries two codes (30.98 IS/TR/TS, 50.98 PAS/ISH/COR); the rows CDISH-table-siblings DECDISH/MERGED/SPLIT/PCC/PRVN/DEL/RPUB/TPUB and the per-deliverable translation/preparation families are not registered as typed-stage abbreviations.
@@ -1079,11 +1079,17 @@ module Pubid
1079
1079
  # P + a /D designator (any draft capture) is a DRAFT, never a
1080
1080
  # printed Std (the owner's 2026-10-24 ruling): the P marker is
1081
1081
  # project status, so the joint/project-draft family owns the row
1082
- # whatever date trails the designator. The non-P rows keep the
1083
- # printed-strip doctrine (the normalization ledger).
1084
- p_with_draft = parsed[:project_marker] &&
1082
+ # whatever date trails the designator. The ruling extends to the
1083
+ # P-less joint rows (pubid#597): a numeric /D designator alone is
1084
+ # project status too — the row is a draft AND takes the P, so the
1085
+ # marker is set below when the source spelling lacked it.
1086
+ p_with_draft = (parsed[:project_marker] || numeric_draft) &&
1085
1087
  (parsed[:draft_version] || parsed[:draft_iso_stage] ||
1086
1088
  parsed[:draft_month] || parsed[:draft_year])
1089
+ if p_with_draft && !parsed[:project_marker]
1090
+ attributes[:project_marker] = true
1091
+ parsed[:project_marker] = "P"
1092
+ end
1087
1093
  printed_joint = parsed[:iso_published] && parsed[:iso_stage].nil? &&
1088
1094
  !p_with_draft &&
1089
1095
  (parsed[:printed_dash_year] || parsed[:printed_month_year] ||
@@ -1272,8 +1278,15 @@ module Pubid
1272
1278
  # rather than the joint-development model.
1273
1279
  if attributes[:draft] && parsed[:iso_stage].nil? &&
1274
1280
  parsed[:iec_stage].nil? && parsed[:amd_number].nil?
1275
- draft_attrs = { code: attributes[:code],
1276
- draft: attributes[:draft] }
1281
+ # The ruling (pubid#597): a joint row with a numeric /D designator
1282
+ # is a draft AND takes the P project marker, whatever the source
1283
+ # spelling printed — the marker is set on the identifier (and the
1284
+ # code prepended) even when the row reached it without one.
1285
+ draft_code = attributes[:code].to_s
1286
+ draft_code = "P" + draft_code unless draft_code.start_with?("P")
1287
+ draft_attrs = { code: draft_code,
1288
+ draft: attributes[:draft],
1289
+ project_marker: true }
1277
1290
  if attributes[:publishers]
1278
1291
  draft_attrs[:publisher] = attributes[:publishers].first
1279
1292
  rest = attributes[:publishers][1..]
@@ -1974,11 +1987,16 @@ module Pubid
1974
1987
  end
1975
1988
  end
1976
1989
 
1977
- # The PARG capture carries its separator (".12", the #471
1978
- # convention); Draft#to_s prints the dot itself, so keep only
1979
- # the digits or "D2022.10.12" renders "D2022.10..12" (pubid#477).
1980
- if draft_data[:revision]
1981
- revision = extract_value(draft_data[:revision])&.delete_prefix(".")
1990
+ # The dotted ordinal stays part of the designator (the #601
1991
+ # convergence): the grammar splits it only on the joint
1992
+ # designation route, so a split field would make the parse and
1993
+ # from_hash paths build different Draft objects on
1994
+ # wire-identical rows ("DP62271-111_D6.1"). #to_s renders
1995
+ # version + revision identically, so the whole tail rides the
1996
+ # version on every route.
1997
+ if draft_data[:revision] && version
1998
+ tail = extract_value(draft_data[:revision])&.delete_prefix(".")
1999
+ version = "#{version}.#{tail}"
1982
2000
  end
1983
2001
 
1984
2002
  # The compound both-systems form (docs/IEEE-DRAFT-STAGES.md
@@ -8,13 +8,13 @@ module Pubid
8
8
  # IEEE draft version
9
9
  # Handles formats like:
10
10
  # /D5 - version only
11
- # /D3.4 - version with revision
11
+ # /D3.4 - dotted designator (the tail rides the version)
12
12
  # /D7, July 2019 - with date
13
13
  class Draft < Lutaml::Model::Serializable
14
14
  include ::Pubid::SubsetMatch
15
15
 
16
- attribute :version, :string # D5, D3, etc.
17
- attribute :revision, :string # .4, .2 in D3.4
16
+ attribute :version, :string # D5, D3.4, etc.
17
+ attribute :revision, :string # unused on construction paths (#601)
18
18
  attribute :year, :string
19
19
  attribute :month, :string
20
20
  attribute :day, :string
@@ -94,8 +94,10 @@ day: nil, iso_stage: nil, iso_iteration: nil)
94
94
  # The compound stage suffix (docs/IEEE-DRAFT-STAGES.md §1.3):
95
95
  # "=DIS.3" is canonical — D (draft) = DIS (the stage), iteration 3.
96
96
  # "=DDIS.3", "=DDIS3", "=DDIS-3" (the stage echoed with its own D)
97
- # are accepted aliases. Captures [stage, iteration].
98
- COMPOUND_SUFFIX = /=D?(PWI|NP|WD|CDV|FDIS|DIS|CD)(?:[.-]?(\d+))?\z/.freeze
97
+ # are accepted aliases. Captures [stage, iteration]. The
98
+ # iteration is SHORT — a long digit run is a glued date
99
+ # ("=CDV-201507", the designator face), not an ordinal.
100
+ COMPOUND_SUFFIX = /=D?(PWI|NP|WD|CDV|FDIS|DIS|CD)(?:[.-]?(\d{1,2}))?\z/.freeze
99
101
  private_constant :COMPOUND_SUFFIX
100
102
 
101
103
  # The D-echo aliases ("DDIS3" = D + DIS + iteration 3) normalize
@@ -103,7 +105,7 @@ day: nil, iso_stage: nil, iso_iteration: nil)
103
105
  # ("CD1", "FCD", "CDV1") restores verbatim -- the compound split
104
106
  # would degrade the glued iterations and drop the stages the
105
107
  # alias list never knew, so from_hash(row) != parse(row).
106
- ECHO_SUFFIX = /\AD(=?(PWI|NP|WD|CDV|FDIS|DIS|CD|FCD))(?:[.-]?\d+)?\z/.freeze
108
+ ECHO_SUFFIX = /\AD(=?(PWI|NP|WD|CDV|FDIS|DIS|CD|FCD))(?:[.-]?\d{1,2})?\z/.freeze
107
109
  private_constant :ECHO_SUFFIX
108
110
 
109
111
  def self.parse(value)
@@ -131,9 +133,19 @@ day: nil, iso_stage: nil, iso_iteration: nil)
131
133
  draft
132
134
  end
133
135
 
136
+ # The stage tokens #to_s renders verbatim (no D prepend). The
137
+ # strip_prefix must refuse them symmetrically: a wire form like
138
+ # "DIS2-1504" opens with the stage's own D, and stripping it
139
+ # corrupts the version ("IS2-1504") while still rendering alike.
140
+ STAGE_VERBATIM = /\A(ED\d|FDIS|FCD|CDV|DIS|CD|WD|PWI|NP)/
141
+ private_constant :STAGE_VERBATIM
142
+
134
143
  # Remove the leading "/D" (or a bare leading "D"/"/") that #to_s emits,
135
- # leaving the version and any trailing date.
144
+ # leaving the version and any trailing date. A stage-token version
145
+ # keeps its whole spelling: #to_s renders it with no designator
146
+ # prepend, so the leading D is the stage's own letter.
136
147
  def self.strip_prefix(str)
148
+ return str if str.match?(STAGE_VERBATIM)
137
149
  return str[2..] if str.start_with?("/D")
138
150
  return str[1..] if str.start_with?("/")
139
151
  return str[1..] if str.start_with?("D") && str.length > 1
@@ -174,7 +186,7 @@ day: nil, iso_stage: nil, iso_iteration: nil)
174
186
  # as "FDIS_March") renders verbatim — prepending D
175
187
  # concatenates a hallucinated token ("DED4", "DFDIS") that no
176
188
  # face spells. Every other version keeps the D designator.
177
- result = version&.match?(/\A(ED\d|(FDIS|FCD|CDV|DIS|CD|WD|PWI|NP))/) ? "/#{version}" : "/D#{version}"
189
+ result = version&.match?(STAGE_VERBATIM) ? "/#{version}" : "/D#{version}"
178
190
  result += "=#{iso_stage}" if iso_stage
179
191
  result += ".#{iso_iteration}" if iso_stage && iso_iteration
180
192
  result += if revision.to_s.start_with?(".")
@@ -141,11 +141,16 @@ module Pubid
141
141
  # so the WHOLE type word is dropped — not just "Std" (pubid#318: the
142
142
  # half-strip left "Draft" in the render, the re-parse dropped it, and
143
143
  # to_s needed three rounds to converge while losing the type).
144
- should_render_type = id.publisher&.match?(/^(IEEE|AIEE)/)
145
-
146
- if should_render_type && !id.typed_stage&.project_status && id.type && !id.type.to_s.strip.empty? && id.type != "P" &&
144
+ # A project draft carries the word Draft whatever the lead
145
+ # publisher — the ISO-led joint drafts (pubid#597) print it too.
146
+ should_render_type = id.publisher&.match?(/^(IEEE|AIEE)/) ||
147
+ id.is_a?(Identifiers::ProjectDraftIdentifier)
148
+
149
+ if should_render_type && !id.typed_stage&.project_status &&
150
+ ((id.type && !id.type.to_s.strip.empty? && id.type != "P") ||
151
+ id.is_a?(Identifiers::ProjectDraftIdentifier)) &&
147
152
  !id.draft_status.to_s.match?(/unapproved/i)
148
- type_str = id.type.dup
153
+ type_str = id.type ? id.type.dup : "Draft"
149
154
  type_str = type_str.sub(/^P/, "") if type_str.start_with?("P")
150
155
  # A draft carries the word Draft alone in every face (the C2
151
156
  # ruling): Std/Standard never renders on a draft, whatever
@@ -89,6 +89,8 @@ module Pubid
89
89
  end
90
90
 
91
91
  def to_s(**opts)
92
+ return super if opts[:format] && opts[:format] != :human
93
+
92
94
  context = build_rendering_context(nil, format: :human, **opts)
93
95
  Pubid::Renderers::GuideRenderer.new(self).render(context:,
94
96
  **opts.slice(:with_edition))
@@ -54,6 +54,8 @@ module Pubid
54
54
  end
55
55
 
56
56
  def to_s(**opts)
57
+ return super if opts[:format] && opts[:format] != :human
58
+
57
59
  context = build_rendering_context(nil, format: :human, **opts)
58
60
  Pubid::Renderers::SupplementRenderer.new(self).render(context:,
59
61
  **opts.slice(:with_edition))
data/lib/pubid/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pubid
4
- VERSION = "2.0.0.pre.alpha.58"
4
+ VERSION = "2.0.0.pre.alpha.60"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.alpha.58
4
+ version: 2.0.0.pre.alpha.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-24 00:00:00.000000000 Z
11
+ date: 2026-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model