mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-01 11:31:51 +08:00
feat: make task global asset sharing opt-in
This commit is contained in:
1 parent
d36e1c3295
commit
080a46eb2d
25 files changed
+838
-328
No files matched your search
+21
-4
@@ -226,13 +226,12 @@ func (t *ToolSet) AddHintTool() actool.CoreTool { return t.addHint()
|
||||
func (t *ToolSet) SetEnrich(e EnrichTrigger) { t.enrich = e }
|
||||
|
||||
// SetOwnerNode sets the exploration node that writes anchor to (worker: its
|
||||
// intent node; planner/main: the begin root). Assets created/referenced while
|
||||
// ownerNode is set are anchored to it as lineage (not visibility).
|
||||
// intent node; planner/main: the begin root). Anchors preserve explicit asset
|
||||
// references and make them available in this task context.
|
||||
func (t *ToolSet) SetOwnerNode(id int64) { t.ownerNode = id }
|
||||
|
||||
// anchorOwner records a lineage edge from this run's owner node to an asset
|
||||
// (no-op if unset). Provenance only — the asset graph is global and shared, so
|
||||
// this no longer affects which assets a task can read.
|
||||
// (no-op if unset). These explicit references also contribute to task visibility.
|
||||
func (t *ToolSet) anchorOwner(assetID int64) {
|
||||
if t.ts != nil && t.ownerNode > 0 && assetID > 0 {
|
||||
_ = t.ts.Anchor(t.ownerNode, assetID)
|
||||
@@ -1054,6 +1053,24 @@ func (t *ToolSet) addOneIntent(it intentItem) (int64, error) {
|
||||
priority = 5
|
||||
}
|
||||
anchors := pidList(it.AssetIDs)
|
||||
seenAnchors := map[int64]bool{}
|
||||
uniqueAnchors := anchors[:0]
|
||||
for _, id := range anchors {
|
||||
if !seenAnchors[id] {
|
||||
seenAnchors[id] = true
|
||||
uniqueAnchors = append(uniqueAnchors, id)
|
||||
}
|
||||
}
|
||||
anchors = uniqueAnchors
|
||||
if t.as != nil && t.taskID > 0 && len(anchors) > 0 {
|
||||
visible, err := t.as.GetByIDsInScope(t.taskID, anchors)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("资产可见范围校验失败:%w", err)
|
||||
}
|
||||
if len(visible) != len(anchors) {
|
||||
return 0, fmt.Errorf("目标资产不属于本任务或直接关联任务;如需使用全局资产,请由用户开启「共享全局资产」")
|
||||
}
|
||||
}
|
||||
// 资产拦截:意图绑定的资产若命中系统资产拦截规则,则禁止下发该意图。
|
||||
if t.as != nil && len(anchors) > 0 {
|
||||
hits, err := t.as.CheckAssetsIntercept(t.taskID, anchors)
|
||||
|
||||
Reference in new issue
Block a user