Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e393793
feat(scope): add durable organization and bindings
PsiACE Sep 2, 2026
a1d0fb0
feat(migration): register existing runtime scopes
PsiACE Sep 2, 2026
99e4088
feat(artifact): publish exact revisions across scopes
PsiACE Sep 2, 2026
bbd4c4a
refactor(scope): replace project reporting with selections
PsiACE Sep 2, 2026
5cce29b
feat(integrations): resolve server-owned scopes
PsiACE Sep 2, 2026
14278d2
test(scope): verify selection and plugin contracts
PsiACE Sep 2, 2026
5d5b550
docs(scope): explain server-owned organization
PsiACE Sep 2, 2026
605701b
refactor(scope): remove legacy runtime migration
PsiACE Sep 2, 2026
d8a637d
fix(scope): retry bindings without savepoints
PsiACE Sep 2, 2026
325f20d
fix(scope): reject unregistered runtime partitions
PsiACE Sep 2, 2026
f45cc69
fix(scope): serialize hierarchy mutations
PsiACE Sep 2, 2026
056dd9e
fix(codex): guard operations by scope mode
PsiACE Sep 2, 2026
5e35afd
fix(publication): reject incomplete memory copies
PsiACE Sep 2, 2026
83f5235
chore: merge master into scope runtime
PsiACE Sep 2, 2026
3daf855
fix(ci): escape plugin shell variable safely
PsiACE Sep 2, 2026
74abed5
chore: merge latest master into scope runtime
PsiACE Sep 3, 2026
015dc00
chore: merge latest master into scope runtime
PsiACE Sep 3, 2026
befc32f
chore: merge latest master into scope runtime
PsiACE Sep 3, 2026
3a14f3a
fix(runtime): preserve referenced scope recall
PsiACE Sep 3, 2026
a7e5e7b
fix(publication): make delivery atomic
PsiACE Sep 3, 2026
94b388a
docs: use registered scope identifiers
PsiACE Sep 3, 2026
e02e10d
chore: merge latest master into scope runtime
PsiACE Sep 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(scope): remove legacy runtime migration
  • Loading branch information
PsiACE committed Sep 2, 2026
commit 605701b1b9fe44b3dd1e4d5562d90160d65ba062
2 changes: 0 additions & 2 deletions src/powercontext/builtin/runtime/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ async def open_builtin_contexts(
memory_reranker=memory_reranker,
memory_rerank_candidate_limit=config.runtime.memory_rerank_candidate_limit,
)
await contexts.scopes.register_existing()
await contexts.scopes.bootstrap_default()
yield contexts
return
Expand Down Expand Up @@ -386,7 +385,6 @@ async def open_builtin_contexts(
memory_reranker=memory_reranker,
memory_rerank_candidate_limit=config.runtime.memory_rerank_candidate_limit,
)
await contexts.scopes.register_existing()
await contexts.scopes.bootstrap_default()
yield contexts

Expand Down
13 changes: 0 additions & 13 deletions src/powercontext/builtin/scope/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ async def bootstrap_default(self) -> ScopeDescriptor:
existing = await self.default_scope()
if existing is not None:
return existing
scopes = await self.list()
if len(scopes) == 1:
return await self.set_default(scopes[0].scope_id)
created = await self.create(
ScopeDraft(
title="Default",
Expand All @@ -78,16 +75,6 @@ async def bootstrap_default(self) -> ScopeDescriptor:
await self.set_default(created.scope_id)
return created

async def register_existing(self) -> tuple[ScopeDescriptor, ...]:
"""Register Scope identities already present in durable runtime data."""

async with self._write_lock, self._database.transaction() as connection:
scope_ids = await self._repository.unregistered_runtime_scope_ids(connection)
registered = []
for scope_id in scope_ids:
registered.append(await self._repository.register_existing(connection, scope_id))
return tuple(registered)

async def create(self, draft: ScopeDraft, /) -> ScopeDescriptor:
async with self._write_lock:
return await self._create(draft)
Expand Down
50 changes: 1 addition & 49 deletions src/powercontext/builtin/scope/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,17 @@
from collections import defaultdict
from hashlib import sha256

from sqlalchemy import delete, insert, select, union, update
from sqlalchemy import delete, insert, select, update
from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.asyncio import AsyncConnection

from powercontext.builtin.persistence.tables import (
ARTIFACT_CANDIDATE_VERSIONS_TABLE,
ARTIFACTS_TABLE,
EXTERNAL_SKILL_REGISTRATIONS_TABLE,
MODEL_USAGE_DAILY_TABLE,
RECALL_TOKEN_DAILY_TABLE,
SCOPE_BINDINGS_TABLE,
SCOPE_CONTEXT_REFERENCES_TABLE,
SCOPE_CREATION_REQUESTS_TABLE,
SCOPE_EXTERNAL_REFERENCES_TABLE,
SCOPE_SETTINGS_TABLE,
SCOPES_TABLE,
SOURCE_CURSORS_TABLE,
SOURCE_JOURNAL_HEADS_TABLE,
SOURCES_TABLE,
)
from powercontext.builtin.scope.models import (
ScopeBinding,
Expand All @@ -49,49 +41,9 @@
)

_DEFAULT_SETTING = "default"
_RUNTIME_SCOPE_TABLES = (
SOURCES_TABLE,
SOURCE_JOURNAL_HEADS_TABLE,
ARTIFACTS_TABLE,
ARTIFACT_CANDIDATE_VERSIONS_TABLE,
SOURCE_CURSORS_TABLE,
EXTERNAL_SKILL_REGISTRATIONS_TABLE,
MODEL_USAGE_DAILY_TABLE,
RECALL_TOKEN_DAILY_TABLE,
)


class ScopeRepository:
async def unregistered_runtime_scope_ids(self, connection: AsyncConnection, /) -> tuple[str, ...]:
discovered = union(*(select(table.c.scope_id) for table in _RUNTIME_SCOPE_TABLES)).subquery()
values = await connection.execute(
select(discovered.c.scope_id)
.outerjoin(SCOPES_TABLE, SCOPES_TABLE.c.scope_id == discovered.c.scope_id)
.where(SCOPES_TABLE.c.scope_id.is_(None))
.order_by(discovered.c.scope_id)
)
return tuple(str(scope_id) for scope_id in values.scalars())

async def register_existing(
self,
connection: AsyncConnection,
scope_id: str,
/,
) -> ScopeDescriptor:
await connection.execute(
insert(SCOPES_TABLE).values(
scope_id=scope_id,
title=scope_id,
summary="Registered from existing runtime data.",
parent_scope_id=None,
version=1,
)
)
registered = await self.get(connection, scope_id)
if registered is None:
raise AssertionError
return registered

async def get(self, connection: AsyncConnection, scope_id: str, /) -> ScopeDescriptor | None:
scopes = await self.get_many(connection, (scope_id,))
return None if not scopes else scopes[0]
Expand Down
29 changes: 1 addition & 28 deletions tests/builtin/test_scope_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from sqlalchemy.exc import IntegrityError

from powercontext.builtin.persistence.sqlite import SQLiteConfig, SQLiteProfile
from powercontext.builtin.persistence.tables import BUILTIN_TABLES, SOURCES_TABLE
from powercontext.builtin.persistence.tables import BUILTIN_TABLES
from powercontext.builtin.scope import (
ScopeApplication,
ScopeBindingKey,
Expand Down Expand Up @@ -51,33 +51,6 @@ async def scenario() -> None:
asyncio.run(scenario())


def test_existing_runtime_scope_is_registered_and_reused_as_default() -> None:
async def scenario() -> None:
async with SQLiteProfile.open(SQLiteConfig(), tables=BUILTIN_TABLES) as profile:
async with profile.database.transaction() as connection:
await connection.execute(
SOURCES_TABLE.insert().values(
scope_id="legacy-scope",
source_type="text",
source_id="source-1",
payload=b"existing",
journal_position=1,
)
)
scopes = ScopeApplication(profile.database)

registered = await scopes.register_existing()
default = await scopes.bootstrap_default()

assert tuple(scope.scope_id for scope in registered) == ("legacy-scope",)
assert await scopes.register_existing() == ()
assert default.scope_id == "legacy-scope"
assert default.title == "legacy-scope"
assert default.summary == "Registered from existing runtime data."

asyncio.run(scenario())


def test_scope_creation_is_idempotent_but_not_ambiguous() -> None:
async def scenario() -> None:
async with SQLiteProfile.open(SQLiteConfig(), tables=BUILTIN_TABLES) as profile:
Expand Down
Loading