Skip to content

[DSPX-3302] (2/5) Manage platform service + install scenario in otdf-sdk-mgr#451

Draft
dmihalcik-virtru wants to merge 1 commit into
DSPX-3302-01-shared-schemafrom
DSPX-3302-02-platform-installer
Draft

[DSPX-3302] (2/5) Manage platform service + install scenario in otdf-sdk-mgr#451
dmihalcik-virtru wants to merge 1 commit into
DSPX-3302-01-shared-schemafrom
DSPX-3302-02-platform-installer

Conversation

@dmihalcik-virtru
Copy link
Copy Markdown
Member

Summary

Second PR in the five-part stack. Promotes the OpenTDF platform service to a first-class managed package in otdf-sdk-mgr, mirroring the existing Go/Java/JS SDK CLI flow, and adds a one-shot install scenario entry point.

  • platform_installer.py: resolves v0.9.0 to the service/v0.9.0 tag in the opentdf/platform monorepo, creates a git worktree, and runs go build -o xtest/platform/dist/<version>/service ./service.
  • install_helper_scripts(main): mirrors platform/scripts/ into xtest/platform/scripts/. Helper scripts are shared across instances and refreshed on demand.
  • New CLI commands:
    • otdf-sdk-mgr install release platform:<version> (alongside go:, js:, java:)
    • otdf-sdk-mgr install lts platform / install tip platform
    • otdf-sdk-mgr install scripts
    • otdf-sdk-mgr install scenario <path> — installs platform pin + per-KAS pins + encrypt/decrypt SDK union from a scenarios.yaml or instance.yaml, writes <path>.installed.json
  • Container-image platform pins are rejected with a clear v1-not-supported message (no public images today).

Stack

  1. (merged into base) Shared schema — chore(xtest): Shared Scenario/Instance Pydantic schema in otdf-sdk-mgr #450
  2. This PR — Platform installer + install scenario
  3. otdf-local multi-instance refactor + new CLI subcommands
  4. xtest/conftest.py integration (--scenario, --instance)
  5. Claude plugin

Test plan

  • cd otdf-sdk-mgr && uv run pytest tests/ → 57 passing (existing 51 + new 6 from PR 1)
  • uv run otdf-sdk-mgr install --help shows the new scenario and scripts commands

Jira: https://virtru.atlassian.net/browse/DSPX-3302

🤖 Generated with Claude Code

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 44697766-b106-4909-bbea-450a0598b071

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch DSPX-3302-02-platform-installer

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 introduces support for installing the OpenTDF platform service and scenario-driven installations. Key changes include the addition of a platform_installer module that manages source builds via git worktrees, a new cli_scenario module for manifest-based installs, and updates to existing CLI commands to handle the "platform" target. Review feedback highlights a bug in updating git worktrees from bare repositories, identifies code duplication in the CLI logic, suggests optimizing YAML parsing to avoid redundant reads, and recommends allowing real-time output for long-running build processes to improve user experience.

_run(["git", f"--git-dir={bare}", "worktree", "add", str(worktree), branch])
else:
print(f"Updating scripts worktree at {worktree}...")
_run(["git", "-C", str(worktree), "pull", "origin", branch])
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.

high

A git worktree added from a bare repository typically does not have remotes configured in its local config. Running git pull origin branch inside the worktree will likely fail with an error that 'origin' is not a git repository. Since _ensure_bare_repo() already fetches updates into the bare repository, you should update the worktree by resetting it to the tracking branch available in the bare repo.

Suggested change
_run(["git", "-C", str(worktree), "pull", "origin", branch])
_run(["git", "-C", str(worktree), "reset", "--hard", f"origin/{branch}"])

Comment on lines +52 to +65
requested = sdks or ALL_SDKS
sdk_targets = [s for s in requested if s != "platform"]
if "platform" in requested:
version = LTS_VERSIONS.get("platform")
if version is None:
typer.echo("Warning: no LTS version defined for platform; skipping", err=True)
else:
try:
install_platform_release(version)
except PlatformInstallError as e:
typer.echo(f"Error: {e}", err=True)
raise typer.Exit(1)
if sdk_targets:
cmd_lts(sdk_targets)
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.

medium

The logic for handling the platform target is duplicated here and in the tip command (lines 82-91). This pattern makes the CLI code harder to maintain. Consider refactoring this into a shared helper function or extending the cmd_lts/cmd_tip functions to handle the platform service internally, similar to how other SDKs are handled.

Comment on lines +53 to +62
raw_kind = _peek_kind(path)
scenario: Scenario | None = None
if raw_kind == "Scenario":
scenario = load_scenario(path)
instance = scenario.instance
elif raw_kind == "Instance":
instance = load_instance(path)
else:
typer.echo(f"Error: {path} has unknown kind {raw_kind!r}", err=True)
raise typer.Exit(1)
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.

medium

The manifest file is being parsed twice: first in _peek_kind to determine the kind, and then again in load_scenario or load_instance. For better performance and cleaner code, you should parse the YAML once and then use the resulting dictionary to decide which Pydantic model to validate against.


def _run(cmd: list[str], cwd: Path | None = None) -> None:
"""Run a command, raising PlatformInstallError on failure."""
result = subprocess.run(cmd, cwd=cwd, capture_output=True, text=True)
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.

medium

Using capture_output=True for long-running operations like go build or git clone prevents real-time feedback in the terminal. The CLI will appear to be frozen until the command finishes. It is generally better to allow these commands to stream their output to the console so the user can monitor progress.

@github-actions
Copy link
Copy Markdown

@dmihalcik-virtru dmihalcik-virtru force-pushed the DSPX-3302-02-platform-installer branch from c6a7895 to ebc0c15 Compare May 15, 2026 16:35
@dmihalcik-virtru dmihalcik-virtru force-pushed the DSPX-3302-02-platform-installer branch from ebc0c15 to 14e5c1e Compare May 15, 2026 16:57
@sonarqubecloud
Copy link
Copy Markdown

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.

1 participant