nx_synthetic_upstream.nx
buildroot/runtime/nx_synthetic_upstream.nx
about
nx_synthetic_upstream.nx -- canned-response replay for adapter testing.
module: nishi-core.ingest.synthetic_upstream
depends: nishi-core.io.syscalls, nishi-core.io.iso8601,
nishi-core.io.json, nishi-core.io.csv
disk_kb: 6
capability: CORE_IO
license_tier: PUBLIC_NISHI_SUBSTRATE
genealogy_id: nock_mock_pattern_software_testing +
wiremock_2011_http_stub_pattern +
vcr_python_cassette_pattern +
nishi_build_the_system_cardinal_2026
Per cardinal [[feedback-build-the-system-not-manual-output]]: this
is THE SYSTEM that proves the ingestion substrate works. Replays
CANNED HTTP responses from disk fixtures back to adapter code, so
every adapter runs end-to-end (URL parse → "fetch" → JSON/CSV
parse → canonicalize → license guard → JSONL emit) WITHOUT needing
real network.
Once this primitive ships, every NX-INGEST adapter shipped this
arc gets exercised in a substrate-level smoke test that proves:
- the URL builder produces the right query string
- the canned response gets parsed correctly
- the canonicalize step extracts the right fields
- the license-tier viral propagation works
- the JSONL emit shape matches expectations
Substrate runs in CI without internet. Once nx_dns_resolve glue
lands, the SAME adapter code (Cardinal 19) swaps the synthetic
upstream for real nx_https_get with no caller change.
dependencies 2 imports · 1 importers
imports: nx_syscalls.nxnx_iso8601.nx
imported by: nx_smoke_harness.nx
structs
| 76 | struct SyntheticUpstream |
| 157 | struct FixtureResponse |
consts
| 45 | const NX_SU_OK: i64 = 1 |
| 46 | const NX_SU_FIXTURE_NOT_FOUND: i64 = 2 |
| 47 | const NX_SU_FIXTURE_PARSE_FAIL: i64 = 3 |
| 48 | const NX_SU_NO_RESPONSE_REGISTERED: i64 = 4 |
| 49 | const NX_SU_MULTIPLE_AMBIGUOUS: i64 = 5 |
| 91 | const NX_SU_BYTES: i64 = 80 // 10 fields * 8 bytes |
| 118 | const NX_SU_FNV1A_OFFSET_BASIS: i64 = -3750763034362895579 |
| 119 | const NX_SU_FNV1A_PRIME: i64 = 1099511628211 |
| 171 | const NX_FIXTURE_RESPONSE_BYTES: i64 = 88 // 11 fields * 8 bytes |
| 304 | const NX_SU_RECORD_MODE_OFF: i64 = 0 // pure replay |
| 305 | const NX_SU_RECORD_MODE_NEW: i64 = 1 // record only if fixture missing |
| 306 | const NX_SU_RECORD_MODE_ALL: i64 = 2 // overwrite existing fixtures |
| 307 | const NX_SU_RECORD_MODE_NONE: i64 = 3 // never record (CI mode) |
functions
| 51 | func nx_su_verdict_name(v: i64) -> *u8 |
| 93 | func nx_synthetic_upstream_new( calls 1: sys_mmap |
| 121 | func nx_su_request_hash(method_ptr: *u8, method_len: i64, url_ptr: *u8, url_len: i64) -> i64 called by 1: nx_synthetic_upstream_serve |
| 177 | func nx_su_build_fixture_path( called by 1: nx_synthetic_upstream_serve |
| 245 | func nx_synthetic_upstream_serve( |
| 309 | func nx_su_record_mode_name(m: i64) -> *u8 |
| 326 | func nx_synthetic_upstream_hit_rate_q10(u: *SyntheticUpstream) -> i64 |