Repository navigation
feat(generation): standardize source access #1461
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
Merged
Zxf-xufeng
merged 17 commits into
master
from
codex/artifact-generation-source-access-implementation
Sep 8, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
596e99f
feat(api): add source and artifact access
Zxf-xufeng f35b67a
Merge branch 'master' into codex/source-artifact-rest-api-implementation
Zxf-xufeng d0b21c0
feat(api): align source and artifact access with RFC
Zxf-xufeng c859468
feat(api): implement latest source and artifact RFC
Zxf-xufeng edd44c4
fix(api): validate artifact family content as JSON
Zxf-xufeng e5006f7
Merge origin/master into codex/source-artifact-rest-api-implementation
Zxf-xufeng c764d64
fix(api): align artifact revision source semantics
Zxf-xufeng ba04cab
Merge remote-tracking branch 'origin/master' into codex/source-artifa…
Zxf-xufeng 0153496
fix(api): reuse family artifact write flows
Zxf-xufeng f669836
Merge remote-tracking branch 'origin/master' into codex/source-artifa…
Zxf-xufeng 20cb679
fix(ci): sync base API generated artifacts
Zxf-xufeng d7eb3d3
test(cli): follow current config validation path
Zxf-xufeng 7c0e573
feat(generation): standardize source access
Zxf-xufeng 3cdc3a2
merge: resolve PR 1461 against latest master
Zxf-xufeng bac14d7
fix(generation): guard memory evidence and retain failing references
Zxf-xufeng fc6a87a
fix(generation): preserve source identity on definition lookup failure
Zxf-xufeng b137a95
merge: resolve PR 1461 against latest master
Zxf-xufeng 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
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
63 changes: 63 additions & 0 deletions
63
src/powercontext/builtin/persistence/generation_sources.py
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,63 @@ | ||
| # Copyright (c) 2026 OceanBase. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Source reads whose purpose is Artifact generation.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Sequence | ||
|
|
||
| from sqlalchemy.ext.asyncio import AsyncConnection | ||
|
|
||
| from powercontext.builtin.persistence.sources import SourceRepository, StoredSource | ||
| from powercontext.builtin.source_eligibility import is_generation_eligible, require_source_eligible | ||
| from powercontext.sources import SourceRef | ||
|
|
||
|
|
||
| class GenerationSourceAccess: | ||
| """Keep generation reads and Source eligibility inseparable.""" | ||
|
|
||
| def __init__(self, repository: SourceRepository, /) -> None: | ||
| self._repository = repository | ||
|
|
||
| async def require_for_generation( | ||
| self, | ||
| connection: AsyncConnection, | ||
| scope_id: str, | ||
| refs: Sequence[SourceRef], | ||
| /, | ||
| ) -> tuple[StoredSource, ...]: | ||
| """Resolve explicit references, rejecting the whole request if any is ineligible.""" | ||
|
|
||
| rows = await self._repository.get_many(connection, scope_id, refs) | ||
| for row in rows: | ||
| require_source_eligible(row.ref, row.value) | ||
| return rows | ||
|
|
||
| async def list_window_for_generation( | ||
| self, | ||
| connection: AsyncConnection, | ||
| scope_id: str, | ||
| /, | ||
| *, | ||
| after: int, | ||
| through: int, | ||
| ) -> tuple[StoredSource, ...]: | ||
| """Resolve one bounded journal window and omit valid lineage-only Sources.""" | ||
|
|
||
| rows = await self._repository.list_window(connection, scope_id, after=after, through=through) | ||
| return tuple(row for row in rows if is_generation_eligible(row.value)) | ||
|
|
||
|
|
||
| __all__ = ["GenerationSourceAccess"] |
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.