Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
36bbabb
feat: add knowledge-base artifact plugin
Zxf-xufeng Nov 15, 2026
6ad456b
fix: enforce knowledge-base replacement and lifecycle guards
Zxf-xufeng Nov 15, 2026
5162992
fix: preserve knowledge-base retry receipts and batch outcomes
Zxf-xufeng Nov 15, 2026
2fb1aab
fix: pin knowledge-base reprocessing to its snapshot revision
Zxf-xufeng Nov 15, 2026
709ad38
fix: preserve knowledge-base context passages and task states
Zxf-xufeng Nov 15, 2026
65b0646
fix: preserve Markdown heading hierarchy in knowledge-base chunks
Zxf-xufeng Nov 15, 2026
3079efc
fix(knowledge-base): reject null paths without aborting imports
Zxf-xufeng Nov 15, 2026
6080d1b
fix(knowledge-base): align framework contracts and repair review regr…
Zxf-xufeng Nov 15, 2026
3adae70
build(knowledge-base): isolate optional plugin type checks
Zxf-xufeng Nov 15, 2026
6a26f9a
fix(knowledge-base): preserve OCR results and correct CI admission
Zxf-xufeng Nov 16, 2026
2afafb8
Merge remote-tracking branch 'origin/master' into codex/knowledge-bas…
Zxf-xufeng Nov 16, 2026
34a7843
fix(knowledge-base): retain saved settings across library selection
Zxf-xufeng Nov 16, 2026
33d8888
fix(knowledge-base): toggle chunk content without duplicating it
Zxf-xufeng Nov 16, 2026
dae67da
feat(knowledge-base): redesign the document dashboard
Zxf-xufeng Nov 16, 2026
231c209
fix(knowledge-base): contain long library names in navigation
Zxf-xufeng Nov 16, 2026
310edd8
feat(knowledge-base): support atomic bulk chunk removal
Zxf-xufeng Nov 16, 2026
70fcfea
fix(knowledge-base): align navigation and processing retries
Zxf-xufeng Nov 16, 2026
8ef30bd
merge: sync knowledge base with latest master
Zxf-xufeng Nov 17, 2026
cccd12b
fix(knowledge-base): preserve Markdown links and scope CI coverage
Zxf-xufeng Nov 17, 2026
dbb32a1
test(runtime): wait for blocked rechecks to finish
Zxf-xufeng Nov 17, 2026
d7678d9
fix(knowledge-base): reject chunks that lose reference links
Zxf-xufeng Nov 17, 2026
1f320cd
feat(knowledge-base): consolidate plugin navigation
Zxf-xufeng Nov 17, 2026
092e584
feat(knowledge-base): add batch document actions
Zxf-xufeng Nov 17, 2026
12db320
fix(knowledge-base): truncate long document names
Zxf-xufeng Nov 17, 2026
ed6f259
merge: align knowledge-base plugin with latest master
Zxf-xufeng Nov 18, 2026
1bfd14c
fix(knowledge-base): preserve short tokens in native indexes
Zxf-xufeng Nov 18, 2026
4d385e8
fix(ci): repair integration import and deadline assertion
Zxf-xufeng Nov 18, 2026
76828fc
ci: share dependency caches and preserve downloads before tests
frf12 Nov 18, 2026
c4b641d
ci: verify cache reuse across fresh runner jobs
frf12 Nov 18, 2026
59863ae
ci: verify Cargo reuse with registry metadata refresh
frf12 Nov 18, 2026
4df0830
ci: remove temporary cache acceptance workflow
frf12 Nov 18, 2026
9ada404
fix(dsh): restore companion memory query preparation
frf12 Nov 18, 2026
1dcd3e4
fix(stats): retry SQLite usage writes after setup expiry
frf12 Nov 18, 2026
34af84f
fix(ci): refresh SQLite persistence compatibility review
frf12 Nov 18, 2026
f7abf52
fix(ci): save complete dependency caches before tests
frf12 Nov 18, 2026
c7c5fff
merge: refresh cache fixes against master
frf12 Nov 18, 2026
b8d3ea9
fix(ci): avoid redundant tool and history downloads
frf12 Nov 18, 2026
0a48188
chore(knowledge-base): merge master and align dashboard navigation tests
Zxf-xufeng Nov 19, 2026
162f1ed
fix(knowledge-base): preserve blockquote outline boundaries
Zxf-xufeng Nov 19, 2026
bc0fd23
ci: allow progressing unit suites to finish on internal runners
Zxf-xufeng Nov 19, 2026
e6f2736
test(knowledge-base): wait for replacement host context before naviga…
Zxf-xufeng Nov 19, 2026
e8fead7
Merge remote-tracking branch 'origin/master' into codex/knowledge-bas…
Zxf-xufeng Nov 19, 2026
ec3856f
fix(dashboard): narrow optional prompt artifact before reading its re…
Zxf-xufeng Nov 19, 2026
87ac483
fix(ci): save Linux installer dependencies before tests
frf12 Nov 19, 2026
280969c
ci: reuse and publish dependency caches before validation
Zxf-xufeng Nov 19, 2026
3584d82
test(dsh): serialize Server startup and allow cold initialization
Zxf-xufeng Nov 19, 2026
d766a09
ci: seed shared dependencies and budget validation cleanup
Zxf-xufeng Nov 19, 2026
77193bc
ci: isolate mise runtime caches per job
Zxf-xufeng Nov 19, 2026
8de6522
ci: resolve temporary cache paths during step execution
Zxf-xufeng Nov 19, 2026
0b0f8e7
ci: isolate writable tool caches in shared setup
Zxf-xufeng Nov 19, 2026
abdc1aa
fix(ci): persist Linux runner caches in internal storage
frf12 Nov 19, 2026
16aab75
fix(ci): register proxy bypass through runner environment files
frf12 Nov 19, 2026
e162d71
ci: isolate OpenCode cache and budget first-time installation
Zxf-xufeng Nov 19, 2026
f2d8af2
Merge remote-tracking branch 'upstream/master' into codex/ci-dependen…
frf12 Nov 19, 2026
73f7ee9
fix(dashboard): narrow optional prompt revision source
frf12 Nov 19, 2026
9108530
ci: prebuild Gateway before parallel acceptance tests
Zxf-xufeng Nov 19, 2026
2911110
fix(ci): split Linux E2E coverage across runner pods
frf12 Nov 19, 2026
c66f8be
Merge master after gateway prefix extraction acceptance
frf12 Nov 19, 2026
d460a32
chore: merge latest master into knowledge-base plugin
Zxf-xufeng Nov 19, 2026
974fb78
fix(ci): cache verified mise bootstrap independently of tools
frf12 Nov 19, 2026
307cfe2
fix(statistics): retry SQLite usage setup within batch budget
Zxf-xufeng Nov 19, 2026
16ab67a
ci: avoid concurrent cold starts in DSH E2E tests
frf12 Nov 19, 2026
265fe0a
test: assert shared embedding budget cancellation without wall-clock …
Zxf-xufeng Nov 19, 2026
b75c066
fix(knowledge-base): preserve canonical callers and unique API operat…
Zxf-xufeng Nov 20, 2026
2b84e11
fix(knowledge-base): keep core and CI fixes outside the plugin PR
Zxf-xufeng Nov 20, 2026
6d4ca12
Merge remote-tracking branch 'origin/master' into codex/knowledge-bas…
Zxf-xufeng Nov 20, 2026
1ab2cc0
Merge remote-tracking branch 'origin/master' into codex/knowledge-bas…
Zxf-xufeng Nov 21, 2026
ab67268
merge: integrate PR 2710 CI fixes into knowledge-base branch
Zxf-xufeng Nov 21, 2026
c8600ec
fix(knowledge-base): refresh imported retrieval and validate batch IDs
Zxf-xufeng Nov 21, 2026
5920361
fix(knowledge-base): preserve Markdown text and scope retrieval updates
Zxf-xufeng Nov 21, 2026
e9d1d6d
fix(knowledge-base): reconcile published revisions and stop forbidden…
Zxf-xufeng Nov 21, 2026
bb05c6c
fix(knowledge-base): stop polling and hide reader content on access d…
Zxf-xufeng Nov 21, 2026
d6bdd73
fix(knowledge-base): invalidate search hits after denied document reads
Zxf-xufeng Nov 21, 2026
29c676c
ci: bound concurrent end-to-end workers per shard
Zxf-xufeng Nov 21, 2026
676caf5
merge: integrate master dependencies into knowledge-base branch
Zxf-xufeng Nov 21, 2026
c1f0e1f
fix(knowledge-base): preserve OCR and HTML text and replay uncertain …
Zxf-xufeng Nov 21, 2026
d124e22
merge: sync upstream Deep Agents checks from master
Zxf-xufeng Nov 21, 2026
435f061
fix(knowledge-base): distinguish unreadable files from unconfirmed up…
Zxf-xufeng Nov 21, 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
31 changes: 31 additions & 0 deletions .github/workflows/knowledge-base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Knowledge-base plugin
on:
pull_request:
paths:
- 'plugins/knowledge-base/**'
- 'src/powercontext/builtin/plugins/**'
- 'src/powercontext/plugins.py'
- 'src/powercontext/server/dashboard/**'
- 'tests/knowledge_base/**'
- 'tests/e2e/test_knowledge_base*.py'
- 'pyproject.toml'
- 'uv.lock'
- '.github/workflows/knowledge-base.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
sqlite-and-ocr:
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: ./.github/actions/setup-python-env
with:
python-version: '3.12'
- name: Install plugin dependencies
run: uv sync --locked --extra knowledge-base
- name: Exercise Server, Worker, revision lifecycle and real OCR
run: uv run --no-sync pytest tests/knowledge_base tests/e2e/test_knowledge_base*.py tests/e2e/test_plugin_pages.py
6 changes: 6 additions & 0 deletions docs/en/docs/develop/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ Listing, reading revisions and history, governance state, and tags call no plugi
`source_refs`. Content identical to the current revision adds no revision, so repeated delivery never writes duplicate
revisions. `writer.stable_id(...)` derives a stable ID from its inputs, so the same Source always writes to the same
Artifact.
- If a write depends on lifecycle state, pass the read snapshot's `governance_generation` as
`tx.put(..., expected_state_version=...)`, alongside `expected_revision`. A concurrent governance change then rejects
publication, including a forget that leaves the content revision unchanged.
- Other operations include `tx.set_lifecycle`, `tx.merge`, `tx.revert`, and `tx.set_tags`; read current state with
`writer.get`, `writer.list`, and `writer.by_source`.
`tx.revert` and `tx.set_lifecycle` return `ArtifactChange`: `result.artifact` is the target snapshot,
Expand Down Expand Up @@ -364,6 +367,9 @@ plugin = ArtifactPlugin(
`scope_param`.
- In handlers, `ctx.require(action, scope_id)` checks further permissions and makes the API return 403 when the caller
lacks them; `ctx.allowed(...)` only answers true or false.
Use `ctx.require("artifact.write", scope_id, artifact_id=...)` before accepting asynchronous replacement of an existing
Artifact; this check targets the current plugin's family. Background execution does not establish the submitter's
authority. The same target argument is supported by `ctx.allowed`.
- Reading and writing core data: `ctx.reads(scope_id)` reads with the caller's permissions; `ctx.writer(scope_id)` and
`ctx.sources.submit(...)` work only for Scopes whose `scope.contribute` was confirmed earlier in the request (by the
route's `access` or a prior `ctx.require`). Changing an existing Artifact, including its tags, handles, and lifecycle,
Expand Down
186 changes: 186 additions & 0 deletions docs/en/docs/workflows/knowledge-base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
---
title: Knowledge-base plugin
description: Import Markdown and images, maintain document revisions, and search across knowledge-base Scopes.
---

# Knowledge-base plugin

The `knowledge-base` plugin implements [RFC #2570](https://github.com/oceanbase/powercontext/pull/2570).
It owns the `document` Artifact family and supports SQLite, embedded SeekDB and OceanBase MySQL tenants.
The plugin provides ingestion, parsing, immutable chunk results, hybrid retrieval and Dashboard pages.

## Install and start

Run from a repository checkout. These commands create a separate local instance, install optional model/OCR dependencies,
and bind the Server to loopback. The first embedding call downloads the pinned public model; provision its cache before
using an offline deployment. Server and Worker must use the same Python environment, plugin code and local data directory.

```bash
uv sync --locked --extra knowledge-base --extra server --extra cli
mkdir -p "$PWD/.powercontext/kb-demo/plugins"
cp -R plugins/knowledge-base "$PWD/.powercontext/kb-demo/plugins/knowledge-base"
export POWERCONTEXT_KB_DATA_DIR="$PWD/.powercontext/kb-demo/data"
export POWERCONTEXT_KB_IMPORT_ROOTS="$PWD/docs"
export POWERCONTEXT_SERVER_PLUGINS_DIR="$PWD/.powercontext/kb-demo/plugins"
export POWERCONTEXT_SERVER_WORKSPACE="$PWD/.powercontext/kb-demo"
export POWERCONTEXT_SERVER_DATABASE='{"kind":"sqlite","url":"sqlite+aiosqlite:///.powercontext/kb-demo/core.db"}'
export POWERCONTEXT_SERVER_RUNTIME='{"artifact_processing_families":[]}'
export POWERCONTEXT_SERVER_DASHBOARD_ENABLED=true
uv run --no-sync powercontext server run --host 127.0.0.1 --port 8765
```

Use the deployment's normal authentication and authorization configuration. Open `/dashboard/plugins/knowledge-base`
after signing in. Space creation/renaming, knowledge-base creation and processing configuration require `server.admin`;
imports require Scope contribution and searches require Scope read. Editing and forgetting also enforce Artifact authority.
New replacement requests for an existing document, including changed-file uploads, retries and explicit reprocessing, also
require its Artifact write authority. Replaying an already accepted request retains its original fixed base and receipt.
Plugin pages receive no session credentials; the Dashboard bridge forwards only declared plugin routes and explicitly
enabled operations for this plugin's own Artifact family, preserving caller identity and version preconditions.

For SeekDB, also install `--extra seekdb` and configure the core SeekDB database. For OceanBase, provision a MySQL user tenant
and core database according to the Server deployment guide. The plugin uses the same backend/account but a separate database,
`powercontext_plugin_<24-character digest of core database and plugin name>`. An administrator may pre-provision it if the
application account cannot create databases; the startup error reports the exact database. No core table columns are added.
SQLite stores a separate plugin database in the framework-managed plugin storage directory.

`POWERCONTEXT_KB_IMPORT_ROOTS` contains allowed local roots separated by the operating system's path separator. An empty value
disables Server-directory imports, while browser uploads remain available. File size is limited to 16 MiB, images to 25 million
pixels, imports to 100 explicit paths per request, and parsed documents to 2,000 chunks. Server/Worker must share the same local
filesystem. Remote object stores, PDF/Office files, restoration, permanent cleanup and generated answers are outside this release.

## Spaces, creation and retries

A space is a plugin-local organizational Scope, not a core parent Scope or an authorization tenant. Each knowledge-base Scope
belongs to one space. A personal space is initialized on first default resolution. Defaults are keyed by authenticated principal;
changing a default requires its current version. Space visibility does not grant access to its knowledge bases.

Let `P=/v1/plugins/knowledge-base/api`. The principal's default comes from `GET P/me/default-space`.
Create a knowledge base with an explicit space and a stable request key:

```json
{"space_scope_id":"<space ID>","title":"Operations","idempotency_key":"operations-create-1"}
```

Send this to `POST P/knowledge-bases`. The response includes `scope_id`, plugin settings and their `version`.
The creation identity includes principal, explicit space and request key. Retry the **same body/key**, even after changing the
default space: an interrupted core-Scope/plugin-membership registration repairs the same knowledge base. Missing space is 422;
reusing an identity with different creation parameters is a conflict. Unregistered Scopes cannot accept imports or enter search.

`GET/POST P/spaces` lists/creates spaces; `PATCH P/spaces/{space_id}` renames with `{title,version}`.
`PUT P/me/default-space` accepts `{space_scope_id,version}`. `GET P/knowledge-bases?space_scope_id=...` returns only readable bases.

## Import and process

The Dashboard supports selecting or dragging files, and explicit Server-directory imports. Markdown references to embedded images
remain references; independently imported PNG/JPEG/WebP images use RapidOCR with ONNX Runtime. OCR produces Markdown text blocks
with original polygons, reading order and confidence. Both paths use heading-aware block packing followed by bounded sentence/line
splits. Default limits are 360 characters and 40-character overlap; complete embedding input is checked against the tokenizer limit.
Markdown HTML blocks, including HTML tables, retain their literal content and source lines in chunks.

For browser uploads, send file bytes to:

```text
POST P/scopes/{scope_id}/uploads?relative_path=runbooks/restart.md&idempotency_key=upload-1
Content-Type: application/octet-stream
```

For local import, send this to `POST P/scopes/{scope_id}/imports`:

```json
{"root":"/allowed/runbooks","paths":["restart.md","checklist.png"],"idempotency_key":"batch-1"}
```

Directory import returns one item per path. A deterministic file error, request conflict or missing document write authority
sets that item's `accepted` to false; conflicts and permission failures include `status` and `error`. Other files continue,
and successful items retain their request/Source receipts. Infrastructure failures still fail the request.

The local importer rejects traversal and file symlinks. OpenDAL manages immutable, content-addressed local snapshots; Workers
verify their digest before reading. Browser and directory collections have separate stable identities. Same collection/path means
the same document, changed bytes create a new original Source, and renames create a new document. Unchanged bytes/configuration
can reuse the published document without another parse. Reusing a request key with different bytes/explicit parameters is a conflict. A retry retains its initially pinned settings.

Acceptance pins the snapshot, original Source, processing settings, embedding profile and expected document revision. Only
`knowledge-base-process` Sources enter the framework cursor/Supervisor; immutable `knowledge-base-file` Sources are evidence.
No independent plugin task queue or scheduler is added. Deterministic input failures are recorded without blocking later files;
infrastructure failures use the framework's window retry/backoff and can block that Scope until repaired.

`GET P/scopes/{s}/imports/{request_id}` reports pending/processing/failed or a publication verified against core history, separately
from the usable revision. `POST .../imports/{request_id}/retry` accepts a **new** `idempotency_key` and creates a new request.
The recent requests returned by `GET P/scopes/{s}/documents` use the same publication check, so committed work is reported as
completed even if its processing observation still says processing.
`POST P/scopes/{s}/documents/{d}/reprocess` reparses with current settings. Its optional `manual_edits_policy:"replace"` explicitly
permits replacing manual edits; otherwise conflicting reprocessing fails. Reprocessing pins the original snapshot and its
document revision together. A concurrent upload, edit or forget prevents stale publication, including changes while the snapshot
is being read; submit a new reprocessing request to use the latest original.
Replaying the same reprocessing key and explicit document/policy returns the accepted request's receipt, even if the document's
original file or processing settings have since changed. Interrupted Source registration resumes from the original pinned input
and base; it never rebases onto the current revision. Reusing the key for another document, policy or operation is a conflict.
Synchronous chunk edits also check the governance version at publication, so forgetting during embedding preparation rejects the edit.

`PATCH P/scopes/{s}/settings` accepts `{version,chunking:{max_chars,overlap}}`; existing documents change only after reprocessing.
The deployment owns an independent, pinned `BAAI/bge-small-zh-v1.5` 512-dimensional embedding profile. It does not inherit core models.
This release does not switch models online; a mismatched profile fails closed. Additional parsers can implement the internal parser
contract and register extensions in `pc_knowledge_base/content.py` without adding another Artifact plugin.

## Read, edit and forget

Generic Artifact GET/history returns a compact manifest, including title, result identity, chunk count, original reference and
processing profile. Chunk text lives in separate immutable rows and is fetched through these plugin routes:

| Operation | Route under `P/scopes/{s}/documents/{d}/revisions/{rev}` |
| --- | --- |
| Chunk directory | `GET /chunks?offset=0&limit=50` (metadata only, at most 100) |
| One chunk | `GET /chunks/{chunk_id}` |
| Batch text | `POST /chunks/batch-get` with `{"chunk_ids":["..."]}` (at most 100) |

An exact revision never falls back to the current revision. To edit, use the generic
`PUT /v1/scopes/{s}/artifacts/document/{d}` with `If-Match: "revision:3"`:

```json
{"content":{"operation":"edit_chunk","chunk_id":"<ID>","text":"Verify the latest backup before restarting."}}
```

Use `operation:"remove_chunk"` and omit `text` to remove a chunk. Both operations are synchronous and create one new document
revision plus a lineage-only Source containing the original command. Manual text replacement preserves the logical chunk ID;
rechunking generates new IDs. Removing the last chunk creates a valid empty revision. Historical chunks and their indexes remain.
New results/indexes are durable before the manifest is committed. Failed publication leaves only invisible, unreferenced results.

`POST /v1/scopes/{s}/artifacts/document/{d}/forget` takes `{revision,state_version}`. Forget changes lifecycle to deprecated,
without adding a document revision or edit Source. Ordinary retrieval immediately excludes it; authorized exact history remains
available. Original Sources and snapshots are retained. Source deletion, cascade deletion and restoration are not implemented.

## Search and storage

```json
{"space_scope_id":"<space ID>","scope_ids":["<operations Scope>","<development Scope>"],"query":"restart prerequisites","mode":"hybrid","limit":10}
```

Send this to `POST P/retrieve`. Omitting the space resolves the current default. Omitting `scope_ids` selects readable knowledge
bases in that space; an explicit empty list selects none. Explicit unreadable/out-of-space IDs fail the whole request. Select at most
20 bases and 50 hits. `POST P/scopes/{s}/retrieve` selects one base independently of the default space. Generic document search and
Prepared Context use the same current-revision filtering.
The plugin retrieval endpoints return individual chunks. The generic Artifact search adapter recalls at most 50 ranked chunks,
groups them by document revision and applies its limit to documents; each document's score is its best matching chunk's score.
Prepared Context receives the grouped passages with chunk IDs, headings, original Source references, locations and manual-edit
markers in the text, so Artifact-level deduplication retains distinct matches from the same document. Its output byte budget still applies.

SQLite uses FTS5 and sqlite-vec cosine distance; SeekDB/OceanBase use native FULLTEXT and VECTOR storage/distance. Retrieval fuses
lexical/vector ranks, then verifies current active document/result/profile and refills candidates. It never compares raw per-library
BM25 scores. Results include Scope, exact document revision, chunk ID, original Source and location. Candidate work is bounded at
5,000 per channel; many retained historical results can reduce recall, so this is not a large-corpus performance guarantee.

The four plugin domain tables are `pc_knowledge_base_spaces`, `pc_knowledge_base_space_defaults`, `pc_knowledge_base_resources`
and `pc_knowledge_base_chunks`. Fulltext/vector projections are derived structures. Core owns Artifact revisions, lifecycle,
lineage-only edit evidence, Sources, cursors, leases and retries. Keep the core database, plugin database and snapshot directory
together when backing up an instance.

## Validation

```bash
uv run --locked --extra knowledge-base pytest tests/knowledge_base tests/e2e/test_knowledge_base.py
```

The default end-to-end test uses deterministic embeddings only in its temporary plugin copy; the installed plugin has no mock
embedding fallback. Set `POWERCONTEXT_TEST_KB_MODELS` to a prepared local data directory to also run real embedding acceptance.
Set `POWERCONTEXT_TEST_KB_SQL` to an isolated OceanBase/SeekDB configuration for native projection tests, and
`POWERCONTEXT_TEST_KB_SERVER_DATABASE` to an isolated core database configuration for the full Server/Worker workflow.
4 changes: 4 additions & 0 deletions docs/zh/docs/develop/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ Server 在一个独立的子进程中导入 `plugin.py` 并检查声明,导入
- 调用模型、解析文件等慢操作放在事务之外,事务里只做写入。
- `tx.put(artifact_id, content=..., source_refs=[...])` 写一个新版本,`source_refs` 记录出处。内容与当前版本相同时不产生新版本,
所以重复交付不会写出重复的版本。`writer.stable_id(...)` 按输入生成稳定的 ID,便于同一条 Source 总是写到同一个 Artifact。
- 写入依赖生命周期状态时,在 `expected_revision` 之外,把读取快照的 `governance_generation` 作为
`tx.put(..., expected_state_version=...)` 传入。并发治理变更会拒绝发布,包括不改变内容 revision 的 forget。
- 还可以用 `tx.set_lifecycle`、`tx.merge`、`tx.revert`、`tx.set_tags` 等方法,以及 `writer.get`、`writer.list`、
`writer.by_source` 读取当前状态。
`tx.revert` 和 `tx.set_lifecycle` 返回 `ArtifactChange`:`result.artifact` 是目标快照,
Expand Down Expand Up @@ -340,6 +342,8 @@ plugin = ArtifactPlugin(
- `authenticated`:只要求已登录;
- `scope.read` / `scope.contribute`:要求调用者对 `scope_param` 指定的路径参数中的 Scope 具备该权限。
- 处理函数里用 `ctx.require(action, scope_id)` 检查其他权限,不具备时接口返回 403;`ctx.allowed(...)` 只返回真假。
接受异步替换已有 Artifact 的请求前,使用 `ctx.require("artifact.write", scope_id, artifact_id=...)` 校验当前插件
family 下的目标。后台执行身份不能代替提交者的修改权限;`ctx.allowed` 也支持相同的目标参数。
- 读写核心数据:`ctx.reads(scope_id)` 按调用者权限读取;`ctx.writer(scope_id)` 和 `ctx.sources.submit(...)` 只能用于本次
请求中已经确认 `scope.contribute` 的 Scope(路由声明了该权限,或处理函数先调用了 `ctx.require`)。修改已有 Artifact
(包括标签、handle 和生命周期)还需要调用者对该 Artifact 有 `artifact.write` 权限,与通用接口相同;没有权限时接口返回 403。
Expand Down
Loading
Loading