Skip to content

Test reference HTTP+JSON transport reliability - #12

Merged
NetworkTheoryAppliedResearchInstitute merged 5 commits into
NTARI-RAND:mainfrom
nirmalhk7:nirmal/protocol-transport-reliability
Nov 12, 2026
Merged

NetworkTheoryAppliedResearchInstitute merged 5 commits into
NTARI-RAND:mainfrom
nirmalhk7:nirmal/protocol-transport-reliability

Conversation

@nirmalhk7

@nirmalhk7 nirmalhk7 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Extend the existing HTTP+JSON transport tests with a signed six-operation lifecycle, exact SPEC §7 success codes, GET response media types, request-context propagation, and concurrent request payload isolation. Each concurrent worker carries distinct node and job IDs, so swapped or reused payloads fail even when the request count is correct.

The branch includes the already merged transport coverage from #15. Its duplicate invalid-request table is removed, and the new numeric NodeID rejection case is added to the existing table. Helpers used by sibling transport tests remain available. Production code, wire behavior, SPEC and dependencies are unchanged.

Validation:

  • go test ./..., go test -race ./transport/httpjson, go vet ./..., and go build ./... pass.
  • python3 testdata/reproduce_spec.py passes.
  • Targeted mutation checks catch substituted node IDs, incorrect status codes/media types and lost handler context.
  • Full Qlty smells/check scans introduce no findings compared with the captured baseline.
  • Go formatting and git diff --check pass.

Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Nirmal. This is a careful, well-built set of tests. I reviewed f7c802e (one commit, test-only, DCO signed off).

What was checked

  • CI run 39908532946: gofmt, go vet and go build pass. go test ./... gives 9 ok and 0 FAIL. Foreign-implementation conformance is 55/55 ALL MATCH, dependency-leaf passes and DCO passes. One caveat: that run tested a merge with main as of 4e52c35 (before #15), because the re-run reused the original merge SHA.
  • On the current merge with main (91e182f, which includes #15's client_test.go and server_test.go), gofmt is clean, go vet ./... passes, and the combined test binary compiles and links. #15 changed only test files, so client.go and server.go are the same code your tests already passed against. The two test packages (httpjson and httpjson_test) share no state.
  • I read the tests against client.go, server.go and SPEC §7. They are deterministic: fixed key seed and timestamps, httptest on port 0, .invalid hosts for fake transports, and no sleeps used to wait on other code. No registry IDs or TestInvariant_* tests are touched, and CONFORMANCE.md needs no change.

What this adds beyond main

  • Signed round trips for all six operations, with uint64 Seq above 2^63, nanosecond timestamps, nested slices, and a NodeID with reserved and non-ASCII characters (transport_test.go:72-125).
  • Coordinator errors checked end to end through the client and the handler together (:166-177).
  • Cancellation for all six operations, including mid-request with a channel handshake (:238-271). This covers the cancellation half of the #15 follow-up.
  • A bound on bytes read from large error bodies (:230).

Nits, none blocking

  1. Overlap with #15, which merged after you opened this. Lines :127-163 repeat server_test.go:149-160 (wrong method gives 405, bad bodies give 400, missing node_id). Optional: drop those and move the one new body, {"NodeID":42}, into the table at server_test.go:157. Please keep roundTripFunc, trackedBody (with its read counter), testCoordinator and clientCalls in package httpjson, because #13 uses them. The PR description's first sentence ("had no focused tests...") is out of date since #15. A one-line update saying what this adds would help.
  2. TestConcurrentClientCalls (:274-293) checks only for no errors and a count of 96, and every goroutine sends identical messages. Until CI runs -race (#14), a future change that swapped two valid request bodies would still pass. Suggestion: give each goroutine distinct NodeIDs and JobIDs, and compare the received (type, NodeID, JobID) set against what was sent. Could you also add the exact local command behind "passed the race-enabled suite"?
  3. A gap from before this PR: nothing asserts the SPEC §7 success codes (204 for the four POSTs, 200 for the two GETs; SPEC.md:393-398), because the client accepts any 2xx (client.go:75). Deleting server.go:80 still passes every test. testCoordinator also ignores ctx, so the handler dropping r.Context() (server.go:38, :51, :76) would go unnoticed. TestSignedLifecycle is a natural place for this: wrap Handler(c) to record status and Content-Type, and pass a context value through to testCoordinator. Fine as a follow-up.

No rebase is needed for any of this. A force-push would reset review and require restacking #13 and #14. Thanks again for the thorough work.

Approved at the tested commit f7c802e on Jodson Graves's instruction.

Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Nirmal. This round fixes everything from my last review, and you merged main instead of force-pushing, which keeps #13 and #14 workable.

What I checked

  • I read the full diff against main (91e182f) and the changes since f7c802e. It's test-only plus a new README section: no production code, SPEC, vector or go.mod change. The new tests import only the standard library and this module's own packages, so the P-lean-code check is unaffected.
  • I also read the tests against #13. Its decode_fuzz_test.go still finds testCoordinator, roundTripFunc, trackedBody and clientCalls, with no duplicate names. TestSignedLifecycle sets every timestamp, so #13's new ValidTime checks won't trip it.
  • I reviewed by reading the code and didn't run it. CI (the CI and dependency-leaf runs) hasn't run on this head yet: runs from a fork wait for a maintainer's OK. This approval holds only if it passes. If anything fails, I'll come back to you.

Earlier points, all addressed

  1. The duplicate rejection table is gone. {"NodeID":42} is now in the shared table (server_test.go:157), the helpers are still in package httpjson (transport_test.go:26-168), and the description is updated.
  2. Each concurrent worker now sends its own node and job IDs, and the test compares the full set of received (operation, node, job) values (concurrent_test.go:24-54). The race command is in the description and README.md:72.
  3. The SPEC §7 success codes and context forwarding are now pinned (server_contract_test.go:20-41). Deleting server.go:80 or dropping r.Context() would now fail.

Heads-up on merge order: main only allows squash or rebase merges, so whichever of #12 and #13 lands second will show an add/add conflict in transport/httpjson/transport_test.go. I'll tell you which way we go. If it's this PR that needs it, please merge main into this branch (a merge, not a rebase or force-push), keep your version of transport_test.go, and sign off the merge commit (git commit -s) like you did on f4ab178.

I left two optional, non-blocking notes inline.

Approved at f4ab178 on Jodson Graves's instruction, conditional on CI passing.

Comment thread README.md
- **Stub, not built:** `anchor/` — the witnessed employment-claim layer
(open problem #6). Labeled as a stand-in; see its package doc.

## Verification

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional, non-blocking: once #14 lands, consider replacing this section with a one-line pointer to RELIABILITY.md. The seven README..md translations won't carry this section. #14 also documents go test -race ./... rather than ./transport/httpjson, and #16 adds its own README commands, so one place for verification commands would stop them drifting apart.

{"success/jobs", "jobs", 200, `[]`, false},
{"success/listing", "listing", 200, `[]`, false},
{"bad-json/jobs", "jobs", 200, `{`, true},
{"bad-json/listing", "listing", 200, `{`, false},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional, FYI: this row and line 22 record that a POST answered with 200 and any body (even {) counts as success. That matches today's client (client.go:75 accepts any 2xx and doesn't read POST bodies), but SPEC §7 says 204. Fine to keep as a record of current behaviour. If the client is ever made strict, these two rows are the ones to flip.

@NetworkTheoryAppliedResearchInstitute

Copy link
Copy Markdown
Contributor

Thanks again, Nirmal. The merge order is decided: #13 went first and merged today as c3fac19, with main's CI green on that commit. So this PR now shows the expected add/add conflict in transport/httpjson/transport_test.go.

To resolve it, merge main into your branch and keep your version of that file:

git fetch <remote-for-NTARI-RAND>
git switch nirmal/protocol-transport-reliability
git merge <remote-for-NTARI-RAND>/main
git checkout --ours transport/httpjson/transport_test.go
git add transport/httpjson/transport_test.go
git commit -s
git push

Please merge rather than rebase or force-push, and sign off the merge commit like you did on f4ab178.

I checked this resolution ahead of time on a scratch copy (current main plus this branch, with your transport_test.go), by reading only. CI will be the real test.

  • No top-level name clashes in either test package. client_test.go's copies of roundTripFunc and trackedBody are in httpjson_test, so they don't collide with yours.
  • Reject invalid signed timestamps and fuzz untrusted inputs #13's decode_fuzz_test.go still finds testCoordinator, roundTripFunc, trackedBody (including closed and read) and clientCalls in your version.
  • The only test from main's copy that goes away is TestHandlerRejectsBadRequestsBeforeDispatch. That's expected, because your shared rejection table in server_test.go replaces it. TestClientCancellation, TestClientClosesResponseBodies and TestConcurrentClientCalls carry on in client_lifecycle_test.go and concurrent_test.go.

Your push will dismiss my approval, because the repo dismisses stale reviews on every push. I'll re-approve once CI passes on the new head.

Merge current main while preserving the transport contract, cancellation, and concurrent payload tests. Keep the shared helpers used by the merged fuzz targets.

Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Nirmal. This is exactly what the 11-10 note asked for. 7b4592d is a real merge of main (parents f4ab178 and c3fac19), it's signed off, and transport_test.go is byte-for-byte your approved version. Every other file matches git's own auto-merge, so the PR's content against main is the same as what I approved at f4ab178. As expected, the only test that drops is TestHandlerRejectsBadRequestsBeforeDispatch, which your shared rejection table replaces.

CI (build, vet, test, conformance) and the dependency-leaf check passed on 7b4592d.

Heads-up for #14: once this lands, it will hit the same transport_test.go conflict. Merging main and keeping main's version of that file should leave #14 with just its workflow, RELIABILITY.md and CONFORMANCE lines.

Approved at 7b4592d on Jodson Graves's instruction.

@NetworkTheoryAppliedResearchInstitute
NetworkTheoryAppliedResearchInstitute merged commit cfe78d1 into NTARI-RAND:main Nov 12, 2026
4 checks passed
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.

2 participants