Repository navigation
feat(guard): planner and main-agent hooks, target-gate scope in every session (S3b 1.1) - #177
Merged
Merged
Conversation
… session (S3b 1.1) Step 1.1 of the S3b phase 1 plan. Wiring only: the approval gate for asset targets is not enforced yet and no behaviour changes. - Planner.Plan and MainAgent.Chat take a hooks parameter, like Worker.Execute. Their sessions had no hooks, so nothing saw their tool calls before execution. - guard.NewTargetOnly: the guard for those two agent kinds. It runs the target-gate seam only: no intercept rule, no fallback judge, and no entry in the audit ring (Guard.record is untouched and not called for these calls). - Task.TargetGuard, built beside Task.Guard. - intercept.WithTargetScope / TargetScopeFromContext: task id or conversation id, an Enabled func and a wait bound, set at the five session entry points (planner round, final planner round with wait bound 0, main-agent turn, worker intent, conversation turn). The seam allows every call and reads and writes nothing. No task or conversation has an opt-in flag yet, so Enabled is nil (off) everywhere.
This was referenced Nov 10, 2026
feat(intercept): target extraction, resolver, exemptions and the gate in the hook (S3b 1.5-1.7)
#179
Merged
Merged
usinfosec
pushed a commit
to usinfosec/ARTEX
that referenced
this pull request
Nov 17, 2026
- 后端 traffic.Page 改为 PageQuery:新增响应内容(FTS)、路径(url_template)、 状态码(精确/Nxx 分桶)、响应长度范围筛选,并支持按 ts/status/resp_len 排序 (尾随 id DESC 保证分页稳定);补 status/resp_len 两个索引(IF NOT EXISTS,旧库自动生效) - server getTraffic 解析 body/path/status/resp_min/resp_max/sort/order 参数 - 前端流量页新增高级筛选行(响应内容/路径/状态码/长度范围)与可排序表头, 排序偏好持久化到 localStorage;抽出公共组件 ui/sortable-head - 仅改动前端页走的 Page,不动 Agent 工具的 query 契约
usinfosec
pushed a commit
to usinfosec/ARTEX
that referenced
this pull request
Nov 17, 2026
…er-sort feat(traffic): 流量列表支持内容检索、路径/状态码/长度筛选与列排序 (BaaRai#177)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 1.1 of the S3b phase 1 plan (approval gate for asset targets): hooks on the planner and the main agent, and a target-gate scope in every session. Wiring only. The gate itself (schema, opt-in flag, requests, extraction, resolver, enforcement) is in later steps and not in this PR.
What changes
(*Planner).Planand(*MainAgent).Chattake ahooks harness.HookRunnerparameter, with the same position and typed-nil guard as(*Worker).Execute. Until now their sessions set no hooks, so nothing saw their tool calls before execution.guard.NewTargetOnly(ic). The guard for those two agent kinds. ItsapplyInterceptruns the target-gate seam and nothing else: no intercept rule, no fallback judge.Task.TargetGuard, built besideTask.GuardintaskFromPG, passed to the planner (regular and final round) and to the main agent.intercept.WithTargetScope/TargetScopeFromContext. The scope is a task id or a conversation id, anEnabled func() booland a wait bound. It is set at the five session entry points: planner round, final planner round (wait bound 0), main-agent turn, worker intent, conversation turn (chat and retester share it).intercept.WithTaskContext(agent namesplannerandmainagent, with an emit that stamps the lane), as the worker context already has.Behaviour
None changes, for any task or conversation:
Guard.targetGate) allows every call unconditionally. It extracts nothing, resolves nothing, and reads and writes nothing.TargetScope.Enabledis nil (off) at every call site.PreToolUsehandler that returns the empty result: no block, no input rewrite. There is noPostToolUse,Stopor prompt handler on it.Interceptor.LogandInterceptor.HandleAsk, which the target-only guard never calls.Guard.record
Guard.recordis not touched, and the target-only guard stays out of it: planner and main-agent calls are not written to any audit ring. The 2000-entry ring ofTask.Guardkeeps holding worker calls only, andGET /api/audit(which readsTask.Guard) returns what it returned before. The target-only guard also registers noPostToolUsehandler, so the failure-attribution counters stay worker-only.Where this differs from the plan text
TargetScopeFromContext(the plan names ittargetScopeFromCtx). The tests the plan lists for this step inagentandserverhave to read the scope from another package.TestChatToolCallReachesHooks: the plan describes recording hooks that block.ChatAgenttakes a*guard.Guard(SetGuard), not a hook runner, so the test uses the guard's audit ring as the recorder and a read-onlyLScall instead of a blocked command.ChatAgentitself is unchanged.intercept.DefaultTargetWaitBoundis 300 s, the default the plan recommends in D6. Nothing reads it yet; the final planner round passes 0.Tests
guard:TestTargetOnlyGuardSkipsRules. The target-only guard runs on an interceptor with no database, so any store access would panic; a control shows the full guard does reach the store. No block, no rewritten input, no audit entry, no attribution count.agent:TestPlannerToolCallReachesHooks,TestMainAgentToolCallReachesHooks,TestWorkerToolCallReachesHooks(PostgreSQL, real entry points, scripted provider, blocking recording hooks: the hook sees the call on a context carrying the task scope and the command does not run),TestChatToolCallReachesHooks(no database).server:TestSteerHooksForwardInnerBlock(no database),TestEveryAgentKindCarriesTargetScope(PostgreSQL, table over the five entry points: each session carries its task or conversation scope with the gate off, and the planner and main-agent tool calls land onTask.TargetGuardwhile the worker's land onTask.Guard),TestFinalPlannerRoundHasZeroWait,TestTargetGateSeamAllowsWithoutDBWrite(throughTask.TargetGuarda call that a deny rule blocks and logs onTask.Guardis allowed, with nointercept_pendingrow and no audit entry).Local run (Go 1.26.7, PostgreSQL 16.15, freshly created databases):
go build ./...andgo vet ./...clean;go test -p 1 ./...passes in every package;go test -race -p 1on the CI package list passes.