-
Notifications
You must be signed in to change notification settings - Fork 3
7 - API (feat): Unify Proposal Number #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
RobertRosca
wants to merge
9
commits into
refactor/remove-global-state
from
feat/unify-proposal-number
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c55bbc3
feat(api/shared): add ProposalNumber value type and ProposalNo scalar
RobertRosca 6e804f9
test(api/shared): cover ProposalNumber validation and formatting
RobertRosca 351ce69
refactor(api): adopt ProposalNumber at runs input and path resolution
RobertRosca a9f4aae
refactor(api/metadata): adopt ProposalNumber in proposal metadata
RobertRosca 9b4f81b
fix(api/mymdc): format proposal number as integer in API URLs
RobertRosca 471bd12
refactor(api/auth): adopt ProposalNumber in user membership
RobertRosca 553515c
test(api): cover ProposalNo scalar rejection and path-not-found
RobertRosca e0bc413
build(api): add ty to lint group
RobertRosca 1579237
docs(api/adr): add ADR-004 proposal path locator
RobertRosca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| --- | ||
| date: 2026-07-07 | ||
| --- | ||
|
|
||
| # ADR-004 - Proposal path resolution: pure value type, injectable locator | ||
|
|
||
| ## Context and Problem Statement | ||
|
|
||
| A proposal number arrives as an untyped string or integer and is used in three ways: as a GraphQL input, as a filesystem path to the proposal's DAMNIT directory, and as a persistence key. Turning a number into a directory requires filesystem probing on GPFS - globbing under the proposal root, checking candidate directories, stat-ing for read-only status. GPFS is a network filesystem, so those calls can stall for seconds, and a hung mount can stall them indefinitely. | ||
|
|
||
| Two questions follow. Where does a proposal number get validated and formatted? Where does number-to-directory resolution live? | ||
|
|
||
| ## Considered Options | ||
|
|
||
| - One `ProposalNumber` type that both validates and resolves its own path, reading configuration directly (the reference tree's approach: a blocking `find_damnit_path_sync` method). | ||
| - A pure `ProposalNumber` value type plus a separate injectable `ProposalPathLocator` that owns resolution. | ||
|
|
||
| ## Decision Outcome | ||
|
|
||
| Chosen option: a pure value type plus a separate locator, because it keeps the value type free of I/O and settings, and isolates slow GPFS access behind a swappable, testable seam. | ||
|
|
||
| ### Consequences | ||
|
|
||
| - Good: `ProposalNumber` validation and formatting are pure and trivially unit-testable, with no settings coupling. | ||
| - Good: path heuristics live in one place behind a protocol, swappable for local mode and for tests. | ||
| - Bad: resolution becomes asynchronous once fully adopted, which will ripple into repository acquisition and the resolvers that call it. | ||
|
|
||
| ## Details | ||
|
|
||
| ### The rules | ||
|
|
||
| 1. `ProposalNumber` (target `core/types.py`, today `shared/models.py`) is a pure value type. It validates (1-999999, rejects floats), formats to the canonical `p{n:06d}` form, and carries a pydantic schema. It does no I/O and reads no settings. | ||
| 2. Number-to-directory resolution belongs in a `ProposalPathLocator` (target `proposals/locator.py`), built by a factory, held on `AppState`, and injected where resolution is needed. Implementations are a GPFS locator (production glob heuristics) and a fixed locator (local mode and tests). | ||
| 3. Filesystem calls in request paths run off the event loop with timeouts. A hung GPFS mount degrades one request, not the whole server. | ||
| 4. A failed resolution raises `ProposalNotFoundError` (see [ADR-001](001-error-classes.md)) at the edge, not a bare error from a constructor. |
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use pyright AND ty? Might make more sense to choose one over the other. Also please include the chosen type checker in the CI and pre-commit.