Implement ADR 0021 so any external-data success is evidence-backed, source-attributable, and evolution-friendly without violating ADR 0017 (no semantic coercion).
This plan preserves project tenets:
- Agent-first mental model.
- Tolerant interfaces by default.
- Runtime ergonomics and clarity over hidden compensation.
- Ubiquitous language aligned to Tool Builder / Tool / Worker cognition.
In scope:
- Provenance envelope contract for external-data
Outcome.ok. - Prompt and contract guidance for provenance authoring.
- Recoverable guardrail enforcement for missing provenance in external-data success paths.
- Compact provenance references in conversation history.
- Observability and health scoring signals for provenance quality.
- Acceptance tests and trace validation workflow.
Out of scope:
- Browser-render/JS execution support.
- Domain-specific parsers (movies/news/recipes) as architecture policy.
- Runtime semantic coercion of emitted outcomes.
What already exists:
- Validation-first fresh generation and guardrail retry lanes (ADR 0016).
- Outcome boundary contract validation (ADR 0014).
- Observational runtime utility semantics (ADR 0017).
- Structured conversation history with canonical schema (ADR 0019).
Observed gaps:
- External-data tools can return
Outcome.okwith weak or missing source evidence. - Follow-up source questions can fail due to absent provenance in history summaries.
- Artifact health can over-report reliability when fallback data is returned as success.
- Provenance enforcement must be a validation/guardrail invariant, not runtime success->error rewriting.
- Guardrail detection for external-data behavior must be conservative and inspectable in v1.
- Provenance schema must remain generic across domains.
- Conversation history must remain compact (ADR 0019 context-capacity constraints).
- Rollout must tolerate legacy artifacts and converge through repair.
Deliver in six phases. Each phase is independently testable and shippable.
Goals:
- Finalize the v1 provenance field profile.
- Define strict vs staged-required fields.
Implementation:
- Define required fields for external-data success:
provenance.sources(array, min 1)provenance.sources[].uriprovenance.sources[].fetched_atprovenance.sources[].retrieval_toolprovenance.sources[].retrieval_mode(live|cached|fixture)
- Mark
content_fingerprintoptional in v1. - Define tolerant key-equivalence semantics (string/symbol).
- Document acceptance assertion style for freshness:
retrieval_mode is livefor freshness-critical flows.
Suggested files:
docs/adrs/0021-external-data-provenance-invariant.mddocs/product-specs/delegation-contracts.mddocs/tolerant-delegation-interfaces.md
Exit criteria:
- Provenance profile documented and unambiguous.
- Required vs optional fields are explicit.
Goals:
- Make provenance the default authoring behavior for external-data tools.
- Reduce shape mistakes in generated code.
Implementation:
- Update system prompt guidance:
- external-data
Outcome.okmust include provenance. context[:tools]registry shape remains explicit.
- external-data
- Add/refresh user prompt examples:
- successful external fetch returning
data + provenance. - fallback path returning typed
low_utilitywith reason.
- successful external fetch returning
- Add self-check lines:
- "Did I include provenance for external-data success?"
- Keep examples domain-generic.
Suggested files:
Exit criteria:
- Prompt text contains provenance invariant and example patterns.
- Prompt tests cover provenance guidance presence.
Goals:
- Block fabricated external-data success in hot path.
- Route violations through existing regeneration lanes.
Implementation:
- Add/extend generated-code policy checks for missing provenance in external-data success flows.
- Keep detector conservative in v1:
- explicit
tool("web_fetcher")/ delegate-fetch patterns, - explicit
net/http,Net::HTTP, concretehttp(s)://usage.
- explicit
- On violation:
- raise recoverable guardrail (
tool_registry_violationlane in current taxonomy), - inject targeted correction hint in retry feedback.
- raise recoverable guardrail (
- Ensure checks run for both fresh and persisted artifact execution paths.
Suggested files:
runtimes/ruby/lib/recurgent/guardrail_policy.rbruntimes/ruby/lib/recurgent/guardrail_code_checks.rbruntimes/ruby/lib/recurgent/call_execution.rbruntimes/ruby/lib/recurgent/persisted_execution.rbruntimes/ruby/spec/recurgent_spec.rb
Exit criteria:
- External-data
okwithout provenance cannot pass execution. - Recovery on next regeneration is demonstrated in tests.
Goals:
- Let Tool Builders express provenance expectations as machine-checkable deliverables.
- Keep enforcement deterministic.
Implementation:
- Extend deliverable-constraint validation for nested provenance keys where needed.
- Add reusable helpers for:
- required nested keys (
provenance.sources) - enum validation (
retrieval_modein allowed set) - min items on source list.
- required nested keys (
- Preserve tolerant key semantics at boundary.
- On mismatch, return typed
contract_violationwith precise metadata.
Suggested files:
runtimes/ruby/lib/recurgent/outcome_contract_validator.rbruntimes/ruby/lib/recurgent/outcome_contract_shapes.rbruntimes/ruby/lib/recurgent/outcome_contract_constraints.rbruntimes/ruby/spec/recurgent_spec.rb
Exit criteria:
- Provenance contract constraints are enforceable via existing validator path.
- Contract violations include actionable mismatch metadata.
Goals:
- Make "what's the source?" answerable from history.
- Keep history records lightweight.
Implementation:
- Extend appended
outcome_summaryfor external-data calls with compact provenance refs:source_countprimary_uriretrieval_mode
- Do not embed full source arrays in history.
- Keep full provenance in logs/artifacts only.
- Add canonical history query hints in prompts where needed.
Suggested files:
runtimes/ruby/lib/recurgent/conversation_history.rbruntimes/ruby/lib/recurgent/conversation_history_normalization.rbruntimes/ruby/lib/recurgent/prompting.rbruntimes/ruby/spec/recurgent_spec.rb
Exit criteria:
- Source follow-up queries can recover compact source info from history.
- History payload growth remains bounded.
Goals:
- Turn provenance completeness into measurable reliability signals.
- Improve artifact evolution pressure.
Implementation:
- Log provenance completeness flags and retrieval_mode distribution in JSONL entries.
- Add artifact metrics for:
- missing-provenance guardrail failures,
- fixture-heavy success patterns,
- cached-only behavior in freshness-critical tools.
- Feed signals into maintenance recommendations (out-of-band lane).
Suggested files:
runtimes/ruby/lib/recurgent/observability.rbruntimes/ruby/lib/recurgent/artifact_metrics.rbruntimes/ruby/lib/recurgent/tool_maintenance.rbdocs/observability.md
Exit criteria:
- Provenance quality is visible in logs and maintenance outputs.
- Repeated weak provenance patterns influence evolution priority.
Goals:
- Prove end-to-end behavior under real assistant traces.
- Roll out safely without breaking forward progress.
Implementation:
- Add acceptance scenarios:
- external fetch success with provenance present,
- hardcoded fallback
okblocked and repaired, - source follow-up answered from compact history refs.
- Capture before/after traces for:
- movies query + source follow-up,
- at least one additional non-movie external-data domain.
- Rollout:
- start with guardrail enabled in debug-first workflows,
- monitor false-positive rate,
- promote to default once stable.
Suggested files:
runtimes/ruby/spec/acceptance/recurgent_acceptance_spec.rbdocs/baselines/<date>/fixturesdocs/architecture.md(flow update)
Exit criteria:
- Acceptance suite verifies provenance invariant end-to-end.
- Trace review confirms fabricated-success suppression and source explainability.
Acceptance matrix (required):
- Existing-tool lane (repair path evidence):
- Domain: news (Google/Yahoo/NYT sequence).
- Expectation: at least one legacy call initially violates provenance invariant, guardrail triggers recoverable retry/repair, final outcome is provenance-compliant.
- Fresh-forge lane (prevention path evidence):
- Domain: newly forged external-data tool (prefer weather or recipes).
- Expectation: first successful external-data outcome already includes provenance (no guardrail repair required).
Pass criteria by lane:
- Repair path:
- violation detected deterministically,
- retry/repair converges within configured budget,
- final success includes required provenance fields.
- Prevention path:
- external-data success includes required provenance on first pass,
- no provenance guardrail violation occurs in that flow.
External-data success payload target shape:
{
"data": "<domain payload>",
"provenance": {
"sources": [
{
"uri": "https://example.com/feed",
"fetched_at": "2026-02-16T00:00:00Z",
"retrieval_tool": "web_fetcher",
"retrieval_mode": "live",
"content_fingerprint": "sha256:..."
}
],
"extraction_tool": "rss_parser",
"extracted_at": "2026-02-16T00:00:01Z"
}
}Rules:
content_fingerprintoptional in v1.retrieval_moderequired for each source.- Symbol/string key variants are tolerated at boundary.
Unit tests:
- Guardrail catches missing provenance in explicit fetch-like success paths.
- Guardrail recovery can regenerate compliant code within budget.
- Contract validator enforces provenance constraints and enum checks.
- History appender stores compact provenance refs only.
Integration tests:
- Assistant flow can answer "what's the source?" from history after external-data response.
- Persisted artifacts with legacy non-provenance success paths are repaired before success.
Acceptance tests:
- Movie/news/recipe-style query returns external-data result with provenance.
- Guidance-only or hardcoded fallback paths become typed failures, not success.
- Existing-tool lane demonstrates guardrail+repair provenance convergence.
- Fresh-forge lane demonstrates provenance-first generation without repair.
Risk 1: false positives from fetch-like detector.
Mitigation: conservative detector scope in v1 + trace review before widening.
Risk 2: legacy persisted artifacts fail guardrails frequently.
Mitigation: rely on existing repair lanes and staged rollout with observability.
Risk 3: provenance bloat in context/history.
Mitigation: compact history refs; keep full provenance only in logs/artifacts.
- ADR 0021 accepted and indexed.
- Prompt guidance includes provenance invariant and examples.
- Guardrail enforcement active for fresh + persisted execution paths.
- Provenance constraints validated at delegated outcome boundary.
- Conversation history stores compact provenance refs.
- Observability exposes provenance quality signals.
- Acceptance traces demonstrate source explainability and fabricated-success suppression.