Files
ARTEX/agent/constraints.go
BaaRai e233c02314 Translate all Chinese text to English
Comments, doc comments, UI labels, log and error messages, LLM prompt
strings, markdown docs, test data and assertions. Identifiers, enum
keys, routes, placeholders and code structure are unchanged.

Notes:
- docs/漏洞流量证据.md renamed to docs/vulnerability-traffic-evidence.md
- tests that exercised CJK specific handling (GBK zip names, Chinese
  full text search) now use ASCII equivalents; go build passes and the
  test suite matches the pre translation baseline (remaining failures
  need a PostgreSQL DSN and fail identically on the original)
- frontend mention syntax now uses English kinds (finding, asset, ...)
  matching the backend, chat mentions tests pass
2026-10-08 23:14:34 +02:00

50 lines
1.7 KiB
Go

package agent
import (
"strings"
"github.com/Autumn-27/artex/db"
)
// constraintBlock renders this task's operation constraints (task_constraints) as a
// high-priority block appended to the planner/worker system prompt. allow/deny are
// grouped; empty string when there are no constraints (or ts is nil). The framing
// deliberately puts these ABOVE the exploration/expansion heuristics so a declared
// boundary wins the tug-of-war against "chase another entry surface".
func constraintBlock(ts *db.ExplorationStore) string {
if ts == nil {
return ""
}
rows, err := ts.ListConstraints()
if err != nil || len(rows) == 0 {
return ""
}
var allow, deny []string
for _, c := range rows {
text := strings.TrimSpace(c.Text)
if text == "" {
continue
}
if c.Kind == "allow" {
allow = append(allow, "- "+text)
} else {
deny = append(deny, "- "+text)
}
}
if len(allow) == 0 && len(deny) == 0 {
return ""
}
var b strings.Builder
b.WriteString("\n\n[Operation constraints (highest priority, above every exploration/expansion heuristic below; before generating any intent or executing any action you must first self-check for violations — if it violates a constraint, do not proceed)]:")
if len(allow) > 0 {
b.WriteString("\nAllowed operations:\n")
b.WriteString(strings.Join(allow, "\n"))
}
if len(deny) > 0 {
b.WriteString("\nForbidden operations:\n")
b.WriteString(strings.Join(deny, "\n"))
}
b.WriteString("\n(Discovering a new target/port/host outside the constraints does not grant authorization: unless it falls within the allowed range above, record it as an out-of-scope fact and skip it — do not spawn intents or execute actions for it.)")
return b.String()
}