Files
FabledCurator/frontend/src/stores/heads.js
T
bvandeusen 1463794778
CI / lint (push) Successful in 2s
CI / frontend-build (push) Successful in 20s
CI / backend-lint-and-test (push) Successful in 26s
CI / integration (push) Successful in 3m23s
feat(heads): auto-apply UI on the Concept-heads card (#114 auto-apply C)
Surfaces earned auto-apply + its observability in Settings → Tagging → Concept
heads:
- Auto-apply section: an on/off switch (writes head_auto_apply_enabled), the
  precision-target + min-examples-to-fire tuning inputs, a Preview (dry-run →
  "would apply N", per-concept chips) and Apply-now button, with live run state.
- "How auto-apply is landing": per-concept table from /api/heads/metrics —
  applied volume, misfires, realized misfire rate (green/amber/red), and missed
  (under-fires) — the signal to tune the precision target from.

store: autoApply(dryRun) / autoApplyStatus() / metrics(). Card polls the sweep
to completion, then refreshes counts + metrics. Completes the auto-apply task.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ttrj5P7upUTueSfoJcxEqa
2026-06-29 00:51:59 -04:00

42 lines
1.6 KiB
JavaScript

import { defineStore } from 'pinia'
import { useApi } from '../composables/useApi.js'
// Heads (#114): the per-concept classifiers that LEARN from your tags and power
// suggestions (replacing Camie + centroid). Training runs as a background task;
// the card rehydrates status from GET /api/heads on mount so it survives
// navigation (the run lives in head_training_run server-side).
export const useHeadsStore = defineStore('heads', () => {
const api = useApi()
// Summary: head_count, graduated_count, last_trained_at, running_id, the
// per-concept head table, and recent training runs.
async function status() {
return await api.get('/api/heads')
}
// (Re)train all eligible heads. One run at a time (409 if already running).
async function train(params = {}) {
return await api.post('/api/heads/train', { body: { params } })
}
// Earned auto-apply: trigger a sweep. dry_run previews (writes nothing);
// a real sweep needs head_auto_apply_enabled on (else 400).
async function autoApply(dryRun = false) {
return await api.post('/api/heads/auto-apply', { body: { dry_run: dryRun } })
}
// Recent sweeps + per-concept report (volume / projected per head).
async function autoApplyStatus() {
return await api.get('/api/heads/auto-apply')
}
// Observability: per-concept counts (volume, misfires, under-fires, realized
// misfire rate, head quality) + the daily time-series, to tune from.
async function metrics() {
return await api.get('/api/heads/metrics')
}
return { status, train, autoApply, autoApplyStatus, metrics }
})