Implement ADR 0017 so utility quality pressure is agent-visible and contract-driven, while runtime remains observational for semantics.
Target outcome:
- Runtime does not rewrite Tool-authored success into failure.
- Inline utility failures are enforced through machine-checkable contract constraints.
- Weak-success drift is captured as telemetry and pushed into out-of-band evolution loops.
This plan explicitly follows project tenets:
- Agent-first mental model:
- Tool Builders own contract quality.
- Tools own truthful success/failure semantics.
- Tolerant interfaces by default:
- Keep symbol/string key equivalence and tolerant shape canonicalization.
- Add explicit constraints only where utility quality must fail fast.
- Runtime ergonomics and clarity:
- Runtime enforces deterministic contract checks.
- Runtime does not silently reinterpret Tool intent.
- Ubiquitous language:
- Tool Builder forges enforceable contracts.
- Tool succeeds meaningfully or fails honestly.
- Worker executes.
In scope:
- Remove runtime semantic coercion (
ok->low_utilityby status string). - Add enforceable utility constraints under
deliverablevalidation. - Preserve and strengthen Tool-authored
low_utility/wrong_tool_boundarypath. - Add weak-success telemetry as observational signals.
- Feed signals into out-of-band maintenance/evolution recommendations.
- Update docs and tests to reflect new contract-first quality model.
Out of scope:
- Runtime-autonomous tool splitting/decomposition.
- Domain-specific hardcoded scraping policies.
- Lua parity work.
Implemented already:
- ADR 0014 delegated outcome boundary validation (shape/required keys + tolerant key semantics).
- ADR 0015 typed outcomes (
low_utility,wrong_tool_boundary) as vocabulary. - ADR 0016 validation-first fresh-call lifecycle and retry mechanisms.
- Prompt nudges for Tool self-evaluation and Outcome API usage.
Gap to close:
- Runtime currently includes a semantic coercion path for weak success strings.
acceptanceprose is not machine-checkable at runtime.- Weak-success telemetry is not yet first-class in out-of-band evolution scoring.
Goals:
- Lock current behavior with baseline traces.
- Define migration guardrails before runtime behavior shift.
Implementation:
- Capture baseline traces for:
- movie scenario (weak success/no parse),
- Google/Yahoo/NYT sequence,
- one deterministic non-open-world scenario (control).
- Add feature marker in code comments for ADR 0017 path boundaries.
- Ensure debug logs expose enough fields to compare pre/post behavior.
Exit criteria:
- Baseline artifacts and traces documented.
- No ambiguity about expected post-change differences.
Goals:
- Runtime no longer rewrites Tool-authored success intent.
Implementation:
- Remove weak-status
Outcome.ok->Outcome.error(low_utility)conversion from boundary validator. - Keep shape validation and tolerant canonicalization untouched.
- Update/replace tests that depended on coercion behavior.
Key files:
Exit criteria:
- No code path performs semantic success->error rewriting.
- Test suite passes with updated expectations.
Goals:
- Move inline utility failure pressure into deterministic contract checks.
Implementation (v1 constraint set):
- Add minimal machine-checkable deliverable constraints:
- array:
min_items - object: per-field constraints for required keys where value is an array (
min_items)
- array:
- Keep constraints optional and backward-compatible.
- On violation, return typed
contract_violationwith metadata:mismatch,- expected vs actual shape/value summary,
- failing key/path.
Suggested schema shape (v1):
deliverable:
type: object
required: [status, movies]
constraints:
properties:
movies:
type: array
min_items: 1Key files:
runtimes/ruby/lib/recurgent/outcome_contract_shapes.rbruntimes/ruby/lib/recurgent/outcome_contract_validator.rbruntimes/ruby/spec/recurgent_spec.rb
Exit criteria:
- Empty result arrays fail only when contract says so.
- Violations are deterministic, typed, and repair-visible.
Goals:
- Teach Tool Builders to express utility requirements in enforceable contracts.
- Keep
acceptanceas explanatory intent, not runtime-enforced logic.
Implementation:
- Update prompt guidance:
- “If utility must fail inline, encode as deliverable constraints.”
- Add contract examples in prompts/docs showing
min_itemsusage. - Keep nudge for Tool-authored
low_utility/wrong_tool_boundaryon open-world uncertainty.
Key files:
runtimes/ruby/lib/recurgent/prompting.rbdocs/product-specs/delegation-contracts.mddocs/tolerant-delegation-interfaces.md(if needed for examples)
Exit criteria:
- Prompt examples align with runtime-enforceable contract model.
- Docs clearly separate enforceable constraints vs prose acceptance.
Goals:
- Detect weak-success patterns without mutating outcome semantics.
Implementation:
- Add observational weak-success flags in call telemetry when heuristics match (for example
success_no_parse, empty arrays under “success” statuses). - Record as separate telemetry fields; do not alter status/outcome.
- Link weak-success events with
user_correctionwhen available.
Key files:
runtimes/ruby/lib/recurgent/observability.rbruntimes/ruby/lib/recurgent/pattern_memory_store.rbruntimes/ruby/lib/recurgent/user_correction_signals.rb
Exit criteria:
- Weak-success is queryable in logs and pattern memory.
- Outcome semantics remain Tool-authored.
Goals:
- Convert repeated weak-success + correction evidence into Tool Builder pressure.
Implementation:
- Extend maintenance/evaluator flow to score:
- weak-success frequency,
- correction-linked weak-success,
- boundary referral counts.
- Emit recommendations:
- strengthen contract constraints,
- re-forge implementation,
- split boundary when repeated
wrong_tool_boundary.
- Keep recommendations advisory (no autonomous runtime mutation).
Key files:
runtimes/ruby/lib/recurgent/tool_maintenance.rbbin/recurgent-tools(if CLI output surface is expanded)docs/observability.md
Exit criteria:
- Repeated weak-success contributes to evolution recommendations.
- Recommendation output is inspectable and deterministic.
Goals:
- Validate behavior end-to-end in real scenarios.
- Tune constraint strictness and telemetry signals.
Implementation:
- Run acceptance traces:
- Google/Yahoo/NYT,
- movie scenario with follow-up ask,
- non-open-world control tasks.
- Compare before/after:
- fewer silent compensations,
- clearer typed failures from contracts,
- stronger evolution signals out-of-band.
- Tune thresholds where needed (weak-success heuristics and recommendation scoring).
Exit criteria:
- Reliability remains stable.
- Emergent adaptation loop is clearer and more explicit.
Unit tests:
- Deliverable constraint validator (
min_items, missing path, wrong type). - Boundary validator does not coerce semantic success.
- Telemetry flags weak-success without status mutation.
Integration tests:
- Contract violation for empty movie list when
min_items: 1. - Persisted repair path triggers on contract-driven failure.
- Repeated weak-success + re-ask produces evolution signal.
Regression tests:
- Existing tolerant key equivalence remains intact.
- Existing guardrail retry and fresh execution repair flow remains intact.
Manual acceptance:
examples/assistant.rbmovie scenario.- Google/Yahoo/NYT scenario with trace analysis.
- Existing contracts without constraints remain valid and unchanged.
- No artifact key changes required.
- Behavior changes only when:
- explicit constraints are present, or
- telemetry/evaluator consumers use new weak-success fields.
- Risk: over-strict constraints produce false failures.
- Mitigation: start with minimal constraint vocabulary and conservative defaults.
- Risk: weak-success heuristics become noisy.
- Mitigation: keep observational-only, calibrate against user-correction links.
- Risk: prompt/docs drift from runtime enforcement.
- Mitigation: add contract examples tied to validator tests.
- Runtime semantic coercion removed.
- Deliverable utility constraints implemented (
min_itemsv1). - Prompt guidance updated to contract-first utility enforcement.
- Weak-success telemetry fields implemented.
- Out-of-band evaluator consumes weak-success + correction signals.
- Unit/integration/regression tests passing.
- Documentation updated (ADR index, docs index, contracts guidance).