Repository navigation
feat(tags): make the per-Artifact and per-query tag limits configurable - #2816
Conversation
| settings=ServerSettings( | ||
| database=SQLiteConfig(url=f"sqlite+aiosqlite:///{tmp_path / 'tags.db'}"), | ||
| inference=InferenceConfig(generation_model="test"), | ||
| runtime=RuntimeConfig(**runtime), |
There was a problem hiding this comment.
[P1] _app() 的 dict 字面量让 ty check 报 83 条 invalid-argument-type,CI preflight 红 ⇒ 全部 suite 跳过
第 42 行的 runtime = {"artifact_processing_families": ()} 让类型检查器把该 dict 推断成 dict[str, int | tuple[()]],第 47 行 RuntimeConfig(**runtime) 的每个字段都是具体类型,联合值不可赋。
证据(实测):CI preflight(run 45326786769 / job 138218203821)在 Makefile:49: workflow-actions-check 处以 exit 1 结束,日志中 83 条 error[invalid-argument-type] 全部指向 tests/test_tag_limits.py:47:35,无第二处错误位置。
影响:quality 失败后 needs.quality.outputs.suites 为空,master.yml 的 suite job 一律 skipped(本次 39 个,含 tests (*)、*-host、desktop-validation)。本 PR 新增的这张 184 行用例表与「可配置标签上限」的实际行为在 CI 里没有任何执行记录;Upgrade release gate 的红是同一原因的级联,不是第二个缺陷。
建议:改成逐字段构造,避免 ** 展开掩盖字段类型,例如
return create_server_app(
settings=ServerSettings(
database=SQLiteConfig(url=f"sqlite+aiosqlite:///{tmp_path / 'tags.db'}"),
inference=InferenceConfig(generation_model="test"),
runtime=RuntimeConfig(
artifact_processing_families=(),
tag_max_per_artifact=artifact if artifact is not None else MAX_TARGET_TAGS,
tag_max_query_labels=query if query is not None else MAX_QUERY_TAG_LABELS,
),
mcp=McpConfig(enabled=False),
)
)若仍要保留 dict 写法,至少要显式标注成能让 ty 通过的类型(dict[str, Any] 一类),并用 uv run ty check tests/test_tag_limits.py 确认该文件零错误,再确认 CI preflight 转绿后各 suite 真正执行到这张用例表。
There was a problem hiding this comment.
Fixed in 9ac84bf. _app() now builds RuntimeConfig with explicit fields:
runtime=RuntimeConfig(
artifact_processing_families=(),
tag_max_per_artifact=MAX_TARGET_TAGS if artifact is None else artifact,
tag_max_query_labels=MAX_QUERY_TAG_LABELS if query is None else query,
)uv run ty check over every changed Python file (including tests/test_tag_limits.py) passes with no diagnostics, ruff is clean, and the 7 tag-limit tests still pass. The preflight failure was ty-only; no product code changed in this commit.
There was a problem hiding this comment.
[P1 closed] The ty failure on this line is gone at 5c61512. _app() now passes artifact_processing_families=(), tag_max_per_artifact and tag_max_query_labels as explicit keyword arguments instead of building a dict literal, so the dict[str, int | tuple[()]] inference that produced the 83 invalid-argument-type errors no longer exists. Evidence: CI preflight on head 5c61512 concluded success (01:57:24Z-02:00:23Z), which is the job that ran the workflow-actions-check / ty step; the other 67 checks are green apart from two unrelated failures (see below).
The two remaining red checks are not caused by this branch: gateway-validation / check died in capacity_process::capability_contract_and_positive_integer_capacity_are_required with bind: Os { code: 98, kind: AddrInUse } at main.rs:361 in port-takeover mode (the same flake the branch already retriggered once in 5c61512), and harness-validation / Acceptance (sqlite) ended with No ACP summary file found and a 0.000 mean over 6:12, which is the harbor harness signature, not a tag or bundle failure.
Separately, the new tag_limit plumbing has one uncovered path; I posted it as its own thread (4690059709) instead of extending this one, since the root cause differs.
|
Fixed in 9ac84bf. runtime=RuntimeConfig(
artifact_processing_families=(),
tag_max_per_artifact=MAX_TARGET_TAGS if artifact is None else artifact,
tag_max_query_labels=MAX_QUERY_TAG_LABELS if query is None else query,
)
|
|
Two fixes are pushed on top of the implementation:
Verification on the pushed head: |
|
The rerun exposed two more generated-artifact issues, both fixed:
On the previous head, every other job passed, including all e2e shards, |
| artifact_content_decoder: Callable[[Mapping[str, Any]], object] | None = None, | ||
| candidate_decoder: Callable[[Mapping[str, Any]], object] | None = None, | ||
| source_decoder: Callable[[Mapping[str, Any]], object] | None = None, | ||
| tag_limit: int = MAX_TARGET_TAGS, |
There was a problem hiding this comment.
[P2] tag_limit defaults silently, and the restore --dry-run path never passes it
PortableBundleService.__init__ now takes tag_limit: int = MAX_TARGET_TAGS and RelationalContexts passes runtime.tag_max_per_artifact, so export/restore validate tag sets against the effective limit instead of the 256 ceiling. The other production construction site, src/powercontext/cli/archive.py::_validate_with_database, still builds PortableBundleService(...) without tag_limit. That function is what pc archive restore --dry-run runs (restore_bundle -> _emit_validation_result -> _validate_only -> _validate_with_database), so the dry-run always validates with the 32 default.
Impact, at a supported configuration: with runtime.tag_max_per_artifact=64 (allowed up to MAX_TARGET_TAGS_CEILING), a bundle whose Artifact carries 33-64 tags fails the dry-run with BundleFormatError("artifact tag set has invalid labels"), while the real restore --yes on the same machine accepts it, because that path goes through open_builtin_runtime -> RelationalContexts. The inverse also holds: with a limit below 32 the dry-run accepts a bundle that the real restore then rejects. A precheck whose verdict contradicts the operation it prechecks is worse than no precheck, since operators use it to decide whether to run the write.
Suggestion: thread settings.runtime.tag_max_per_artifact through _validate_only into _validate_with_database, and add one case that pins the dry-run verdict at a non-default limit. The increment currently adds no test at all for the effective-limit change, so neither path is pinned.
There was a problem hiding this comment.
Fixed in 728eddd. _validate_only now passes settings.runtime.tag_max_per_artifact into _validate_with_database, which forwards it as tag_limit to PortableBundleService; the dry-run therefore validates against the effective write limit. Export validates historical sets at the contract ceiling, while validate/restore use the effective limit, so lowering the limit cannot block exporting existing data. The default remains only for direct service construction.
There was a problem hiding this comment.
[P2] tag_limit 的传递已生效,但 dry-run 这条路径仍无回归保护
在 head 25c27eb16f 上核对(git -C D:/test/github/review/_bare/powercontext.git show refs/pr/2816:<path>):
- 传参链完整:
src/powercontext/cli/archive.py:157的_validate_only四个分支(:166/:172/:179/:184)都传settings.runtime.tag_max_per_artifact;_validate_with_database在:190接收该值、:209转成PortableBundleService(tag_limit=...)。 - 出口侧与回复一致:
bundle.py:633的export()用MAX_TARGET_TAGS_CEILING,validate()(:658)与恢复目标校验(:902)用self._tag_limit。 - 实测(exact head、SQLite,探针
D:/test/github/review/oceanbase-powercontext-pr-2816/probes/probe_dryrun_tag_limit.py):同一份含 33 个标签的 bundle,tag_limit=32→BundleFormatError: artifact tag set has invalid labels;tag_limit=64与tag_limit=33→compatible=True。这个参数就是判定的分歧点,不是装饰。
缺口:tests/ 与 e2e/ 里 tag_max_per_artifact 只出现在 tests/test_tag_limits.py:44 与 :181(HTTP 侧),tag_limit 关键字在测试里 0 命中;tests/e2e/test_portable_archive.py:599 与 tests/e2e/test_plugin_archive.py:114-117 的 archive restore --dry-run 全部在默认设置下运行(默认 32 与有效 32 相同)。因此把上面四处传参删回默认值,现有用例的判定不变、仍然全绿——本轮这条修复没有任何用例能拦住回退。
建议补一例:建一个 Artifact 带 33 个标签的 bundle(export 走 ceiling,能成功导出),在 tag_max_per_artifact=64 的设置下跑 archive restore --dry-run 期望通过,在默认设置下期望 BundleFormatError。一例同时钉住「CLI 侧传参」与「export 侧 ceiling」两个方向;否则这条修复只能靠人工阅读维持。
There was a problem hiding this comment.
Added the regression test in 4b4db27: test_archive_cli_dry_run_uses_the_configured_tag_write_limit exports a 33-label Artifact (export still uses the ceiling), then runs archive restore --dry-run: with tag_max_per_artifact=64 it is compatible (exit 0), and with 32 it exits 2 with artifact tag set has invalid labels. Reverting the four call-site arguments would now fail this test.
There was a problem hiding this comment.
[P2 闭合] 在 head 8eaf6250 复核,dry-run 这条路径现在有回归保护。
- 传参链:
cli/archive.py的_validate_only四个分支都传settings.runtime.tag_max_per_artifact,_validate_with_database以tag_limit透传PortableBundleService;export()走MAX_TARGET_TAGS_CEILING,validate()/restore 目标校验走self._tag_limit。 - 新用例
tests/test_archive_cli_dry_run_uses_the_configured_tag_write_limit已存在并通过(pytest tests/test_archive_cli.py -k dry_run_uses_the_configured→ 1 passed);tests/test_tag_limits.py+tests/test_archive_cli.py合跑 40 passed(Python 3.14 / SQLite / 本机镜像 exact head)。 - 顺带核到与本次改动相关的门禁:
scripts/upgrade_release_gate.pyexit 0(persistence_sha256与托管输入一致,digest 已随persistence/records.py、persistence/tags.py、limits.py更新);generate_api.py --check、generate_js_operations.py --check均 exit 0;contractSha256复算2aaad075…与desktop/.../operations.json、compatibility.json的记录一致。
本线程无残留问题,可按作者判断处置。
NeverENG
left a comment
There was a problem hiding this comment.
Reviewed 5c61512. The effective query-tag limit is bypassed by the Atomic Memory endpoints; reproduced through the public HTTP API, with details inline. The previously reported archive dry-run limit mismatch is also still present; I have not duplicated that thread.
| @classmethod | ||
| def validate_tags(cls, value: tuple[str, ...]) -> tuple[str, ...]: | ||
| normalize_tags(value, maximum=16, allow_empty=False) | ||
| normalize_tags(value, maximum=MAX_QUERY_TAG_LABELS_CEILING, allow_empty=False) |
There was a problem hiding this comment.
[P2] Apply the effective query limit to Atomic Memory routes
Raising TagFilter validation to the 64-label ceiling removes its former 16-label bound, but server/atomic_memory.py builds this filter without checking the deployment limit, and the runtime does not enforce tag_max_query_labels. Reproduced with RuntimeConfig(tag_max_query_labels=2): POST /v1/atomic-memory/list with {"scope_id": scope, "tags": ["one", "two", "three"]} returns 200; /v1/atomic-memory/search with the same tags and "query": "fact" also returns 200. In the same application, /v1/memory/search with those labels in tag_filter.tags returns 422 as configured. Enforce the effective policy at the owning runtime boundary so these supported routes and direct callers honor it as well, while retaining the larger contract ceiling.
There was a problem hiding this comment.
Fixed in 728eddd. AtomicMemoryApplication now receives tag_query_limit and ScopedAtomicMemory._require_tag_query_limit enforces it in manifest, list_query, list and search, so the HTTP Atomic Memory list/search routes and direct runtime callers share the effective limit. tests/test_tag_limits.py::test_atomic_memory_routes_apply_the_query_limit reproduces the public-HTTP bypass and now gets the query-limit 422.
There was a problem hiding this comment.
The Atomic Memory routes apply the limit now, and test_atomic_memory_routes_apply_the_query_limit fails if _require_tag_query_limit is disabled.
The same TagFilter/TagQuery change reaches two embedded paths that don't check the limit. ScopedRecordApplication.query_artifacts(..., tag_filter=...) and query_tags forward straight to the record service (runtime/application.py:876, :907). On SQLite with default settings, both accept 17 labels, which 942e61f9a rejects. With tag_max_query_labels=2, both accept 3.
Plugin reads have a related gap that predates this PR. The tag-filtered list in plugins/writer.py:236 calls normalize_tags without maximum, so it uses the fixed 32-label bound regardless of tag_max_query_labels.
There was a problem hiding this comment.
Confirmed at 25c27eb through open_builtin_runtime on SQLite: with tag_max_query_labels=2, both records.for_scope(scope).query_tags(TagQuery(tags=("one", "two", "three"))) and query_artifacts(..., tag_filter=TagFilter(tags=("one", "two", "three"))) succeed. The Atomic Memory-specific fix does not cover these supported embedded query paths.
There was a problem hiding this comment.
Fixed in 4b4db27. RelationalTagService.query and RelationalRecordService.query_artifacts now call the shared require_tag_query_limit with the runtime's tag_max_query_labels, and both services receive it from RelationalContexts. test_embedded_runtime_queries_apply_the_query_limit drives open_builtin_runtime with tag_max_query_labels=2 and asserts both query_tags and query_artifacts reject three labels.
There was a problem hiding this comment.
Verified fixed at a735614 through open_builtin_runtime on SQLite: with tag_max_query_labels=2, both query_tags and query_artifacts now reject three labels with InvalidBaseAccessRequestError. The previous embedded-query bypass reproduction no longer succeeds.
hidb4ai
left a comment
There was a problem hiding this comment.
Reviewed 5c61512. Two additional correctness issues reproduced with real SQLite storage: lowering the admission limit prevents exporting existing data, and embedded Runtime tag replacement bypasses the configured write limit. Details inline. The existing dry-run and Atomic Memory query-limit threads are not duplicated here.
| _parse_bundle(archive_path) | ||
| with _validate_dependencies(archive_path, candidate_decoder=self._candidate_decoder): | ||
| with _validate_dependencies( | ||
| archive_path, candidate_decoder=self._candidate_decoder, maximum=self._tag_limit |
There was a problem hiding this comment.
[P2] Keep exports independent of the current write-admission limit
Passing the effective limit here prevents backing up valid existing data after the limit is lowered. Reproduced on SQLite: persist 40 labels with tag_max_per_artifact=40 and export successfully; close and reopen the same database with the limit set to 10. All 40 labels remain readable, but portability.export(...) now raises BundleFormatError("artifact tag set has invalid labels"). This violates #2720's requirement that lowering admission limits must not make exports unreadable/unavailable. Validate exported historical tag sets against the contract ceiling; keep the effective write limit on admission/restore as appropriate.
There was a problem hiding this comment.
Fixed in 728eddd. export now validates dependencies with MAX_TARGET_TAGS_CEILING, while validate/restore keep the effective self._tag_limit. Lowering the write limit therefore still permits exporting existing tag sets, and restoring an archive the target cannot store is rejected explicitly. The existing archive tests pass (121 passed, 65 skipped).
| execution_context=None, | ||
| ) -> ArtifactTagSet: | ||
| desired = normalize_tags(tags) | ||
| desired = normalize_tags(tags, maximum=MAX_TARGET_TAGS_CEILING) |
There was a problem hiding this comment.
[P2] Enforce the configured write limit for embedded Runtime callers
This change raises storage validation to 256, but the new effective-limit guard exists only in the HTTP adapter. The supported runtime.records.for_scope(scope_id).replace_tags(...) path reaches this method without enforcing RuntimeConfig.tag_max_per_artifact. Reproduced through open_builtin_runtime with real SQLite and tag_max_per_artifact=2: replacing an Atomic Memory tag set with ("one", "two", "three") succeeds and persists all three labels. The unchanged default of 32 is likewise no longer enforced on this path. Enforce the effective limit at the owning runtime/service write boundary while retaining ceiling-bound reads of historical sets.
There was a problem hiding this comment.
Fixed in 728eddd. RelationalTagService now takes tag_limit, and the embedded Runtime constructs it with tag_max_per_artifact; replace_in_transaction enforces the effective limit on the desired set while reading the previous set at the contract ceiling, so historical oversized sets stay readable and replaceable. Merge tag selection already receives the same configured limit. The regression is covered by the embedded-runtime path in the tag-limit tests.
|
Follow-up review: the head is still GitHub now also reports merge conflicts. The Gateway check and SQLite harness acceptance remain failing. My changes-requested review remains in place. |
5c61512 to
25c27eb
Compare
|
All four open P2 threads are addressed in
Regression coverage: The branch is |
Fengzdadi
left a comment
There was a problem hiding this comment.
Checked 25c27eb16 on SQLite through the embedded Runtime, the Server app under TestClient, and the archive CLI, comparing with 942e61f9a where behavior changed.
The four fixes from the last round work. Embedded replace_tags rejects a set above tag_max_per_artifact. Export succeeds after the limit is lowered from 40 to 10. archive restore --dry-run --env-file validates against the limit in that file. The Atomic Memory routes apply the query limit. The P1 is inline, and one more query-limit gap is in NeverENG's thread.
Tests. Of the four fixes, only the Atomic Memory one is protected by a test: disabling _require_tag_query_limit fails test_atomic_memory_routes_apply_the_query_limit. I reverted the other three: persistence/tags.py:178 back to the ceiling, the export call at bundle.py:633 back to self._tag_limit, and cli/archive.py:209 back to the default. The tag and archive suites still pass: 268 passed, 69 skipped across tests/test_tag_limits.py, tests/test_archive_cli.py, tests/builtin/portability/test_bundle.py, tests/e2e/test_portable_archive.py and six more files. No other test sets either limit. A probe on the same tree reproduced all three bugs. The embedded-write reply says "The regression is covered by the embedded-runtime path in the tag-limit tests", but tests/test_tag_limits.py only goes through TestClient, where _require_tag_admission rejects the request before the runtime sees it. Each of these fixes needs a test that fails without it; the dry-run case at a non-default limit is what AlexStocks asked for in the dry-run thread.
Docs.
docs/zh/docs/operate/configuration.md:57-58still says a merge result keeps at most 32 tags. The English paragraph describes the configurable limit.- #2720 asks the docs to say whether changing these settings needs a restart. Neither locale does.
Not blocking.
- Two over-limit errors outside HTTP don't name the limit. Embedded
replace_tagsraisestags has an invalid number of labels. The restore dry-run reportsarchive validation failed: artifact tag set has invalid labels, which reads like a malformed label rather than a set larger than the target'stag_max_per_artifact. - #2720 also asks for query and write costs at a documented larger configuration. The PR doesn't report any.
|
|
||
| class CatalogChangeProposal(TagDreamTarget, TagChangeProposal): | ||
| before_tags: tuple[str, ...] = Field(max_length=32) | ||
| before_tags: tuple[str, ...] = Field(max_length=MAX_TARGET_TAGS_CEILING) |
There was a problem hiding this comment.
[P1] Raise the candidate contract along with these bounds
These models now accept up to 256 labels, but the contract's CatalogChangeProposal still caps before_tags and after_tags at 32 (openapi/powercontext.yaml:14729-14736, generated http/_generated/models.py:4674-4675). candidate_response validates each proposal into that model, so any candidate with more than 32 labels on either side fails response validation.
Reproduced on SQLite with the Dream e2e harness (tests/e2e/dream_support.py) and the Server app under TestClient:
tag_max_per_artifact=40, a target holding 40 tags, and a plan proposing one tag. Everything is within the configured limit./v1/candidates/getand/v1/candidates/listreturn 422invalid_request("The request violates the API contract.",loc: ["before_tags"])./v1/candidates/approvereturns the same 422, yet the target's tags are now["verified"]./v1/candidates/rejectalso returns 422 and commits: a repeat returns 409candidate_terminal.
- Default limits and a plan proposing 33 tags. At
942e61f9athe run fails, becauseTagChangeProposalrejects 33 labels. Here the run succeeds with a pending candidate holding 33after_tags.- get and list fail on
after_tags. - Approve returns 422 "The request is invalid." with
details: null, so the response doesn't carry the 32-tag message from_approve_once. - Reject clears the candidate, but also answers 422.
- get and list fail on
_candidate_responses maps the whole page, so /v1/candidates/list fails for every page that contains such a candidate.
The second case also changes behavior at default settings. The generator's output type is DreamPlan (composition.py:1549), and its after_tags schema now has maxItems: 256 instead of 32. propose() doesn't check the effective limit either, so a plan the deployment can't apply becomes a pending candidate.
Suggested direction:
- Raise both contract bounds to the 256 ceiling and regenerate, so stored candidates stay readable after any limit change.
- Check the effective limit when the candidate is proposed.
- Keep the approval check for candidates created before a limit was lowered, and give it details the client can act on.
#2720 asks to explicitly define and test that approval case. HTTP tests for get, list, approve and reject would cover it.
There was a problem hiding this comment.
Independently reproduced at 25c27eb with real SQLite persistence and the controlled Dream generator: a valid target with 40 tags produces a pending candidate, GET returns 422 on before_tags, and APPROVE also returns 422 while the stored tags have already changed to ["verified"]. This confirms a committed write behind an error response, not just a static schema mismatch. Please align the candidate response contract with the supported tag ceiling before merging.
There was a problem hiding this comment.
Fixed in 4b4db27. CatalogChangeProposal.before_tags/after_tags and CatalogTagResult.tags now allow the contract ceiling (256) in openapi/powercontext.yaml, and the generated models were refreshed. The new test_candidate_proposal_accepts_labels_above_the_default_limit validates a 40-label proposal, so a candidate over the old 32-label bound no longer fails response validation after approval commits.
There was a problem hiding this comment.
Fixed in 4b4db27. The candidate response contract is now widened to 256 labels and regenerated; the 40-label model regression test covers the exact shape that returned 422 at 25c27eb. Validation over HTTP and the Dream harness needs the new wheel; I also requalified the Desktop contract at this head.
There was a problem hiding this comment.
Verified fixed at a735614. Replayed the same SQLite-backed Dream scenario with 40 existing labels: candidate get and approve now both return 200, and readback confirms the approved tag set. The former error-after-commit reproduction no longer fails.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed 25c27eb. The export-after-limit-reduction and embedded write-limit fixes pass independent SQLite/restart probes. However, the candidate response contract still returns 422 after committing approval, and the two embedded record-query paths still bypass the configured limit; independent reproductions are added to the existing threads. Please fix those before merging. Real-provider SQLite capture/generation, embedding and tag-filtered FTS/vector/hybrid recall passed. OceanBase acceptance did not reach the business flow: startup rejected the disposable database with DreamSchemaNotReadyError (candidate constraints). This is a validation limit, not a newly attributed PR defect.
25c27eb to
8eaf625
Compare
|
Rebased onto
Validation: 246 passed/81 skipped across tag, archive CLI, portable archive, catalog-change, API/JS contract suites; |
Fengzdadi
left a comment
There was a problem hiding this comment.
Rechecked 8eaf625 on SQLite through a real powercontext server run, the embedded Runtime and the archive CLI. The candidate P1 is fixed: with the per-Artifact limit at 64, 40-label candidates list, get, approve and read back over HTTP, and no approval commits behind an error. The two embedded query paths and the dry-run test are fixed too. One gap remains at the default settings: the Server now creates and revises tag candidates it can't approve.
What I checked
- I compared the author's changes rather than the rebase. I applied the 25c27eb diff to 389c440 and diffed the result against 8eaf625. The new changes are the
maxItems: 256bound thatbefore_tags,after_tagsandCatalogTagResult.tagsshare, the query check inRelationalTagService.queryandRelationalRecordService.query_artifacts, two tests, and the regenerated artifacts. - I seeded Dream candidates with the controlled generator from
tests/e2e/dream_support.py. I read and acted on them over HTTP through a real Server process.- At
TAG_MAX_PER_ARTIFACT=64, I tried a target holding 40 tags with a 1-label plan, and an empty target with a 40-label plan. In both cases list, get, approve, a repeated approve and get all return 200, and the target reads back with 1 and 40 tags. Reject returns 200 and leaves the 40 tags, and a repeated reject returns 409candidate_terminal. At 25c27eb with a limit of 40, the first case still answers 422 onbefore_tagsafter committing. - I lowered the limit. A candidate with 40
after_tagscreated at 64 stays readable after a restart at 32: get and list return 200. Approve returns 422 and the target is unchanged. A 1-label candidate for a target that already holds 40 tags approves at 32.
- At
- Query limit.
- Embedded
query_tagsandquery_artifacts(tag_filter=…)accept 16 labels and reject 17 at the default, reject 3 at a limit of 2, and accept 64 at a limit of 64. - Over HTTP,
artifact-tags/query,GET …/artifacts/atomic-memory?tag=…andmemory/entries/listreject 17 labels at the default, with the "16-label query limit" message. At 64 they accept 64 labels, and the contract rejects 65.
- Embedded
- Dry-run.
archive restore --dry-runon a 33-label archive exits 0 at 64, at 33, and with--env-fileset to 64. It exits 2 at 32 and at the default. - Test suites. The tag, archive, catalog-change, Dream and portability suites pass: 374 passed, 173 skipped.
test_api_contract.py,test_js_operations.pyandtest_desktop_contract.pypass: 69 passed. Also passing:generate_api.py --check,generate_js_operations.py --check, the Difygenerate_contract.py --checkandupgrade_release_gate.py. Main CI on 8eaf625 is green, with the OceanBase and SeekDB jobs skipped. - Reverts. I reverted the source change behind each new test. Each new test then fails: the generated bounds back at 32, either query check, and the CLI call sites.
Remaining findings
-
[P2] Tag candidates above the effective limit are still created, and revise now accepts them too.
- Widening
CatalogChangeProposalalso widens a request.ReviseCandidateRequest.proposalusesCatalogChangeProposal(openapi/powercontext.yaml:12913-12922,:14716-14736). Neither the revise route (server/app.py:6110-6121) norrevise()(catalog_changes/service.py:234-277) checks the deployment limit. propose()(catalog_changes/service.py:162-189) still doesn't check the limit either. At default settings, a Dream plan with 33after_tagsbecomes a pending candidate, while on master the same run fails. The JSON schema ofDreamPlan, the generator's output type, now allows 256after_tags(32 on master), whatever limit the deployment sets.- Approve rejects every one of these candidates. They also break clients built from the master contract, which still caps
after_tagsat 32. At default settings,PowerContextClient.get_candidatefrom 389c440 raisesInvalidResponseError("violated the API schema") on the revised 33-label candidate. - RFC 1715 bounds a revision's
after_tagsat 0–32. With a configurable limit, the consistent rule is 0 to the effective limit. - The direction I'd take:
- Check
after_tagsagainst the effective limit inpropose()andrevise(), and in the revise route, the way_require_tag_admissionguards tag writes. - A Dream run whose plan exceeds the limit then fails as it does on master.
- Keep the approval check for candidates created before a limit was lowered.
- Check
- Widening
-
[P2] The new test doesn't cover the response that committed behind an error.
test_candidate_proposal_accepts_labels_above_the_default_limit(tests/test_tag_limits.py:205) only validates the model. I set the generatedCatalogTagResult.tagsback tomax_length=32and leftCatalogChangeProposalat 256. The tag, archive, catalog-change and Dream suites andtest_api_contract.pystill pass: 413 passed.- On a real Server at a limit of 64, that mutant answers approve of a 40-label candidate with 422 on
result.tags, while the target now holds all 40 tags. This is the original defect. - No test sets the per-Artifact limit above 32 and goes through candidate get, list, approve and reject over HTTP. #2720 also asks for the lowered-limit approval case to be tested.
- The round-one fixes for export after lowering the limit (
portability/bundle.py:633) and the embedded write limit (persistence/tags.py:181) are also still untested. Reverting either one leaves the same suites green, although both behave correctly at this head. - One HTTP test at a limit of 40 or 64 should approve and read back a candidate with more than 32 labels, approve one after the limit is lowered, and assert the response and the stored tags. That would cover the P1 path.
-
[P3] An over-limit approval returns no details.
_approve_onceraisesInvalidCandidateError("after_tags", "the candidate exceeds the deployment's 32-tag Artifact limit")(catalog_changes/service.py:305-309)._CANDIDATE_ERROR_REASONS(server/app.py:7742) has no entry for it, so the client gets 422 "The request is invalid." withdetails: null.- With that check removed, the same request fails in
replace_in_transactionand carries{"field": "tags", "reason": "has an invalid number of labels"}. The explicit check makes the response less specific. - A mapped reason for
after_tags, together with the limit, would let the Dashboard and clients explain why the candidate can't be approved.docs/*/docs/workflows/review-dream-revisions.mddoesn't describe this outcome yet.
-
[P3] Docs. These are unchanged since 25c27eb.
docs/zh/docs/operate/configuration.md:57-58still says a merge result keeps at most 32 tags. The English paragraph atdocs/en/docs/operate/configuration.md:67-70describes the configurable limit.- Neither locale says whether changing the two settings requires a restart, which #2720 asks for.
- Neither locale says that a limit above 32 needs clients built from this contract. A client from master rejects tag sets and candidates larger than 32 labels.
Notes (not blocking)
- Two errors still don't name the limit. An embedded over-limit
replace_tagsraises "tags has an invalid number of labels", and the restore dry-run reports "artifact tag set has invalid labels". - The cost figures #2720 asks for are still missing.
- hidb4ai's two findings and AlexStocks' dry-run test request are addressed, as checked above. I didn't run OceanBase.
- As it stands, #2745 changes the same contract digest, Desktop compatibility profile,
limits.pyandrelease/upgrade-support.json. Whichever merges second needs to regenerate those files and add a new Desktop profile.
|
Addressed the remaining P2 findings and the documentation details in
Validation: tag, archive CLI, catalog-change, portable-archive and Dream suites → 259 passed, 81 skipped; Two non-blocking notes remain as stated: the restore dry-run message is still the generic |
Fengzdadi
left a comment
There was a problem hiding this comment.
Rechecked c71da4b on SQLite through real powercontext server run processes and the embedded Runtime. Both P2 findings are fixed. At default settings a 33-label revision is now rejected and a 33-label Dream plan leaves no candidate. The new tests fail when each fix is reverted. Over-limit approval now returns details. What's left is small: two sentences in the new docs paragraph, some Chinese line breaks, and the notes below. I have no blocking concerns, so I'm approving.
What I checked
- Proposal and revision limits. I seeded Dream candidates with the controlled generator from
tests/e2e/dream_support.pyand acted on them over HTTP.- Default limit: revising a 1-label candidate to 32 labels returns 200 and stores version 2. Revising it to 33 returns 422 with
{"field": "after_tags", "reason": "tag_limit_exceeded", "limit": 32}, and the candidate stays at version 2 with 32 labels. - Default limit: a Dream plan with 33
after_tagsends as afailedrun with errorinvalid_generation_output, after 1 attempt and 1 model call. It leaves no candidate rows. On 389c440 a real model's 33-label output would fail output validation, which_map_errorturns into the same error code. The Dream generator runs withmax_requests=1, so neither branch retries. - Limit 64: revise to 64 returns 200 and revise to 65 returns 422 with
limit: 64. At a limit of 100, revise to 101 reportslimit: 100, so the parsed limit isn't limited to two digits. - Limit 64, 40-label candidate: list, get, approve, repeated approve and get all return 200, with
result.tagsholding 40. The target reads back with 40 tags. PUT of 64 tags returns 200, and 65 returns 422 naming the 64-label limit. - Lowered limit: a 40-label candidate created at 64 and served at 32 returns 200 for get and list. Approve returns 422 with
limit: 32, the target stays empty and the candidate stays pending. Reject then returns 200, and a repeated reject returns 409candidate_terminal.
- Default limit: revising a 1-label candidate to 32 labels returns 200 and stores version 2. Revising it to 33 returns 422 with
- No other way in. Every proposal goes through
propose(). In the Server its only caller is Dream's_propose, and no route creates a tag candidate directly. Embedded callers ofcatalog_changes.for_scope(...).propose()hit the same check. Portable archives reject tag candidates ("tag Candidates are not supported by portable archives"), so restore can't bring one in. - Clients built from 389c440.
- The new 422 parses:
approve_candidateraisesServerResponseErrorwithdetails={'field': 'after_tags', 'reason': 'tag_limit_exceeded', 'limit': 32}. - On 40-label data,
get_candidate,get_artifact_tagsandlist_candidates(for the pending candidate) raiseInvalidResponseError. This is the case the new configuration paragraph describes. - A client built from c71da4b reads all of them.
- The new 422 parses:
- Reverts. I reverted each fix alone and ran the tag, archive, portability, catalog-change, Dream and
test_api_contract.pysuites.- Removing the
propose()check or therevise()check failstest_candidate_proposal_and_revision_respect_the_effective_limit. - Removing the
tag_limit_exceededmapping or thelimitkey failstest_lowering_the_limit_keeps_candidates_readable_but_not_approvable. - Removing the embedded write check in
replace_in_transaction, or restoring the 8eaf625 version of it, failstest_embedded_runtime_rejects_tag_writes_above_the_configured_limit. - Pointing the export validation back at the configured limit fails
test_export_survives_a_lowered_write_limit. - Setting the generated
CatalogTagResult.tagsback tomax_length=32, with the proposal left at 256, failstest_candidate_larger_than_the_default_limit_approves_over_http. This is the mutant that survived on 8eaf625. - Removing the approval check fails the lowered-limit test.
- Removing the
- Test suites. At c71da4b the tag, archive CLI, portability, portable/plugin archive, artifact-tag, catalog-change and Dream suites pass, together with
test_api_contract.py,test_js_operations.pyandtest_desktop_contract.py: 426 passed, 169 skipped. Also passing:generate_api.py --check,generate_js_operations.py --check, the Difygenerate_contract.py --checkandupgrade_release_gate.py. CI on c71da4b is green: 72 checks pass and 22 are skipped, including the OceanBase and SeekDB jobs. - Desktop profile. c71da4b differs from 7160b93 only in
desktop/VALIDATION.mdandcompatibility.json, soserverCommit7160b93 matches the head's Server code. The contract digest is unchanged since 8eaf625.
Remaining findings
- [P3] The new paragraph in
review-dream-revisions.mddoesn't describe a Dream proposal correctly, and it splits a sentence pair.- It says an over-limit proposal is rejected with a
422 invalid_requestresponse. Over HTTP a tag proposal only comes from a Dream run, which has no response to return: the run fails withinvalid_generation_outputand creates no candidate. An embeddedcatalog_changescaller getsInvalidCandidateError. Only revise and approve return the 422. The zh paragraph says the same. - In
docs/en/docs/workflows/review-dream-revisions.md:88-93the paragraph sits between "Approval checks both the Tag ETag and content baseline atomically." and " The result contains the complete tags and new ETag…". They render as one paragraph, so "The result" now follows "leaves the target unchanged" and reads as the rejected approval's result. Moving the new text after the result sentence fixes it.
- It says an over-limit proposal is rejected with a
- [P3] The new zh lines break between two Chinese characters, which the website renders as a space.
docs/zh/docs/operate/configuration.md: 58→59 (重启后|生效), 59→60 (去重后|超过), 60→61 (顺序见|[使用…). The old text kept the last one on one line.docs/zh/docs/workflows/review-dream-revisions.md: 90→91 (已创建的|候选).- The zh workflow page also gains a second blank line at line 12 and after the new paragraph.
Notes (not blocking)
- In
revise(), the limit check runs beforelock_pending. A 33-label revise of a rejected candidate therefore returns 422tag_limit_exceeded, while a 1-label revise of the same candidate returns 409candidate_terminal. Both responses are rejections, but the 409 tells the caller more. _candidate_error_detailsparseslimitback out of the message with a regex, so the two places that build the message (_require_after_tag_limitand the inline copy in_approve_once) have to keep "deployment's N-tag" exactly. Calling_require_after_tag_limit(current.proposal)from_approve_once, or carrying the limit on the error, would remove that coupling.DreamPlan's JSON schema, which the model sees throughPromptedOutput, still allows 256after_tagswhatever the deployment sets, and the instructions don't mention the limit. A model at default settings is no longer told 32. The run fails cleanly either way, as above.release/upgrade-support.jsonschema_review.rationalenow has two "PR #2816 makes the per-Artifact and per-query tag limits configurable…" sentences. The new one appears to be meant to replace the old one.- RFC 1715 (en line 127, zh line 301) still bounds
after_tagsat 0–32, and RFC 1467 (en line 242, zh line 232) still says at most 32 tags. The behavior now matches "0 to the deployment's effective limit, 32 by default". Updating both, here or in a follow-up, would keep the RFCs in line with the code. - The revise limit is covered through
CatalogChangeService.reviseand not throughPOST /v1/candidates/revise. The HTTP behavior is correct, as above. - As it stands, #2745 still changes
openapi/powercontext.yaml, the generated models and schema,compatibility.json,desktop/VALIDATION.md,limits.py,server/app.py, bothconfiguration.mdpages andrelease/upgrade-support.json. Whichever merges second needs to regenerate those files and requalify Desktop. - I didn't run OceanBase or the Desktop native probe.
Correct the Tag review paragraph: a Dream proposal over the limit fails its run and creates no candidate, while revise and approval return the mapped 422; move it after the approval-result sentence. Reuse _require_after_tag_limit for the approval check so the message has one owner, drop the duplicate PR oceanbase#2816 rationale, fix Chinese line breaks, and update RFC 1715/1467 from a fixed 32-tag bound to the deployment's effective limit.
|
All remaining P3 items are fixed on
Still open as acknowledged follow-ups: the revise limit check runs before Validation on the new head: tag/catalog/Dream suites pass, |
There was a problem hiding this comment.
Re-reviewed a735614. The previously reproduced candidate-response, embedded query/write-limit, export-after-limit-reduction and archive dry-run issues are fixed; confirmations are in the existing threads. I found no new blocking correctness issue in the reviewed changes.
Real-provider SQLite capture/generation, embedding and tag-filtered FTS/vector/hybrid recall passed. Fresh OceanBase acceptance also passed at this commit in both enforced and disabled access modes. Each mode used a separate disposable database, initialized through the full Server migration runner (plan/apply/verify to revision 000), followed by the existing tag HTTP behavior suite and real-provider capture/generation, embedding, and tag-filtered FTS/vector/hybrid recall. HTTP handlers were exercised through in-process ASGI transport with the real database and providers. Both databases were dropped after successful validation.
The earlier OceanBase startup failure came from the pre-existing configured database, before disposable-database creation. The fresh run avoids using that old business schema for the administrative connection. This validates fresh initialization and the tested business flows, not migration of that existing database. Larger-limit query/write costs remain unquantified.
hireview001
left a comment
There was a problem hiding this comment.
- Resolve merge conflicts with the target branch.
| context: Any = None, | ||
| change: UserChange | None = None, | ||
| caller_scoped: bool = False, | ||
| tag_limit: int = MAX_TARGET_TAGS, |
There was a problem hiding this comment.
[P2] Apply the configured query limit to plugin listings
With tag_max_query_labels=40, plugin calls to writer.list(tags=...) and tx.list(tags=...) still reject 40 distinct labels because _Reads.list calls normalize_tags with its default maximum of 32. Propagate the query limit through both plugin host and Worker specs into the list validator so these filters honor the deployment setting.
|
Thanks. I checked
hireview001's new P2 on plugin listings holds from the code. My approval from |
|
@Lumea-art plz fix the file confliction and then we can merge it. |
a735614 to
49e0782
Compare
|
Rebased onto
Validation on the rebased head: 146 passed/18 skipped across tag, plugin-writer, archive CLI, catalog-change, Dream, API/JS suites; upgrade gate, generation checks, Desktop contract and the Bearer probe (13 operations, 64/65 and 20/21 boundaries) pass. The branch is |
There was a problem hiding this comment.
The plugin query-limit propagation fixes the previous admission gap, but introduces a pagination regression in tagged plugin listings. Reproduced through a running Server and spawned plugin Host; please preserve the caller's page size when validating the tag count.
Validation limit: the fresh OceanBase rerun at this commit stopped during explicit schema initialization with native error 4012 (RPC post error), before the real-provider business flow. Cleanup succeeded on retry and the disposable database was verified absent. The earlier OceanBase acceptance was on a735614 and is not claimed as acceptance of this updated commit.
| statement = statement.where(heads.c.artifact_id > cursor) | ||
| if tags: | ||
| keys = tuple(normalize_tags(tuple(tags), allow_empty=False)) | ||
| limit = owner.tag_query_limit |
There was a problem hiding this comment.
[P2] Keep the query-label bound separate from the page-size limit
This assignment overwrites the caller's pagination limit after SQL has already been built with .limit(limit + 1). The later identities[:limit] and next_cursor calculation therefore use tag_max_query_labels instead of the requested page size. Reproduced at 49e0782 through a running Server and spawned plugin Host: with three matching tagged artifacts and tag_max_query_labels=40, ctx.reads(scope).list(tags=["selected"], limit=1) returns two items and next_cursor=None, so the third matching artifact is unreachable through pagination. The shared implementation also affects writer.list and tx.list, including default settings whenever page size differs from the query-label limit. Use a separate local for the tag bound and cover a nonempty tagged multi-page result.
There was a problem hiding this comment.
独立复核上述结论,缺陷由本 PR 引入,且影响面比单个 writer.list 更宽。
- 归因:master
b8603175的src/powercontext/builtin/plugins/writer.py(blobeb933c9f)在该查询处只有.limit(limit + 1),没有limit = owner.tag_query_limit;本 PR head49e07823在.limit(limit + 1)(:231)之后新增.limit重绑定(:236),随后identities[:limit](:256)与next_cursor计算(:259)都用到了被覆盖后的值。 - 共享实现:该
list定义在_Reads(writer.py:213),PluginArtifactTransaction(:317)与PluginArtifactWriter(:699)都继承它,因此ctx.reads(...).list、writer.list、tx.list三处同受影响;host.py:316/:467把spec.tag_max_query_labels注入为tag_query_limit。 - 两个方向的后果都可以从代码直接推出,不需要运行:
- 请求
limit小于 tag 上限时丢页:默认tag_max_query_labels=16,若调用方limit=1,SQL 取 2 行,identities[:16]返回 2 条而len(2) > 16为假 ⇒next_cursor=None,第 3 条及之后不可达(与上述limit=1/tag_max_query_labels=40的复现同因,但默认配置即成立,不限于显式放大 tag 上限)。 - 请求
limit大于 tag 上限时静默缩小页:limit=50、tag 上限 16 时每页只返回 16 条。
- 请求
- 修复方向:tag 数量校验与
normalize_tags的上界用独立局部变量(例如tag_bound = owner.tag_query_limit),不要覆盖分页用的limit;回归用「3 个同标签 Artifact +limit=1+ 默认 tag 上限」断言len(page.items) == 1且next_cursor非空,再补一条limit > tag 上限的页大小断言。
说明:本条不涉及我此前在本 PR 的两条线程(tests/test_tag_limits.py 的 ty 失败、bundle.py 的 dry-run tag_limit 透传),那两条在 49e07823 上仍成立(本地 ty check tests/test_tag_limits.py 通过;tests/test_archive_cli.py 30 passed;移除 _validate_only 四处透传后该用例 1 failed)。
There was a problem hiding this comment.
Fixed in b7399de. _Reads.list now keeps the caller's limit for SQL, slicing and next_cursor, and uses a separate tag_bound = owner.tag_query_limit only for the label-count check and normalize_tags maximum. test_plugin_listing_keeps_the_requested_page_size creates 20 tagged artifacts and asserts limit=1 returns one item with a non-empty cursor and a second page reaches a different artifact, then asserts limit=20 returns all 20 with no cursor, so both the shrunken-page and lost-page cases are covered.
There was a problem hiding this comment.
Verified fixed at 0786032 through the running Server and spawned plugin Host: with three tagged artifacts, query-label limit 40 and page size 1, the response now contains one item and a non-empty next cursor. The nonempty pagination regression test also passes on the current merge result. Host and Worker paths still accept 40 query labels and reject 41.
Add RuntimeConfig.tag_max_per_artifact (default 32, ceiling 256) and tag_max_query_labels (default 16, ceiling 64). Enforce the effective policy at the owning boundaries: HTTP tag writes/queries/filters, the Atomic Memory runtime list/search/manifest filters, embedded Runtime tag and artifact queries, plugin Artifact listings and writes, Dream/catalog proposal, revision and approval, merge tag selection and the storage write service. Read, export and import paths stay ceiling-bound so lowering a limit never hides existing sets. Widen the candidate response contract to the same 256-label ceiling, reject over-limit proposals and revisions before they are stored, apply the query limit to plugin listings without changing the caller's page size (default 16 rather than 32), and keep export independent of the current write-admission limit with the CLI dry-run passing the configured value. Cover the candidate HTTP paths, both embedded query paths, plugin listing bounds and pagination, the embedded write limit and the dry-run boundary; refresh generated artifacts, docs and environment template; recompute the managed persistence digest after the content-limit merge.
Record sqlite-tag-limits-b7399de-v1 for the wheel built from the merged implementation commit. The Bearer probe covers all thirteen Desktop operations, the 64/65 Artifact-label and 20/21 query-label boundaries, and the Atomic Memory list query-limit rejection.
49e0782 to
0786032
Compare
|
Rebased onto
The OceanBase 4012 failure you hit was during disposable schema initialization, before the business flow; I have not claimed OceanBase acceptance for this head. Please re-review the page-size fix and the merge. |
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed 0786032. The tagged plugin pagination regression is fixed; confirmation is in the original thread. I found no remaining blocking correctness issue in the reviewed changes.
Fresh OceanBase initialization to 000, tag HTTP behavior, and real-provider generation/embedding plus tag-filtered FTS/vector/hybrid recall passed at this head with access enforcement enabled; the disposable database was removed. The current merge result cbaf025 (master 15b2548 plus this head) also passed plugin pagination tests and the SQLite real-provider journey. Database/provider calls were real; these backend journeys used in-process ASGI HTTP transport, while the plugin check used a running TCP Server and spawned Host/Worker processes. This does not certify upgrades of the existing database or high-limit performance.
No new tables, migrations or HTTP routes are introduced. There are new deployment configuration interfaces and expanded existing API bounds, so I am leaving a comment rather than automatic approval under the requested review policy.
Which issue or RFC does this PR close?
Closes #2720.
Rationale for this change
The 32-labels-per-Artifact and 16-labels-per-query bounds were hard-coded in domain validation, OpenAPI arrays and
several duplicate paths. Raising either required editing source, and changing only one copy would leave another supported
path rejecting the same input. This change makes both limits deployment-wide settings while keeping the defaults and
putting a bounded ceiling in the contract.
What changes are included in this PR?
RuntimeConfig.tag_max_per_artifact(POWERCONTEXT_SERVER_RUNTIME_TAG_MAX_PER_ARTIFACT, default 32, range 1–256) andRuntimeConfig.tag_max_query_labels(POWERCONTEXT_SERVER_RUNTIME_TAG_MAX_QUERY_LABELS, default 16, range 1–64),exposed through the embedded runtime configuration and the Server's runtime settings.
writes (host and Worker), Dream/Catalog approval and merge tag selection.
static validation; runtime admission reports the effective limit.
existing larger set stays readable and can be replaced with a compliant set or cleared.
.env.exampleand the configuration reference describe the settings, ranges and precedence;Desktop contract identity and its qualification record are refreshed.
Are there any user-facing changes?
Two new runtime settings with unchanged defaults. Without overrides behavior is identical; configured larger values now
succeed up to the effective limit, and values above it fail with an actionable validation error naming the limit.
How was this change tested?
tests/test_tag_limits.py(7 tests): default 32/16 boundaries, configured 40/20 boundaries, Artifact-list filters,Memory search filters, lowering a limit with existing oversized tag sets (read, replace and clear), and rejection of
configuration above the ceilings.
pytest tests/test_tag_limits.py tests/e2e/test_real_artifact_tags.py tests/builtin/artifacts/atomic_memory tests/builtin/persistence/test_records.py tests/test_api_contract.py tests/test_js_operations.py→ 284 passed,7 skipped;
tests/builtin/dream tests/builtin/plugins→ 20 passed, 2 skipped.generate_api.py --check,generate_js_operations.py --check,upgrade_release_gate.py,ruffandtypass;tests/test_desktop_contract.py→ 4 passed.TAG_MAX_PER_ARTIFACT=64andTAG_MAX_QUERY_LABELS=20and enforced Bearerauthentication: 64 labels accepted, 65 rejected with
422; a 20-label query succeeded and a 21-label query wasrejected with
400;desktop/VALIDATION.mdrecords the probe, including that the native probe was not rebuilt here.AI usage statement
Built with an AI coding assistant (DeepSeek Harness). Changes were reviewed and executed locally against a real
SQLite Server built from the wheel; the OceanBase limit is reported as not exercised.
Plugin note: Artifact tag filters in plugin hosts now default to 16 labels (the documented query-label limit) and accept up to the deployment's configured value; previously they accepted at most 32.