Module: Hecks::Adapters::PostgresEra::LineageManager::Minter
- Included in:
- Hecks::Adapters::PostgresEra::LineageManager
- Defined in:
- lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager/minter.rb
Overview
The mint path: name the source era, find the one edge that leaves it, hold the compute approval to what was actually reviewed, check coverage, audit the live chain, and mint — or refuse toward the authoring loop by name.
Instance Method Summary collapse
-
#ensure_named!(lineage, era) ⇒ Object
Era names are minted once.
- #mint!(registry, bluebook, current_text, lineage, latest, role: nil, directory: nil) ⇒ Object
-
#refuse_toward_the_scaffold!(registry, bluebook, lineage, latest, ordinal, directory) ⇒ Object
No edge yet: the boot refuses toward the authoring loop — naming both tools and the era ordinal.
-
#scaffold!(registry, bluebook, lineage, latest, directory) ⇒ Object
Diff the held era against the current shape and write the edge file — confident rules inline, ambiguities as parse-refusing
unresolvedlines.
Instance Method Details
#ensure_named!(lineage, era) ⇒ Object
Era names are minted once. An era held before any drift was seen has no name yet; it gets one the moment an edge needs to leave it.
121 122 123 124 125 126 127 |
# File 'lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager/minter.rb', line 121 def ensure_named!(lineage, era) return if era[:hash] held_bluebook = shadow(era[:held_text]) hash = Runtime::StorageShape.mint_hash(held_bluebook) lineage.mint_name!(era[:ordinal], hash, hash[0, Runtime::StorageShape::LABEL_LENGTH]) end |
#mint!(registry, bluebook, current_text, lineage, latest, role: nil, directory: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager/minter.rb', line 15 def mint!(registry, bluebook, current_text, lineage, latest, role: nil, directory: nil) ensure_named!(lineage, latest) latest = lineage.eras.last hash = Runtime::StorageShape.mint_hash(bluebook) label = hash[0, Runtime::StorageShape::LABEL_LENGTH] ordinal = latest[:ordinal] + 1 edges = registry.translations.select { |t| t.domain == bluebook.name && t.from == latest[:label] } if edges.empty? refuse_toward_the_scaffold!(registry, bluebook, lineage, latest, ordinal, directory) end if edges.size > 1 raise Runtime::WiringError, "cannot boot #{bluebook.name}: #{edges.size} translation edges leave era #{latest[:ordinal]} " \ "(#{latest[:label]}) — eras fork mechanically; keep one edge per source shape" end edge = edges.first unless edge.to == label raise Runtime::WiringError, "cannot boot #{bluebook.name}: the translation edge from #{latest[:label]} targets " \ "#{edge.to}, but the current shape is #{label} — the edge is stale; re-run bin/scaffold_translation" end # A compute's (and, the same way, a rekey's) only verification # is the audit's human-approved sample — mint stays # non-interactive by requiring the approval to already exist, # recorded IN THIS DATABASE by `bin/translation_audit … # --approve` and bound to what was actually reviewed: this # edge's parsed content, and the journal as it stood when the # samples were read. A journal that has advanced past the # review invalidates it — the approved samples no longer cover # the data. if edge.aggregates.any? { |declared| !declared.computes.empty? || !declared.rekeys.empty? } approval = lineage.approval_for(from: edge.from, to: edge.to) unless approval && approval[:edge_digest] == Translation::Audit.edge_digest(edge) raise Runtime::WiringError, "cannot mint era #{ordinal} of #{bluebook.name}: this edge carries a compute or rekey " \ "rule, and the audit's human-approved sample is its only verification — run " \ "bin/translation_audit with --approve, then boot again" end tip = lineage.last_ordinal if approval[:reviewed_ordinal] != tip raise Runtime::WiringError, "cannot mint era #{ordinal} of #{bluebook.name}: the journal advanced past the approved " \ "review (ordinal #{approval[:reviewed_ordinal]} reviewed, #{tip} now) — the samples a " \ "human approved no longer cover the data; re-run bin/translation_audit with --approve" end end check_coverage!(registry, bluebook, shadow(latest[:held_text]), edge) chain = edge_chain(registry, bluebook, lineage.eras, label) audit!(bluebook, lineage, chain, ordinal, edge) lineage.mint_era!( ordinal: ordinal, hash: hash, label: label, held_text: current_text, aggregates: bluebook.aggregates, edges: chain, role: role, projection: Runtime::StorageShape.project(bluebook) ) ordinal end |
#refuse_toward_the_scaffold!(registry, bluebook, lineage, latest, ordinal, directory) ⇒ Object
No edge yet: the boot refuses toward the authoring loop — naming both tools and the era ordinal. With HECKS_SCAFFOLD=1 the boot RUNS the scaffold first (an explicit flag, never a silent side-effect) and the refusal names the file it wrote.
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager/minter.rb', line 82 def refuse_toward_the_scaffold!(registry, bluebook, lineage, latest, ordinal, directory) if ENV["HECKS_SCAFFOLD"] == "1" && directory path = scaffold!(registry, bluebook, lineage, latest, directory) raise Runtime::WiringError, "cannot boot #{bluebook.name}: the shape changed (era #{ordinal}) — wrote #{path}; " \ "review it (resolve every unresolved), check it with bin/translation_audit, then boot again" end raise Runtime::WiringError, "cannot boot #{bluebook.name}: the shape changed (era #{ordinal}) and no translation edge " \ "covers it — run bin/scaffold_translation to write the edge, " \ "check it with bin/translation_audit, then boot again" end |
#scaffold!(registry, bluebook, lineage, latest, directory) ⇒ Object
Diff the held era against the current shape and write the edge
file — confident rules inline, ambiguities as parse-refusing
unresolved lines. Returns the file path.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager/minter.rb', line 99 def scaffold!(registry, bluebook, lineage, latest, directory) ensure_named!(lineage, latest) latest = lineage.eras.last hash = Runtime::StorageShape.mint_hash(bluebook) held_bluebook = shadow(latest[:held_text]) diffed = Translation::Scaffold.diff(held_bluebook, bluebook) edge = Translation::Scaffold::Edge.new( domain: bluebook.name, from: latest[:label], to: hash[0, Runtime::StorageShape::LABEL_LENGTH], ordinal: latest[:ordinal] + 1, label: hash[0, Runtime::StorageShape::LABEL_LENGTH], aggregates: diffed[:aggregates], retired: diffed[:retired] ) Translation::Scaffold.write!(directory, edge) end |