Batch navigation endpoints + problem listing via reflection#364
Open
wrigjl wants to merge 3 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
refactor(nav): resolve problem listing via reflection — the
ALL_/NPC_/P_/NPHard_ProblemsRefactorendpoints still scanned the on-diskProblems/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). AddsProblemNavigationData(built once fromProblemProvider.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.feat(nav): add batch navigation endpoints —
Navigation/BatchwithGET 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.test(nav): cover Navigation/Batch endpoints — 11 tests focused on the no-drift guarantee.
How this differs from #168
Problems/on disk, splits folder namesProblemProvider.*/*NavigationData(single source of truth)IMemoryCache+ 1h TTL +AddMemoryCache()+clearCacheLazy<string>POSTfor reads,problemTyperequiredGET, noproblemTypeargumentallInfokeeps Newtonsoft to matchProblemProvider.info)allInfoinstantiates every interface (likeProblemProvider.info) but only on first call; instances are discarded after serialization and only the JSON string is retained.Testing
dotnet buildclean,dotnet test689/689 pass (+11).allInfobyte-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 fiverequestAll*helpers toGET(drop the unusedproblemType). Response shapes are otherwise compatible.🤖 Generated with Claude Code