امتثال
واجهة البرمجة

Versions

POST
/v1/jobs/{job_id}/versions

Allocates a new evaluation run and starts ReEvaluateOnVersionWorkflow on Temporal. Verdict rows produced by the new run are tagged with evaluation_run_id; run 1 (NULL evaluation_run_id) verdicts are preserved unchanged. Returns 202 immediately with {job_id, run_id, workflow_id}; poll the diff endpoint to compare results.

TODO PRD-005: revision_of job chains (amended drawings → new job) land with migration 084's revision_of column — out of scope here.

Authorization

BearerAuth
headerAuthorizationBearer <token>

JWT access token. Obtain via POST /v1/auth/login.

Path Parameters

job_id*Job Id
Formatuuid

Header Parameters

accept-language?string|null

Request Body

application/json
  1. body

Optional body for POST /versions.

Both fields are optional; omitting them re-evaluates all codes for the job using the job's existing drawing graph.

codes?array<string>|null
document_ids?array<>|null

Response Body

Re-evaluation started.

response?unknownapplication/json
curl -X POST 'https://api.aisc.sa/v1/jobs/497f6eca-6276-4993-bfeb-53cbbbba6f08/versions' \  -H 'Content-Type: application/json' \  -d '{}'
null
GET
/v1/jobs/{job_id}/versions/{version_a}/diff/{version_b}

Returns {fixed, new, still_failing, unchanged, not_rechecked} — the diff of verdict states between two evaluation runs of the same job, per (element, code, rule). fixed means version_a held a FAIL and version_b judged that rule on that element and it passed; nothing else is a fix. A finding version_b never judged (it failed, is still running, or loaded no rules) is not_rechecked and keeps its version_a state. Every row carries from_state and to_state. Pass the earlier run as version_a: the order is not checked.

Sentinel: version_a == job_id (or version_b == job_id) means run 1 (initial evaluation; evaluation_run_id IS NULL in the DB). Any other UUID is an evaluation_run_id from projects.job_evaluation_runs.

Cross-job diff (revision_of chains) is not yet supported (TODO PRD-005, migration 084). Query is scoped to the URL job_id + RLS so cross-tenant access is impossible; a run UUID that doesn't belong to this job yields empty buckets for that run.

TODO pagination: add limit/offset when verdict counts exceed 10k.

Authorization

BearerAuth
headerAuthorizationBearer <token>

JWT access token. Obtain via POST /v1/auth/login.

Path Parameters

job_id*Job Id
Formatuuid
version_a*Version A
Formatuuid
version_b*Version B
Formatuuid

Header Parameters

accept-language?string|null

Response Body

Diff result.

response?unknownapplication/json
curl -X GET 'https://api.aisc.sa/v1/jobs/497f6eca-6276-4993-bfeb-53cbbbba6f08/versions/497f6eca-6276-4993-bfeb-53cbbbba6f08/diff/497f6eca-6276-4993-bfeb-53cbbbba6f08'
{  "fixed": [    {      "code_id": "801",      "element_id": "...",      "from_state": "FAIL",      "rule_id": "SBC801-1.1",      "to_state": "PASS"    }  ],  "job_id": "00000000-0000-0000-0000-000000000001",  "new": [],  "not_rechecked": [],  "still_failing": [],  "unchanged": [],  "version_a": "00000000-0000-0000-0000-000000000001",  "version_b": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"}