Skip to content

fix(goal): harden contextual tool and migration boundaries / Goal/context 工具与迁移边界完整修复 - #8007

Merged
SivanCola merged 3 commits into
esengine:main-v2from
SivanCola:fix/goal-context-execution-boundary
Aug 9, 2026
Merged

fix(goal): harden contextual tool and migration boundaries / Goal/context 工具与迁移边界完整修复#8007
SivanCola merged 3 commits into
esengine:main-v2from
SivanCola:fix/goal-context-execution-boundary

Conversation

@SivanCola

@SivanCola SivanCola commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up hardening for #7959 after Goal/context-tool boundary review.

@bfxh identified the original issue.

Problem

Context-dependent tools could be called from stale transcripts or the wrong workflow phase. Mixed tool batches could repeat valid work after one unavailable contextual call, child agents could inherit parent Goal/Jobs/live-memory state, and failed legacy AutoResearch migration could lose its retry identity after restart.

Fix

  • Centralize execution-time availability in the internal ContextualTool contract while keeping provider schemas static for cache stability.
  • Gate contextual tools before permissions, hooks, leases, and execution; pair mixed batches, execute valid calls once, and stop after one repair.
  • Isolate child Goal recorders, Jobs managers, and memory queues, while allowing explicitly child-owned memory queues.
  • Use effective contextual schemas for agent metadata and persistent child identity.
  • Retain pending autoResearchTaskID with researchMode=On while legacy archives are blocked; validate and read archives without mutation, retry on restart or /goal resume, and clear compatibility fields only after the Goal-only sidecar is durably written.
  • Update the Unreleased changelog.

Compatibility

Existing sidecars with Goal text migrate without reading an archive. Sidecars awaiting archive migration remain fail-closed and retryable across restarts. New Goal-only writes use budgetClass as the budget authority and researchMode=Off as the downgrade fence, so older readers do not reactivate AutoResearch after a successful migration.

Verification

  • go test ./... -count=1
  • cd desktop && go test ./... -count=1
  • go test -race ./internal/control ./internal/agent ./internal/tool ./internal/tool/builtin ./internal/jobs ./internal/memory -count=1
  • go vet ./...
  • golangci-lint run --timeout=5m
  • go run ./tools/repolint
  • scripts/cache-guard.sh
  • scripts/check-cache-impact.sh
  • scripts/check-docs-impact.sh
  • git diff --check

Repolint-baseline: updated only the aggregate complexity budget and the affected contextual-boundary files; unrelated baseline drift was left unchanged.
Documentation-impact: none - CHANGELOG.md is the release ledger; no docs/*.md contract changed.
Cache-impact: none - provider-visible tool schemas remain static; contextual projections are used only by host execution and metadata.
Cache-guard: go test -race ./internal/control ./internal/agent ./internal/tool ./internal/tool/builtin ./internal/jobs ./internal/memory; scripts/cache-guard.sh
System-prompt-review: reviewed against the cache-first contract; no system prompt bytes changed.

Problem:
Context-dependent tools could be called outside their owning Goal, Plan, Jobs, or child-agent context, and failed legacy AutoResearch migration lost its retry identity after restart.

Root cause:
Availability was enforced by scattered execution checks while provider-visible registration, host metadata, mixed batches, and inherited child context used different state. The Goal sidecar writer also fenced every new write without preserving a pending legacy task id.

Fix:
Add a shared ContextualTool execution contract with one-repair run-loop handling, isolate child Goal/Jobs/memory state, project contextual schemas only for host metadata, and retain pending legacy task ids until a Goal-only sidecar is durably committed.

Verification:
go test ./... -count=1
cd desktop && go test ./... -count=1
go test -race ./internal/control ./internal/agent ./internal/tool ./internal/tool/builtin ./internal/jobs ./internal/memory -count=1
go vet ./...
golangci-lint run --timeout=5m
scripts/cache-guard.sh
git diff --check
@SivanCola
SivanCola requested a review from esengine as a code owner August 9, 2026 01:12
@github-actions github-actions Bot added skills Skill system (internal/skill, internal/tool) agent Core agent loop (internal/agent, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development labels Aug 9, 2026
Problem:
The repository lint baseline rejected the intentional size and complexity increase from the contextual execution gate, mixed-batch repair handling, child context isolation, and retryable Goal migration state.

Root cause:
The new owner-level safeguards add measured branches and lines to existing shared files, so the current baseline was lower than the post-fix repository metrics.

Fix:
Update only the affected file budgets and the aggregate complexity budget; unrelated baseline drift is left unchanged.

Verification:
go run ./tools/repolint
git diff --check
Problem:
The pull request was based on an older main-v2 and became conflicting after session recovery changes landed.

Root cause:
The base evolved shared agent, controller, desktop, and lint-baseline files after this branch was created.

Fix:
Merge the latest main-v2 into the contextual-boundary fix, resolve the repolint baseline semantically, and retain both session recovery and Goal/context isolation changes.

Verification:
Repolint baseline was regenerated from the merged tree; focused and full checks will run against the pushed merge head.
@SivanCola
SivanCola merged commit 209a467 into esengine:main-v2 Aug 9, 2026
22 checks passed
esengine added a commit that referenced this pull request Aug 9, 2026
Baseline: main-v2 entries kept, this branch's three memory entries
re-applied (store.go 83, store_v2 17/17), totals adjusted by those
deltas on top of main-v2's #8007 baselined growth.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) skills Skill system (internal/skill, internal/tool) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant