8000 feat: harden backend-suite gates and fix live-network test fallback by irfan-dahir · Pull Request #604 · jikan-me/jikan · GitHub
[go: up one dir, main page]

Skip to content

feat: harden backend-suite gates and fix live-network test fallback - #604

Merged
irfan-dahir merged 1 commit into
chore/backend-suite-onboardingfrom
feat/backend-suite-hardening
Oct 11, 2026
Merged

irfan-dahir merged 1 commit into
chore/backend-suite-onboardingfrom
feat/backend-suite-hardening

Conversation

@irfan-dahir
Copy link
Copy Markdown
Collaborator

Stacked on #603 (the onboarding PR). Four files, total hardening of jikan's backend-suite setup.

1. Fix the live-network test fallback (the finding #603 surfaced)

test/unit/HttpFilesystemCacheClientCallback.php used to fall back to a live HttpClient::create() whenever a fixture file was missing — a suite that looks offline while hitting the real site. It is now a pure cache reader: a missing recording raises a named RuntimeException telling the developer to run composer link-fixtures.

  • Fixture hash derivation is unchanged, so all existing recordings resolve.
  • composer test (new script below) passes 394/394 — proving every fixture is already present and no test depended on live fetching.
  • audit_test_network_coupling (which measured this exact coupling on jikan) now reports clean.

2. Gate commits on error_handling + test_network_coupling

hooks.map.json now marks both entries preCommit: true:

  • Error-handling guard — deterministic greps, scoped to changed dirs.
  • Test network coupling — wholeRepo, catches the fallback pattern returning.

Both are fast (<0.5s) and invariant, so they qualify as commit gates. Verified live: the commit for this PR ran both gates and the existing grumphp flow. Per-machine wiring is a hand-merged .git/hooks/pre-commit (suite gate → grumphp), since grumphp already owns the hook; grumphp's original is backed up at pre-commit.grumphp.backup.

3. More audit sections live

  • apiConsistency — loadBearingCopy/hardBakedCopy on; authoredSemantics + vocabulary off with written reasons. Finds 20 real findings (see below).
  • toolchainGates — with a new "test": "phpunit" composer script; the suite measured jikan declared no test command despite phpunit.xml existing. Now clean.
  • errorShape / versioning stay refused (exit 2, honestly) — jikan is a client library: it authors no HTTP error envelope and has no versioned route files. Documented in _readme.

Final posture (repo-health)

Audit Status
error_handling ✅ clean (388 files)
test_network_coupling ✅ clean (was 🟡 1 finding)
toolchain_gates ✅ clean (after test script)
api_consistency 🟡 20 findings
form_request_validation, prose_flags, route_model_binding ✅ clean
12 others (route/layer/contract/mock/cache/rate-limit/endpoint-parity/shape/versioning …) ⚪ refused honestly (N/A or unconfigured for a library)

The 20 findings worth a decision

api_consistency load-bearing-copy: parsers compare scraped text against hard-coded sentinels that also appear on the wire — 'Unknown', 'N/A', 'Filler', 'Recap', 'Currently Airing', 'Not available', 'Publishing', 'Synonyms', 'None' (e.g. AnimeParser.php:207, MangaParser.php:217, AnimeEpisodeParser.php:151). A client that localizes or re-brands that copy silently breaks the semantics. Report-only per the suite's contract — deciding whether to extract enums/constants is a human call, not this PR's.

- test/unit/HttpFilesystemCacheClientCallback.php: remove the live
  HttpClient::create() fallback. A missing fixture is now a named
  RuntimeException telling the developer to run 'composer link-fixtures'.
  audit_test_network_coupling (which measured this shape-2 coupling on jikan)
  now reports clean; the full suite still passes 394/394 with fixtures present.
- .backend-suite/hooks.map.json: gate commits on audit_error_handling and
  audit_test_network_coupling (preCommit: true; fast + invariant).
- .backend-suite/arch-rules.json: add apiConsistency (loadBearingCopy and
  hardBakedCopy live; authoredSemantics and vocabulary off with reasons) and
  toolchainGates (manifestGlob/runnerGlob/requiredScripts: [test]).
- composer.json: add a 'test' composer script (the suite measured that jikan
  declared no test command despite phpunit.xml existing).
- .backend-suite/hooks.map.json / arch-rules _readme: document why errorShape
  and versioning stay refused (client library, no HTTP error envelope, no
  versioned routes).

audit posture: error_handling clean, test_network_coupling clean, api_consistency
20 load-bearing-copy findings (compared sentinels like 'Unknown'/'N/A'/'Filler'),
toolchain_gates clean after the script addition.
@irfan-dahir
irfan-dahir merged commit d2f24a4 into chore/backend-suite-onboarding Oct 11, 2026
3 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.

1 participant

0