refactor(graph_overview): 概览各列表加数量上限,止住上下文膨胀
用"最新一窗 + 计数/pull 兜底"替换 hot/cold 拆分与 balancedCap: - recent_facts 20、recent_done_intents 12、open_intents 30(按 priority) - cold_digests 15,按最新成员时间(max member id)降序,溢出的更旧 digest 只给裸 id(cold_digests_more),仍可 expand_digest 展开 - 新增 CountOpenIntents,frontier_open 报开放意图真实总数(与截断视图解耦) - 删除 balancedCap/unfoldedCap/unfolded_truncated 及其测试 掉出窗口的节点不丢:facts/done_intents_total/frontier_open/findings_total 计数在,list_facts/list_findings/node_detail/expand_digest 可按需回捞
This commit is contained in:
1 parent
43d1743dc0
commit
3aac6754a8
4 files changed
+93
-99
No files matched your search
@@ -10,6 +10,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/Autumn-27/artex/db"
|
||||
actool "github.com/Autumn-27/norma/tool"
|
||||
@@ -54,6 +55,50 @@ func activeDigestBodies(store *db.ExplorationStore) []map[string]any {
|
||||
return out
|
||||
}
|
||||
|
||||
// coldDigestsRecent returns the current task's active digests as flat bodies for
|
||||
// graph_overview, ordered by the recency of their freshest member (max member id ≈
|
||||
// latest cooled node — a digest near the live frontier is likelier relevant), and
|
||||
// capped at `cap`. Overflow digest ids are returned separately (moreIDs) so they
|
||||
// stay reachable via expand_digest even when not shown inline — cold_digests is the
|
||||
// only exit for folded cold nodes.
|
||||
func (t *ToolSet) coldDigestsRecent(cap int) (shown []map[string]any, moreIDs []int64) {
|
||||
ads, err := t.ts.ActiveDigests()
|
||||
if err != nil || len(ads) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
type dg struct {
|
||||
id int64
|
||||
entry map[string]any
|
||||
freshness int64 // max member id (ids are monotonic ≈ creation time)
|
||||
}
|
||||
items := make([]dg, 0, len(ads))
|
||||
for _, d := range ads {
|
||||
var p struct {
|
||||
Body string `json:"body"`
|
||||
}
|
||||
_ = json.Unmarshal(d.Payload, &p)
|
||||
ms, _ := t.ts.DigestMembers(d.ID) // sorted asc → last = freshest
|
||||
var fresh int64
|
||||
if len(ms) > 0 {
|
||||
fresh = ms[len(ms)-1]
|
||||
}
|
||||
items = append(items, dg{
|
||||
id: d.ID,
|
||||
entry: map[string]any{"id": d.ID, "body": p.Body, "member_count": len(ms)},
|
||||
freshness: fresh,
|
||||
})
|
||||
}
|
||||
sort.Slice(items, func(i, j int) bool { return items[i].freshness > items[j].freshness })
|
||||
for i, it := range items {
|
||||
if i < cap {
|
||||
shown = append(shown, it.entry)
|
||||
} else {
|
||||
moreIDs = append(moreIDs, it.id)
|
||||
}
|
||||
}
|
||||
return shown, moreIDs
|
||||
}
|
||||
|
||||
// hiddenMembersFor returns a predicate telling whether a member is hidden (folded
|
||||
// into an active digest AND still cold) in the given store — so a source task's
|
||||
// overview folds exactly the way that task folds itself (§2 cross-task: "当前任务
|
||||
|
||||
Reference in new issue
Block a user