Skip to content

cluster-029: workflow scope/channel use typed proto fields, not metadata bag#689

Merged
loning merged 4 commits into
devfrom
refactor/iter15-cluster-029-workflow-scope-metadata
May 19, 2026
Merged

cluster-029: workflow scope/channel use typed proto fields, not metadata bag#689
loning merged 4 commits into
devfrom
refactor/iter15-cluster-029-workflow-scope-metadata

Conversation

@loning
Copy link
Copy Markdown
Contributor

@loning loning commented May 19, 2026

Summary

iter15 cluster-029 (medium severity, AG-STRONG-TYPING-01 + AG-METADATA-01).

  • Old: ChatRunRequestNormalizer accepted scope id / channel facts from metadata bag string keys as fallback to typed fields.
  • New: typed proto field is the only source of truth; metadata bag fallback paths removed.

Violated CLAUDE.md "核心语义强类型".

Scope

4 files (+35/-54, net deletion). Targeted tests pass; query_projection_priming_guard + architecture_guards green.

See implement-cluster-029 summary.

🤖 Auto-loop / codex-refactor-loop iter15 batch A

loning and others added 2 commits May 19, 2026 14:34
set -euo pipefail at top +  when ADD_DIRS is empty array
triggered 'ADD_DIRS[@]: unbound variable' exit 1, blocking every
spawn-codex.sh call that didn't pass --add-dir. Iter15 audit dispatch
failed before reaching codex.

Guard with the empty-array-safe ${ADD_DIRS[@]+"${ADD_DIRS[@]}"}
parameter expansion — expands to nothing when unset, preserves
individual element quoting when set.

Verified: probe call without --add-dir now succeeds.

Co-Authored-By: codex-refactor-loop <noreply@aevatar>
…ster-029)

Refactor (iter15/cluster-029):
- Old pattern: ChatRunRequestNormalizer accepted scope id / channel
  facts from metadata bag string keys as fallback to typed fields,
  letting stable business semantics live in an open extension bag.
  Violated CLAUDE.md "核心语义强类型:影响业务语义、控制流、稳定读取且
  仓库内可控的数据,必须建模为 proto field / typed option /
  typed sub-message".
- New principle: stable scope/channel use typed proto fields;
  metadata bag remains only for genuine open extension. Fallback paths
  removed; typed field is the only source of truth.

4 scoped files. Targeted tests pass; query_projection_priming_guard +
architecture_guards green.

Co-Authored-By: codex (gpt-5) <noreply@openai.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.42%. Comparing base (601d92b) to head (b1104be).

Files with missing lines Patch % Lines
...tructure/CapabilityApi/ChatRunRequestNormalizer.cs 83.33% 1 Missing ⚠️
@@           Coverage Diff           @@
##              dev     #689   +/-   ##
=======================================
  Coverage   82.42%   82.42%           
=======================================
  Files         938      938           
  Lines       59753    59731   -22     
  Branches     7831     7826    -5     
=======================================
- Hits        49251    49235   -16     
+ Misses       7128     7124    -4     
+ Partials     3374     3372    -2     
Flag Coverage Δ
ci 82.42% <88.88%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ervice.Hosting/Endpoints/ScopeWorkflowEndpoints.cs 67.53% <ø> (+0.17%) ⬆️
...ication.Abstractions/Runs/WorkflowChatRunModels.cs 100.00% <100.00%> (ø)
...frastructure/CapabilityApi/ChatCapabilityModels.cs 100.00% <ø> (ø)
...structure/CapabilityApi/ChatRunStartErrorMapper.cs 80.00% <ø> (+8.12%) ⬆️
...tructure/CapabilityApi/ChatRunRequestNormalizer.cs 92.07% <83.33%> (+1.21%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loning loning changed the base branch from refactor/2026-05-19_auto-refactor-trial to dev May 19, 2026 07:28
@loning
Copy link
Copy Markdown
Contributor Author

loning commented May 19, 2026

🤖 Multi-codex review (v2, round 1) — Phase 8

Verdicts | 三组独立 codex 评审结论

Reviewer Verdict
Architect (CLAUDE/AGENTS clause compliance) comment
Tests (coverage + quality) reject
Quality (readability + simplicity) comment

Not unanimous approve → enter fix-retry loop (per Phase 8 policy, max 3 rounds before human escalation).


English

The 3 reviewer codex ran independently against origin/dev...origin/refactor/iter15-cluster-029-workflow-scope-metadata.

  • Architect (comment): workflow scope/channel typed-field promotion complies with CLAUDE "API 字段单一语义" + "核心语义强类型".
  • Quality (comment): normalizer refactor is smaller and readable; refactor self-doc present.
  • Tests (reject): ChatRunRequestNormalizer.cs:164 processes defaultMetadata through the same new scope-key filtering path as request metadata, but WorkflowCapabilityEndpointsCoverageTests.cs:219-282 only covers ChatInput.Metadata — no test passes defaultMetadata containing scope_id or WorkflowRunCommandMetadataKeys.ScopeId and asserts it is neither promoted into WorkflowChatRunRequest.ScopeId nor forwarded. Demand: behavior test for Normalize(input, defaultMetadata: ...) where default metadata includes scope keys; assert Request.ScopeId stays null unless typed ChatInput.ScopeId is set, scope metadata keys are not forwarded, unrelated default metadata still merges.

Next action (automatic): fix codex round 1 dispatched to add the defaultMetadata scope-key test on a worktree off this PR's HEAD.

Full local artifacts: .refactor-loop/runs/review-pr689-*.md, .refactor-loop/logs/v2-review-pr689-*.log.


中文

3 个独立 reviewer codex 在 origin/dev...origin/refactor/iter15-cluster-029-workflow-scope-metadata 上跑出结论。

  • Architect (comment): workflow scope/channel 升级为 typed field 符合 CLAUDE 的 "API 字段单一语义" 与 "核心语义强类型"。
  • Quality (comment): normalizer 重构后更小、可读;refactor 自文档齐全。
  • Tests (reject): ChatRunRequestNormalizer.cs:164defaultMetadata 走与 request metadata 相同的 scope-key 过滤路径,但 WorkflowCapabilityEndpointsCoverageTests.cs:219-282 只覆盖了 ChatInput.Metadata — 没有测试在 defaultMetadata 中放 scope_idWorkflowRunCommandMetadataKeys.ScopeId 并断言它既不被提升进 WorkflowChatRunRequest.ScopeId,也不被往下游转发。要求:为 Normalize(input, defaultMetadata: ...) 加行为测试,defaultMetadata 含 scope keys;断言 Request.ScopeId 仍为 null (除非显式 typed ChatInput.ScopeId)、scope metadata keys 不转发、其他无关 default metadata 仍正常合并。

下一步 (自动): fix codex round 1 已 dispatch 到本 PR HEAD 的 worktree,补 defaultMetadata scope-key 测试。

本地完整产物: .refactor-loop/runs/review-pr689-*.md, .refactor-loop/logs/v2-review-pr689-*.log

@loning loning added the auto-loop-fixing Phase 8 fix codex round in flight (AI iterating to consensus) label May 19, 2026
Applied 7 fixes (FIX_DONE:689:round-1:applied-7:rejected-0:blocked-0):
- (A) tests: add defaultMetadata scope_id/scope-key behavior test
  (addresses tests reviewer reject — was the blocking demand)
- (A) architect: add Refactor (iter15/cluster-029) old/new comments
  on NormalizedChatContext + AddNormalizedMetadataEntry
- (A) quality: delete dead WorkflowChatRunStartError.ConflictingScopeId
  enum member (no longer produced after scope conflict refactor)
- (B) quality SCOPE_EXTEND: remove dead ConflictingScopeId mappings
  from ChatRunStartErrorMapper + ScopeWorkflowEndpoints (parallel
  API outcome cleanup for the deleted enum member)
- (A) quality: revert unrelated spawn-codex.sh drift change out of
  this PR (already on auto-refact-dev where it belongs)

Build pass; targeted tests 27/27 pass; test_stability_guards pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@loning loning requested a review from eanzhao as a code owner May 19, 2026 08:26
@loning
Copy link
Copy Markdown
Contributor Author

loning commented May 19, 2026

🤖 Fix codex round 1 — FIX_DONE:689:round-1:applied-7:rejected-0:blocked-0

Pushed: cdcdac72

English

Fix codex addressed all reviewer demands in one round:

  • (A) Tests reject (the only blocker): added defaultMetadata scope-key behavior test in WorkflowCapabilityEndpointsCoverageTests.cs:285 — asserts Request.ScopeId stays null without typed ChatInput.ScopeId, scope metadata keys are filtered out, unrelated default metadata still merges.
  • (A) Architect comment: added // Refactor (iter15/cluster-029): old/new markers on NormalizedChatContext (line 22) and AddNormalizedMetadataEntry (line 182).
  • (A) Quality comment: deleted dead WorkflowChatRunStartError.ConflictingScopeId enum member (no longer produced).
  • (B SCOPE_EXTEND) Quality comment: removed dead ConflictingScopeId mappings in ChatRunStartErrorMapper.cs and ScopeWorkflowEndpoints.cs (parallel API outcome cleanup for the deleted enum).
  • (A) Quality comment: reverted unrelated spawn-codex.sh strict-mode drift out of this PR (the actual fix lives on auto-refact-dev where it belongs).

Validation: build pass; targeted tests 27/27 pass (WorkflowCapabilityEndpointsCoverageTests + ChatRunStartErrorMapperTests); test_stability_guards.sh pass. Pre-existing unrelated NyxIdApiClient DI failure in WorkflowHostingExtensionsCoverageTests is the same known issue documented in implement-cluster-029.md.

Next action (automatic): re-dispatch 3 reviewer codex (architect/tests/quality) against new HEAD cdcdac72. Round 2 verdicts coming as follow-up.

Full local artifact: .refactor-loop/runs/fix-pr689-round-1.md.


中文

fix codex 一轮处理掉了所有 reviewer 需求:

  • (A) Tests reject (唯一阻塞项): 在 WorkflowCapabilityEndpointsCoverageTests.cs:285defaultMetadata scope-key 行为测试 — 断言无 typed ChatInput.ScopeIdRequest.ScopeId 仍为 null、scope metadata keys 被过滤、无关 default metadata 仍正常合并。
  • (A) Architect comment: 在 NormalizedChatContext (line 22) 和 AddNormalizedMetadataEntry (line 182) 上补 // Refactor (iter15/cluster-029): 旧/新模式注释。
  • (A) Quality comment: 删除已废弃的 WorkflowChatRunStartError.ConflictingScopeId enum (不再被产出)。
  • (B SCOPE_EXTEND) Quality comment: 删除 ChatRunStartErrorMapper.csScopeWorkflowEndpoints.cs 中已死的 ConflictingScopeId 映射 (与上一项联动的 API 输出清理)。
  • (A) Quality comment: 把无关的 spawn-codex.sh 严格模式漂移回退出本 PR (修复本身已经在 auto-refact-dev 上,本属那里)。

验证: 构建通过; targeted 测试 27/27 通过 (WorkflowCapabilityEndpointsCoverageTests + ChatRunStartErrorMapperTests); test_stability_guards.sh 通过。WorkflowHostingExtensionsCoverageTestsNyxIdApiClient DI 的失败是已知的、与本 cluster 无关的问题,记录在 implement-cluster-029.md 里。

下一步 (自动): 重新派 3 个 reviewer codex (architect/tests/quality) 对新 HEAD cdcdac72 复评。Round 2 结论会作为后续评论 post。

本地完整产物: .refactor-loop/runs/fix-pr689-round-1.md

@loning loning added auto-loop-reviewing Phase 8 reviewer codex round in flight and removed auto-loop-fixing Phase 8 fix codex round in flight (AI iterating to consensus) labels May 19, 2026
@loning
Copy link
Copy Markdown
Contributor Author

loning commented May 19, 2026

✅ Multi-codex consensus reached (round 2) — auto-merging

Verdicts | 共识结论

Reviewer Round 1 (v2) Round 2 (v3)
Architect comment approve
Tests reject approve
Quality comment approve

Unanimous approve → auto-merge queued via gh pr merge --auto --merge. GitHub will complete merge once remaining CI checks (coverage-quality, kafka-transport-integration, console-web) settle to pass.


English

All 3 reviewer codex independently re-evaluated PR HEAD cdcdac72 after fix-codex round 1 addressed every demand:

  • tests: defaultMetadata scope-key behavior test added
  • architect: refactor old/new self-doc markers added
  • quality: dead ConflictingScopeId enum + mappings removed, unrelated spawn-codex.sh drift reverted

The cluster's net behavior: workflow scope/channel routing now uses typed proto fields (ChatInput.ScopeId) instead of metadata bag string keys; default metadata containing scope keys is filtered and not silently promoted; no semantic regression on existing metadata pass-through.

After this auto-merge, cluster-029 moves to clusters_done and the integration branch auto-refact-dev can advance.

Local artifacts: .refactor-loop/runs/v2-review/, .refactor-loop/runs/review-pr689-*.md (round 2), .refactor-loop/runs/fix-pr689-round-1.md.


中文

3 个独立 reviewer codex 在 fix-codex 处理完所有需求后,对新 HEAD cdcdac72 独立重审:

  • tests: 加上 defaultMetadata scope-key 行为测试
  • architect: 补 Refactor 旧/新自文档注释
  • quality: 删除已废弃的 ConflictingScopeId enum 与映射,把无关的 spawn-codex.sh 漂移回退

cluster 净行为: workflow scope/channel 路由改用 typed proto field (ChatInput.ScopeId),取代 metadata bag 字符串 key;default metadata 中的 scope key 被过滤,不会被静默提升;不影响其他 metadata 透传语义。

auto-merge 后 cluster-029 进入 clusters_done,integration 分支 auto-refact-dev 可继续推进。

本地产物: .refactor-loop/runs/v2-review/, .refactor-loop/runs/review-pr689-*.md (round 2), .refactor-loop/runs/fix-pr689-round-1.md

@loning loning removed the auto-loop-reviewing Phase 8 reviewer codex round in flight label May 19, 2026
@loning loning merged commit 16bcf04 into dev May 19, 2026
13 checks passed
@loning loning mentioned this pull request May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant