Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/donor-decoding-profile.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Transport CREATE (`transport.create@1` and `@2`) accepts an optional `donor_profile` parameter: a canonical JSON document that selects a versioned donor-decoding profile and states each of its choices. The first profile, `populace-us-cps-asec` version 1, stages household tenure, legal marital status and full-time study from the donor's raw survey answers and SPM units, refuses a document written for other donor bytes, and records its counts in CREATE's receipt. No graph selects a profile in this change, and a graph that sets none keeps its CREATE frame and receipt bytes.

The change edits `microcosm/frame/transport.py` and `microcosm/build/transport/population_kernels.py`, so seven kernel refs move once: `transport.create@1`, `transport.create@2`, `transport.currency@1`, `transport.quantile_map@1`, `transport.quantile_map@2`, `transport.support_bounds@1` and `transport.boundary@1`. Their implementation hashes change, so the node records of these kernels and of every node downstream of them re-key, and those nodes run again. A stored CREATE inventory stops matching, because its store key includes CREATE's implementation hash (`transport/cli.py`). Support-bounds evidence records its producer's implementation hash, so the battery's header check refuses evidence stored before this change when that evidence is supplied to it (`transport/evidence_contract.py`). An ordinary graph run does not supply it: the producer's node key includes the new hash, so the executor misses its cache and runs the producer again (`graph/executor.py`). `gates.battery@1` does not move, and no committed digest moves.
35 changes: 35 additions & 0 deletions docs/concept-schema-transport-adr.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,41 @@ These hold for every input and are tested (Hypothesis properties unless noted):
nonmissing ages in completed years, from 0 through 130.
`DonorBank.dropped_parent_cycle_edges` exposes the number of dropped edges.
Longer cycles and other inconsistent relationships still fail validation.
- A graph selects a donor-decoding profile through CREATE's optional
`donor_profile` parameter. The value is a canonical JSON document with the
fields `format` (`microcosm.donor-profile/1`), `profile`, `version`,
`donor_sha256` and `choices`. `parse_donor_profile` refuses an unknown or
missing field and any choice outside the closed sets in
`DONOR_PROFILE_CHOICES`, and a profile has no defaults: the document states
every choice. The one profile, `populace-us-cps-asec` version 1, stages
household `tenure` from `tenure_type`, `H_TENURE` and the SPM units'
tenure and housing assistance, person `legal_marital_status` from
`A_MARITL`, and person `enrolled_full_time` from `A_ENRLW` and `A_FTPT`.
The reader refuses a document whose `donor_sha256` names other bytes
before it opens the file. It checks the raw codes, in their own integer or
float storage, and the SPM joins before decoding. It checks each rent and
mortgage cost against its own concept's contract, then reconciles the
costs with the staged tenure, and then validates the whole frame. CREATE's
receipt records the document's digest, its choices and the staging counts
under `donor_profile`. A graph that sets no profile reads what it read
before (the person and household tables and the `_time_period` series)
and never the `spm_unit` table, and its CREATE frame and receipt keep the
bytes captured at the commit before this change. No graph selects a
profile when the parameter lands. The parameter still moves seven kernel
refs once, because it edits the reader's module and CREATE's module:
`transport.create@1` and `@2`, `transport.currency@1`,
`transport.quantile_map@1` and `@2`, `transport.support_bounds@1` and
`transport.boundary@1`. The node records of these kernels and of every node
downstream of them re-key. A stored CREATE inventory stops matching,
because its store key includes CREATE's implementation hash. The battery
refuses support-bounds evidence that records the old implementation hash
when that evidence is supplied to it. An ordinary graph run does not
supply it: the producer's node key includes the new hash, so the executor
misses its cache and runs the producer again. `gates.battery@1` does not
move, and no committed digest moves. A choice value the closed sets do not
offer needs a further edit to the reader's module, which moves every one
of these refs again except `transport.boundary@1`, whose hash reads
CREATE's module but not the reader's.
- The consuming builder supplies the destination frame declaration after
transport. New Zealand's group bindings now execute on benefit units built
from the concept pointers. Belgium's 39 `person_role` bindings on `Child`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
(``donor_pin_sha256``, ``unit_rule_sha256``, ``mass_reference_sha256``,
``currency_sha256`` and ``bands_sha256``) is checked for format only: it
moves the node key and authenticates nothing.

An optional ``donor_profile`` carries a donor-decoding profile document
(``microcosm.frame.transport.parse_donor_profile``). The reader refuses a
document whose own ``donor_sha256`` differs from this kernel's
``donor_sha256`` parameter and stages the profile's concepts; the receipt's
``donor_profile`` key records what it staged.
Without the parameter, CREATE reads the donor and writes its frame and
receipt as before.
"""

from __future__ import annotations
Expand Down Expand Up @@ -41,6 +49,7 @@
from microcosm.frame.transport import (
currency_bridge,
derive_transport_seed,
parse_donor_profile,
quantile_map,
read_populace_us_donor,
)
Expand Down Expand Up @@ -141,6 +150,7 @@ class TransportCreateKernel(KernelBase):
"seed_stream",
}
)
_optional = frozenset({"facts_sha256", "chronicle_feed_pin", "donor_profile"})

def implementation_hash(self) -> str:
return source_hash(
Expand All @@ -164,10 +174,13 @@ def implementation_hash(self) -> str:

def run(self, context: KernelContext) -> KernelResult:
require_params(
context,
self.ref,
required=self._required,
optional=frozenset({"facts_sha256", "chronicle_feed_pin"}),
context, self.ref, required=self._required, optional=self._optional
)
# Parsed once, before any source is read; the reader stages it.
profile = (
parse_donor_profile(string_param(context, self.ref, "donor_profile"))
if "donor_profile" in context.params
else None
)
donor_source = string_param(context, self.ref, "donor_source")
facts_source = string_param(context, self.ref, "facts_source")
Expand Down Expand Up @@ -218,6 +231,7 @@ def run(self, context: KernelContext) -> KernelResult:
context.sources[donor_source],
sha256=sha256_param(context, self.ref, "donor_sha256"),
size=context.params["donor_size"],
profile=profile,
)
tables, dropped = split_for_transport(donor.tables)
# pandas 3's inferred text dtype spells itself "str"; graph columns
Expand Down Expand Up @@ -313,6 +327,11 @@ def run(self, context: KernelContext) -> KernelResult:
else diagnostics,
"mass_reference": registry.specs[0].name,
"facts": dict(surface.facts),
**(
{}
if donor.donor_profile is None
else {"donor_profile": donor.donor_profile}
),
},
)

Expand Down
Loading
Loading