Open EPM ← Back to openepm.dev

Schedule an authorized program

Replace the placeholders with values from your own authorized scope before copying this prompt into an MCP client.

Inputs

  • {{workspace_id}} Stable workspace ID.
  • {{application_id}} Stable application ID.
  • {{definition}} Reviewed schedule definition with target pin, bindings, recurrence and delegation.
  • {{save_key}} Stable key for saving the version.
  • {{publish_key}} Separate stable key for authorized publication.
  • {{rule_publish_operation_id}}, {{rule_published_revision}}, and {{rule_digest}} Exact rule publication operation ID, integer committed revision and program digest.
  • {{first_due_at}} First due time, one day in the future for the disposable example.

Prompt

In {{workspace_id}} / {{application_id}}, verify {{definition}} against the exact target publication, bounded bindings and active delegation for this schedule ID and version.
Use execute_v2_application_schedule with schedule.version.read for the scheduleId and omit idempotency_key for that read. Read application.state.read for the application revisions. Use expectedStateRevision 0 and version 1 when the read reports defined false. Otherwise use the latest definition's stateRevision and next version.
Call execute_v2_application_schedule with schedule.version.save, definition {{definition}}, expectedStateRevision, expectedMetadataRevision, expectedPolicyRevision and expectedSchemaEpoch, and idempotency_key {{save_key}}.
Read the exact saved scheduleId and version. Verify the definitionDigest and take the new stateRevision from that read. Refresh the application revisions because saving a schedule advances policyRevision.
Recheck the exact rule publication and active delegation before publishing. Call schedule.version.publish with the same scheduleId and version, the four refreshed expected revisions, and idempotency_key {{publish_key}}. Read the exact version and report its Published status and recurrence. Leave the first occurrence for its configured due time.
Stop on a changed target publication, stale revision, insufficient delegation or invalid timing.

Example inputs

In the disposable Operating Data Cube, follow the rule publication procedure with the rule ID docs.daily-uplift-rule, version 1, and the Python source below. Each run reads the current InputA amount and refreshes a named calculation result. With an input of 12.50000000, facts.calculation.read returns 15.00000000 under the result key docs.daily-uplift-result.

from openepm import Amount, ApplicationRule, CubeExpression, Program

def build(context, parameters):
    source = {
        "Account": "InputA", "Entity": "PointA", "Year": "Y2027",
        "Period": "P01", "View": "Input", "Value": "Raw",
        "Scenario": "Actual", "DataType": "InputData", "Custom01": "ItemA",
    }
    calculation = Program.expression_calculation(
        source, CubeExpression.source_amount() + Amount("2.50"),
        "docs.daily-uplift-result", name="refresh-uplift",
    )
    return ApplicationRule("docs.daily-uplift-rule", 1, calculation)

Take the operation ID and committed revision from that rule publication response or receipt. Compare its digest and revision to application.rule.version.read. Use execution.delegation.create with the authorized issuer and subject, operationScope containing application.rule.run, and the exact scheduleId and scheduleVersion below. Make the delegation active now and valid through the desired run window. Set firstDueAt to a UTC timestamp one day in the future, rounded down to a whole minute. Keep the exact values for replay.

{
  "format": "openepm-application-schedule-v1",
  "scheduleId": "docs.daily-uplift",
  "version": 1,
  "target": {
    "kind": "ApplicationRule", "ruleId": "docs.daily-uplift-rule", "version": 1,
    "publicationOperationId": "{{rule_publish_operation_id}}",
    "publishedRevision": {{rule_published_revision}},
    "programDigest": "{{rule_digest}}"
  },
  "bindings": {},
  "pov": [],
  "recurrence": {
    "kind": "FixedInterval", "intervalSeconds": 86400, "firstDueAt": "{{first_due_at}}",
    "catchUpPolicy": "latest", "maxCatchUp": 1
  },
  "retryPolicy": {"maxAttempts": 3, "backoffSeconds": 60, "needsInspectionAfter": true},
  "cancellationPolicy": "PreserveCommittedStopFuture",
  "delegation": {"delegationId": "docs.daily-uplift-runner", "version": 1}
}

Tools used include read_v2_program, execute_v2_application_schedule, and execute_v2_execution_delegation. See the module guidelines and tool index.

Discussion

Discussing Schedule an authorized program

The discussion service requires JavaScript and a connection to Firebase.