Skip to content

Interface: OsfqlRefusal

@kortexya/reasoninglayer


@kortexya/reasoninglayer / OsfqlRefusal

Defined in: src/types/osfql.ts:1550

Machine-actionable detail of a write the engine refused.

Present on an OsfqlError (errorType: 'execution', HTTP 422) when the failure is a REFUSAL with a typed cause, so a gate or a self-repair loop can rewrite the statement instead of parsing prose. code is one of:

  • link_endpoint_not_found, link_endpoint_ambiguous, link_endpoint_binding_mismatch, upsert_ambiguous — the write-designation ladder;
  • key_value_clash, key_meet_bottom, key_meet_non_principal — the write contradicts the term that already holds the sort’s @key;
  • key_identity_conflict — the write’s @key values name more than one stored term (reasoninglayer#1255): duplicates of one entity through one key, or different entities through several. The message names those the writer may read, in id order; candidates is 2, read as “two or more”. The named terms stay editable by id;
  • bound_constraint_violated — a CHECK ON axiom of the sort refused the values, or an axiom of a term that reads a written term through a reference refused the write (reasoninglayer#1245); sort then names that term’s sort;
  • bound_constraint_over_engine_records — a CHECK ON a sort whose subtree holds a sort whose terms only the engine writes (reasoninglayer#1249). A program replayed from an export is refused the same way;
  • reference_term_unknown — a COPY, MERGE, IMPORT or USE would write a reference to a term its writer may not read (reasoninglayer#1239), as POST /api/v1/terms refuses it. The message names no hidden id, and nothing is kept;
  • constraint_over_unread_data — a CHECK ON axiom that reads data the program’s writer may not read refused the values of an INSERT (reasoninglayer#1230), the axiom of a term that reads a written term included (#1245). The message is the one bare refusal, the same whichever such axiom refused and however; it names no bound, feature or constraint. Test it with isOsfqlConstraintOverUnreadData(error);
  • write_targets_derived_fact — every term the write designated is a rule’s conclusion; the repairs name the premises to write and the rule to withdraw;
  • retract_has_referrers — other terms designate a matched term; CASCADE or DETACH repairs it;
  • retract_named_by_rules — rule terms name a matched term; withdraw the rules first;
  • retract_cascade_too_large — the CASCADE closure exceeds cascadeLimit; retract in batches;
  • write_creates_rule — the write carried a non-empty list under when, which would make the term a rule; the use_derive repair states it with DERIVE. A scalar when is ordinary data.
  • engine_feature_write_refused — the statement names a feature only the engine writes (a runtime-record tag such as _pref_user, or bookkeeping such as _derived_by) on INSERT, UPSERT, UPDATE, CURRY, APPLY, REMOVE or an AWAIT action (reasoninglayer#1269). No principal is exempt, so repairs is empty; sort names the written sort (empty for CURRY, APPLY and REMOVE). The REST term doors answer the same code with 422;
  • program_registrant_not_actor — an AWAIT from a request with no native user (X-Authenticated-User: user:<uuid>) to register its demon as (reasoninglayer#1256). Send the attested user: set ClientConfig.authenticatedUser, or RequestOptions.authenticatedUser for one call;
  • program_trigger_unreadable — an AWAIT on a trigger sort the caller may not read (reasoninglayer#1256); sort names the trigger sort;
  • bound_feature_undeclared — a CHECK ON names a feature the sort does not declare or inherit, and the name is all digits or the sort is @closed (reasoninglayer#1265). Bound a feature by a constant with @range(min, max) on its declaration;
  • governed_sort_write_refused — the write, delete or rule conclusion targets a @governed sort (or a descendant of one), whose terms only an engine-internal door writes. No principal is exempt and no rewrite repairs it.

Each count has ONE meaning across every code: candidates is what the refused statement’s pattern designated, referrers what blocks a RETRACT, cascadeLimit the bound a RETRACT … CASCADE exceeded.

const refusal: OsfqlRefusal = {
code: 'upsert_ambiguous',
sort: 'customer',
candidates: 2,
repairs: [
{
kind: 'add_discriminator_or_key',
rewrite: 'UPSERT customer(<add @key feature or discriminator>);',
},
],
};

candidates: number

Defined in: src/types/osfql.ts:1599

How many terms the refused statement’s own pattern designated.

  • link_endpoint_not_found: 0;
  • link_endpoint_ambiguous, upsert_ambiguous: 2, read as “two or more” (the designation scan stops at the second match);
  • link_endpoint_binding_mismatch: 1, the bound term;
  • write_targets_derived_fact: the exact number designated, all of them derived facts;
  • key_value_clash, key_meet_bottom, key_meet_non_principal: 1, the existing keyed term;
  • bound_constraint_violated: 1, the term being written;
  • write_creates_rule: 1 for the term an INSERT writes, or the number of terms an UPDATE designated;
  • governed_sort_write_refused: 1;
  • retract_has_referrers, retract_named_by_rules, retract_cascade_too_large: the exact number of asserted terms the RETRACT pattern matched. It is NOT the number of blocking terms — read referrers for that.

optional cascadeLimit?: number

Defined in: src/types/osfql.ts:1612

For retract_cascade_too_large only: the bound the CASCADE closure exceeded. The closure walk stops at the bound, so its full size is not reported — only that it is larger. Absent for every other code.


code: string

Defined in: src/types/osfql.ts:1552

Typed refusal cause, snake_case, copied verbatim.


optional denialCode?: GovernanceRefusalCode

Defined in: src/types/osfql.ts:1568

The precise code of a client-door write, delete or Manage denial (reasoninglayer#1207, #1231), beside the published code.

code keeps the published write_refused, governed_sort_write_refused or authz_relation_derived; this field names the code the REST routes answer the same denial with (reserved_sort_write_refused, sort_write_not_granted, filing_term_unread, reserved_sort_delete_refused, sort_delete_not_granted, operational_authority_denied, …), and sort_manage_not_granted for a sort the program defines, changes or moves without a Manage grant (execution, 422; an ALTER SORT move is refused, 403). Absent for a refusal that is no client-door denial.


optional referrers?: number

Defined in: src/types/osfql.ts:1606

The terms outside the matched set that block a RETRACT: for retract_has_referrers the data terms that designate a matched term, for retract_named_by_rules the rule terms that name one. Absent for every other code.


repairs: OsfqlRepair[]

Defined in: src/types/osfql.ts:1619

Concrete rewrites, most-preferred first. Empty when no statement rewrite repairs the refusal: key_value_clash, key_meet_bottom, bound_constraint_violated, constraint_over_unread_data, retract_named_by_rules and retract_cascade_too_large.


optional role?: string

Defined in: src/types/osfql.ts:1577

The link endpoint role (source / target) when the statement is a link.


sort: string

Defined in: src/types/osfql.ts:1575

The sort the refusal concerns: the sort the refused statement’s pattern names or, for key_*, bound_constraint_violated and write_targets_derived_fact through a bound variable, the sort of the term being written.