Skip to content

feat(docs): document TDF assertions in SDK docs#268

Merged
marythought merged 7 commits into
mainfrom
docs/dspx-2624-assertions-polish
Apr 3, 2026
Merged

feat(docs): document TDF assertions in SDK docs#268
marythought merged 7 commits into
mainfrom
docs/dspx-2624-assertions-polish

Conversation

@marythought

@marythought marythought commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add comprehensive Assertions section to docs/sdks/tdf.mdx covering types, scopes, AppliesToState, statements, signing/verification, and end-to-end examples in Go/Java/JS
  • Document System Metadata Assertions (WithSystemMetadataAssertion) — available in all three SDKs (Go, Java, JS)
  • Add type reference entries for AssertionConfig, Assertion, Statement, AssertionKey, and AssertionVerificationKeys
  • Add WithSystemMetadataAssertion to the encrypt options reference
  • Fix Go scope constant in encrypt options examples: sdk.TrustedDataObjsdk.TrustedDataObjScope

Test plan

  • npm run build passes with no new broken anchors
  • Surge preview renders correctly

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added an Assertions section describing assertion categories, scopes, statement structure, and processing timing.
    • Documented a System Metadata Assertion with its fixed identifiers, schema, type, scope, state, and default signing behavior; explained how to enable it in supported SDKs.
    • Added end-to-end assertion examples showing creation, signing, and verification during decrypt/read.
    • Updated navigation and type reference to include assertion-related types.

Add comprehensive assertions section to tdf.mdx covering types, scopes,
AppliesToState, statements, signing/verification, system metadata
assertions, and end-to-end examples in Go/Java/JS. Add type reference
entries for AssertionConfig, Assertion, Statement, AssertionKey, and
AssertionVerificationKeys. Add WithSystemMetadataAssertion to encrypt
options. Fix Go scope constant (TrustedDataObj → TrustedDataObjScope).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
@marythought
marythought requested review from a team as code owners March 31, 2026 17:37
@coderabbitai

coderabbitai Bot commented Mar 31, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Added documentation and cross-language examples for TDF Assertions, renamed several Encrypt Options headings, updated Go assertion examples to use TrustedDataObjScope, and introduced a System Metadata Assertion with fixed ID/schema/type/scope/state and usage snippets for Go, Java, and JavaScript.

Changes

Cohort / File(s) Summary
Encrypt Options docs
code_samples/tdf/encrypt_options.mdx
Renamed section headings to option-style names (WithDataAttributes, WithMetadata, WithAssertions), updated Go assertion example to use sdk.TrustedDataObjScope (including SigningKey variant), and added a "System Metadata Assertion" section with Go sdk.WithSystemMetadataAssertion(), Java Config.withSystemMetadataAssertion(), and JS .withSystemMetadataAssertion(true) plus documented fixed ID/schema/type/scope/state and default DEK-bound HS256.
TDF SDK docs
docs/sdks/tdf.mdx
Added an "Assertions" section describing assertion categories (HandlingAssertion, BaseAssertion), scopes (TrustedDataObjScope, PayloadScope), processing timing (Encrypted, Unencrypted), Statement structure (Format/Schema/Value), signing/verification behavior (DEK-bound HS256 default; optional RS256 with decrypt-time public keys), TOC updates, and Type Reference entries (AssertionConfig, Assertion, Statement (type), AssertionKey, AssertionVerificationKeys).
New code samples
code_samples/tdf/assertion_examples.mdx
New examples page with two workflows: (1) System Metadata Assertion — enabling in Go/Java/JS and sample JSON payload plus config inspection (Go); (2) End-to-end Handling Assertion — encrypt-time RSA signing and decrypt-time verification with matching public keys across Go/Java/JS, showing where verification failures surface and how to access assertions in loaded manifests.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • eugenioenko
  • elizabethhealy

Poem

🐰 I hop through docs with a tiny drum,

System metadata joins the TDF hum,
Go, Java, JS all learn to say "attach",
Assertions snug in every batch,
A rabbit winks — the examples come!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding documentation for TDF assertions across SDK docs, which is the primary focus of all three file modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/dspx-2624-assertions-polish

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive documentation for TDF Assertions, covering types, scopes, signing mechanisms, and system metadata assertions across Go, Java, and JavaScript SDKs. The review feedback points out naming inconsistencies for the "TrustedDataObjScope" constant and the "state" property in the newly added code examples and descriptions, which should be corrected for cross-SDK consistency.

Comment thread docs/sdks/tdf.mdx Outdated
Comment thread docs/sdks/tdf.mdx Outdated
Comment thread docs/sdks/tdf.mdx Outdated
@github-actions

Copy link
Copy Markdown
Contributor

📄 Preview deployed to https://opentdf-docs-pr-268.surge.sh

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
code_samples/tdf/encrypt_options.mdx (1)

551-555: Consider making the JS system-metadata snippet directly executable.

This snippet currently only builds params. A short client.createTDF(...) usage line here would match the rest of this page’s pattern and improve copy/paste usability.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@code_samples/tdf/encrypt_options.mdx` around lines 551 - 555, The snippet
only constructs EncryptParams via EncryptParamsBuilder; update it to show an
executable example by invoking the SDK's createTDF call with those params (e.g.,
call client.createTDF(encryptParams) or the equivalent async method) so readers
can copy-paste a complete encrypt flow; reference the EncryptParamsBuilder usage
and the client.createTDF (or SDK method name) to insert a single-line call after
.build() demonstrating invocation and handling of the returned TDF.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/sdks/tdf.mdx`:
- Around line 1191-1428: The docs page contains large inline language-specific
examples (the Go block using rsa.GenerateKey and client.CreateTDF, the Java
block building AssertionConfig and Config.newTDFConfig, and the JS block calling
client.createTDF/client.read and EncryptParamsBuilder) that should be moved into
separate files under code_samples and referenced from this MDX; extract each
long example into a single source file per language, replace the inline fenced
code with an MDX include/reference to the corresponding sample, and update the
surrounding text to reference the samples (preserving IDs like "handling-1",
assertion field names, and the call sites client.CreateTDF,
sdk.GetSystemMetadataAssertionConfig, Config.newTDFConfig, and client.createTDF)
so the docs no longer duplicate large blocks and remain maintainable.

---

Nitpick comments:
In `@code_samples/tdf/encrypt_options.mdx`:
- Around line 551-555: The snippet only constructs EncryptParams via
EncryptParamsBuilder; update it to show an executable example by invoking the
SDK's createTDF call with those params (e.g., call
client.createTDF(encryptParams) or the equivalent async method) so readers can
copy-paste a complete encrypt flow; reference the EncryptParamsBuilder usage and
the client.createTDF (or SDK method name) to insert a single-line call after
.build() demonstrating invocation and handling of the returned TDF.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 56051994-8734-44bf-90d6-f1cd69c339d0

📥 Commits

Reviewing files that changed from the base of the PR and between 70d68f6 and 78a0b92.

📒 Files selected for processing (2)
  • code_samples/tdf/encrypt_options.mdx
  • docs/sdks/tdf.mdx

Comment thread docs/sdks/tdf.mdx Outdated
marythought and others added 2 commits March 31, 2026 10:44
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
Move system metadata and end-to-end assertion examples from inline
tdf.mdx into code_samples/tdf/assertion_examples.mdx, following the
repo convention for long code examples.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
code_samples/tdf/assertion_examples.mdx (1)

20-28: Complete the Go customization flow to avoid a dead-end snippet.

This block says “before passing it to WithAssertions” but does not show that final call, so the example currently stops short of the intended usage.

Suggested doc snippet update
 cfg, err := sdk.GetSystemMetadataAssertionConfig()
+if err != nil {
+    log.Fatal(err)
+}
 // cfg.Statement.Value contains JSON like:
 // {"tdf_spec_version":"4.3.0","creation_date":"2026-03-31T12:00:00Z",
 //  "operating_system":"linux","sdk_version":"Go-0.3.4",
 //  "go_version":"go1.23.0","architecture":"amd64"}
+
+// Optionally customize cfg.Statement.Value here, then pass it to WithAssertions:
+_, err = client.CreateTDF(&buf, plaintext,
+    sdk.WithKasInformation(sdk.KASInfo{URL: kasURL}),
+    sdk.WithAssertions(cfg),
+)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@code_samples/tdf/assertion_examples.mdx` around lines 20 - 28, The example
stops before showing how to pass the inspected/modified config to
WithAssertions; update the snippet to show retrieving cfg via
GetSystemMetadataAssertionConfig, optionally mutating cfg.Statement.Value (or
other fields) as needed, then calling WithAssertions(cfg) when building your
assertion pipeline so readers see the full flow (use the existing symbols
GetSystemMetadataAssertionConfig, cfg.Statement.Value and WithAssertions to
locate where to add the final call).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@code_samples/tdf/assertion_examples.mdx`:
- Around line 20-28: The example stops before showing how to pass the
inspected/modified config to WithAssertions; update the snippet to show
retrieving cfg via GetSystemMetadataAssertionConfig, optionally mutating
cfg.Statement.Value (or other fields) as needed, then calling
WithAssertions(cfg) when building your assertion pipeline so readers see the
full flow (use the existing symbols GetSystemMetadataAssertionConfig,
cfg.Statement.Value and WithAssertions to locate where to add the final call).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 238ceb37-bb50-4446-b0f1-f9307b2861fa

📥 Commits

Reviewing files that changed from the base of the PR and between 5754b11 and ef09e21.

📒 Files selected for processing (2)
  • code_samples/tdf/assertion_examples.mdx
  • docs/sdks/tdf.mdx
✅ Files skipped from review due to trivial changes (1)
  • docs/sdks/tdf.mdx

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
elizabethhealy
elizabethhealy previously approved these changes Apr 3, 2026

@elizabethhealy elizabethhealy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! i think a second review from @pflynn-virtru or @sujankota would be helpful as they know a lot more about assertions

pflynn-virtru
pflynn-virtru previously approved these changes Apr 3, 2026
…nflict

The encrypt options "Assertions" header produced the same #assertions
anchor as the main Assertions section, causing TOC links to jump to
the wrong spot. Renamed to "WithAssertions" to match the SDK option
name and avoid the duplicate anchor.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Documents the naming convention for code_samples headers to avoid
duplicate anchors when imported into doc pages. References #273 for
planned CI enforcement.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
pflynn-virtru
pflynn-virtru previously approved these changes Apr 3, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@marythought
marythought merged commit c8f780c into main Apr 3, 2026
9 checks passed
@marythought
marythought deleted the docs/dspx-2624-assertions-polish branch April 3, 2026 16:44
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.

3 participants