feat(prompts): add scope-owned prompt management - #1473
Open
Teingi wants to merge 1 commit into
Open
Conversation
Member
Author
Teingi
marked this pull request as ready for review
September 5, 2026 12:50
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Which issue or RFC does this PR close?
Closes #1465.
Implements the Scope-owned prompt management design in #1468.
Rationale for this change
Agents and users need different memory extraction rules without bypassing PowerContext's Scope isolation. The same requirement applies to other built-in generation and reranking operations. This change makes operational prompts Scope-owned, versioned Artifacts while preserving server-owned schemas, evidence checks, model settings, and authority boundaries.
What changes are included in this PR?
Register the
promptArtifact family formemory.extract,memory.rerank,experience.incubate,experience.generate,skill.generate, andhandoff.generate.Support Auto/custom modes and strict content containing
schema_version,mode,instructions, and ordered typeddemonstrationswithinputandexpected_output. Validate operation-specific reference and output semantics as well as JSON structure.Reuse existing Artifact storage and conditional writes: no new database tables. Provide signed, Scope-bound revision-history pagination; restoring an old revision creates a new revision rather than moving the head backward.
Resolve and freeze the effective prompt for an operation and its retries, including before coarse memory retrieval. Preserve injected-component interfaces and expose supported/disabled/injected capabilities.
Record bounded prompt identity and digest metadata without adding prompt bodies to tracing. Preserve exact configuration lineage on generated Artifacts, and use signed generation receipts for Handoff prepare/finalize/commit attribution. Prompt configuration is not factual evidence.
Add the
/promptsDashboard with Scope selection, instructions, positive/negative case groups, unsaved case generation, version history, restore, and ETag conflict handling.Update OpenAPI, generated Python models/operations, the HTTP client, and integration operation tables. The only two new HTTP operations are:
GET /v1/scopes/{scope_id}/artifacts/{family}/{artifact_id}/revisionsPOST /v1/scopes/{scope_id}/prompts/{prompt_key}/demonstrationsInclude two fixes exercised by real-provider acceptance: use SQLite
lastrowidinstead of unsupportedINSERT ... RETURNINGon older SQLite, and validate generated Skill package constraints inside the existing bounded LLM retry loop.Are there any user-facing changes?
prompt_keyforfamily=prompt. Existing families retain their request shapes; replacement remains path-selected and acceptscontent.How was this change tested?
Local validation used Python 3.11.13 and Node 22.22.3. These are local results, not a claim that remote CI has passed.
Passed:
Final focused regression: 105 passed, 1 skipped:
UV_PYTHON=3.11 make contract-test: 38 passed, including generated-code freshness checks.UV_PYTHON=3.11 uv run --locked ty check src tests: passed.Formatting/lint and the non-type pre-commit hooks: passed;
git diff --check: passed.DSH build and full plugin tests: 75 passed. Pi tests: 48 passed with
--testTimeout=30000; Pi TypeScript checking passed.Built the wheel and verified that the prompt modules and Dashboard assets are packaged.
Real LLM and embeddings with both the configured OceanBase database and SQLite: 2 passed:
The opt-in test reads local
.envconfiguration, creates isolated Scopes, exercises all six operations, checks isolation/version restore/lineage, and cleans up only its own Scopes and derived indexes. No credentials or local configuration are included in this PR.Real browser checks covered generated cases remaining unsaved, saving, Auto mode, restoring a historical revision, Scope isolation, unsupported operations, stale-ETag conflict handling that preserves edits, Chinese UI, and a narrow mobile viewport.
Known validation limitations:
tests/e2e/test_opencode_plugin_host.py, finished with 1379 passed, 1 failed, 19 skipped. The failure was the 10-second subprocess startup timeout intest_recorded_virtualenv_python_can_import_service_launcher. That test also failed in the clean-master comparison; the complete currenttests/test_service.pymodule passed separately (90 passed, 1 skipped).ty checkreports three existingscripts.scope_bindingimport errors in the Codex hooks. They were reproduced on clean master; implementation and test type checking passes. Only that known failing type hook is skipped for the commit.queryStringreference error and the real-host failure were also reproduced on clean master. They are not changed by this PR; its generated source operation table is updated, without an unrelated bundle rebuild.AI usage statement
OpenAI Codex assisted with implementation, regression tests, real-provider and browser validation, and preparation of this PR. The changes require maintainer review; AI assistance is not a substitute for review or CI.