Skip to content

Rate calculation method foundation: value object, method registry, rate table - #82

Closed
vcjdeboer wants to merge 1 commit into
develfrom
st-engine/rate-methods-foundation
Closed

vcjdeboer wants to merge 1 commit into
develfrom
st-engine/rate-methods-foundation

Conversation

@vcjdeboer

Copy link
Copy Markdown
Owner

Summary

This PR adds the foundation that every rate calculation method registers into. The registry is empty. No method is implemented here; each method family is a later work item.

It is work item st-seahtrue-rate-calculation-method-value-object-method-5j2b in the swamp_seahtrue factory. The design is packages/st-engine/rate-methods.md in swamp_seahtrue.

  • The method value object. rate_method() and method_parameter() build it; method_id() returns name@version.

    • method_canonical_json() returns RFC 8785 JSON with the keys corrections, family, fun, input_methods, instrument_models, name, output_kinds, parameters, plate_inputs and version.
    • method_digest() is the sha256 of that JSON.
    • Parameter values are decimal strings exactly as written in their source, so a digest never depends on how a float prints.
  • The method registry. method_registry() returns it keyed by method id, and lookup_rate_method() finds one by exact match only. The registry is checked on every call:

    • each method id is unique;
    • each method function is an exported seahtrue function and never the xlsx reader, so the Rate sheet is never a method;
    • each input method is registered and outputs what it is consumed as;
    • an O2 series feeds only a tick-rates method;
    • an O2 series is output only by an O2 correction;
    • the input graph has no cycle.
  • Registry files.

    • inst/extdata/method_registry.json is generated from the registry, and a test checks it matches byte for byte.
    • inst/extdata/method_registry_released.tsv is the append-only record of released method ids and their digests. A test fails when the package version is newer than this record but the registry differs from it.
    • Another test keeps the registry empty until the recompute test on a public plate exists. The first method's work item replaces it.
  • compute_rates(plate, method_id, inputs, plate_inputs). It checks, in order:

    • the plate is one plate with a sha256 plate id;
    • the inputs are exactly the method's input methods, each a rate table checked against the producer's method digest;
    • the plate inputs are exactly the declared ones.

    Then it calls the exported method function and checks what comes back: a rate table, plus a fitted-values table when the method declares one. The method id is on every row.

    The table constructors are internal. O2 series inputs and outputs are refused until their container is defined (ticket st-seahtrue-o2-auc-method-phzb).

  • New Import: digest (>= 0.6.39).

    • The CRAN source tarball's sha256, 8bf048b49b2d17077138fae758bda56bbd53278d9437f2fdeaedf979c90a13c9, matched across two CRAN mirrors.
    • The webR binary's sha256 is 0531577e58efa9e61aeb4505c31766c53507d7bb59db9c4ce0ed2e7e9e862d07; its md5 matches the repository index.

The branch is cut from devel (981999f, 1.7.2). The version is not bumped.

Checks

  • devtools::test(): 0 failures.
    • 145 new expectations in 4 files.
    • The canonical JSON and digests match vectors computed independently with Python's json.dumps(sort_keys=True, separators=(",", ":"), ensure_ascii=False) and hashlib.
    • The 49 warnings come from the existing calculate_space tests (a tidyselect deprecation) and are unchanged.
  • R CMD check --no-manual --ignore-vignettes: Status OK, with 0 errors, 0 warnings and 0 notes.
  • webR 0.6.0 (R 4.6.0), using check-rate-methods.mjs in swamp_seahtrue packages/st-engine/webr-check/:
    • the digest binary was verified;
    • library(seahtrue) loads;
    • the registry is empty;
    • method_digest() under webR equals the independent vector.

This PR is a draft. Do not merge or tag it; Vincent decides the release.

🤖 Generated with Claude Code

…ate table

- rate_method(), method_parameter(), method_id(), method_canonical_json()
  and method_digest() (sha256 of the method's RFC 8785 JSON).
- The append-only method registry: method_registry() and
  lookup_rate_method() (exact match). It checks unique ids, exported method
  functions (never the xlsx reader), registered input methods that output
  what they feed, an O2 series fed only to a tick-rates method, and no input
  cycle. It ships empty.
- inst/extdata/method_registry.json (generated, tested byte-equal) and
  inst/extdata/method_registry_released.tsv (append-only record, tied to
  the package version by a test).
- compute_rates(): one plate (sha256 plate id), exact input methods and
  declared plate inputs, an exported method function, and a checked rate
  table (and fitted-values table) carrying the method id on every row.
  O2 series inputs and outputs are refused until their container exists.
- New Import: digest (>= 0.6.39).

Work item st-seahtrue-rate-calculation-method-value-object-method-5j2b
(swamp_seahtrue factory).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vcjdeboer vcjdeboer closed this Oct 3, 2026
@vcjdeboer
vcjdeboer deleted the st-engine/rate-methods-foundation branch October 3, 2026 20:01
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.

1 participant