Skip to content

feat(docs): document WithPolicyFrom re-wrap helper#323

Open
marythought wants to merge 3 commits into
mainfrom
demo/docs-drift-with-policy-from
Open

feat(docs): document WithPolicyFrom re-wrap helper#323
marythought wants to merge 3 commits into
mainfrom
demo/docs-drift-with-policy-from

Conversation

@marythought
Copy link
Copy Markdown
Contributor

@marythought marythought commented May 18, 2026

Summary

Adds a tdf.mdx section for sdk.WithPolicyFrom, a new TDFOption builder that binds the source TDF's policy — its attribute value FQNs — to a new TDF being created. Targets re-wrap pipelines where the source policy should carry forward without callers handling the manifest's base64 + JSON encoding themselves.

Call site is a single line, matching the existing With* option-builder idiom:

if ok, _ := sdk.IsValidTdf(file); !ok {
    return // pass through unchanged
}
reader, err := client.LoadTDF(file)
if err != nil {
    return err
}
_, err = client.CreateTDF(out, transformed, sdk.WithPolicyFrom(reader))

Reader.Init is not required — DataAttributes reads the policy from the manifest, which LoadTDF has already populated.

Companion PR

Documents the function landing in opentdf/platform#3476. Draft until that PR merges — the example references a symbol that doesn't exist in the SDK yet.

How this was drafted

Generated by the docs-drift skill mining the function's godoc example block verbatim. No example code was invented; the snippet shown is exactly what the function's author wrote in the godoc.

Test plan

🤖 Generated with Claude Code

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@marythought has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 57 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 10d79aa4-3e71-4763-9845-0382dc27e219

📥 Commits

Reviewing files that changed from the base of the PR and between 5be45e2 and c6fc6c7.

📒 Files selected for processing (1)
  • docs/sdks/tdf.mdx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch demo/docs-drift-with-policy-from

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.

Copy link
Copy Markdown
Contributor

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

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 adds documentation for the WithPolicyFrom function in the Go SDK, which allows binding a source TDF's policy to a new TDF. Feedback was provided regarding an inconsistency in the documentation concerning the Init(ctx) requirement for Reader.DataAttributes. Additionally, the example code contains a logic error where a return statement is missing after a validation check, and the SDK client variable naming is inconsistent with the rest of the document.

Comment thread docs/sdks/tdf.mdx Outdated
Comment thread docs/sdks/tdf.mdx Outdated
@github-actions
Copy link
Copy Markdown
Contributor

❌ Surge preview build failed — no preview was deployed. Check the workflow logs for details.

Once the build passes, the preview will be at: https://opentdf-docs-pr-323.surge.sh

Common cause: If the build failed on vendored YAML validation, run the following locally and commit the result:

npm run update-vendored-yaml
git add specs/
git commit -m "chore(deps): update vendored OpenAPI specs"

@marythought marythought marked this pull request as ready for review May 20, 2026 18:36
@marythought marythought requested review from a team as code owners May 20, 2026 18:36
marythought and others added 2 commits May 20, 2026 11:36
Adds a tdf.mdx section for sdk.WithPolicyFrom, the option-builder helper
landing as part of DSPX-2603. The function returns a TDFOption that
binds the source TDF's policy (attribute FQNs) to a new TDF being
created — useful in re-wrap pipelines where the policy should carry
forward without callers handling base64+JSON manifest encoding.

Demo output of the /docs-drift skill — example block is mined verbatim
from the function's godoc, no inference. Section placed after IsValidTdf
since both are re-wrap-flavored helpers. Skill's name-only sniff
proposed a new with-policy-from.mdx file; placement overridden manually
to match the existing tdf.mdx structure.

Not for merge until the underlying sdk.WithPolicyFrom function lands in
opentdf/platform.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
- Reader.Init is not required; DataAttributes reads from the manifest
  which LoadTDF already populated. Calling Init triggers an unnecessary
  KAS rewrap.
- Add missing return after IsValidTdf check
- Add error handling for LoadTDF
- Use `client` instead of `s` for consistency with the rest of the page

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
@marythought marythought force-pushed the demo/docs-drift-with-policy-from branch from e8f0d10 to 18221fc Compare May 20, 2026 18:37
@github-actions
Copy link
Copy Markdown
Contributor

❌ Surge preview build failed — no preview was deployed. Check the workflow logs for details.

Once the build passes, the preview will be at: https://opentdf-docs-pr-323.surge.sh

Common cause: If the build failed on vendored YAML validation, run the following locally and commit the result:

npm run update-vendored-yaml
git add specs/
git commit -m "chore(deps): update vendored OpenAPI specs"

@github-actions
Copy link
Copy Markdown
Contributor

❌ Surge preview build failed — no preview was deployed. Check the workflow logs for details.

Once the build passes, the preview will be at: https://opentdf-docs-pr-323.surge.sh

Common cause: If the build failed on vendored YAML validation, run the following locally and commit the result:

npm run update-vendored-yaml
git add specs/
git commit -m "chore(deps): update vendored OpenAPI specs"

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

2 participants