feat(skill): persist flattened tool sets #460

Merged
freemo merged 1 commit from feature/m4-skill-registry-db into master 2026-02-27 21:32:21 +00:00
Owner

Summary

Adds persistence support for flattened tool sets in the skill registry, enabling cached resolution of skill-to-tool mappings with hash-based invalidation.

Changes

Alembic Migration (m4_002_skill_flattened_tools)

  • Adds 5 new columns to skills table: flattened_tools_json, includes_json, capability_summary_json, yaml_text, flattening_hash
  • Adds uniqueness constraint on skill name (defence-in-depth on PK)
  • Uses batch_alter_table for SQLite compatibility

SkillModel Updates

  • 5 new SQLAlchemy Column definitions matching the migration
  • UniqueConstraint added to __table_args__

SkillRepository Extensions

  • update_flattened_tools() — persists all 5 cache fields
  • get_flattened_tools() — returns dict of cached fields
  • needs_refresh() — compares stored hash vs current hash
  • recompute_flattening_hash() — SHA-256 computation + storage
  • invalidate_cached_summaries() — nulls all cached fields
  • update() method now invalidates cached fields on mutation
  • All methods follow @database_retry + flush-don't-commit pattern with structlog logging

Documentation

  • Updated docs/reference/database_schema.md with skills table fields and mapping table

Tests

  • Behave: 6 scenarios in features/skill_registry_persistence.feature (all pass)
  • Robot: 2 smoke tests in robot/skill_registry_persistence_smoke.robot (all pass)
  • ASV: 3 benchmarks in benchmarks/skill_registry_persist_bench.py

Quality Gates

  • lint: PASS
  • typecheck: PASS (0 errors, 0 warnings)
  • unit_tests: PASS
  • integration_tests: PASS

Closes #166

## Summary Adds persistence support for flattened tool sets in the skill registry, enabling cached resolution of skill-to-tool mappings with hash-based invalidation. ## Changes ### Alembic Migration (`m4_002_skill_flattened_tools`) - Adds 5 new columns to `skills` table: `flattened_tools_json`, `includes_json`, `capability_summary_json`, `yaml_text`, `flattening_hash` - Adds uniqueness constraint on skill name (defence-in-depth on PK) - Uses `batch_alter_table` for SQLite compatibility ### SkillModel Updates - 5 new SQLAlchemy Column definitions matching the migration - UniqueConstraint added to `__table_args__` ### SkillRepository Extensions - `update_flattened_tools()` — persists all 5 cache fields - `get_flattened_tools()` — returns dict of cached fields - `needs_refresh()` — compares stored hash vs current hash - `recompute_flattening_hash()` — SHA-256 computation + storage - `invalidate_cached_summaries()` — nulls all cached fields - `update()` method now invalidates cached fields on mutation - All methods follow `@database_retry` + flush-don't-commit pattern with structlog logging ### Documentation - Updated `docs/reference/database_schema.md` with skills table fields and mapping table ### Tests - **Behave**: 6 scenarios in `features/skill_registry_persistence.feature` (all pass) - **Robot**: 2 smoke tests in `robot/skill_registry_persistence_smoke.robot` (all pass) - **ASV**: 3 benchmarks in `benchmarks/skill_registry_persist_bench.py` ## Quality Gates - lint: PASS - typecheck: PASS (0 errors, 0 warnings) - unit_tests: PASS - integration_tests: PASS Closes #166
freemo scheduled this pull request to auto merge when all checks succeed 2026-02-27 02:32:26 +00:00
freemo force-pushed feature/m4-skill-registry-db from 515e54991e
All checks were successful
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 16s
CI / lint (pull_request) Successful in 30s
CI / security (pull_request) Successful in 33s
CI / quality (pull_request) Successful in 44s
CI / typecheck (pull_request) Successful in 53s
CI / integration_tests (pull_request) Successful in 3m33s
CI / benchmark-regression (pull_request) Successful in 21m21s
CI / unit_tests (pull_request) Successful in 29m59s
CI / docker (pull_request) Successful in 39s
CI / coverage (pull_request) Successful in 38m4s
to 60b2a075b1
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 13s
CI / build (pull_request) Successful in 16s
CI / quality (pull_request) Successful in 18s
CI / security (pull_request) Successful in 29s
CI / typecheck (pull_request) Successful in 31s
CI / integration_tests (pull_request) Successful in 3m35s
CI / unit_tests (pull_request) Successful in 11m0s
CI / docker (pull_request) Successful in 1m22s
CI / benchmark-regression (pull_request) Successful in 26m42s
CI / coverage (pull_request) Failing after 38m49s
2026-02-27 02:33:16 +00:00
Compare
freemo force-pushed feature/m4-skill-registry-db from 60b2a075b1
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 13s
CI / build (pull_request) Successful in 16s
CI / quality (pull_request) Successful in 18s
CI / security (pull_request) Successful in 29s
CI / typecheck (pull_request) Successful in 31s
CI / integration_tests (pull_request) Successful in 3m35s
CI / unit_tests (pull_request) Successful in 11m0s
CI / docker (pull_request) Successful in 1m22s
CI / benchmark-regression (pull_request) Successful in 26m42s
CI / coverage (pull_request) Failing after 38m49s
to 7235d46ade
All checks were successful
CI / quality (pull_request) Successful in 19s
CI / lint (pull_request) Successful in 21s
CI / benchmark-publish (pull_request) Has been skipped
CI / security (pull_request) Successful in 50s
CI / typecheck (pull_request) Successful in 58s
CI / build (pull_request) Successful in 29s
CI / integration_tests (pull_request) Successful in 4m16s
CI / unit_tests (pull_request) Successful in 12m18s
CI / docker (pull_request) Successful in 1m30s
CI / benchmark-regression (pull_request) Successful in 25m15s
CI / coverage (pull_request) Successful in 1h21m51s
CI / build (push) Successful in 15s
CI / quality (push) Successful in 17s
CI / lint (push) Successful in 21s
CI / security (push) Successful in 28s
CI / typecheck (push) Successful in 31s
CI / benchmark-regression (push) Has been skipped
CI / integration_tests (push) Successful in 2m47s
CI / unit_tests (push) Successful in 11m0s
CI / docker (push) Successful in 40s
CI / benchmark-publish (push) Successful in 12m22s
CI / coverage (push) Successful in 44m42s
2026-02-27 20:09:27 +00:00
Compare
freemo merged commit 7235d46ade into master 2026-02-27 21:32:21 +00:00
freemo deleted branch feature/m4-skill-registry-db 2026-02-27 21:32:21 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core!460
No description provided.