Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a8f2c92
refactor(runtime): remove the legacy APScheduler scheduling path
jackie-cqz Oct 26, 2026
17e261d
refactor(authz)!: move access control into the built-in runtime
jackie-cqz Oct 26, 2026
41bceaf
refactor: move shared helpers out of the cli and client packages
jackie-cqz Oct 26, 2026
6ee3626
Merge branch 'master' into fix/src-layering
jackie-cqz Oct 26, 2026
42f8bcc
Merge branch 'master' into fix/src-layering
jackie-cqz Oct 28, 2026
a60ef4f
test(release): import the access-control types the installed release …
jackie-cqz Oct 30, 2026
241398a
Merge branch 'master' into fix/src-layering
jackie-cqz Oct 30, 2026
d483061
Merge branch 'master' into fix/src-layering
jackie-cqz Nov 1, 2026
1e48704
Merge branch 'master' into fix/src-layering
jackie-cqz Nov 3, 2026
c9c9448
Merge branch 'master' into fix/src-layering
jackie-cqz Nov 4, 2026
a3ee50d
Merge branch 'master' into fix/src-layering
jackie-cqz Nov 4, 2026
3273d81
Merge branch 'master' into fix/src-layering
jackie-cqz Nov 6, 2026
c11fe6e
Merge branch 'master' into fix/src-layering
jackie-cqz Nov 8, 2026
12b1df0
Merge branch 'master' into fix/src-layering
jackie-cqz Nov 9, 2026
4c527bb
Merge branch 'master' into fix/src-layering
jackie-cqz Nov 9, 2026
cc246ee
Merge branch 'master' into fix/src-layering
jackie-cqz Nov 9, 2026
0cf83b5
Merge branch 'master' into fix/src-layering
jackie-cqz Nov 11, 2026
98f19c7
Merge branch 'master' into fix/src-layering
jackie-cqz Nov 12, 2026
1b26eb3
Merge branch 'master' into fix/src-layering
jackie-cqz Nov 13, 2026
6940326
Merge branch 'master' into fix/src-layering
jackie-cqz Nov 14, 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
4 changes: 2 additions & 2 deletions deploy/observability/init-db.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

from sqlalchemy.engine import make_url

from powercontext.builtin.authz import PrincipalRef
from powercontext.builtin.authz.composition import open_builtin_access_control
from powercontext.builtin.runtime.composition import open_builtin_runtime
from powercontext.builtin.runtime.config import BuiltinConfig
from powercontext.server.authz import PrincipalRef
from powercontext.server.authz.composition import open_builtin_access_control
from powercontext.server.settings import ServerSettings


Expand Down
2 changes: 1 addition & 1 deletion deploy/observability/run-host.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def main() -> int:
if args.container:
environment = dict(os.environ)
else:
from powercontext.cli.env_file import read_environment_file
from powercontext.env_file import read_environment_file

environment.update(read_environment_file(local / "server.env"))
if not args.container:
Expand Down
6 changes: 3 additions & 3 deletions desktop/tests/real_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ def probe_measurement(


def fixture_provider(config, admin):
from powercontext.builtin.authz import PrincipalRef
from powercontext.server.authentication import (
AuthenticationRejectedError,
AuthenticationResult,
ProviderReadiness,
)
from powercontext.server.authz import PrincipalRef

class FixtureProvider:
async def authenticate(self, request):
Expand Down Expand Up @@ -290,9 +290,9 @@ async def run():
if not config.get("provider"):
await server.serve()
return
from powercontext.builtin.authz import PrincipalRef
from powercontext.builtin.authz.composition import open_builtin_access_control
from powercontext.builtin.persistence.migrations.server_readiness import prepare_server_storage
from powercontext.server.authz import PrincipalRef
from powercontext.server.authz.composition import open_builtin_access_control
from powercontext.server.settings import AccessControlConfig

admin = PrincipalRef(type="service", id="desktop-fixture-admin")
Expand Down
4 changes: 2 additions & 2 deletions docs/en/development/core-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ conflicts and persistence; the family service is responsible for its domain beha
A `Trigger` is a policy over a signal and prior state. It returns a `PolicyTransition` containing the next state and
zero or more actions. A Trigger should not open storage, schedule itself, or perform the action it selects.

APScheduler belongs to the Builtin runtime lifecycle. It decides when to evaluate a policy. The Trigger decides what
the observed signal means.
The Builtin runtime's Artifact Processing Supervisor decides when to evaluate a policy. The Trigger decides what the
observed signal means.

## Ownership boundaries

Expand Down
6 changes: 3 additions & 3 deletions docs/en/development/remote-access-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ and OceanBase uses HNSW for `vector` and `hybrid` searches.

Inference configuration is documented in [Configure Pydantic AI inference](pydantic-ai-inference.md).

Set `POWERCONTEXT_SERVER_RUNTIME_SCHEDULE_SECONDS` to process pending Source windows on a persisted interval. Scheduled
jobs use the SQLite sidecar at `POWERCONTEXT_HOME/scheduler.db`. Scheduling works with either application database and
requires a configured generation pipeline.
Set `POWERCONTEXT_SERVER_RUNTIME_MEMORY_SCHEDULE_SECONDS` to admit pending Source windows on an interval. The Artifact
Processing Supervisor keeps its processing state in the application database and creates no separate scheduler
database. Scheduling works with either application database and requires a configured generation pipeline.

## HTTP surface

Expand Down
6 changes: 3 additions & 3 deletions docs/en/docs/develop/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ selector retains that selector, and Experience incubation uses its independent c
## Scheduled Experience incubation

An integration can capture a completed task as a Content Source with metadata `"kind": "task-outcome"`. When the
Experience schedule is configured, APScheduler scans bounded Source windows and asks the configured schema-bound
pipeline for reusable situation, action, outcome, and lesson proposals. Each proposal cites exact Sources and enters
the Review Inbox as a pending Experience Candidate.
Experience schedule is configured, the Artifact Processing Supervisor scans bounded Source windows and asks the
configured schema-bound pipeline for reusable situation, action, outcome, and lesson proposals. Each proposal cites
exact Sources and enters the Review Inbox as a pending Experience Candidate.

Experience incubation has its own persisted Source cursor, independent from Memory extraction. Candidate writes and
cursor advancement commit together; a generation or write failure leaves the window available for retry. Ordinary
Expand Down
4 changes: 4 additions & 0 deletions docs/en/rfcs/0019_local_source_memory_runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ description: A proposal for a SQLite-backed Runtime that captures scoped Sources

> **Note:** PowerContext now uses bundled sqlite-vec for SQLite vector search. Statements about Vec1 in this RFC no
> longer apply and remain only as a record of the original design.
>
> **Note:** Automatic processing runs under the Artifact Processing Supervisor
> ([RFC 1515](1515_artifact_processing_supervisor.md)). The APScheduler interval job, its SQLite sidecar, and
> `ScheduledSourceProcessor` described in this RFC no longer exist and remain only as a record of the original design.

# Summary

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/development/core-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ service 负责领域行为。
`Trigger` 是基于 signal 和先前 state 的策略。它返回 `PolicyTransition`,其中包含下一状态和零个或多个 action。
Trigger 不应打开存储、调度自身或执行它选择的 action。

APScheduler 属于 Builtin runtime 的生命周期,负责决定何时评估策略。Trigger 只解释当前 signal 的含义。
Builtin runtime 的 Artifact Processing Supervisor 负责决定何时评估策略。Trigger 只解释当前 signal 的含义。

## 职责边界

Expand Down
6 changes: 3 additions & 3 deletions docs/zh/development/remote-access-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export POWERCONTEXT_SERVER_DATABASE_URL="mysql+aoceanbase://user:password@host:2

inference 配置见[配置 Pydantic AI 推理](pydantic-ai-inference.md)。

设置 `POWERCONTEXT_SERVER_RUNTIME_SCHEDULE_SECONDS` 可以按持久化 interval 处理待消费的 Source window。
定时 job 使用 `POWERCONTEXT_HOME/scheduler.db` 作为 SQLite sidecar。调度可以配合任一 application database
使用,但必须配置 generation pipeline。
设置 `POWERCONTEXT_SERVER_RUNTIME_MEMORY_SCHEDULE_SECONDS` 可以按 interval 准入待消费的 Source window。
Artifact Processing Supervisor 把处理状态保存在 application database 中,不会创建独立的 scheduler 数据库。
调度可以配合任一 application database 使用,但必须配置 generation pipeline。

## HTTP 接口

Expand Down
6 changes: 3 additions & 3 deletions docs/zh/docs/develop/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ selector;Experience 孵化继续使用独立的游标和定时任务。
## 后台 Experience 孵化

Integration 可以把已完成任务采集为 metadata 含 `"kind": "task-outcome"` 的 Content Source。启用
Experience schedule 后,APScheduler 会扫描有上限的 Source window,并让配置好的 schema-bound pipeline
生成可复用的 situation、action、outcome 和 lesson。每条 proposal 都引用精确 Source,并以 pending
Experience Candidate 进入 Review Inbox。
Experience schedule 后,Artifact Processing Supervisor 会扫描有上限的 Source window,并让配置好的
schema-bound pipeline 生成可复用的 situation、action、outcome 和 lesson。每条 proposal 都引用精确 Source,
并以 pending Experience Candidate 进入 Review Inbox。

Experience 孵化使用独立于 Memory extraction 的持久化 Source cursor。Candidate 写入和 cursor 推进会在同一
事务提交;generation 或写入失败时,该 window 保留给下次重试。普通 Prompt Source 不是 Task Outcome,
Expand Down
3 changes: 3 additions & 0 deletions docs/zh/rfcs/0019_local_source_memory_runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ description: 本地 Runtime 的设计提案,以 SQLite 保存 Scope 内的 Sou

> **注意:** PowerContext 当前使用随 builtin 依赖捆绑的 sqlite-vec 提供 SQLite 向量检索。本 RFC 中关于 Vec1 的
> 表述已不再适用,仅作为原始设计记录保留。
>
> **注意:** 自动处理由 Artifact Processing Supervisor 执行([RFC 1515](1515_artifact_processing_supervisor.md))。
> 本 RFC 描述的 APScheduler interval job、SQLite sidecar 和 `ScheduledSourceProcessor` 已不存在,仅作为原始设计记录保留。

# Summary

Expand Down
6 changes: 3 additions & 3 deletions evaluation/agent_tool_recovery/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
AuthenticationResult,
ProviderReadiness,
)
from powercontext.server.authz import AccessBinding, AccessBindingState, AccessRole, ResourceRef
from powercontext.server.authz.models import PrincipalRef
from powercontext.server.authz.repository import ACCESS_TABLES, RelationalAccessRepository
from powercontext.builtin.authz import AccessBinding, AccessBindingState, AccessRole, ResourceRef
from powercontext.builtin.authz.models import PrincipalRef
from powercontext.builtin.authz.repository import ACCESS_TABLES, RelationalAccessRepository
from powercontext.server.context import is_internal_bridge
from powercontext.server.factory import create_server_app
from powercontext.server.settings import AccessControlConfig, McpConfig, ServerSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ async def run_experiment(
extraction_instructions=definition.default_instructions,
)
# Real ASGI HTTP routes and application lifespan, not a mocked capture handler.
with TestClient(create_server_app(settings=settings, scheduler_path=private_dir / "scheduler.db")) as client:
with TestClient(create_server_app(settings=settings)) as client:
response = client.post(
"/v1/scopes",
json={
Expand Down
2 changes: 1 addition & 1 deletion evaluation/memory/source_poisoning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ do not point them at a production catalog. No paid-provider call is part of a no
),
inference=configured_inference,
)
app = create_server_app(settings=settings, scheduler_path=temporary_scheduler)
app = create_server_app(settings=settings)
```

3. For each entry in `cases.json`, create a new Scope using `POST /v1/scopes`. For each `sources` string, call
Expand Down
11 changes: 4 additions & 7 deletions evaluation/performance/input_encoding/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,18 @@ async def _attempt(


@asynccontextmanager
async def _open_runtime(config: BuiltinConfig, *, scheduler_path: Path):
async def _open_runtime(config: BuiltinConfig):
"""Reject absent external databases before each evaluation or readback opening."""
if isinstance(config.database, OceanBaseConfig):
async with OceanBaseProfile.open_existing(config.database, tables=()):
pass
async with open_builtin_runtime(config, scheduler_path=scheduler_path) as runtime:
async with open_builtin_runtime(config) as runtime:
yield runtime


async def _reopen(configs, args) -> None:
for mode, config in configs.items():
async with _open_runtime(config, scheduler_path=args.output / f"scheduler-{mode}.db") as runtime:
async with _open_runtime(config) as runtime:
for path in sorted((args.output / "attempts").glob("*.json")):
result = json.loads(path.read_text())
if result["mode"] != mode or "artifact_ref" not in result:
Expand Down Expand Up @@ -390,10 +390,7 @@ async def run(args) -> None:
with observe_usage():
async with AsyncExitStack() as stack:
runtimes = {
mode: await stack.enter_async_context(
_open_runtime(config, scheduler_path=args.output / f"scheduler-{mode}.db")
)
for mode, config in configs.items()
mode: await stack.enter_async_context(_open_runtime(config)) for mode, config in configs.items()
}
execution_start = time.perf_counter()
segment["startup_seconds"] = execution_start - startup
Expand Down
4 changes: 2 additions & 2 deletions examples/jupyter/13_team_access_control.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@
"import secrets\n",
"from secrets import compare_digest\n",
"\n",
"from powercontext.builtin.authz import PrincipalRef\n",
"from powercontext.builtin.authz.composition import open_builtin_access_control\n",
"from powercontext.client import ForbiddenResponseError, PowerContextClient\n",
"from powercontext.server.authentication import AuthenticationRejectedError, AuthenticationResult, ProviderReadiness\n",
"from powercontext.server.authz import PrincipalRef\n",
"from powercontext.server.authz.composition import open_builtin_access_control\n",
"from powercontext.server.settings import AccessControlConfig, BearerAuthConfig\n",
"\n",
"principals = {\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/jupyter/_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def _start_server(self) -> None:
)
if self.settings_overrides:
settings = ServerSettings.model_validate({**dict(settings), **self.settings_overrides})
app = create_server_app(settings=settings, scheduler_path=self.directory / "scheduler.db", **self.app_options)
app = create_server_app(settings=settings, **self.app_options)
listener = socket.socket()
listener.bind(("127.0.0.1", 0))
self._listener = listener
Expand Down
1 change: 0 additions & 1 deletion examples/systemone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ async def main() -> None:
async with open_builtin_runtime(
config,
decision_model=backend,
scheduler_path=directory / "scheduler.db",
) as runtime:
model = runtime.decision_model
if model is None:
Expand Down
3 changes: 1 addition & 2 deletions examples/systemone/applicability_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
from powercontext.builtin.persistence.sqlite import SQLiteConfig
from powercontext.builtin.runtime import DecisionModel, DecisionOutcome, RuntimeConfig
from powercontext.builtin.runtime.config import ExternalSkillsConfig
from powercontext.cli.env_file import EnvironmentFileError, read_environment_file
from powercontext.client import PowerContextClient
from powercontext.env_file import EnvironmentFileError, read_environment_file
from powercontext.http import ArtifactReference
from powercontext.server.factory import create_server_app
from powercontext.server.settings import McpConfig, MetricsConfig, ServerSettings
Expand Down Expand Up @@ -221,7 +221,6 @@ async def run(args: argparse.Namespace, config: SystemOneConfig) -> Path:
mcp=McpConfig(enabled=False),
metrics=MetricsConfig(enabled=False),
),
scheduler_path=directory / "scheduler.db",
)
budget = load_laya_budget(args.checkpoint) if config.provider == "laya" else None
source_digests = {
Expand Down
4 changes: 1 addition & 3 deletions examples/systemone/decision.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ async def evaluate(
runtime_config = BuiltinConfig(database=SQLiteConfig(url=f"sqlite+aiosqlite:///{data_dir / 'runtime.db'}"))
async with httpx.AsyncClient(timeout=config.timeout_seconds) as client:
backend = SystemOneDecisionModel(config, client, laya_budget=budget)
async with open_builtin_runtime(
runtime_config, decision_model=backend, scheduler_path=data_dir / "scheduler.db"
) as runtime:
async with open_builtin_runtime(runtime_config, decision_model=backend) as runtime:
decision_model = runtime.decision_model
if decision_model is None:
raise RuntimeError("The Runtime did not expose the injected decision model") # noqa: TRY003
Expand Down
4 changes: 1 addition & 3 deletions examples/systemone/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,7 @@ async def review(self, run: dict[str, Any]) -> None:
client,
laya_budget=self.laya_budget if provider == "laya" else None,
)
async with open_builtin_runtime(
config, decision_model=backend, scheduler_path=directory / "scheduler.db"
) as runtime:
async with open_builtin_runtime(config, decision_model=backend) as runtime:
if runtime.decision_model is None:
raise DemoError("The Runtime did not expose the injected decision model.") # noqa: TRY003
for arm in _ARMS:
Expand Down
2 changes: 1 addition & 1 deletion examples/systemone/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def execute(request: dict[str, Any]) -> dict[str, Any]:
raise ValueError("The run directory must be an absolute path") # noqa: TRY003
await asyncio.to_thread(directory.mkdir, parents=True, exist_ok=True)
config = BuiltinConfig(database=SQLiteConfig(url=f"sqlite+aiosqlite:///{directory / 'runtime.db'}"))
async with open_builtin_runtime(config, scheduler_path=directory / "scheduler.db") as runtime:
async with open_builtin_runtime(config) as runtime:
memory = runtime.atomic_memory
if memory is None:
raise RuntimeError("Atomic Memory is unavailable") # noqa: TRY003
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ powercontext = "powercontext.cli.app:main"
powercontext-ops = "powercontext.ops.__main__:main"

[project.entry-points."powercontext.cli"]
code = "powercontext.builtin.code.cli:app"
code = "powercontext.cli.code:app"
config = "powercontext.cli.config:app"
doctor = "powercontext.cli.system:doctor_app"
observability = "powercontext.observability.cli:app"
Expand Down
4 changes: 2 additions & 2 deletions release/upgrade-support.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/dashboard_multiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def replay(arguments: argparse.Namespace) -> None:
}
# Restart the Server each day to verify persistence across process lifecycles.
with time_machine.travel(date, tick=True):
app = create_server_app(settings=settings, scheduler_path=output / "scheduler.db")
app = create_server_app(settings=settings)
with TestClient(app, raise_server_exceptions=False) as client:
client.headers["Authorization"] = f"Bearer {token}"
default = call(client, directory, "server-default", "GET", "/v1/scopes/default")
Expand Down
2 changes: 1 addition & 1 deletion scripts/upgrade_release_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"src/powercontext/builtin/persistence",
"src/powercontext/builtin/code",
"src/powercontext/server/identity.py",
"src/powercontext/server/authz",
"src/powercontext/builtin/authz",
"src/powercontext/limits.py",
)
PHASES = frozenset({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Server-owned authentication and authorization building blocks."""
"""Authorization building blocks shared by the built-in Runtime and the Server."""

from typing import TYPE_CHECKING

from powercontext.server.authz.errors import (
from powercontext.builtin.authz.errors import (
AccessBindingNotFoundError,
AccessConflictError,
AccessControlError,
Expand All @@ -25,8 +25,8 @@
AccessInvalidRequestError,
AccessUnavailableError,
)
from powercontext.server.authz.keys import IDEMPOTENCY_KEY_LIMIT, bounded_idempotency_key
from powercontext.server.authz.models import (
from powercontext.builtin.authz.keys import IDEMPOTENCY_KEY_LIMIT, bounded_idempotency_key
from powercontext.builtin.authz.models import (
DEFAULT_DEPLOYMENT_ID,
PUBLIC_ACCESS_ACTIONS,
ROLE_CARDINALITIES,
Expand All @@ -48,7 +48,7 @@
PrincipalRef,
ResourceRef,
)
from powercontext.server.authz.service import (
from powercontext.builtin.authz.service import (
AccessAuditContext,
AccessAuditPage,
AccessAuditStore,
Expand All @@ -74,18 +74,18 @@
)

if TYPE_CHECKING:
from powercontext.server.authz.authzen import AuthZenAuthorizationProvider
from powercontext.server.authz.casbin import CasbinAuthorizationProvider
from powercontext.builtin.authz.authzen import AuthZenAuthorizationProvider
from powercontext.builtin.authz.casbin import CasbinAuthorizationProvider


def __getattr__(name: str) -> object:
# Runtime consumers use the shared Access contract without selecting a Server provider.
if name == "AuthZenAuthorizationProvider":
from powercontext.server.authz.authzen import AuthZenAuthorizationProvider
from powercontext.builtin.authz.authzen import AuthZenAuthorizationProvider

return AuthZenAuthorizationProvider
if name == "CasbinAuthorizationProvider":
from powercontext.server.authz.casbin import CasbinAuthorizationProvider
from powercontext.builtin.authz.casbin import CasbinAuthorizationProvider

return CasbinAuthorizationProvider
message = f"module {__name__!r} has no attribute {name!r}"
Expand Down
Loading
Loading