Skip to content

Sr versions#3382

Draft
jmthomas wants to merge 8 commits into
mainfrom
sr_versions
Draft

Sr versions#3382
jmthomas wants to merge 8 commits into
mainfrom
sr_versions

Conversation

@jmthomas
Copy link
Copy Markdown
Member

@jmthomas jmthomas commented May 18, 2026

Still needs some playwright tests and code reviews but this is the effect:
image

jmthomas and others added 6 commits May 5, 2026 09:17
Enable bucket versioning on OPENC3_CONFIG_BUCKET via versitygw, threading
a sibling /versions volume + VGW_VERSIONING_DIR through the openc3-buckets
image and entrypoint. Add list_object_versions and version_id-aware
get/head/delete to AwsBucket. Introduce ScriptLifecycleModel to track
per-version state (saved/validated/reviewed/executed) with usernames and
timestamps; saves over a reviewed version return 409 unless force_taint
is sent, in which case the new version is flagged with provenance back
to the prior reviewer. Auto-validate inline on save (syntax + mnemonic)
to record validated_at for API-driven saves. Remove Script.lock entirely
along with the editor-locking UI now that versioning eliminates overwrite
risk.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add four new endpoints under /script-api/scripts/*name: GET versions
(S3 versions merged with lifecycle metadata, newest-first), GET version
(body of a specific version_id), POST restore (re-PUT a historical body
with the same review-lock + force_taint semantics as save), and POST
review (sign-off, gated by a new can_approve_script? predicate that's
no-op in Core and overridable in Enterprise's existing Authorization
module). Sign-off requires the supplied version_id to match the current
latest_version_id, returning 409 version_mismatch if the script was
edited between display and click.

Refactor ScriptLifecycleModel into nested validated/reviewed blocks plus
a richer executions array (disconnect, environment, suite_runner,
running_script_id) so the UI can render three independent badges
(validated/reviewed/executed) that fill in with metadata as each facet
acquires data. Final execution status stays in ScriptStatusModel —
dereferenced via running_script_id — to avoid cross-process writes from
the spawned RunningScript.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add three lifecycle badges (validated/reviewed/executed) to the Script
Runner toolbar, each greyed out and filling in with status as its facet
acquires data. Reviews now carry a decision (approved | changes_requested);
only approved decisions lock the script for further saves. The reviewed
badge renders bright green on approval, dull green when an earlier version
was approved but the current isn't, and red on changes_requested. Executed
badge dereferences the latest run's running_script_id against
ScriptStatusModel and colors by terminal state (green/yellow/red), with a
live tonal-blue while the user is running it in-session.

Combine the Script -> Syntax Check and Mnemonic Check menu items into a
single Script -> Validate that records the result on the validated block,
and surface validation failures from the inline auto-validate-on-save in
the same dialog. Replace the now-removed Script.lock UI with a 409
locked_for_review handler that prompts the user to taint, plus a
sign-off dialog with separate Approve and Request Changes buttons.

Bug fix: save-on-Start triggered the locked_for_review 409 even when the
content was unchanged. Frontend now skips non-menu saves when nothing has
been modified, and the controller treats identical-body saves as no-ops
that bypass the lock check.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ly lock

Add a Version History dialog with side-by-side ace-diff and per-version
restore (with the same force_taint flow as save) under Script -> Version
History. Routes reordered so the GET catchall doesn't swallow the new
specific paths (/versions, /version, /latest), and the diff dialog uses
absolute positioning anchored to its column so ace-diff's editors can't
push the title bar off screen.

Capture the plugin-installed baseline on first edit: copy targets/{name}
to targets_modified/{name} before the user's first save and record it as
saved_by '<original>' so the original content shows up as V1 in history
and is restorable.

Lock the editor read-only when the latest version is approved. A yellow
banner above the editor shows the reviewer + notes with "View History"
and "Edit Anyway" buttons; clicking Edit Anyway flips a per-session
override that auto-applies force_taint on the next save. After the save
lands the lock releases naturally as the new version isn't reviewed.

Polling endpoint /scripts/*name/latest now returns the full latest
lifecycle so reviewed/executed badges update in near-real-time when one
user signs off or runs a script while another is watching the same
version. Frontend mirrors the polled lifecycle only when on the latest
version, and re-fetches ScriptStatusModel state for the badge color
when a new running_script_id appears.

Defensive AWS error handling on /version and /restore — Aws::Errors::
ServiceError (e.g. Invalid version id specified from real-S3/MinIO when
a null-version-marker is fetched) now returns 404 with the backend's
reason instead of a 500. Bucket policy for the SR user gains s3:Get
ObjectVersion and s3:ListBucketVersions so version reads survive in
permission-enforcing backends.

Other UI polish: tainted toolbar chip removed (the reviewed badge alone
conveys the lock state); diff pane has a close X and re-clicking the
active version closes it; validation failures pop the same dialog as
Script -> Validate when surfaced from inline auto-validate-on-save.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jmthomas jmthomas requested review from clayandgen and ryanmelt May 18, 2026 19:58
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

❌ Patch coverage is 26.78571% with 82 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.76%. Comparing base (02a0d63) to head (b2ad750).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...t-runner-api/app/controllers/scripts_controller.rb 9.67% 56 Missing ⚠️
openc3/lib/openc3/utilities/aws_bucket.rb 42.85% 20 Missing ⚠️
openc3/lib/openc3/utilities/target_file.rb 20.00% 4 Missing ⚠️
openc3/lib/openc3/utilities/bucket.rb 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3382      +/-   ##
==========================================
- Coverage   78.87%   78.76%   -0.11%     
==========================================
  Files         687      687              
  Lines       57285    57383      +98     
  Branches      728      728              
==========================================
+ Hits        45184    45199      +15     
- Misses      12023    12106      +83     
  Partials       78       78              
Flag Coverage Δ
python 80.04% <ø> (+<0.01%) ⬆️
ruby-api 81.45% <15.15%> (-1.09%) ⬇️
ruby-backend 82.17% <43.47%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

command: () => {
this.showVersionHistory = true
},
},
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Rather than a hidden menu option should this be a front and center history icon?

@sonarqubecloud
Copy link
Copy Markdown

@jmthomas jmthomas marked this pull request as ready for review May 20, 2026 15:31
@jmthomas jmthomas marked this pull request as draft May 20, 2026 17:41
@jmthomas
Copy link
Copy Markdown
Member Author

I'd like to experiment with a git based system before merging this bucket version based system

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