Skip to content

feat: document embeds Phase 1 — parser, renderers, CLI, provenance#95

Merged
avrabe merged 7 commits intomainfrom
feat/document-embeds-phase1
Apr 1, 2026
Merged

feat: document embeds Phase 1 — parser, renderers, CLI, provenance#95
avrabe merged 7 commits intomainfrom
feat/document-embeds-phase1

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 1, 2026

Summary

Completes Document Embeds Phase 1 (issue #91) — the unified EmbedRequest architecture for computed data embeds in documents.

  • EmbedRequest parser: parses {{name:arg1:arg2 key=val}} syntax with positional args and key=value options
  • Stats & coverage renderers: {{stats}}, {{stats:types}}, {{coverage}}, {{coverage:rule-name}} embeds produce HTML tables
  • render_to_html refactor: added embed_resolver closure parameter so each caller (serve, export, CLI) can provide its own resolution context
  • rivet embed CLI command: rivet embed "stats:types" for scripting and terminal-friendly output
  • Export provenance stamps (SC-EMBED-4): every computed embed in HTML export includes commit hash + timestamp footer
  • Dirty-tree warning (SC-EMBED-1): rivet export --format html warns on stderr when working tree has uncommitted changes

Safety constraints satisfied

Constraint Mechanism
SC-EMBED-1 cmd_export_html() checks git.is_dirty, prints stderr warning
SC-EMBED-3 EmbedError::to_error_html() renders visible <span class="embed-error">, never empty string
SC-EMBED-4 render_provenance_stamp() appended to every computed embed in export

Test coverage

  • 17 new unit tests (parser, renderers, provenance, edge cases, backward compat)
  • 3 CLI integration tests (rivet embed command)
  • 2 serve integration tests (no embed errors, stats API)
  • 2 Playwright E2E tests (no embed-error spans, stats table rendering)

Closes #91.

Test plan

  • cargo test --workspace — all ~580 tests pass
  • cargo clippy --all-targets -- -D warnings — clean
  • CI checks (Playwright E2E, mutation testing, Miri, etc.)

🤖 Generated with Claude Code

Test and others added 7 commits April 1, 2026 16:36
Introduces rivet-core::embed module with EmbedRequest::parse() for
unified {{name:arg key=val}} syntax. EmbedError renders visible HTML
per SC-EMBED-3.

Refs: FEAT-074
Implements render_stats() and render_coverage() in the embed module,
dispatched via resolve_embed(). Renders HTML tables with type counts,
status groups, validation summary, and per-rule coverage percentages.

Refs: FEAT-074
Thread embed_resolver through render_to_html → resolve_inline.
Legacy embeds (artifact/links/table) keep inline logic. New computed
embeds (stats/coverage) dispatch through the closure. All call sites
updated.

Refs: FEAT-074
Resolves embed queries (stats, coverage) from CLI with text or HTML
output. Useful for scripting and testing embed resolution.

3 integration tests: stats:types, coverage, unknown embed error.
Computed embeds in exported documents now include a provenance footer
with commit hash and timestamp (SC-EMBED-4). Export warns on stderr
when the working tree is dirty (SC-EMBED-1).

Satisfies: SC-EMBED-1, SC-EMBED-4
Adds integration tests for embed resolution in serve and CLI,
plus parser edge-case unit tests for backward compatibility with
existing artifact/links/table embed syntax. Playwright tests verify
no embed-error spans appear in rendered documents.

Verifies: SC-EMBED-3
Add #[allow(clippy::too_many_arguments)] for export functions and
remove needless borrow in documents embed resolver.
@avrabe avrabe merged commit ca97dd9 into main Apr 1, 2026
12 of 13 checks passed
@avrabe avrabe deleted the feat/document-embeds-phase1 branch April 1, 2026 21:04
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 79.12621% with 86 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rivet-core/src/embed.rs 80.36% 64 Missing ⚠️
rivet-core/src/export.rs 50.00% 12 Missing ⚠️
rivet-core/src/document.rs 83.87% 10 Missing ⚠️

📢 Thoughts on this report? Let us know!

avrabe added a commit that referenced this pull request Apr 21, 2026
Addresses three gaps found in the post-v0.4.0 dogfooding audit.

**v0.4.0 shipped-work artifacts** — `artifacts/v040-features.yaml` was
last touched 2026-04-12 and describes variant/PLE work (FEAT-106..114),
not the verification pyramid that actually shipped on 2026-04-19. New
file `artifacts/v040-verification.yaml` authors 4 design decisions
(DD-052 four-layer verification pyramid, DD-053 suffix-based
yaml-section matching, DD-054 non-blocking framing for formal CI
jobs, DD-055 cfg-gate platform syscalls), 8 features
(FEAT-115..122 covering Kani 27-harness expansion, differential YAML
tests, operation-sequence proptest, STPA-Sec suite, suffix-based UCA
extraction, nested control-action extraction, Zola export, Windows
support), and 1 requirement (REQ-060 cross-platform binaries).
Counts were verified against the actual codebase — 27 `#[kani::proof]`
attrs in proofs.rs, 6 differential tests, 16 STPA-Sec tests.

**Retroactive trailer map** — extended `AGENTS.md` with three more
legacy orphans (51f2054 #126, f958a7e, 75521b8 #44), a new v0.4.0
PR-level section for #150/#151/#152/#153, and an honest
"genuinely-unmappable" section calling out `ca97dd9f` (#95) whose
`SC-EMBED-*` trailers point to artifacts that were never authored.

**Verus Proofs → hard gate** — rules_verus PR #21 (merged as
5bc96f39) fixes the hub-repo's ambiguous `:all` alias by emitting
proper `toolchain()` wrappers per platform. Updates the git_override
pin from e2c1600a (Feb 2026, broken) to 5bc96f39 and removes
`continue-on-error: true` from the Verus job.

Implements: REQ-030, REQ-060
Refs: DD-052, DD-053, DD-054, DD-055, FEAT-115, FEAT-116, FEAT-117, FEAT-118, FEAT-119, FEAT-120, FEAT-121, FEAT-122
Verifies: REQ-030
avrabe added a commit that referenced this pull request Apr 21, 2026
Addresses three gaps found in the post-v0.4.0 dogfooding audit.

**v0.4.0 shipped-work artifacts** — `artifacts/v040-features.yaml` was
last touched 2026-04-12 and describes variant/PLE work (FEAT-106..114),
not the verification pyramid that actually shipped on 2026-04-19. New
file `artifacts/v040-verification.yaml` authors 4 design decisions
(DD-052 four-layer verification pyramid, DD-053 suffix-based
yaml-section matching, DD-054 non-blocking framing for formal CI
jobs, DD-055 cfg-gate platform syscalls), 8 features
(FEAT-115..122 covering Kani 27-harness expansion, differential YAML
tests, operation-sequence proptest, STPA-Sec suite, suffix-based UCA
extraction, nested control-action extraction, Zola export, Windows
support), and 1 requirement (REQ-060 cross-platform binaries).
Counts were verified against the actual codebase — 27 `#[kani::proof]`
attrs in proofs.rs, 6 differential tests, 16 STPA-Sec tests.

**Retroactive trailer map** — extended `AGENTS.md` with three more
legacy orphans (51f2054 #126, f958a7e, 75521b8 #44), a new v0.4.0
PR-level section for #150/#151/#152/#153, and an honest
"genuinely-unmappable" section calling out `ca97dd9f` (#95) whose
`SC-EMBED-*` trailers point to artifacts that were never authored.

**Verus Proofs → hard gate** — rules_verus PR #21 (merged as
5bc96f39) fixes the hub-repo's ambiguous `:all` alias by emitting
proper `toolchain()` wrappers per platform. Updates the git_override
pin from e2c1600a (Feb 2026, broken) to 5bc96f39 and removes
`continue-on-error: true` from the Verus job.

Implements: REQ-030, REQ-060
Refs: DD-052, DD-053, DD-054, DD-055, FEAT-115, FEAT-116, FEAT-117, FEAT-118, FEAT-119, FEAT-120, FEAT-121, FEAT-122
Verifies: REQ-030
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document embeds Phase 1: finish Tasks 4-6

1 participant