Skip to content

Batch navigation endpoints + problem listing via reflection#364

Open
wrigjl wants to merge 3 commits into
ReduxISU:CSharpAPIfrom
wrigjl:feature/nav-reflection-and-batch
Open

Batch navigation endpoints + problem listing via reflection#364
wrigjl wants to merge 3 commits into
ReduxISU:CSharpAPIfrom
wrigjl:feature/nav-reflection-and-batch

Conversation

@wrigjl

@wrigjl wrigjl commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Reworks the batch-metadata idea from #168 to sit on the reflection infrastructure this tree already has, and closes a gap the earlier navigation refactors left open. Three commits:

  1. refactor(nav): resolve problem listing via reflection — the ALL_/NPC_/P_/NPHard_ProblemsRefactor endpoints still scanned the on-disk Problems/ layout and split directory names on _, even though solver/verifier/visualization navigation had already moved to reflection (Implementation of Single Source Shortest Path Problem #317/Verifier nav: match on problem name, ignore problemType prefix #318/Problem_VisualizationsRefactor uses traversal + required problemType #331). Adds ProblemNavigationData (built once from ProblemProvider.Problems), reading the complexity class from each type's namespace and listing only top-level problems. Output is identical to the old scan (42 NPComplete + 5 P + 2 NPHard = 49), with no on-disk dependency and no name-truncation bug.

  2. feat(nav): add batch navigation endpointsNavigation/Batch with GET allProblems, allSolvers, allVerifiers, allVisualizations, allInfo, so the GUI can prime its state in one request instead of N per-problem round-trips. Every payload is projected from the same reflected data the singular controllers use, so a batch response can never drift from its per-problem counterpart.

  3. test(nav): cover Navigation/Batch endpoints — 11 tests focused on the no-drift guarantee.

How this differs from #168

#168 This PR
Scans Problems/ on disk, splits folder names Projects reflected ProblemProvider.* / *NavigationData (single source of truth)
IMemoryCache + 1h TTL + AddMemoryCache() + clearCache No new services; data is already process-lifetime, serialized once via Lazy<string>
POST for reads, problemType required GET, no problemType argument
Newtonsoft throughout System.Text.Json (allInfo keeps Newtonsoft to match ProblemProvider.info)

allInfo instantiates every interface (like ProblemProvider.info) but only on first call; instances are discarded after serialization and only the JSON string is retained.

Testing

  • dotnet build clean, dotnet test 689/689 pass (+11).
  • Verified live: batch output is element-for-element identical to the singular endpoints; allInfo byte-identical across calls.

Frontend note

The companion frontend PR (ReduxISU/Redux_GUI#82) currently calls these endpoints via POST with a ?problemType= query, matching #168. Against this backend those calls return 405 — the frontend needs to switch the five requestAll* helpers to GET (drop the unused problemType). Response shapes are otherwise compatible.

🤖 Generated with Claude Code

wrigjl and others added 3 commits July 13, 2026 17:52
The Problem-listing endpoints (ALL_/NPC_/P_/NPHard_ProblemsRefactor) still
scanned the on-disk Problems/ folder layout and derived names by splitting
directory names on '_', even though the solver/verifier/visualization
navigation had already moved to reflection (ReduxISU#317/ReduxISU#318/ReduxISU#331).

Introduce ProblemNavigationData, built once from ProblemProvider.Problems,
mirroring the sibling *NavigationData caches. A problem's complexity class is
read from its namespace (API.Problems.<Class>.<Folder>); only top-level
problems are listed, so nested helper variants such as
NPC_CLIQUE.Inherited (SipserClique) are excluded — matching the old
top-level directory scan exactly (42 NPComplete + 5 P + 2 NPHard = 49).

No on-disk dependency, no name-splitting bug (folder names with multiple
'_' were previously truncated), and consistent with the reflected
solver/verifier/visualization maps.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds Navigation/Batch with GET allProblems, allSolvers, allVerifiers,
allVisualizations and allInfo so the GUI can prime its state in one request
instead of N per-problem round-trips.

Reimplements the idea of upstream PR ReduxISU#168 on the reflection infrastructure
this tree already has: every payload is projected from the same reflected
data the singular Navigation controllers use (ProblemProvider.* and the
*NavigationData caches), so a batch response can never drift from its
per-problem counterpart.

Unlike PR ReduxISU#168 this does not scan the on-disk Problems/ layout, take a
problemType argument, or register an IMemoryCache: the reflected dictionaries
are already a process-lifetime in-memory cache, so each payload is serialized
exactly once via Lazy<string>. allInfo instantiates every interface (like
ProblemProvider.info) but only on first call; the instances are discarded
after serialization and only the JSON string is retained. Reads use GET and
System.Text.Json (allInfo keeps Newtonsoft to match ProblemProvider.info).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds Batch_Endpoint_Tests exercising all five batch endpoints, focused on the
no-drift guarantee: allProblems matches ALL_ProblemsRefactor and excludes the
inherited SipserClique helper; allSolvers/allVerifiers entries for SAT3 match
the singular per-problem endpoints; allInfo returns problem objects and is
byte-identical across calls (Lazy cache); and the endpoints reject POST.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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