[codex] Trajectory store schema + retention#643
Conversation
|
@claude Do a thorough review of this PR in terms of: KISS, YAGNI, DRY, Fail Fast, Secure by Default and performance/speed |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Pull request overview
Implements trajectory schema v2 and configurable retention/pruning for captured skill-run trajectories, including docs and test coverage updates for the new behavior.
Changes:
- Upgrades trajectory JSONL records to schema v2 with first-class fields (input/output/model/tools/outcome/score) while retaining the raw
skill_runevent payload. - Adds trajectory retention configuration (global + per-tenant overrides) and normalizes it during runtime config reload.
- Integrates trajectory pruning into the periodic Adaptive Skills inspection/maintenance path and documents the new config.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/skills-observation.test.ts | Updates expectations to assert schema v2 trajectory fields are captured. |
| tests/skills-inspection.test.ts | Adds coverage for tenant-specific trajectory retention pruning and empty-partition cleanup. |
| tests/config-reload.integration.test.ts | Adds coverage for retention config normalization on reload. |
| src/skills/skills-inspection.ts | Runs scheduled trajectory pruning during periodic inspection. |
| src/skills/skill-run-trajectories.ts | Implements schema v2 record building (incl. score/tools) and JSONL retention pruning by tenant. |
| src/skills/adaptive-skills-types.ts | Extends Adaptive Skills config types with retention fields. |
| src/config/runtime-config.ts | Adds defaults + normalization for trajectory retention settings. |
| docs/development/reference/configuration.md | Documents trajectory retention configuration. |
| docs/development/extensibility/adaptive-skills.md | Documents retention policy and trajectory capture config fields. |
| docs/content/reference/configuration.md | Mirrors retention config documentation for published docs. |
| docs/content/extensibility/adaptive-skills.md | Mirrors retention policy documentation for published docs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@claude Do a thorough review of this PR in terms of: KISS, YAGNI, DRY, Fail Fast, Secure by Default and performance/speed |
|
Claude finished @furukama's task in 2m 33s —— View job PR Review: KISS · YAGNI · DRY · Fail Fast · Secure by Default · Performance
Overall this is a solid, well-structured PR. The permissions model, test coverage, and config normalization are all good. A few issues worth addressing — one is on the hot path and should be fixed before merge; the rest are minor clean-up items. 🔴 Performance — Synchronous DB read in the write hot path
// skill-run-trajectories.ts:206
const [score] = getAgentSkillScores({
agentId: event.agent_id,
skillName: event.skill_id,
limit: 1,
});The score snapshot (
Copilot flagged this too. Fix this → 🟡 YAGNI / KISS —
|
| Area | Finding | Severity |
|---|---|---|
| Performance | Sync DB read (getAgentSkillScores) in skill_run event hot path |
🔴 Fix before merge |
| YAGNI | tenant_id === agent_id always — premature abstraction |
🟡 |
| KISS/PERF | readTrajectoryTenantId opens every file in prune path; filename is sufficient |
🟡 |
| DRY | Two near-identical agent-ID enable-check functions | 🟡 |
| Fail Fast | Silent null score on DB error; no signal to caller | 🟡 |
| KISS | Overloaded pruneExpiredSkillRunTrajectories input object |
🟡 |
| Test | Flaky midnight race in pruning test | 🟡 |
| Security | Large first-line silently skips file during prune | 🟢 |
Summary
Implements #488 by making captured skill-run trajectories schema version 2 records with first-class fields for input, output, model, tools used, outcome, and score.
What changed
input,output,model,tools_used,outcome, andscorewhile preserving the rawskill_runevent payload for compatibility.adaptiveSkills.trajectoryCapturewith a 365-day default and per-tenant overrides viaretentionDaysByTenant.Validation
biome check --write srcbiome check srctsc --noEmit --noUnusedLocals --noUnusedParameterswith Node 22vitest run --configLoader runner --config vitest.unit.config.ts tests/skills-observation.test.ts tests/skills-inspection.test.tswith Node 22vitest run --configLoader runner --config vitest.integration.config.ts tests/config-reload.integration.test.tswith Node 22Closes #488.