fix(worker): 写回计数按事实/资产/漏洞分开统计
原先 record_fact/insert_assets/report_finding 共用一个 wrote 计数器,
日志却统一打印成"写回 N 条事实",把资产、漏洞也算进"事实"里,容易误导
(如枚举意图插入 25 个资产 + 1 条 fact 会显示"写回 26 条事实")。
改为 WriteCounts{Facts,Assets,Findings} 分类计数,日志打印
"写回 事实1 资产25 漏洞0",Total() 保留"是否落库任何东西"的判定。
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
1 parent
2c3ca4b194
commit
abc551cc76
4 files changed
+36
-15
No files matched your search
+5
-4
@@ -193,9 +193,10 @@ func renderWorkerGraphOverview(data map[string]any) string {
|
||||
// Execute runs one intent. hooks (the per-task Guard) gates every tool call; may
|
||||
// be nil. emit, if non-nil, receives one ActivityRecord per execution step.
|
||||
// Returns the terminal reason (so the engine can distinguish completed vs
|
||||
// max_turns) and how many facts were written back (so an intent that explored but
|
||||
// persisted nothing isn't mistaken for done).
|
||||
func (w *Worker) Execute(ctx context.Context, name string, taskID int64, as *db.AssetStore, ts *db.ExplorationStore, intent *db.Node, hooks harness.HookRunner, emit func(db.Activity), enr EnrichTrigger) (harness.TerminalReason, int, error) {
|
||||
// max_turns) and a per-kind breakdown of what was written back (so an intent that
|
||||
// explored but persisted nothing isn't mistaken for done, and the engine can log
|
||||
// facts/assets/findings separately instead of lumping them under "facts").
|
||||
func (w *Worker) Execute(ctx context.Context, name string, taskID int64, as *db.AssetStore, ts *db.ExplorationStore, intent *db.Node, hooks harness.HookRunner, emit func(db.Activity), enr EnrichTrigger) (harness.TerminalReason, WriteCounts, error) {
|
||||
tsx := NewToolSet(ts, name)
|
||||
tsx.SetTaskID(taskID)
|
||||
if as != nil {
|
||||
@@ -298,5 +299,5 @@ func (w *Worker) Execute(ctx context.Context, name string, taskID int64, as *db.
|
||||
defer runCancel()
|
||||
}
|
||||
_, reason, err := captureRunSession(runCtx, s, input, emitWrap)
|
||||
return reason, tsx.Wrote(), err
|
||||
return reason, tsx.Writes(), err
|
||||
}
|
||||
Reference in new issue
Block a user