server: add /api/v1/types endpoint + lazy bare-type fallback#9
Merged
Conversation
Phase 2.5(c). Closes two of the remaining three conformance failures by
adding discovery-style endpoints + a lazy-mode fallback for bare-type
queries.
Changes:
1. registry_loader.py: new load_type_info(registry_dirs, secid_type)
helper reads registry/<type>.json from the first directory that has it.
Returns the parsed type-level metadata (description, purpose, format,
examples) or None.
2. registry_loader.py: new list_all_types(registry_dirs) returns
metadata for all 10 SecID types in canonical order. Used by the
/api/v1/types endpoint and informs future centralization of subtype
declarations.
3. resolver.py: bare-type queries (e.g., secid:advisory) now fall back
to load_type_info() when the store doesn't have the index. Bulk-load
builds the index at startup; lazy mode now lazily fills it in too.
Closes the list-advisory-namespaces conformance failure.
4. secid_server.py: new GET /api/v1/types endpoint mirrors SecID-Service.
Returns {types: [{type, description, long_description, subtypes}, ...]}.
Subtypes are always [] today — those descriptions live in
SecID-Service's type-registry.ts, not yet in registry data. Closes
the list-types conformance failure.
Tests:
- 4 new unit tests in test_smoke.py covering:
- /api/v1/types returns exactly 10 types
- Each entry has the canonical shape
- list_all_types() works without any registry data
- load_type_info() returns None for missing files
- 23/23 tests pass locally.
Conformance progression:
After Phase 2.5(a): 7/10
After this PR: 9/10
Remaining: 1/10 (resolve-cve-cross-source — needs bare-
namespace cross-source search, Phase 2.5d)
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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
Phase 2.5(c) — closes two of the remaining three conformance failures by adding discovery-style endpoints + a lazy-mode fallback for bare-type queries.
What's fixed
`list-types` conformance fixture
New endpoint `GET /api/v1/types` returns the canonical type list with descriptions, mirroring SecID-Service's same endpoint. Type metadata sourced from `registry/.json` files in the configured registry directories.
Open question for the spec: subtype descriptions currently live in SecID-Service's `type-registry.ts` only — not in registry data. The Python endpoint returns `subtypes: []` for every type and notes the limitation in a docstring. Future work could centralize a `schemas/type-registry.json` in SecID so all implementations read from one canonical source.
`list-advisory-namespaces` conformance fixture
Bare-type queries (`secid:advisory`) now work in lazy mode. The bug: `bulk_load` builds the `secid:` index, but `load_single` doesn't — so lazy mode never had the data. The fix: lazy-load `registry/.json` from disk on demand, exactly like `load_single` does for namespace files.
Conformance progression
New helpers in `registry_loader.py`
Tests
Out of scope (Phase 2.5(d))
🤖 Generated with Claude Code