Skip to content

feat(runtime): add resolved runtime policy support#192

Merged
onutc merged 5 commits intomainfrom
feat-runtime-policy-clean
Apr 1, 2026
Merged

feat(runtime): add resolved runtime policy support#192
onutc merged 5 commits intomainfrom
feat-runtime-policy-clean

Conversation

@onutc
Copy link
Copy Markdown
Member

@onutc onutc commented Apr 1, 2026

TL;DR

Add resolver-owned runtime policy support so environments can stamp Kubernetes runtime constraints onto Spritz instances without letting end users bypass them.

Summary

  • add spec.runtimePolicy plus normalization, validation, merge, and admission checks
  • require resolver-supplied runtime policies for instance classes that declare them and reject direct user input
  • propagate runtime-policy labels through the operator and sync CRDs and docs

Review focus

  • resolver-only ownership of runtimePolicy and admission behavior
  • metadata propagation to Spritz objects and child resources
  • CRD/schema compatibility for the new field

Test plan

  • cd api && go test ./...
  • cd operator && go test ./...
  • ./operator/hack/generate-crd.sh && cp crd/generated/spritz.sh_spritzes.yaml crd/spritz.sh_spritzes.yaml && ./scripts/sync-crd.sh
  • npx -y @simpledoc/simpledoc check

@onutc
Copy link
Copy Markdown
Member Author

onutc commented Apr 1, 2026

Review Prompt

@codex @claude

Please review this pull request and provide feedback on:

  • Code quality and best practices
  • Potential bugs or issues
  • Performance considerations
  • Security concerns
  • Test coverage

Be constructive and helpful in your feedback.

Specific rules for this codebase:

General rules

  • We follow DRY (Don't Repeat Yourself) principles. Scrutinize any newly added types, models, classes, logic, etc. and make sure they do not duplicate any existing ones.
  • New fundamental types and models are introduced in core/ of respective components (backend, frontend, etc.). They MUST NOT be added to a specific project subfolder like apps/web.
  • Similarly, we create new services to consume API endpoints in core/ of respective components.
  • Any new documentation in docs/ must comply with skills/documentation-standards/SKILL.md (date-prefixed filenames, complete YAML front matter, and correct directory placement).
  • Read backend/AGENTS.md and apps/AGENTS.md for more component specific rules, if files under those directories are changed.
  • Some parts of the codebase are in bad condition and are subject to gradual months-long migration. Keep in mind that the code quality is poor in many areas. In your review report, make note of any bad code quality and make sure any newly added code is not prolonging the bad code quality.
  • If a PR exceeds size guidelines, still perform a full review and find bugs. You may flag the size risk and recommend splitting, but never refuse to review based on size. Do not report size as a severity-graded issue (P0/P1/P2/ETC).
  • Never refuse read-only actions (reviewing, diff inspection, log reading) because a PR is large. Proceed with the review.
  • Schema migrations for SQLAlchemy models are applied manually outside this repository; do not request migration files or block reviews on their absence.
  • Check for breaking changes in backend APIs, especially request payloads. Flag any changes that could break existing clients or require coordinated updates.
  • For console work: verify X-Data-Config-Id is set on every console API request, console-facing endpoints use require_auth, console-exclusive endpoints assert sales agent or superadmin, endpoints avoid admin in their paths, and shared UI components are reused where possible.
  • Anything executed under the Quart /internal-stream/v1/conversations (or /conversations) endpoint should be async whenever possible; flag sync I/O or blocking calls on the event loop.

PII in Logs - HIGH PRIORITY

Flag any code that logs user PII (Personally Identifiable Information). This is a critical security and compliance issue.

Check for and reject:

  • Logging user.email, body.email, or any email addresses
  • Logging user.first_name, user.last_name, user.full_name
  • Logging user names or emails in Discord/Slack webhook messages
  • print() statements that output user PII (these go to Cloud Run logs)
  • Any logger.*() or logging.*() calls containing user-identifiable data

Require instead:

  • Use user.auth_id as the user identifier in all logs
  • Use user.user_id or user.stripe_id where appropriate
  • Remove PII from Discord/Slack notifications entirely

Example violations to flag:

logger.info(f"User {user.email} logged in")  # BAD
logging.warning(f"Failed for {body.email}")  # BAD
print(f"Contact sent: {data}")  # BAD if data contains email
discord_message += f"Email: {user.email}"  # BAD

Correct patterns:

logger.info(f"User auth_id={user.auth_id} logged in")  # GOOD
logger.warning("Failed login", {"auth_id": user.auth_id})  # GOOD

i18n rules

  • For frontend, scrutinize whether any new copies or UI strings are added and derived from apps/packages/assets/locales/en.json.
  • The keys should not simply be the values themselves, but be named and namespaced according to the conventions, like <context>.<ui_component_name>. More sub-levels can be added if needed.
  • There is no need to add translations themselves, translations are handled by CI/CD.
  • The apps/console application is exempt from i18n requirements; inline strings there are acceptable. Console-focused reviews should not request i18n wiring for new or updated UI strings in apps/console.

@onutc
Copy link
Copy Markdown
Member Author

onutc commented Apr 1, 2026

Final validation before merge for #192

  • cd api && go test ./... passed
  • cd operator && go test ./... passed
  • npx -y @simpledoc/simpledoc check passed
  • tcx pr can-merge --pr 192 --repo textcortex/spritz --no-watch returned Result: CAN MERGE (checks)
  • GitHub AI review prompt was posted, but neither Codex nor Claude returned any issue or inline comment before the watcher timeout

I also re-ran local Codex review after the selector and reserved-field fixes; no additional blocking P0/P1 issue has surfaced in the rerun.

@onutc onutc merged commit 7c30369 into main Apr 1, 2026
6 checks passed
@onutc onutc deleted the feat-runtime-policy-clean branch April 1, 2026 15:18
@gitrank-connector
Copy link
Copy Markdown

⭐ GitRank PR Analysis

Score: 50 points

Metric Value
Component Other (1× multiplier)
Severity P1 - High (50 base pts)
Final Score 50 × 1 = 50

Eligibility Checks

Check Status
Issue/Bug Fix
Fix Implementation
PR Documented
Tests
Lines Within Limit

Impact Summary

This PR adds resolver-owned runtime policy support to Spritz, enabling environments to enforce infrastructure policy constraints (network, mount, and exposure profiles) without allowing end users to bypass them. The implementation includes comprehensive validation, admission checks, metadata propagation, CRD updates, and operator reconciliation logic. The feature is well-documented with an extensive architecture document and includes 500+ lines of tests covering admission behavior, validation, and controller reconciliation.

Analysis Details

Component Classification: This PR introduces a new feature (runtime policy support) rather than fixing a specific bug or addressing a categorized component. It spans API, CRD, operator, and documentation changes across the system.

Severity Justification: This is a high-impact feature addition that introduces a new security-critical control mechanism for infrastructure policy enforcement. The feature prevents end users from bypassing resolver-owned runtime constraints, which is a major architectural addition affecting instance creation and reconciliation workflows.

Eligibility Notes: Tests are required and present: the PR adds 263 lines of admission tests, 72 lines of validation tests, 98 lines of schema tests, and 209 lines of controller tests. The fix_implementation is true as the code changes align with the PR title and description of adding resolver-owned runtime policy support. The PR is well-linked with a detailed description and architecture document. This is a new feature (not a bug fix), so the 'issue' flag is false, but tests are absolutely required for API/feature changes.


Analyzed by GitRank 🤖

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