Repository navigation
feat: add template provenance, idempotent enablement, and first-run outcome to presets - #322
Merged
Merged
Conversation
…utcome to presets
Contributor
Contributor
|
🚀 Released in 1.7.0. |
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Issue #76 asks for default/preset automations with version identity and user-level enablement, re-scoped so that the automation service does not own a template registry: template definitions and configurable fields live in
OpenHands/extensions; this service stores opaque provenance and implements safe lifecycle behavior. Its dependency #56 asks to persist an opaque extension template identifier, version, and non-secret submitted configuration (superseding stale PR #89, which targeted the old repo layout and had migration-number collisions).Today the preset endpoints record nothing about which template an automation came from, cannot create a disabled automation (clients work around it with create-then-PATCH), enabling the same template twice silently duplicates it, and nothing reports whether an enabled preset actually worked on its first run.
Summary
preset_metadataJSON column (migration013, genericsa.JSON, SQLite + PostgreSQL) populated by both preset endpoints and returned onAutomationResponse; the prompt key is re-synced on PATCH.template: {id, version, config}(stored verbatim, never catalog-validated, config ≤ 16 KB) and explicitenabled(defaulttrue).get_event_automationsprecedent; the small concurrent-create race is documented and accepted (no cross-database unique index on a JSON path).preset_metadata["first_run"](status,failure_stage,template_version,recorded_at) — absence of the key is the once-guard,SELECT … FOR UPDATEon PostgreSQL — plus oneautomation_template_first_runtelemetry event. Recording never raises, and each hook site is placed so a recording failure cannot affect the run transition.Issue Number
Resolves #76
How to Test
New tests (14) live beside the behavior they pin:
tests/test_preset_router.py— provenance storage on both endpoints, explicitenabled, 200-idempotency (including cross-endpoint), 16 KB config cap (422), soft-delete does not block re-enabling.tests/test_router.py::TestCompleteRun— first-run success/failure via the completion callback (stageexecution), record shape carries nothing sensitive, once-only, no record without template provenance.tests/test_dispatcher.py— dispatcher failure records stagedispatch; SKIPPED does not consume the slot.tests/test_watchdog.py— watchdog failure records stagewatchdog.Manual check:
POST /v1/preset/prompttwice with the sametemplate.id— second response is 200 with the first automation's id;GET /v1showstotal: 1andpreset_metadata.templatepopulated.Video/Screenshots
N/A — backend-only change; behavior is pinned by the API-level tests above.