Skip to content

fix: ground task workers in the assigned project and preserve terminal plan state - #1562

Closed
santoshkumarradha wants to merge 8 commits into
devfrom
fix/manager-task-ground-and-plandb-store
Closed

santoshkumarradha wants to merge 8 commits into
devfrom
fix/manager-task-ground-and-plandb-store

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Real terminal workflow evidence

Goal and result: starting chat from home, build and actually use a maintenance CLI in a named project. Natural follow-ups add in-progress chores, JSON output and exact-title completion. The task worker/checker used the assigned project copy; the finished CLI persists the completed dryer chore and correctly shows the two remaining chores. 25 tests pass; all five local PlanDB tasks are done; 87/87 completed calls used OpenRouter deepseek/deepseek-v4.1-flash.

Actual chat showing the maintenance CLI used from home

Watch the clean live follow-up MP4 · Completed-result GIF

Tested at combined 41cf9cd0f, including #1562/#1603/#1604 and #1610. Original individual-head grounding evidence and CI are separate below. The clean video shows the final home-directory use; the source cast contains the full build/correction/task/landing-recovery sequence. The retained task branch required a natural follow-up to integrate earlier uncommitted changes; the files were manually copied and committed, then the task branch deleted; the retained-copy hint remains because this was not a successful engine landing receipt. An unnecessary cache deletion was denied in the actual approval UI before read-only use succeeded.


Fixes #1561.

A task started from a home-directory conversation could still run outside its project: the default bash run door bypassed the ground resolver entirely. It now uses the same resolver as proposed and legacy tasks, including a repository named in the brief or configured project fallback. Children retain their parent folder. Every plan worker and checker receives its actual assigned working directory before the work order, while the original request and unrelated reference paths remain unchanged.

Bash guidance now uses project-scoped discovery and plandb --help for missing plan documentation. A late completion of a cancelled task reports its terminal state before ownership or review validation, preserves the stored result, and retains the existing composite-placeholder completion behavior. The manual and change entry describe the resulting behavior.

Validation:

  • Starting a conversation from home: named project resolved to an isolated worktree, relative design document read, missing document handled within the project, expected RESULT.txt committed, and worker/reviewer completed in 14.671 seconds. The UI showed done, one file, branch kept (the fixture used protected main). All 8 recorded calls, including auxiliary roles, used OpenRouter deepseek/deepseek-v4.1-flash. No outside-copy write was attempted after the assigned-directory change.
  • Regression coverage includes the default run door, configured fallback, child folder preservation, actual worktree document availability, verbatim reference preservation, runtime worker briefing, cancellation/ownership, and the 16 KiB system-prompt budget. The actual built PlanDB CLI also rejects cancelled-task completion with the terminal-state message.
  • Final make test-quick passed, and fresh e2e, plandb, and run package suites passed. An initial full session run exposed existing fixture races and a heartbeat compiler timeout (also reproduced on original PR revision f6aca9b); cleanup now waits for full run closure and heartbeat checks use a deterministic failure→repair fixture. All four initially failing tests passed 10 repetitions in 21.825 seconds.
  • Exact-head CI on 1fe960214 passed all required checks, including the full touched-package suite. The redundant final local run was stopped after CI passed; it is not counted as a local full-suite pass.

Live verification changed task.max_load only inside its disposable profile because shared-host load otherwise held the task before any model call. Personal configuration and credentials were not published.

Review media below are direct PR attachments. Repository-hosted evidence links have been removed. Exact revisions, validation results and limitations remain in this description; original source recordings and generated examples are retained locally.

final-screen

final-screen

…earch guidance

In Store.Done(), check if task is already terminal before checking requireOwner().
When a task is cancelled upstream, ClaimedBy is cleared or empty, which previously
caused Done to fail obscurely with 'task is not claimed'. Checking terminal status
first reports an explicit and actionable error: 'task is already terminal (cancelled)'.

Also update bashworker prompt guidance to prune heavy directories when running find,
preventing workers from freezing across deep trees.

Fixes #1561

Assisted-by: CodeAF (gemini-3.8-flash-high)
Co-Authored-By: CodeAF <267109073+agentfield-bot@users.noreply.github.com>
@santoshkumarradha santoshkumarradha added this to the Reliable agent milestone Sep 27, 2026
@santoshkumarradha santoshkumarradha added bug Something the code does that it should not area:session The engine — turns, tasks, the toolbelt, checkpoints labels Sep 27, 2026
agentfield-bot and others added 3 commits September 26, 2026 22:38
…epository

When a session operates with workspace outside a repository (e.g. user home
folder ~ in a team manager session), task ground derivation would fall through
to taskGroundNothing at dir: ~, leading spawned tasks to inherit ~ as ground.
Workers looking for repository docs like docs/design/plandb-cli/ would then
fail to locate them and launch unpruned find commands across the entire home drive.

Fall back to a.config.Place.Workspace when workspace has no repository root,
preserving taskGroundStandingIn on the intended project repository.

Fixes #1561

Assisted-by: CodeAF (gemini-3.8-flash-high)
Co-Authored-By: CodeAF <267109073+agentfield-bot@users.noreply.github.com>
Assisted-by: CodeAF (gemini-3.8-flash-high)
Co-Authored-By: CodeAF <267109073+agentfield-bot@users.noreply.github.com>
Assisted-by: CodeAF (gemini-3.8-flash-high)
Co-Authored-By: CodeAF <267109073+agentfield-bot@users.noreply.github.com>
@santoshkumarradha

Copy link
Copy Markdown
Member Author

Two-Pass Quality Review

Pass 1: Defects & Contracts

  • Terminal Status vs. Composite Placeholder Contract: In internal/plandb/store.go, terminal(task.Status) is verified inside if !placeholder. This ensures that auto-completed placeholder parents can still be claimed/adopted by their landing worker, while cancelled or terminal tasks immediately fail with an explicit reason (task <id> is already terminal (<status>)) rather than a misleading task is not claimed error.
  • Ground Hierarchy Preservation: In internal/session/taskstands.go, fallback from workspace to Place.Workspace occurs only when workspace has no git repository root and differs from Place.Workspace. If the user is standing inside any valid git repository, that repository takes precedence as designed.
  • Unit Test Coverage: Both bug conditions are tested with dedicated unit tests (internal/plandb/done_terminal_test.go and internal/session/taskstands_test.go).

Pass 2: Architecture & Clean Code

  • Scope & Footprint: Changes are surgical and minimal (53 lines across 5 files including tests and changelog). No unnecessary abstractions or extra dependencies introduced.
  • Changelog: Verified via make changelog-check with valid entry in docs/changes/unreleased/1562-plandb-done-terminal-and-manager-ground.md.
  • CI Gate: 100% green across all checks (check, license/cla, light gate, touched packages).

—
Drafted with CodeAF · reviewed and owned by the author

@santoshkumarradha
santoshkumarradha marked this pull request as ready for review September 27, 2026 02:55
@santoshkumarradha

Copy link
Copy Markdown
Member Author

@AbirAbbas this is review ready

@santoshkumarradha santoshkumarradha changed the title fix(plandb): check terminal status before ownership in Done, prune search guidance (#1561) fix: ground task workers in the assigned project and preserve terminal plan state Sep 27, 2026
@santoshkumarradha

Copy link
Copy Markdown
Member Author

Superseded by aggregate PR #1627: #1627 . The exact reviewed green head is verified as an ancestor of published Santosh/dev; its issue details, validation, direct GitHub media attachments and limitations are preserved in the aggregate. Closing this source PR under the approved batch-1 workflow. Source branch retained; no merge into dev/main is implied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:session The engine — turns, tasks, the toolbelt, checkpoints bug Something the code does that it should not

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session: worker tasks in team chats inherit manager cwd ~ and unpruned find freezes on missing plandb doc

2 participants