ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)
Go aiai-agentsautonomous-agentsbug-bountydockergolanglinuxllmmcpnextjspenetration-testingpentestpostgresqlreareactred-teamsecuritysecurity-automationsqlitetypescript
feat(planner): done 触发块列出本意图新产生的 fact id
Autumn-27083defc8c036
diff --git a/agent/planner.go b/agent/planner.goindex ccfcc2e..91b6d1c 100644--- a/agent/planner.go+++ b/agent/planner.go@@ -178,12 +178,30 @@ func renderTriggers(ts *db.ExplorationStore, evs []TriggerEvent) string {b.WriteString(fmt.Sprintf("\n- 意图 #%d 由用户删除,意图内容是:%s、删除原因是:%s。该意图已停止(不再执行),其原因已作为事实挂在该意图上;请据此重新规划。", ev.IntentID, intentSummary(ts, ev.IntentID), ev.Detail))default: // "done"b.WriteString(fmt.Sprintf("\n- 意图 #%d(%s)的 worker 结束,输出结论:%s", ev.IntentID, intentSummary(ts, ev.IntentID), workerOutput(ts, ev.IntentID)))+ if fids := factIDsYielded(ts, ev.IntentID); fids != "" {+ b.WriteString(fmt.Sprintf(";本意图新产生的事实 id:%s ", fids))+ }}}b.WriteString("\n(完整细节可 node_detail / get_worker_output / list_findings 再查。)")return b.String()}+// factIDsYielded lists the fact ids an intent produced this run as "#12、#15", so the+// planner can jump straight to the round's incremental facts. Empty (best-effort) when+// the intent yielded no facts or the lookup fails.+func factIDsYielded(ts *db.ExplorationStore, id int64) string {+ ids, err := ts.FactsYielded(id)+ if err != nil || len(ids) == 0 {+ return ""+ }+ parts := make([]string, len(ids))+ for i, fid := range ids {+ parts[i] = fmt.Sprintf("#%d", fid)+ }+ return strings.Join(parts, "、")+}+// intentSummary reads an intent node's one-line summary (best-effort, "?" on miss).func intentSummary(ts *db.ExplorationStore, id int64) string {n, err := ts.GetNode(id)@@ -381,7 +399,7 @@ func (p *Planner) Plan(ctx context.Context, taskID int64, as *db.AssetStore, ts// clamped(被任务 deadline 夹逼)时改用 PromptByReason(见 wrapupSettlementForTask)。Settlement: settle,NonStreaming: p.nonStreaming(), // 该 profile 选非流式时走 Provider.Complete- MaxTokens: p.maxTokens(), // 0 = 不发上限,由服务端默认值决定+ MaxTokens: p.maxTokens(), // 0 = 不发上限,由服务端默认值决定}if p.tx != nil { // persist raw LLM conversation; one accumulating file per task's planneropts.Transcript = p.txdiff --git a/db/exploration.go b/db/exploration.goindex a4260c2..c90a290 100644--- a/db/exploration.go+++ b/db/exploration.go@@ -768,6 +768,31 @@ func (s *ExplorationStore) Edges(limit int) ([]Edge, error) {return out, rows.Err()}+// FactsYielded returns the ids of fact nodes an intent produced (intent --yields-->+// fact), oldest first. Used to spell out the round's incremental facts to the planner+// alongside the finished worker's output. Best-effort: returns nil for an intent with+// no facts (or a missing one).+func (s *ExplorationStore) FactsYielded(intentID int64) ([]int64, error) {+ rows, err := s.db.Query(`SELECT n.id+ FROM exploration_edges e+ JOIN exploration_nodes n ON n.id=e.dst_id AND n.exploration_id=e.exploration_id+ WHERE e.exploration_id=$1 AND e.src_id=$2 AND e.rel=$3 AND n.kind=$4+ ORDER BY n.id`, s.expID, intentID, RelYields, KindFact)+ if err != nil {+ return nil, err+ }+ defer rows.Close()+ var ids []int64+ for rows.Next() {+ var id int64+ if err := rows.Scan(&id); err != nil {+ return nil, err+ }+ ids = append(ids, id)+ }+ return ids, rows.Err()+}+// FindingLineage returns the sub-DAG that leads FROM the exploration root TO the// given node: the node itself plus all its ancestors (nodes reverse-reachable by// following edges backward), and every edge whose both endpoints are in that set.