Implement Self-Evolving Project Skills v2 run 17 - #895
Draft
adriandemian wants to merge 7 commits into
Draft
Conversation
…to ralphx/ralphx/agent-b73874ac # Conflicts: # src-tauri/src/application/publish_resilience_tests.rs # src-tauri/src/application/services/pr_merge_poller.rs # src-tauri/src/commands/ideation_commands/ideation_commands_restart.rs # src-tauri/src/commands/question_commands.rs # src-tauri/src/http_server/handlers/agent_workspaces/mod.rs # src-tauri/src/infrastructure/sqlite/migrations/mod.rs
A stored or fresh judge Approve for plan artifact version N could be applied to a later version of the same artifact because the guards compared only evaluated_artifact_id. The backend now stamps evaluatedArtifactVersion into the normalized verdict at invocation time and both the fresh and stored apply paths discard verdicts whose version does not match the current artifact; legacy stored verdicts without a version fail closed.
Workspace Review blocker B1: the plan-mode decline capture reused the accept path's ledger identity (source_ref_kind="planning_session" / source_ref_id=planning_session_id). PlanMode rows are outside the terminal-PR rank lattice, so resolve_task_outcome_upsert overwrote the earlier verdict in place and a decline followed by an accept in one planning session destroyed the decline. - Extract the length-prefixed component encoder out of plan_verdict_ledger and key plan-mode proposal rows on session + verdict class through it, so the two writers cannot drift apart. Repeat delivery of one verdict stays idempotent. - Cover the decline path: detector unit tests, mutual exclusivity with accept, and a production-entry regression proving accept and decline both survive (falsified: it fails with the old session-only key). - Remove the duplicated publication_pushed_sha = NULL merge residue from the restart SQL and align restore_after_restart (SQLite + memory + trait docs) with the production column set, with a production-path restart assertion. - Decline path: log repository read failures instead of silently returning, derive project_id the same way the accept path does, and document the reason source difference. - Note the retired "accepted"/"declined"/"revision_requested" outcome-class strings intentionally fall through to Other(...) and are not backfilled. Migration edge: rows already written under the bare planning_session_id key are unreachable by the new key. The next verdict for such a session inserts a new row, leaving one orphaned legacy row per affected session; not backfilled.
…to ralphx/ralphx/agent-b73874ac
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.
Summary
publication_pushed_shastorage to agent workspaces and threaded it through the domain entity, workspace preparation, and both repository implementations.plan_mode_revision_requestedoutcome class.User Impact
Technical Context
publication_pushed_shatoAgentConversationWorkspace, plus validation and repository support, and introduced a SQLite migration for the new column.plan_verdict_historyto create idempotent task outcomes from project, conversation, session, artifact version, actor, and verdict identity data.agent_workspace_merge_classificationand a terminal observation status override so merged PR observations can reflect clean and follow-up distinctions.Risks / Follow-Ups
View full plan
Spec §PR D4 — Merged-Clean and Plan-Verdict Capture
Goal
Implement the authoritative D4 slice on the current merged D1–D3 base: retain the exact commit successfully pushed for each publication attempt, use authoritative GitHub evidence to refine an already-observed merge into clean versus follow-up outcomes without false upgrades, and append deterministic User/Judge/PlanImport verdict history while keeping the approved-plan projection approved-only.
Assumptions grounded in the specification and current code:
mergedstatus;workspace_pr_merged_cleanandworkspace_pr_merged_with_followupsare typed ledger refinements.ghpath. Any ambiguity, including squash cases the available metadata cannot prove, stays plain merged.This is an architectural/stateful backend slice because it crosses persisted workspace state, every publication push seam, merge finalization/recovery, plan projection, and the typed outcome ledger.
Existing-Work Assessment
Evidence at current HEAD:
src-tauri/crates/ralphx-domain/src/repositories/task_outcome_repository.rs: canonical{pr_number}:terminaldedupe, row identity preservation, class ranking, equal-rank evidence replacement, higher-rank upgrade, lower-rank no-op, and status derivation already exist.v20260723143416_typed_ledger_sources_classes_failure_fingerprints,TaskOutcomeSource,TaskOutcomeClass, andOutcomeLedgerService. Theplan_modesource is live and non-terminal, so it is already outside the terminal PR lattice.AgentWorkspaceOutcomeAdapter::record_pr_terminalalready understandsmerged_cleanandmerged_with_followups, but current terminal observations and reconciliation emit only plainmerged. D4 should supply evidence-backed classification, not recreate the adapter or lattice.src-tauri/src/commands/question_commands.rs: accepted user verdicts can reach the outcome ledger, andPlanApprovalActor::{User, Judge, PlanImport}already exists. Missing pieces are decline/revise/import coverage, actor/version-aware idempotency, a shared post-transaction helper, and projection-preservation proofs.publication_pushed_shaand a dedicated repository setter do not exist. This is the one schema gap requiring an additive migration.src-tauri/src/http_server/handlers/external/ideation_start/start.rs; re-derive it plus the exhaustive push-call inventory withrgat implementation HEAD and record both in the tracker before production edits. Do not infer either from stale spec line anchors.The PR description must include this assessment, the final callsite inventory, any anchor drift, requirements confirmed already landed, D4 gaps implemented, and explicit non-applicability of C1/UI/MCP work.
Traceability Note
Before production edits, create/update the ignored implementation tracker at
.artifacts/specs/spec-pr-d4/tracker.mdwith the current HEAD/base, exact push and verdict producer inventory, and this mapping:publication_pushed_shawith a dedicated setterghrecord_pr_terminal,{pr}:terminal, andresolve_task_outcome_upsert; do not add a second terminal dedupe mechanismplan_mode/revision_requestedtyped vocabulary if HEAD confirms absentOutcomeLedgerService; encode the full stable identity in ledger linkage/evidence; exact duplicate delivery is idempotent while distinct actors/versions/verdicts appendSpec §PR D4, the D-lane dependency, and the approvals-approved-only adjudication; no C1 changesAffected Files
Exact files are revalidated at implementation HEAD; bounded ownership follows current repository seams.
Migration and workspace persistence
src-tauri/src/infrastructure/sqlite/migrations/v<UTC>_agent_workspace_publication_pushed_sha.rsand sibling test: add nullablepublication_pushed_sha TEXTwithout rewriting unrelated tables.src-tauri/src/infrastructure/sqlite/migrations/mod.rsand the schema-version constant using the repository migration workflow.src-tauri/crates/ralphx-domain/src/entities/agent_conversation_workspace.rs: add the nullable field and preserve legacy/default construction.src-tauri/crates/ralphx-domain/src/repositories/agent_conversation_workspace_repository.rs: add a dedicated setter/clear contract rather than overloading unrelated publication updates.src-tauri/src/infrastructure/sqlite/sqlite_agent_conversation_workspace_repo.rsandsrc-tauri/src/infrastructure/memory/memory_agent_conversation_workspace_repo.rs: row mapping and parity implementation.Push capture and restart
src-tauri/src/application/publish_resilience.rs: capture the exact local source-branch OID only after each successful push and persist it for the owning publication attempt.src-tauri/src/application/agent_conversation_workspace_restart.rs: clear the SHA in the same canonical restart flow that resets publication state.GitHubService::push_branch/push retry/fenced helpers undersrc-tauri/src/application/, includingpush_publish_branch,ensure_publish_base_pushed,ensure_plan_publish_branch_fresh, integration publication, plan publication, recovery/resume, and any handler-owned publish path. Record why each call does or does not ownpublication_pushed_sha; unrelated base-branch pushes must not overwrite the PR publication SHA.src-tauri/src/domain/services/github_service.rsonly if the established push abstraction must return the pushed OID. Prefer resolving the exact branch OID at the owning git seam over introducing harness-specific state.Merge classification and terminalization
mergedas clean/follow-ups/plain from persisted pushed SHA plus authoritative GitHub metadata.src-tauri/src/application/agent_workspace_terminal_observation.rs,agent_workspace_terminalization.rs,agent_workspace_external_pr_reconciliation.rs, andpr_merge_poller.rsas current call graphs require so poller, recovery, reconciliation, ReviewPr/automation finalization, and re-entry use the same classifier before branch deletion.src-tauri/src/domain/services/agent_workspace_outcomes.rsandsrc-tauri/crates/ralphx-domain/src/repositories/task_outcome_repository.rs; edit them only for a proven missing typed mapping/test, not to replace landed D1 behavior.gh; do not construct an ad hoc PATH lookup or turn SHA/branch input into a filesystem path.Plan verdict history
OutcomeLedgerServicefor deterministic post-transaction plan verdict capture.src-tauri/src/commands/question_commands.rs: route existing user acceptance and user decline through the helper after the owning transaction.src-tauri/src/application/automation/scheduler.rs: record Judge approve/revise verdict rows aftertransition_plan_judge_state,approve_current_plan_artifact, orset_plan_pending_instructionsaccepts the current artifact/version, including stored-verdict replay.src-tauri/src/application/automation/plan_judge.rslimited to parsing/typed-vocabulary support ifplan_mode_revision_requestedremains absent at implementation HEAD.src-tauri/src/http_server/handlers/external/ideation_start/start.rsfor PlanImport approval propagation; record PlanImport verdict rows only after the approval clone/upsert succeeds. Re-checksrc-tauri/src/application/plan_reference_import.rsand related tests for additional import paths before editing.TaskOutcomeClassparsing/serialization only ifplan_mode_revision_requestedremains absent at implementation HEAD. D3 intentionally has no outcome-class DDL CHECK, so this should not require a ledger-table migration.plan_artifact_approval_repository.rs, its table schema, and its existing approved projection writer semantically unchanged; only pass committed identity to the ledger helper.Tests and handoff artifacts
agent_workspace_outcomes_tests.rs,question_commands_tests.rs, SQLite/memory workspace repository tests,pr_merge_poller_tests.rs, and the relevantsuite_agent_workspace/automation plan tests..artifacts/specs/spec-pr-d4/tracker.mdthroughout implementation; it remains ignored local state.src/is unexpectedly touched, rebuild and commit its distribution.Data / State
Workspace publication SHA
Merge refinement
After an authoritative merged observation and before branch deletion:
gh.workspace_pr_merged_clean.workspace_pr_merged_with_followups.ghfails, retainworkspace_pr_merged.Plan verdict rows
Each row uses:
source = plan_mode;plan_mode_accepted,plan_mode_declined, orplan_mode_revision_requested; add the revision-requested variant if it remains absent at implementation HEAD;user,judge, orplan_import;session + artifact + version + actor + verdict;Exact duplicate delivery is a no-op/equal replacement according to the existing non-terminal outcome repository semantics; a different actor, artifact version, or verdict is a distinct historical row. The helper runs after the authoritative transaction. If ledger delivery fails after commit, preserve the committed projection/verdict, surface/log the failure according to the owning flow, and make retry safe through the same key.
The approved projection changes only through the existing approved writer. Decline/revise rows never clear, replace, or masquerade as the last approved artifact. Judge revise cannot recursively trigger or later be mistaken for judge approval.
Agent And MCP Surface
UI / UX
No direct UI work is planned. Fine merge classifications and verdict rows are backend ledger data in D4; the existing approved projection remains the UI source for the approved plan. This prevents revise/decline history from presenting as an approved plan and avoids introducing a second visible approval state.
Progression Scenarios
Constraints
CLAUDE.md,src-tauri/CLAUDE.md, and the stateful-workflow, task-state-machine, merge-recovery-consistency, Rust-test, CodeQL path-safety, multi-harness, production CLI, stable Rust, and PR-description rules.TaskTransitionService.mod.rsor runcargo fmt.cd src-tauri && cargo cleanseparately before handoff.[codex]prefix. The PR body leads with context, user impact, decisions, and risks, then D4 traceability/existing-work/changelog assessment and concise validation.Avoid
Decisions
ghseam and D1 terminal adapter/lattice.Proof Obligations
None; restart clears stale evidence.Spec §PR D4traceability, D1–D3 dependency reuse, origin-item mapping, adopted approved-only decision, convergence/changelog adjudication, current-base assessment, risks, and validation.Testing Strategy
Write focused failures first, then implement:
None; invalid/stale target does not mutate.ghfailure → plain merged.--features test-utils.suite_agent_workspaceandsuite_pr_githubnextest expressions.python3 scripts/validate_sqlite_migrations.py.rustfmt --edition 2021 --check <each touched leaf.rs>.python3 scripts/check-layering.pyonly if module/import boundaries change.cd src-tauri && cargo clean.git diff --check, the complete diff against HEAD, branch freshness, PR base/head, and auto-merge state.Exact cargo filters are selected from the final test symbols after TDD files are added; do not fall back to broad lib/workspace suites.
Generated by RalphX
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.