11 Commits

Author SHA1 Message Date
CoreRasurae 8a7e353767 fix(actors): llm token consumption undercounted
CI / lint (pull_request) Successful in 35s
CI / typecheck (pull_request) Successful in 50s
CI / security (pull_request) Successful in 49s
CI / quality (pull_request) Successful in 33s
CI / unit_tests (pull_request) Successful in 3m5s
CI / integration_tests (pull_request) Successful in 1m19s
CI / build (pull_request) Successful in 35s
CI / coverage (pull_request) Successful in 3m7s
CI / status-check (pull_request) Successful in 3s
CI / lint (push) Successful in 33s
CI / typecheck (push) Successful in 50s
CI / security (push) Successful in 50s
CI / quality (push) Successful in 33s
CI / integration_tests (push) Successful in 1m11s
CI / build (push) Successful in 34s
CI / unit_tests (push) Failing after 14m51s
CI / coverage (push) Has been cancelled
CI / status-check (push) Has been cancelled
- enforces pruning model token-tracking metadata availability for cost tracking
- also temporarily enforces pruning-model match

ISSUES CLOSED: #65
2026-07-01 14:55:58 +01:00
CoreRasurae 964e87cc0f feat(tool-loop): add token-budget awareness and tool output pruning
CI / lint (pull_request) Successful in 1m31s
CI / typecheck (pull_request) Successful in 50s
CI / security (pull_request) Successful in 50s
CI / quality (pull_request) Successful in 33s
CI / unit_tests (pull_request) Successful in 3m5s
CI / integration_tests (pull_request) Successful in 1m7s
CI / build (pull_request) Successful in 34s
CI / coverage (pull_request) Successful in 3m7s
CI / status-check (pull_request) Successful in 3s
CI / lint (push) Successful in 33s
CI / typecheck (push) Successful in 50s
CI / security (push) Successful in 50s
CI / quality (push) Successful in 33s
CI / integration_tests (push) Successful in 1m12s
CI / build (push) Successful in 33s
CI / unit_tests (push) Successful in 3m5s
CI / coverage (push) Successful in 3m6s
CI / status-check (push) Successful in 6s
Implement token-budget awareness (§4.4.7) and tool output pruning
(§4.4.8-9) for the multi-turn tool-call loop to prevent context-window
exhaustion.

Token budget: tracks estimated token count before each ainvoke(), emits
warning at 75% budget, injects synthesis prompt at exhaustion with one
final tool-call round. Estimation via chat_model.get_num_tokens() with
len(content)//4 heuristic fallback. Config key: token_budget_percent.

Tool output pruning: implicit LLM extraction pass scoped to file_read
calls. Schema augmentation injects output_prune (bool) and
output_prune_context (string) meta-arguments. Pruning model responds
with [PRUNE_INFO_START/END] and [PRUNE_OUTPUT_START/END] markers.
Config keys: allow_tool_output_pruning, pruning_model.

- Capture output_prune value in budget synthesis flow with proper guard
- Fix ADR D-4: synthesis prompt is HumanMessage not SystemMessage
- Fix Robot tests: replace /dev/null with temp file path

ADR-2031 documents all specification extensions. 21 new BDD scenarios,
5 Robot integration tests, 16 ASV benchmarks.

ISSUES CLOSED: #61
2026-06-26 18:21:14 +01:00
CoreRasurae 517dfb4cce feat(registry): implement local namespace reference resolution
CI / lint (pull_request) Successful in 35s
CI / quality (pull_request) Successful in 45s
CI / integration_tests (pull_request) Successful in 1m2s
CI / typecheck (pull_request) Successful in 1m10s
CI / security (pull_request) Successful in 1m10s
CI / build (pull_request) Successful in 42s
CI / unit_tests (pull_request) Successful in 3m21s
CI / coverage (pull_request) Successful in 3m7s
CI / status-check (pull_request) Successful in 3s
CI / quality (push) Successful in 50s
CI / security (push) Successful in 51s
CI / lint (push) Successful in 54s
CI / typecheck (push) Successful in 58s
CI / integration_tests (push) Successful in 1m0s
CI / build (push) Successful in 43s
CI / unit_tests (push) Successful in 3m23s
CI / coverage (push) Successful in 3m14s
CI / status-check (push) Successful in 3s
Implements the local:<path> reference scheme per Package Registry Standard v1.0.0 §5.3.

Closes #46
2026-06-12 17:11:35 +01:00
CoreRasurae 28df55b83e test(benchmark): Fix failing benchmark tests from pre-existing features
Fixes ASV benchmark method signatures and import paths to run correctly
against the current project baseline.
2026-06-12 17:11:32 +01:00
CoreRasurae 054b432197 feat(registry): implement RegistryCache with LRU eviction and TTL
CI / lint (pull_request) Successful in 56s
CI / typecheck (pull_request) Successful in 56s
CI / security (pull_request) Successful in 1m2s
CI / quality (pull_request) Successful in 41s
CI / integration_tests (pull_request) Successful in 1m11s
CI / build (pull_request) Successful in 45s
CI / unit_tests (pull_request) Successful in 3m29s
CI / coverage (pull_request) Successful in 3m14s
CI / status-check (pull_request) Successful in 4s
CI / lint (push) Successful in 48s
CI / typecheck (push) Successful in 58s
CI / security (push) Successful in 1m1s
CI / quality (push) Successful in 39s
CI / integration_tests (push) Successful in 1m15s
CI / build (push) Successful in 41s
CI / unit_tests (push) Successful in 3m31s
CI / coverage (push) Successful in 3m27s
CI / status-check (push) Successful in 3s
- Add RegistryCache with LRU eviction, TTL expiry, SHA-1 content validation
 - Add CacheFactory for centralised cache configuration (Factory Method pattern)
 - Add CacheStats dataclass for hit/miss/eviction observability
 - Implement singleflight coalescing for concurrent-miss protection
 - Use tuple keys for resolve store to prevent separator collision
 - Fix cancellation-safe singleflight via plain Future + asyncio.shield
 - Independent max_size budgets per store (content + resolve)
 - Concurrent test assertions strengthened
 - All test imports moved to module level per CONTRIBUTING.md
 - Unused dead code removed from tests

 ISSUES CLOSED: #28
2026-06-11 19:26:04 +01:00
CoreRasurae 284d2a9f00 feat(registry): extend TemplateType and integrate PackageReference into template system
CI / quality (pull_request) Successful in 37s
CI / lint (pull_request) Successful in 49s
CI / typecheck (pull_request) Successful in 50s
CI / build (pull_request) Successful in 50s
CI / security (pull_request) Successful in 55s
CI / integration_tests (pull_request) Successful in 59s
CI / unit_tests (pull_request) Successful in 3m38s
CI / coverage (pull_request) Successful in 3m35s
CI / status-check (pull_request) Successful in 4s
CI / lint (push) Successful in 33s
CI / quality (push) Successful in 58s
CI / typecheck (push) Successful in 1m1s
CI / security (push) Successful in 1m1s
CI / build (push) Successful in 52s
CI / integration_tests (push) Successful in 1m12s
CI / unit_tests (push) Successful in 3m41s
CI / coverage (push) Successful in 3m35s
CI / status-check (push) Successful in 3s
Extend TemplateType enum with TEMPLATE, SKILL, ACTOR, MCP, LSP.
Add optional package_ref field to ComponentReference for registry references.
Create ReferenceResolver with multi-server RegistryClient pool and caching.
Update InstantiationContext for registry-aware resolution with _original_reference.
Extend TemplateRegistry, EnhancedTemplateRegistry, and TemplateStore for 8 types.
Add registry reference detection in instantiate_from_config.
Add GenericTemplate for new package types without specialized template classes.

ISSUES CLOSED: #27
2026-06-10 12:50:38 +01:00
CoreRasurae 4e12902492 feat(registry): implement ReferenceResolver with version alias resolution
CI / quality (pull_request) Successful in 35s
CI / security (pull_request) Successful in 54s
CI / lint (pull_request) Successful in 58s
CI / build (pull_request) Successful in 42s
CI / typecheck (pull_request) Successful in 59s
CI / integration_tests (pull_request) Successful in 1m14s
CI / unit_tests (pull_request) Successful in 3m48s
CI / coverage (pull_request) Successful in 3m34s
CI / status-check (pull_request) Successful in 3s
CI / quality (push) Successful in 33s
CI / lint (push) Successful in 38s
CI / typecheck (push) Successful in 48s
CI / security (push) Successful in 48s
CI / build (push) Successful in 41s
CI / integration_tests (push) Successful in 1m15s
CI / unit_tests (push) Successful in 3m37s
CI / coverage (push) Successful in 3m34s
CI / status-check (push) Successful in 3s
Introduce ReferenceResolver implementing the Package Registry Standard v1.0.0
§5.3 and §4.2:

ReferenceResolver:
- parse(ref_str) → PackageReference handles all three reference schemes
  (registry, ID, local), wrapping ValueError into InvalidPackageReferenceError
- resolve(ref_str) → PackageId resolves references to concrete IDs:
  ID refs directly, registry refs via RegistryClient, local refs reserved
- Integrates with RegistryClient for remote HTTP resolution

Version resolution (§4.2):
- resolve_version(version, available_versions) resolves concrete (vX.Y.Z)
  and mutable aliases (latest, vx, x, vX.x, vX.Y.x)
- is_concrete_version() / is_version_alias() classification helpers

Integration tests: 35 Robot Framework test cases against fake registry server
with version alias resolution support

Benchmarks: 7 ASV benchmark classes covering parse, resolve, and version
resolution across small/medium/large version lists

ISSUES CLOSED: #26
2026-06-10 12:04:00 +01:00
CoreRasurae 8fa9e7652d feat(registry): implement Canonicalizer with NFC normalization and SHA-1 hashing
CI / quality (pull_request) Successful in 42s
CI / lint (pull_request) Successful in 46s
CI / security (pull_request) Successful in 47s
CI / build (pull_request) Successful in 50s
CI / typecheck (pull_request) Successful in 1m4s
CI / integration_tests (pull_request) Successful in 1m9s
CI / unit_tests (pull_request) Successful in 3m43s
CI / coverage (pull_request) Successful in 3m42s
CI / status-check (pull_request) Successful in 3s
CI / lint (push) Successful in 59s
CI / typecheck (push) Successful in 58s
CI / quality (push) Successful in 1m5s
CI / security (push) Successful in 1m9s
CI / build (push) Successful in 51s
CI / integration_tests (push) Successful in 1m40s
CI / unit_tests (push) Successful in 3m53s
CI / coverage (push) Successful in 3m35s
CI / status-check (push) Successful in 3s
Create Canonicalizer class implementing Package Registry Standard v1.0.0 §6:
- NFC normalization of all string values via unicodedata.normalize
- Lexicographic key sorting for deterministic output
- Lifecycle field stripping (version, release_date)
- RFC-8785 canonical JSON serialization (no whitespace, sorted keys)
- SHA-1 content-addressed hashing via compute_package_id()
- Internal reference resolution with configurable resolver callback

10 integration test cases covering:
- Complex content canonicalization with lifecycle stripping
- Deterministic output across multiple runs
- Key sorting enforcement
- Unicode NFC normalization
- PackageId computation for all 8 package types
- Different content produces different output

ISSUES CLOSED: #25
2026-06-10 11:33:50 +01:00
CoreRasurae 92d5305a20 feat(registry): implement async RegistryClient using httpx
CI / quality (pull_request) Successful in 38s
CI / lint (pull_request) Successful in 44s
CI / build (pull_request) Successful in 35s
CI / typecheck (pull_request) Successful in 1m11s
CI / security (pull_request) Successful in 1m8s
CI / integration_tests (pull_request) Successful in 1m8s
CI / unit_tests (pull_request) Successful in 3m35s
CI / coverage (pull_request) Failing after 3m49s
CI / status-check (pull_request) Failing after 3s
CI / lint (push) Successful in 41s
CI / security (push) Successful in 54s
CI / typecheck (push) Successful in 56s
CI / quality (push) Successful in 1m3s
CI / build (push) Successful in 42s
CI / integration_tests (push) Successful in 56s
CI / unit_tests (push) Successful in 3m38s
CI / coverage (push) Failing after 3m42s
CI / status-check (push) Failing after 3s
Add async RegistryClient implementing the Package Registry Standard
v1.0.0 HTTP API endpoints (§8) using httpx.AsyncClient.

- GET /packages/{id} — retrieve package content by PackageId
- GET /{type}/{ns}/{name}?version= — resolve references with
  version alias resolution (latest, vx, vX.Y.x, vX.x per §4.2)
- GET /browse — discover published packages with type/namespace filters
- GET /.well-known/cleverthis-packages — registry metadata discovery
- Maps all 8 standard error types (§13.2) to typed exceptions
- Supports anonymous reads (§9.1) and optional API key auth (§9.2)
- Async context manager support (__aenter__/__aexit__)
- 32 Behave BDD scenarios, 7 Robot Framework integration tests,
  ASV benchmarks, 100% registry module coverage

ISSUES CLOSED: #24
2026-06-05 22:01:21 +00:00
hurui200320 6b80be2117 feat(merge_configs): expose public merge_configs(*dicts) API per §3.1 deep-merge algorithm
CI / lint (pull_request) Successful in 42s
CI / integration_tests (pull_request) Successful in 49s
CI / quality (pull_request) Successful in 53s
CI / build (pull_request) Successful in 50s
CI / typecheck (pull_request) Successful in 54s
CI / security (pull_request) Successful in 1m12s
CI / unit_tests (pull_request) Successful in 3m53s
CI / coverage (pull_request) Successful in 3m50s
CI / status-check (pull_request) Successful in 3s
CI / lint (push) Successful in 43s
CI / quality (push) Successful in 46s
CI / security (push) Successful in 47s
CI / typecheck (push) Successful in 48s
CI / build (push) Successful in 50s
CI / integration_tests (push) Successful in 54s
CI / unit_tests (push) Successful in 3m49s
CI / coverage (push) Successful in 3m42s
CI / status-check (push) Successful in 3s
Implement a new module-level merge_configs() function in
src/cleveractors/config_utils.py that exposes the §3.1 deep-merge
algorithm as a public, importable API.

Motivation: The internal ReactiveConfigParser._merge_configs() method
mutates its base dict in place and only accepts two dicts. The
CleverThis router (wave 2 of cleveragents/cleveragents-webapp#275)
needs a public merge_configs() to combine platform base configs with
actor configs from the database without side-effects.

Implementation:
- merge_configs(*dicts) accumulates into a fresh dict, applying each
  overlay using the §3.1 rules:
    * Key absent → add via deep copy.
    * Both mappings → deep-merge recursively (_apply_merge helper).
    * Both sequences → extend (existing + deep copy of new).
    * Otherwise → replace with deep copy of new value.
- Runtime type guard: non-dict arguments raise TypeError immediately
  (fail-fast per CONTRIBUTING.md argument validation guidelines).
- Zero-argument call returns {}.
- Inputs are never mutated (copy.deepcopy used for all stored values).
- Internal _merge_configs on ReactiveConfigParser is unchanged.

Exports: merge_configs added to cleveractors/__init__.py import and
__all__ so consumers can use 'from cleveractors import merge_configs'.

Tests:
- 15 Behave BDD scenarios in features/merge_configs.feature covering
  zero-args, single-dict deep copy (including nested identity),
  empty-dict arguments, TypeError on None, absent-key insertion,
  scalar override, recursive mapping merge, sequence append,
  three-dict chained merge, deep nesting, input mutation guard,
  result-mutation independence from inputs, and type-mismatch
  replacement.
- 4 Robot Framework integration tests in robot/config.robot with
  strengthened assertions (len check, overlay immutability).
- 5 ASV benchmarks with realistically sized three-way merge fixtures
  (50 keys each with overlap).

Project files: Added CONTRIBUTORS.md per CONTRIBUTING.md §PR Process
rule 8.

Coverage: 97% (config_utils.py: 100%).
Quality gates: ruff lint ✓, pyright strict ✓ (0 errors),
all BDD/Robot tests ✓.

ISSUES CLOSED: #11
2026-06-03 14:44:18 +00:00
CoreRasurae 55ce2acfdf chore: Base repo structure commit 2026-05-26 21:45:54 +01:00