From 1e3536f571d8df07a6069d05f59dcf450dd84f4b Mon Sep 17 00:00:00 2001 From: wangdefa <1+wangdefa@noreply.gitea.bcde.io> Date: Tue, 20 Oct 2026 23:16:31 -0700 Subject: [PATCH] =?UTF-8?q?test:=20=E5=AF=B9=E9=BD=90=20coverage.scope=20?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E3=80=81=E6=B5=8B=E8=AF=95=E6=94=B9=E5=90=8D?= =?UTF-8?q?=EF=BC=8C=E5=88=A0=E6=8E=89=20CI=20-skip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 06a43f3 已有意删除 coverage.scope(范围根资产+company 富化)以精简规划上 下文,但该测试仍断言此字段。去掉相关断言、改名为 TestAssociatedCompany AssetsEnterTaskContext(仍校验公司资产进入任务上下文),并移除 CI 里的 -skip。 --- .gitea/workflows/ci.yml | 4 +--- agent/blackboard_inheritance_test.go | 31 ++++++++-------------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 32f5214..cda1bf2 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -116,10 +116,8 @@ jobs: - name: 测试 run: | # -p 1:各包共用一个库,串行执行避免跨包数据竞争。 - # -skip:TestGraphOverviewExpandsAssociatedCompanyScope 在当前代码上 - # 已失败(coverage["scope"] 为 nil),与本流程无关,修好后请删掉。 run_tests() { - go test -p 1 ./... -count=1 -skip 'TestGraphOverviewExpandsAssociatedCompanyScope' + go test -p 1 ./... -count=1 } # 已知偶发:server 包的后台 worker 会在测试结束后继续写 t.TempDir(), # 触发 "TempDir RemoveAll cleanup: directory not empty"。根因是 diff --git a/agent/blackboard_inheritance_test.go b/agent/blackboard_inheritance_test.go index 9f55359..aadb98d 100644 --- a/agent/blackboard_inheritance_test.go +++ b/agent/blackboard_inheritance_test.go @@ -25,7 +25,15 @@ func callReadJSON(t *testing.T, tool actool.CoreTool, input string) any { return out } -func TestGraphOverviewExpandsAssociatedCompanyScope(t *testing.T) { +// TestAssociatedCompanyAssetsEnterTaskContext verifies that an asset attributed +// to a task's company surfaces in the agent's task context: it is linked to the +// task with company provenance, counted in coverage.host_count, and reachable via +// list_untested_assets / list_assets and as an intent target — with or without the +// coverage feature. It no longer asserts coverage.scope: that overview field (scope +// root assets + company enrichment) was intentionally dropped in 06a43f3 to slim the +// per-round planner context; the association itself still holds through the checks +// below. +func TestAssociatedCompanyAssetsEnterTaskContext(t *testing.T) { d := testDB(t) defer d.Close() @@ -82,27 +90,6 @@ func TestGraphOverviewExpandsAssociatedCompanyScope(t *testing.T) { if !ok { t.Fatalf("coverage missing: %#v", overview["coverage"]) } - scopeRows, ok := coverage["scope"].([]map[string]any) - if !ok || len(scopeRows) != 1 { - t.Fatalf("task scope missing: %#v", coverage["scope"]) - } - companyScope, ok := scopeRows[0]["company_scope"].([]map[string]any) - if !ok || len(companyScope) != len(inputs) { - t.Fatalf("company scope not expanded: %#v", scopeRows[0]) - } - kinds := make(map[string]string, len(companyScope)) - for _, rule := range companyScope { - kinds[fmt.Sprint(rule["kind"])] = fmt.Sprint(rule["value"]) - } - for _, input := range inputs { - if kinds[input.Kind] != input.Value { - t.Errorf("scope %s=%q want %q", input.Kind, kinds[input.Kind], input.Value) - } - } - keywords, ok := scopeRows[0]["company_keywords"].([]string) - if !ok || len(keywords) != 1 || keywords[0] != keyword { - t.Fatalf("company keywords missing: %#v", scopeRows[0]["company_keywords"]) - } if hc, _ := coverage["host_count"].(int); hc < 1 { t.Fatalf("company asset host not counted in agent context: %#v", coverage["host_count"]) }