Skip to content

refactor: enforce one task contract per turn#30

Merged
2002yy merged 10 commits into
mainfrom
agent/single-task-contract
Jul 14, 2026
Merged

refactor: enforce one task contract per turn#30
2002yy merged 10 commits into
mainfrom
agent/single-task-contract

Conversation

@2002yy

@2002yy 2002yy commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Scope

Seal TaskContract as one immutable per-turn decision before G10-C2.4.

  • classify a new turn once from persisted learning state and optional explicit override
  • reuse the original persisted contract for continuations and retries
  • pass the same contract through routing, external-data policy, pedagogy evaluation, pedagogy planning, route snapshots, and pedagogy snapshots
  • accept an explicit task_intent override through the chat API
  • remove frontend re-interpretation of the persisted contract from learning_state
  • retain backward-compatible fallback classification for direct legacy calls outside the production preparation path
  • update the unique project status source and move the next code slice to G10-C2.4

Root cause

The production flow previously classified task intent independently in routing, pedagogy evaluation, and pedagogy planning. The frontend then performed a fourth inference from the returned learning state. These classifiers used different active-learning signals, so one turn could have conflicting task semantics.

Invariants

  • new turn: explicit override > explicit text markers > active-learning inheritance > safe quick-answer default
  • continuation/retry: persisted parent contract wins; request text or a new override cannot mutate the original turn semantics
  • downstream layers consume a contract; they do not silently replace it
  • the frontend displays the server-owned contract exactly as persisted
  • unknown API override values are rejected before preparation begins

Deliberate boundary

This PR does not add a composer task selector, integrate chat with durable ResearchRun, change closure endpoints, or implement G10-C2.4 PR review context. The API capability is complete; the visual task selector remains a documented UI gap.

Validation

GitHub Actions CI #670 on head 84c7c97798786b57cbc570e57daf74816f2af475 passed:

  • pytest: 702 passed
  • Ruff: passed
  • package helper: passed
  • detect-secrets: passed
  • incremental mypy baseline gate: passed
  • frontend Vitest: passed
  • TypeScript project build: passed
  • Vite production build: passed

@2002yy
2002yy marked this pull request as ready for review July 14, 2026 08:11
@2002yy
2002yy merged commit d604302 into main Jul 14, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant