Repository navigation
Conversation
Add RuntimeConfig.tag_max_per_artifact (default 32, ceiling 256) and tag_max_query_labels (default 16, ceiling 64). Enforce the effective policy on HTTP tag writes, tag queries and Artifact or Memory tag filters, on plugin Artifact writes, on Dream/catalog approval and on merge tag selection; widen the OpenAPI arrays to the contract ceilings and keep read, export and import paths ceiling-bound so existing tag sets stay readable after a limit is lowered. Docs, the environment template and tests cover the defaults, configured values, filters, lowering, replacement/clearing and the configuration ceiling.
Record sqlite-tag-limits-17fcab7-v1 for the wheel built from the implementation commit. The Bearer probe covers all thirteen Desktop operations plus the 64/65 Artifact-label and 20/21 query-label boundaries.
| 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.
Construct RuntimeConfig with explicit fields instead of a `**`-expanded dict so the type checker validates every setting; the previous dict literal produced 83 invalid-argument-type diagnostics and failed the CI preflight.
|
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,
)
|
Thread the deployment's Artifact tag limit into PortableBundleService so archive validation rejects tag sets the target cannot store, while single-label parsing stays at the contract ceiling. Store the limit on RelationalContexts so the runtime export and restore path receives the configured value instead of the default.
|
Two fixes are pushed on top of the implementation:
Verification on the pushed head: |
Regenerate the Dify contract for the widened tag arrays and add the TagFilter description to the generated Rust wire model, which is the only wire model the new schema documentation touches.
Run the pinned OpenAPI generator with the new TagFilter description. The generator emits the description on the constructor as well as the model, which the hand-edited line could not reproduce.
|
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.
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.