Skip to content

Add learned-skill substrate foundation - #366

Open
adriandemian wants to merge 132 commits into
mainfrom
ralphx/ralphx/agent-88af9c08
Open

Add learned-skill substrate foundation#366
adriandemian wants to merge 132 commits into
mainfrom
ralphx/ralphx/agent-88af9c08

Conversation

@adriandemian

@adriandemian adriandemian commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Context

This PR repairs ralphx/ralphx/agent-88af9c08 after the original ideation/task branch lost the expected learned-skill work. It also merges the recovered unsquashed adapter history so the visible branch contains the work that was previously only present in task/worktree history.

What Landed

  • Recovered the unsquashed adapter/injection history into this PR branch.
  • Added the Phase 1 persistence substrate:
    • task_outcomes
    • project_skills
    • skill_usage_events
    • domain entities, repository traits, SQLite repos, memory repos, services, AppState wiring, and focused tests.
  • Added read-only Rust HTTP/API-key project skill surfaces:
    • POST /api/project_skills/list
    • POST /api/project_skills/get
    • project-scope enforcement for learned project skill list/get paths.
  • Added read-only MCP learned skill tools:
    • list_project_skills
    • get_project_skill
    • plugin server dispatch, MCP-side project scope validation, canonical agent allowlists, generated build output, and MCP tests.
  • Added Agent Composer learned skill read support:
    • backend catalog includes approved repository-backed project-wide learned skills;
    • frontend schema accepts source: "learned";
    • selected learned skills serialize stable ralphx_project_skill directives carrying project_skill_id.
  • Added a repository-backed service resolver for Composer learned-skill directives that returns citations only for same-project, approved, non-archived skills.

Decisions

  • This PR does not pretend Phase 4 curator/import/promotion is complete. The earlier substrate was absent, so this branch first lands the prerequisite substrate/read surface.
  • Path-scoped learned skills are intentionally hidden from Agent Composer until Composer sends an explicit active path/scope contract.
  • The task-e471f6fc adapter work is treated as follow-up adapter logic, not the substrate itself.
  • Lifecycle and directive eligibility live in backend services, not only UI controls.

Remaining Gaps

  • Phase 0 dark memory capture validation/repair is still open.
  • Runtime prompt composition still needs to call the repository-backed directive resolver and record selected learned-skill usage through SkillUsageService after AgentRun creation.
  • Distillation, approval workflow, reviewer flagship, task-pipeline/PR outcome capture, export to target .claude/skills, reporting/scoring, curator/import/promotion, and AgentProfile overlays remain follow-on milestones.
  • Usage-dependent reporting/curation must remain gated until Claude and Codex usage attribution is wired and tested.

Validation

  • cargo check --manifest-path src-tauri/Cargo.toml --lib
  • cargo test --manifest-path src-tauri/Cargo.toml learned_skill --lib
  • cargo test --manifest-path src-tauri/Cargo.toml project_skill_scope_guard --lib
  • cargo test --manifest-path src-tauri/Cargo.toml agent_composer --lib
  • cargo test --manifest-path src-tauri/Cargo.toml prompt_selected_citations_resolve_only_approved_same_project_skills --lib
  • cd plugins/app/ralphx-mcp-server && npm run build
  • cd plugins/app/ralphx-mcp-server && npm run test
  • cd frontend && npm run test:run -- src/components/agents/composer/agentComposerCore.test.ts src/components/agents/AgentComposerSurface.test.tsx
  • cd frontend && npm run typecheck
  • git diff --check

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

@adriandemian
adriandemian force-pushed the ralphx/ralphx/agent-88af9c08 branch from afedfc9 to e24272a Compare June 15, 2026 15:37
Comment thread src-tauri/src/http_server/handlers/learned_skills.rs Fixed
Comment thread src-tauri/src/http_server/handlers/learned_skills.rs Fixed
@adriandemian
adriandemian force-pushed the ralphx/ralphx/agent-88af9c08 branch 8 times, most recently from 7666408 to 8fa7331 Compare June 15, 2026 22:05
Adds a Delete affordance to the latest automation run card, wired to the
existing delete_automation_run backend command. The trash button shows only
on the latest run and only when its status is running, agent_failed, or
cancelled; a running run is stopped-then-deleted. Destructive confirm varies
copy for the running (stop & delete) case, then archives the conversation and
tears down the worktree/branch. Never shown for completed/published/merged or
non-latest runs.

Also removes an AutomationOverviewTab phase cap (limit=6) that slipped in via
the main merge, restoring the all-phases scrollable list the branch tests
assert.
Design-system polish of the Automation Detail view:
- Elevate Section/Config cards to the canonical SectionCard chrome and add
  a shared FieldLabel eyebrow primitive across all label sites.
- New design-system-native components: NoticeBanner (tinted, WKWebView-safe
  longhands) and CopyableRef (truncating ref + copy affordance).
- Unify run/phase status -> StatusPill tone mapping (agent_failed=error,
  cancelled=neutral, paused=warning) across every writer; colored timeline
  marker dots and tone-bordered cards.
- De-weight the run failure block into a NoticeBanner; humanize the paused
  stage; phase list uses status icons with only the in-progress row as a pill.
- Run-card header restructured into an action cluster (delete preserved as a
  sibling of the expand toggle, with a slot reserved for a future Resume
  action); collapsed cards compacted.
- Grouped-config rhythm/separators, inset segmented tabs, copyable branch refs.

Regenerated automation-detail visual baselines. All vitest suites green.
Product-design pass on the runs timeline and detail tabs:
- Neutral uniform run cards (no per-status tinting); the timeline marker dot
  is the only status color outside the pill — accent for the active run.
- Header shows one StatusPill + demoted secondary states as muted text
  (ends the 3-pill noise); PR link inline; delete anchored in the header's
  right cluster instead of floating.
- Footer action row groups View plan + Open conversation (a real button, no
  orange link float) with a reserved Resume slot; Run prompt is a borderless
  text disclosure.
- Failure message is a calm left-rule instead of a full-bleed box; aligned
  metadata definition grid gives the previously-orphaned agent a real field;
  task-ledger counts anchored on the label row.
- Collapsed cards compact to a single smart line (Run N, status, PR, time).
- Spec tab gains a purpose caption + tidy header/excerpt/markdown rendering;
  Inputs tab explains itself with a clean source-PR row and empty state.

Regenerated automation-detail visual baselines; all vitest suites green.
Adds resume-by-reopen for the latest failed automation run: a confined
corrective transition (AgentFailed -> Running, bypassing the allow-table only
through the dedicated reopen_run_corrective seam) followed by a re-drive into
the run's EXISTING conversation + worktree, so the prior attempt's uncommitted
work and history continue instead of restarting.

- reopen_automation_run composition (application/automation/reopen.rs): gates
  (latest + AgentFailed + has-conversation/workspace + agent-not-running +
  not-paused, all fail-closed); claims authority via the corrective CAS FIRST,
  then resets stale state (clear judge_state+verdict, finished_at, publication
  metadata, re-arm a blocked review monitor, plan_reminder_count), sets a fresh
  agent_phase_started_at basis, and re-drives with a continue-in-place prompt.
- New repo helpers clear_judge_state + clear_finished_at (trait + SQLite +
  Memory + test mock); resume_automation_run command wired in the registry.
- Re-drive is behind an injectable AutomationRunRedriver seam so it is unit
  testable without a real agent spawn; tests cover the happy path (state resets
  + redrive into the existing conversation) and the reject/gate paths.

Also fixes a main-merge break: recover_stale_publish_repair_for_workspace and
its siblings gained a TaskOutcomeRepository arg on main but several test call
sites weren't updated, which was breaking the entire lib-test build.
Wires the runs timeline to the resume_automation_run backend command. A Resume
CTA (accent, Play icon) renders in the run-card footer's reserved slot only on
the latest run when its status is agent_failed; confirming reopens the run in
place (continuing the existing agent in its worktree, keeping prior work and
history). Mirrors the delete-run wiring: resumeRun API wrapper,
isAutomationRunResumable predicate, mutation + confirm in the detail view,
onResumeRun threaded through the runs tab. Delete and Resume coexist on a
latest failed card.
Merged runs (the success end-state) get a green marker dot and a soft
success-tinted bg/border in the timeline; all other statuses stay neutral.
Reopening the latest failed run now transitions the owning automation
Paused/Stopped -> Active (clearing the paused reason) after the run's
corrective CAS, so the reopened run is actually advanced by the scheduler
instead of sitting under a paused automation. No-op when already Active.
Replaces the 8-column grid table with a coherent, scannable list:
- Each row is a status dot + a two-line identity block (name; then a muted
  secondary line folding stage/next-action, phase count, and mode·model) +
  a right meta cluster (StatusPill, runs N/M with a micro-progress hint, last
  run, chevron). Drops the PROJECT (always the filtered project) and BASE
  (truncated to noise) columns; drops the uppercase column header.
- Resolves the STATUS vs NEXT-ACTION redundancy: the pill carries the coarse
  state, the secondary line carries the humanized reason (never 'Paused' twice).
- Adds a shared PAUSED_REASON_LABELS map in automationRunView so the list,
  detail overview, and agents panel all render humanized paused reasons
  (no raw snake_case codes leaking to the UI).
- Status->tone/dot color system via the existing Pill shim; stopped is neutral
  (red reserved for failures). One wrapping card with row dividers, no gridlines,
  WKWebView-safe longhands, memoized rows, rebuilt skeleton.

Also fixes a stale merged-run card-color assertion left by the earlier merged
success-treatment commit. typecheck + lint clean; 222 vitest tests green.
…#855)

* feat: add project skill schema versioning

* chore: preserve pending project skill schema edits
…-sync

Run-card refinements from design feedback:
- runTimelineHighlight now gives each key status a soft treatment: running/
  active = soft accent (orange) bg+border, failed = soft darker surface with an
  error marker, merged = soft green (kept); everything else stays neutral.
- 'Open conversation' becomes an outline button (reads clearly as a button).
- Task ledger: replace the oversized 'In progress' StatusPill with a small
  status dot (animated pulse only on the live task), and wrap the rows in a
  bordered panel with row dividers for structure.
- Task ledger stays in sync with the run's terminal state: on a merged/
  completed/published run, a task the agent left 'active' renders as 'done'
  (no misleading live dot on a finished run).

Regenerated runs-tab baseline; typecheck + lint clean; 222 vitest tests green.
New automation runs branch off this branch and their agents follow this
rule when validating. The whole src-tauri lib test target must compile
before any filter runs, and it depends on Tauri mock-app helpers
(create_mock_app*, tauri::test) — plus, once B2 lands, feature-gated
test-only repo trait methods — all behind test-utils. Bare
`cargo test … --lib` fails to compile (E0433/E0425/E0407) regardless of
filter, making a run agent's local validation gate report a false
failure. Update every lib-pinpoint example to `--features test-utils`
and add a non-negotiable note; the standalone crates/ralphx-domain
command is unaffected.
* feat(project-skills): update-over-create resolution (B2)

Route all ProjectSkill writes through a single atomic `resolve` seam
(candidate-load → pure evaluator → insert/update current row → append
version) on both SQLite (one BEGIN IMMEDIATE) and memory (one write lock).
Ambiguous matches fail closed to Conflict; lifecycle exclusions and
approved-immutability-via-companion hold; reads are strict/fail-closed;
versions are monotonic.

`create`/`update_content`/`append_version`/`seed_for_test` become
test-only (`cfg(any(test, feature = "test-utils"))`) so production can
only write through `resolve`; `src-tauri`'s `test-utils` feature now
enables `ralphx-domain/test-utils` so the lib test target sees them.

* docs(rust-test-execution): lib pinpoints require --features test-utils

The whole `src-tauri` lib test target must compile before any filter
runs, and it depends on Tauri mock-app helpers (`create_mock_app*`,
`tauri::test`) — plus, since B2, feature-gated test-only repo trait
methods — all behind `test-utils`. Bare `cargo test … --lib` fails to
compile (E0433/E0425/E0407) regardless of filter, which makes an agent's
validation gate report failure. Update every lib-pinpoint example to
`--features test-utils` and add a non-negotiable note; the standalone
`crates/ralphx-domain` command is unaffected (`cfg(test)` covers it).
…ement

- Task ledger reads as an aligned table now: task # · status dot · title ·
  status label, inside a clearer elevated bordered panel with soft
  per-state colours (accent for in-progress, green for done).
- Move the run delete action out of the header (it sat next to the collapse
  chevron and was easy to misclick) into the footer, grouped with Run prompt
  and separated from the primary Open conversation / Resume actions.
- fix(automations): silence clippy dead_code on the test-only
  resume_automation_smart_with_redriver / SmartResumeReopener::Redriver seam
  so the --no-default-features lib clippy lane passes.
…on states

Adds coverage for AutomationRunTaskLedger's error, all-terminal (no active
tasks), and active→done terminal-coercion branches surfaced by codecov.
Drop the unextracted automation publish-shortcut residue from skills-branch
surfaces (now PR'd separately off main), migrate DEFAULT_PROJECT_VIEW usages
to DEFAULT_APP_VIEW, dedupe a doubled scheduler test block, and fix arity at
call sites that main's ManualRoleRuntimeOverride and task-outcome threading
changed.
…ict ledger (#905)

Spec §PR D4 lands three coupled pieces:
- nullable publication_pushed_sha on AgentConversationWorkspace with a
  branch-fenced setter, dedicated clear, and memory/SQLite parity
- a conservative merged_clean / merged_with_followups classifier fed by
  PrSyncState before terminal cleanup, never using merge_commit_sha
- a deterministic plan-verdict ledger keyed by
  session+artifact+version+actor+verdict, wired into User approval,
  accept/reject-finalize, judge approve/revise, and approved-plan import

Workspace Review repair:
- persist the backend-stamped evaluated artifact version on judge verdicts
  and reject stored verdicts whose version differs from the current plan, so
  replaying an Approve verdict for v1 can no longer auto-approve a revised v2
- drop a needless borrow in pr_merge_poller that failed the clippy lane
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.

3 participants