Skip to content

test: contract + reflexive suites — closes Tier-1 punch list (D+ → C) - #192

Merged
hyperpolymath merged 2 commits into
mainfrom
claude/fix-security-issues-9zrz0
Apr 23, 2026
Merged

hyperpolymath merged 2 commits into
mainfrom
claude/fix-security-issues-9zrz0

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Closes the last two open items on the Tier-1 punch list for testing-taxonomy grade C, promoting Hypatia from D+ → C.

test/support/contract_case.ex + test/contract_test.exs (19 tests)

  • ContractCase helper: use-macro tags the module :contract, provides assert_invariant/2, assert_pre/2, assert_post/2. Invariant failures name the violated contract in CI output.
  • Covers: TriangleRouter.dispatch_strategy/1 thresholds (5), RateLimiter burst (3), Quarantine auto-quarantine + reversibility (7), VCL.Client.parse/1 totality mirroring ParserTotality.lean (4).

test/reflexive_test.exs (16 tests)

  • SelfDiagnostics — health_report shape, circuit_state initial, 3-failure opens circuit, 2-failure safe, success resets counter, half_open→closed recovery path (6).
  • VCL.Client.stats/0 key contract (1), RateLimiter.stats/0 key contract + dispatch increment (2), Quarantine.list_quarantined/0 (2).
  • Justfile doctor recipe structural test: existence, required tools, optional FFI tools, exit 1 on failure, heal follows (5).

Infrastructure

  • mix.exs: elixirc_paths/1 added so test/support/ compiles in :test.
  • .machine_readable/testing/blitz.a2ml: CTR weak → partial, REF weak → strong, summary recounted, Tier-1 punch list all marked done, grade bumped D+ → C.

Test plan

  • mix test --only contract — 19 contract tests pass
  • mix test --only reflexive — 16 reflexive tests pass
  • mix test — full suite still green (no regression from new files or from elixirc_paths change)
  • Invariant-named failure message renders cleanly on a forced failure (sanity check of assert_invariant)

https://claude.ai/code/session_01HydKmB9xuTP9Xr11Au1N2o


Generated by Claude Code

claude added 2 commits April 23, 2026 21:56
…Tier-1 punch-list #2)

Adds test/support/contract_case.ex (ContractCase — use ExUnit.Case +
assert_invariant/assert_pre/assert_post macros) and test/contract_test.exs
(19 tests across 4 contract surfaces):

  • TriangleRouter.dispatch_strategy/1 — confidence threshold contracts:
    ≥0.95 → :auto_execute, [0.85,0.95) → :review, <0.85 → :report_only,
    non-numeric → :report_only (fail-safe), boundary separation.
  • RateLimiter — burst-limit contract: fresh bot allowed, 10 dispatches
    saturate burst window, retry_after_ms is positive.
  • Quarantine — auto-quarantine contracts: 5 consecutive failures →
    hard, 4 failures safe, FP rate >30% (min 5 outcomes) → soft,
    FP rate ≤30% safe, manual quarantine/release reversible, reroute nil
    for clean bot.
  • VCL.Client.parse/1 — totality contract: well-formed SELECT → {:ok, _},
    empty string → {:error, _}, 8 malformed inputs all return ok|error
    never raise, parse→execute roundtrip returns a result.

mix.exs: add elixirc_paths/1 so test/support/ is compiled in :test env.
blitz.a2ml: CTR weak → partial; summary counts updated; punch-list item
contract-test-harness marked done 2026-04-23; items-open shrinks to
[reflexive-test-suite].

Run contract tests only: mix test --only contract

https://claude.ai/code/session_01HydKmB9xuTP9Xr11Au1N2o
…(D+ → C)

Adds test/reflexive_test.exs tagged :reflexive, covering the four
self-introspection surfaces the testing-taxonomy audit flagged:

  • SelfDiagnostics — health_report/0 returns a map, circuit_state/0
    starts :closed, 3 consecutive dispatch failures open the circuit,
    2 failures don't, dispatch_success resets the counter, and the
    full half_open → closed recovery path (simulated by sending
    :try_half_open directly to avoid the 15-min cooldown timer).
  • VCL.Client.stats/0 — exposes :query_count, :cache_size, :cache_ttl_ms
    with the expected types and ranges.
  • RateLimiter.stats/0 — exposes all 6 counter keys; total_dispatched
    increments after record_dispatch/1.
  • Quarantine.list_quarantined/0 — starts empty; manual quarantine
    appears in the roster with the right level and reason.
  • Justfile doctor recipe — structurally tested (existence, required
    tool checks, optional tool checks, non-zero exit on failure,
    heal recipe follows).

blitz.a2ml:
  • REF weak → strong (dedicated suite + just doctor coverage).
  • Summary: strong 8 → 9, weak 4 → 3.
  • Punch list: reflexive-test-suite marked done; items-open = [];
    all-tier-1-complete = true.
  • Grade: D+ → C (target now B); all 5 Tier-1 items closed.

https://claude.ai/code/session_01HydKmB9xuTP9Xr11Au1N2o
@hyperpolymath
hyperpolymath merged commit ccf6e42 into main Apr 23, 2026
28 of 55 checks passed
@hyperpolymath
hyperpolymath deleted the claude/fix-security-issues-9zrz0 branch April 23, 2026 22:09
hyperpolymath added a commit that referenced this pull request Nov 5, 2026
…of the manifest (#1010)

## Why

hyperpolymath/echidnabot#192 puts echidnabot's GraphQL API behind a
bearer credential. Hypatia holds the *route* credential, which may only
call `submitProofObligation`, for the repositories echidnabot lists.
Without this PR, once #192 is deployed, Hypatia's obligations and
re-queues get 401.

Separately, `FleetDispatcher` copied every obligation's claim and
context into `data/verisim/dispatch/pending.jsonl`, which lives in a
git-backed tree. Those lines were also dead letters:
`dispatch-runner.sh` skips entries with no `.strategy`.

This is Wave 0, merged row 2, of the echidna proof-route plan
(metadatastician/standards#1397).

## What changes

- `EchidnabotObligation.auth_headers/0` reads
`HYPATIA_ECHIDNABOT_TOKEN`, trimmed. When it is unset or blank, no
header is sent. Both senders use it:
- `FleetDispatcher`, on the per-bot `HYPATIA_ECHIDNABOT_URL` path only.
The fleet coordinator never receives the credential.
  - `LearningScheduler`, on its re-queue.
- **Redirects are not followed** (359f0a8, from review).
`FleetDispatcher.http_post/3` and `LearningScheduler.http_post_json/3`
now pass `{:autoredirect, false}`, so a 3xx comes back as `{:error,
{:http_status, 3xx}}`.
- Probed locally on OTP 25: for 307 and 308, `:httpc` re-POSTs the body
to the `Location` host and reports that host's 2xx as success. For 301,
302 and 303 it re-sends as GET.
- OTP 25 did not forward `authorization`. CodeRabbit reports that OTP
releases before 27.3.4.13 do; the repo pins 27.3.4.4. I have not tested
that claim.
- For echidnabot, the manifest line records `variables_sha256` (from
`EchidnabotObligation.variables_digest/1`) instead of the variables.
Other bots' manifest lines are unchanged.
- `docs/wiki-pages/Operations.md` documents the new variable.

## Tests

The capturing server in `test/echidnabot_dispatch_test.exs` now reports
request headers too. A redirecting server was added. Six tests are new:
- the credential reaches the per-bot path (whitespace trimmed);
- no header is sent when the variable is blank;
- the credential never reaches the fleet coordinator;
- the re-queue sends the credential;
- the dispatcher does not follow a 307, and the redirect target is never
contacted;
- the re-queue does not follow a 308.

The manifest test asserts that the line holds no claim or context. It
checks the digest against a SHA-256 the test computes itself.

**CI result on 359f0a8:** Integration Tests runs `mix test --include
integration` on OTP 27 / Elixir 1.17. It reported 2484 tests, 0
failures, 242 excluded; the excluded tests are the known `:verisim_data`
tag. The log shows `Live dispatch to echidnabot failed ({:http_status,
307})` for the redirect test. Every other check is green.

**Locally:** I could not run the suite. Ubuntu's Elixir 1.14 is too old
for `phoenix_template`. The changed files parse, and `mix format
--check-formatted` reports no diff in lines this PR touches.

## Not done

- Deployment wiring: setting `HYPATIA_ECHIDNABOT_TOKEN` wherever Hypatia
runs, to the same value as echidnabot's `ECHIDNABOT_API_ROUTE_TOKEN`.
That is an owner action.
- Upgrading the pinned OTP past 27.3.4.13. That is a separate change
beyond this PR.
- Rate limiting, Kin gate and quarantine on the echidnabot dispatch
path. These are later rows of the plan.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01J4QvDgzT72Tq2HTJmikyNg
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