Use POST /api/v1/rules/compile to compile user-authorized durable constraints into
OpenViking Rules, then verify the task result and saved Rules.
Use the same instance and identity for upload, compilation, task polling, and verification.
available. Use SDK methods for source upload, compilation, task polling, and reading.
for source upload, compilation, task polling, and reading.
Do not mix SDK calls and direct HTTP calls within one compilation workflow.
instruction and sources; at least one must be non-empty.Preserve the source's obligations, applicability conditions, exceptions, thresholds,
and identifiers without inventing policy.
Python SDK mode
options supports sources. Each source may be a local file or directory path, a
remote URL, a Resource URI, or an advanced source dictionary. The SDK uploads local
paths automatically.
```python
task = client.rule_compile(
instruction="Compile the supplied policy into durable Rules.",
options={
"sources": [
"/local/path/policy.md",
"https://example.org/policy.md",
"viking://resources/team-policy",
]
},
)
taskid = task["taskid"]
```
Poll with client.get_task(task_id) and read saved content withclient.read_raw(uri).
HTTP mode
HTTP has no options wrapper. Put instruction and sources directly in the JSON
body. Use resource_uri for an existing Resource, path for a remote text source,
or temp_file_id returned by POST /api/v1/resources/temp_upload for local content.
```json
{
"instruction": "Compile the supplied policy into durable Rules.",
"sources": [
{"resource_uri": "viking://resources/team-policy"},
{"path": "https://example.org/policy.md"},
{"tempfileid": "tmpxxx", "sourcename": "policy.md"}
]
}
```
Submit this body to POST /api/v1/rules/compile. Never send a client-local path to
that endpoint. Poll GET /api/v1/tasks/{task_id} and read saved content throughGET /api/v1/content/read?uri=...&raw=true.
Save the returned task_id; acceptance does not mean compilation has completed.
Query the existing task rather than resubmitting the request.
result.operations, written_uris, and write_result. Distinguish savedRules from NOOP, UNCERTAIN, and REJECT results; completed does not guarantee new Rules.
policy text and evidence, and verify rules/<scenario_id>/abstract.md holds Scenario
metadata while Rule files sit directly beside it as <atomic_id>.md.
Report the task ID, actual changes, representative URIs, and unresolved decisions.
applies_when conditions supported by the source.Empty applies_when means applicable in every situation except exception, not unknown.
Use ARCHIVE only when the user's instruction explicitly asks to delete, discard, or
move a Rule to the recycle bin. Use PAUSE for pause, disable, deactivate, retire,
stop-applying, or stop-using requests without deletion intent. Archived Rules are
logically deleted: they are not compiler candidates and cannot be restored through
Rule compilation.
instances or expose credentials to resolve a failed request.
reads at most 128 files and 128000 characters. Split oversized material into self-contained
policies with their conditions and exceptions rather than silently omitting content.
Previously imported Resources are not rolled back when later Rule compilation fails.
indexing may still be pending.