Chapter 12 Implementation Bindings & APIs (I)


I. Abstract & Scope
This chapter defines the implementation bindings and external interface family I80-* / API v1 for Oriented Tension across CLI/SDK/HTTP layers: unified request–response contracts, unit & dimension (Unit/Dim) carriage, integration with DatasetCard/ModelCard/MetrologyCard/PipelineCard, reproducible execution of SimStack-OT, error semantics & quotas, and security & audit. Equations and symbols use English notation wrapped in backticks; SI units with 3 significant figures by default. Any ToA result must return both forms in parallel with explicit path gamma(ell) and measure d ell.

II. Dependencies & References

  1. Geometry & orientation: Chapter 3 (S80-1/2).
  2. Constitutive & dynamics: Chapter 4 (S80-3/4, P80-2/3/9/10).
  3. Metrology: Chapter 5 (M80-1…4).
  4. Couplings & media: Chapter 6 (S80-5/6).
  5. Energy accounting: Chapter 7 (S80-7/8).
  6. Numerical methods & simulation: Chapter 10 (SimStack-OT).
  7. Data & pipelines: I75-*/M75-* (Chapter 14 conventions, reusing this volume’s card formats).

III. Normative Anchors (added in this chapter, I80-*)

  1. I80-0 (Interface Layers): a single contract & error semantics across:
    • CLI: ot <command> [--flags]
    • SDK (Python): from ot import api
    • HTTP/JSON: POST /v1/...
  2. I80-1 oriented_tension(Q_ij, grad_u) -> T_fil_ij: compute oriented tension from the order tensor and deformation gradient; return Pa, symmetric & traceless-consistent.
  3. I80-2 infer_Q_from_polarimetry(data, R_inst) -> {Q_ij, Cov_Q}: invert Q_ij and covariance from polarimetry/scattering while enforcing Tr(Q)=0.
  4. I80-3 couple_transport(Q_ij, fields, params) -> {W_cpl, D_eff, eps_ij, mu_ij, C_eff}: produce coupling free energy and effective transport/wave tensors.
  5. I80-4 edx_balance(T_fil_ij, W_orient, flows, fields) -> {P_in, P_mech, P_cpl, P_diss, Phi_E}: power decomposition and closure residuals.
  6. I80-5 simulate_ot(SimCfg) -> {products, metrics}: run SimStack-OT for numerical simulations & benchmarks.
  7. I80-6 fit_ot(bundle, model, priors) -> {posterior, evidence, masks}: joint fitting of OT constitutive/coupling parameters with evidence and dominance masks.
  8. I80-7 export_cards(artifact) -> {DatasetCard|ModelCard|MetrologyCard|PipelineCard}: export standard cards from artifacts.
  9. I80-8 metrics_validate(metrics, thresholds) -> {pass|fail, diff}: metric gates (incl. EDX-closure).
  10. I80-9 (Contract & Units): all numeric fields MUST carry unit & dim; Phi(E) MUST include sr and energy dimension; Q_ij is dimensionless and traceless; tensor units & dimensions must close.
  11. I80-10 (ToA Requirement): any request/response with T_arr MUST return T_arr^A/T_arr^B plus {gamma(ell), d ell} and delta_form.
  12. I80-11 (Reproducibility): optional request seed; responses return {rng_state, code_hash, data_hash}; artifacts may be registered as benchmarks.

IV. Body Structure


I. API Layers & Styles


II. Contracts & Schemas (JSON examples)

{

"bundle": {"datasets": ["cards/dataset_pol.json","cards/dataset_mech.json"], "unit": "SI"},

"model": {"card": "cards/model_ot.json"},

"priors": {"tau_relax": {"type":"LogNormal","mu":-2.3,"sigma":0.5}},

"seed": 1729

}

{

"posterior": {

"tau_relax": {"mean": 0.12, "sd": 0.02, "unit": "s"},

"D_Q": {"mean": 1.6e-11, "sd": 0.3e-11, "unit": "m^2·s^-1"}

},

"evidence": {"Z": 2.1e3, "logZ": 7.65},

"masks": {"eta_dom": [{"band":"EM-1","E_min":"1e-2 eV","E_max":"1 eV","channel":"EM-coupling"}]},

"rng_state": "...",

"hash": {"code_hash":"sha256:...","data_hash":"sha256:..."}

}


III. Unit & Dimension Audits


IV. Error Semantics & Quotas


V. Security, Audit & Quotas


VI. Workflows & Use Cases (M-series map)


VII. Cross-References


VIII. Validation, Criteria & Counterexamples


IX. Figures & Lists