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
Next Next commit
feat(scope): add durable organization and bindings
  • Loading branch information
PsiACE committed Sep 2, 2026
commit e39379327f11183525881d055148b77776a0f98b
86 changes: 85 additions & 1 deletion src/powercontext/builtin/persistence/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@
MAX_EXTERNAL_SKILL_HOST_ID_LENGTH,
MAX_EXTERNAL_SKILL_LOCATOR_LENGTH,
MAX_EXTERNAL_SKILL_NAME_LENGTH,
MAX_SCOPE_BINDING_EXTERNAL_ID_LENGTH,
MAX_SCOPE_BINDING_INTEGRATION_LENGTH,
MAX_SCOPE_BINDING_KIND_LENGTH,
MAX_SCOPE_EXTERNAL_REFERENCE_KIND_LENGTH,
MAX_SCOPE_EXTERNAL_REFERENCE_VALUE_LENGTH,
MAX_SCOPE_ID_LENGTH,
MAX_SCOPE_IDEMPOTENCY_KEY_LENGTH,
MAX_SCOPE_SUMMARY_LENGTH,
MAX_SCOPE_TITLE_LENGTH,
MAX_SOURCE_ID_LENGTH,
MAX_SOURCE_TYPE_LENGTH,
)
Expand Down Expand Up @@ -75,6 +83,82 @@ def _entry_text_type():
return Text().with_variant(MEDIUMTEXT(), "mysql")


SCOPES_TABLE = Table(
"pc_scopes",
SHARED_METADATA,
Column("scope_id", identity_string(MAX_SCOPE_ID_LENGTH), primary_key=True),
Column("title", String(MAX_SCOPE_TITLE_LENGTH), nullable=False),
Column("summary", String(MAX_SCOPE_SUMMARY_LENGTH), nullable=False),
Column("parent_scope_id", identity_string(MAX_SCOPE_ID_LENGTH)),
Column("version", Integer, nullable=False),
ForeignKeyConstraint(
("parent_scope_id",),
("pc_scopes.scope_id",),
ondelete="RESTRICT",
),
CheckConstraint("version > 0", name="ck_pc_scopes_version_positive"),
)

SCOPE_CONTEXT_REFERENCES_TABLE = Table(
"pc_scope_context_references",
SHARED_METADATA,
Column("scope_id", identity_string(MAX_SCOPE_ID_LENGTH), primary_key=True),
Column("referenced_scope_id", identity_string(MAX_SCOPE_ID_LENGTH), primary_key=True),
ForeignKeyConstraint(("scope_id",), ("pc_scopes.scope_id",), ondelete="CASCADE"),
ForeignKeyConstraint(("referenced_scope_id",), ("pc_scopes.scope_id",), ondelete="RESTRICT"),
CheckConstraint("scope_id <> referenced_scope_id", name="ck_pc_scope_context_references_not_self"),
)

SCOPE_EXTERNAL_REFERENCES_TABLE = Table(
"pc_scope_external_references",
SHARED_METADATA,
Column("scope_id", identity_string(MAX_SCOPE_ID_LENGTH), primary_key=True),
Column("ordinal", Integer, primary_key=True),
Column("kind", identity_string(MAX_SCOPE_EXTERNAL_REFERENCE_KIND_LENGTH), nullable=False),
Column("value", String(MAX_SCOPE_EXTERNAL_REFERENCE_VALUE_LENGTH), nullable=False),
Column("value_digest", identity_string(64), nullable=False),
ForeignKeyConstraint(("scope_id",), ("pc_scopes.scope_id",), ondelete="CASCADE"),
UniqueConstraint("scope_id", "kind", "value_digest", name="uq_pc_scope_external_references_value"),
CheckConstraint("ordinal >= 0", name="ck_pc_scope_external_references_ordinal_nonnegative"),
)

SCOPE_CREATION_REQUESTS_TABLE = Table(
"pc_scope_creation_requests",
SHARED_METADATA,
Column("idempotency_key", identity_string(MAX_SCOPE_IDEMPOTENCY_KEY_LENGTH), primary_key=True),
Column("request_digest", identity_string(64), nullable=False),
Column("scope_id", identity_string(MAX_SCOPE_ID_LENGTH), nullable=False),
ForeignKeyConstraint(("scope_id",), ("pc_scopes.scope_id",), ondelete="RESTRICT"),
)

SCOPE_SETTINGS_TABLE = Table(
"pc_scope_settings",
SHARED_METADATA,
Column("name", identity_string(64), primary_key=True),
Column("scope_id", identity_string(MAX_SCOPE_ID_LENGTH), nullable=False),
ForeignKeyConstraint(("scope_id",), ("pc_scopes.scope_id",), ondelete="RESTRICT"),
)

SCOPE_BINDINGS_TABLE = Table(
"pc_scope_bindings",
SHARED_METADATA,
Column("integration", identity_string(MAX_SCOPE_BINDING_INTEGRATION_LENGTH), primary_key=True),
Column("kind", identity_string(MAX_SCOPE_BINDING_KIND_LENGTH), primary_key=True),
Column("external_id", identity_string(MAX_SCOPE_BINDING_EXTERNAL_ID_LENGTH), primary_key=True),
Column("scope_id", identity_string(MAX_SCOPE_ID_LENGTH), nullable=False),
ForeignKeyConstraint(("scope_id",), ("pc_scopes.scope_id",), ondelete="RESTRICT"),
)

SCOPE_TABLES = (
SCOPES_TABLE,
SCOPE_CONTEXT_REFERENCES_TABLE,
SCOPE_EXTERNAL_REFERENCES_TABLE,
SCOPE_CREATION_REQUESTS_TABLE,
SCOPE_SETTINGS_TABLE,
SCOPE_BINDINGS_TABLE,
)


SOURCES_TABLE = Table(
"pc_sources",
SHARED_METADATA,
Expand Down Expand Up @@ -452,4 +536,4 @@ def _entry_text_type():

STATISTICS_TABLES = (MODEL_USAGE_DAILY_TABLE, RECALL_TOKEN_DAILY_TABLE)

BUILTIN_TABLES = SHARED_TABLES + MEMORY_TABLES + STATISTICS_TABLES
BUILTIN_TABLES = SCOPE_TABLES + SHARED_TABLES + MEMORY_TABLES + STATISTICS_TABLES
52 changes: 52 additions & 0 deletions src/powercontext/builtin/scope/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 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.

"""Durable Scope organization and binding."""

from powercontext.builtin.scope.application import ScopeApplication, generate_scope_id
from powercontext.builtin.scope.errors import (
ScopeBindingNotFoundError,
ScopeError,
ScopeIdempotencyConflictError,
ScopeNotFoundError,
ScopeRelationshipError,
ScopeVersionConflictError,
)
from powercontext.builtin.scope.models import (
ScopeBinding,
ScopeBindingKey,
ScopeDescriptor,
ScopeDraft,
ScopeExternalReference,
ScopeMutation,
ScopeSelection,
)

__all__ = [
"ScopeApplication",
"ScopeBinding",
"ScopeBindingKey",
"ScopeBindingNotFoundError",
"ScopeDescriptor",
"ScopeDraft",
"ScopeError",
"ScopeExternalReference",
"ScopeIdempotencyConflictError",
"ScopeMutation",
"ScopeNotFoundError",
"ScopeRelationshipError",
"ScopeSelection",
"ScopeVersionConflictError",
"generate_scope_id",
]
Loading