Contract, UI, and Surface Reference
This checked-in reference is generated from the current Pharos repository contracts. It describes the app-owned declaration surfaces that the shared runtime and builder consume: routes, surfaces, UI elements, forms, actions, workflows, integrations, entities, queries, policies, and derived generated surfaces.
The filename remains library-reference.md because the docs app route, navigation, and agent knowledge index already use that stable path. The document title is the accurate name of the content.
Table of Contents
- contract inventory
- terminology
- route
- surface
- ui.element
- form
- action
- workflow
- integration.adapter
- integration.webhook_endpoint
- entity
- query
- policy
- generated_surface
- update contract
Contract Inventory
| Contract area | Source files | Declared records | Runtime use | | --- | ---: | ---: | --- | | routes | 8 | 176 | request path matching and dispatch | | surfaces | 5 | 17 | page, API, form, fragment, and UI library declarations | | UI elements | 3 | 16 types | canonical shared controls and preview fragments | | forms | 1 | 17 | field validation and submitted input contracts | | actions | 6 | 109 | validation, mutation execution, responses, and effects | | workflows | 5 | 13 workflows, 42 transitions | state machines and lifecycle events | | integrations | 3 | 13 adapters | outbound webhooks, notifications, audit, and local file records | | entities | 4 | 58 | storage, generated surface derivation, identity, and scope | | queries | 1 | 20 | relational lookup and projection contracts | | policies | 4 | 50 capabilities | auth gates and capability checks |
Terminology
contractmeans an app-owned declaration file underdata/contracts/that the Pharos runtime or builder consumes.fixtureremains present in some schema names and legacy field names, but the current repository uses these files as executable contract declarations, not throwaway test fixtures.surfacemeans a declared user-facing or machine-facing interface such as an HTML page, JSON API, form, fragment, UI library, generated admin page, or generated API.generated_surfacemeans a derived framework-owned CRUD surface built from entity, form, query, and route metadata.
route
Routes bind request paths to pages, actions, static artifacts, generated surfaces, or route-level request hooks.
Current route kinds:
actionmirror_query_parammirror_request_headerpagerequire_headerrequire_query_paramset_header
Common fields: route_id, path, kind, method, page_id, action_id, artifact, policy_id, auth_gate, security, request_hook, and response_hook.
Example:
route_id: dev_docs_library
path: /reference/library-reference.html
kind: page
artifact: reference/library-reference.html
surface
Surfaces declare renderable or callable app interfaces. Source surface files cover explicitly declared pages, APIs, forms, fragments, and UI libraries. Generated admin/API surfaces are derived at build time from entity metadata.
Current surface kinds:
formfragmentgenerated_admingenerated_apihtml_pagejson_apistatus_pageui_lib
Observed source fields:
introsurface_idsurface_kindtitle
Example:
surface_id: dynamic_app_ui_lib
surface_kind: ui_lib
title: Framework-owned UI element library
intro: The native runtime renders these UI examples directly from checked fixture data so app authors can see the current shared surface contract in one place.
sections:
- section_id: inputs_and_widgets
title: Inputs and widgets
intro: Use shared framework inputs and long-form widgets when operators need typed entry surfaces without app-specific control markup.
layout: grid
examples:
- id: business_name
element_type: input
input_type: text
title: Text input
label: Business name
name: business_name
placeholder: Lotus Studio
usage: Use for short single-line text values such as names, slugs, titles, and other operator-entered identifiers that should stay concise.
tooltip: Framework-owned single-line input for short text fields. Best for values operators can review quickly without opening a longer editor.
- id: reviewer_email
element_type: input
input_type: email
title: Email input
label: Reviewer email
name: reviewer_email
placeholder: reviewer@llight.io
usage: Use for operator-entered email addresses that should follow a strongly typed contact shape.
tooltip: Framework-owned email widget for contact and notification targets. Prefer this over free-form text when the contract expects an address.
ui.element
UI elements are canonical shared controls and preview fragments declared in ui-elements.yml, ui-examples.yml, and UI-library surface sections.
Current UI element types:
badge_listbuttonbutton_rowcardcard_gridcheckboxcheckbox_groupdetailinputlistradio_groupselectsplit_layoutstat_grouptabletextarea
form
Forms define accepted fields and validation rules for submitted input. Generated surfaces and app-authored actions both use these contracts.
Current validation rule kinds:
aftermatchrangerequired
Example:
form_id: service_form
entity_id: service
fields: form-fields.yml#form.service.service_form.fields
submits_action: create_service
validation_rules:
- rule_id: service_name_required
kind: required
field_id: name
- rule_id: service_duration_required
kind: required
field_id: duration_minutes
- rule_id: service_cost_required
kind: required
field_id: cost
defaults:
service_type: standard
location_type: business
buffer_minutes: 0
description: ''
is_active: true
booking_options: []
technician_ids: []
relation_inputs:
- field: technician_ids
related_collection: technicians
related_scope_field: business_id
label_field: name
form_checkbox_prefix: technician_ids__
invalid_rule_id: service_technician_ids_invalid
scope_rule_id: service_technician_scope_invalid
invalid_message: Assigned technicians must be integer ids.
scope_message: Assigned technicians must belong to the same business.
action
Actions define input contracts, mutation primitives, response contracts, and bounded effects.
Current mutation primitive kinds:
append_recordappend_records_from_input_listappend_records_from_related_collectionapproval_transitionbulk_updatedelete_records_by_scopereplace_records_from_input_listreservation_transitionscoped_reassignmentscoped_status_transitionset_root_fieldsupdate_recordupsert_record
Current response kinds:
jsonredirect
Current effect hook groups:
audit_recordsfile_recordsnotificationsscheduled_jobswebhook_dispatch
Example:
action_id: create_task
entity_id: task
policy_gate: public
input_contract:
fields: entity-fields.yml#entity.task.create_task.fields
mutation_primitives:
- primitive_id: create_task_record
primitive_kind: append_record
collection: items
record_contract:
id:
source: next_id
title:
source: input
field: title
done:
source: literal
value: false
workflow_state:
source: literal
value: created
- primitive_id: mark_last_action_create
primitive_kind: set_root_fields
fields: entity-fields.yml#entity.task.mark_last_action_create.fields
response_contract:
response_kind: redirect
location: /
effect_hooks:
scheduled_jobs:
- notify-task-created
webhook_dispatch: []
workflow
Workflows group states and transitions around action-owned lifecycle changes. Transitions can emit audit events, event names, and scheduled jobs.
Common fields: workflow_id, states, transitions, transition_id, from_state, to_state, action_id, policy_gate, emits_audit_event, emits_event, scheduled_jobs, and presentation.
Example:
workflow_id: task_lifecycle
states:
- none
- created
- done
transitions:
- transition_id: create_task_transition
from_state: none
to_state: created
action_id: create_task
policy_gate: public
emits_audit_event: true
emits_event: task_created
scheduled_jobs:
- notify-task-created
presentation:
transition_label: Create task
from_label: New
to_label: Created
- transition_id: create_task_api_transition
from_state: none
to_state: created
action_id: create_task_api
policy_gate: public
emits_audit_event: true
emits_event: task_created_api
scheduled_jobs:
- notify-task-created-api
presentation:
transition_label: Create task API
from_label: New
to_label: Created
integration.adapter
Integration adapters declare outbound delivery and local side-effect targets used by action effect hooks and delivery workers.
Current adapter kinds:
append_jsonl_localaudit_localhttp_formhttp_jsonnotification_localwebhookwrite_json_local
Example:
adapter_id: board-webhook
adapter_kind: webhook
target_url_env: PHAROS_DYNAMIC_APP_BOARD_WEBHOOK_URL
content_type: application/json
timeout_seconds: 5
max_response_bytes: 8192
allow_plaintext_local: true
max_attempts: 2
backoff_seconds: 1
integration.webhook_endpoint
Webhook endpoints declare inbound webhook handling, including endpoint kind and signature verification settings.
Current endpoint kinds:
json_webhook
entity
Entities declare relational storage, identity fields, tenant or parent scope, soft-delete behavior, uniqueness, generated surface requests, and field metadata.
Current storage kinds:
relational
Example:
entity_id: service
storage_kind: relational
table: service
identity_field: id
scope_field: business_id
generated_surfaces:
- admin
- form
- api
- manifest
fields: entity-fields.yml#entity.service.fields
soft_delete_field: is_active
query
Queries declare reusable lookups and projections used by generated surfaces, page parameter builders, auth flows, and runtime handlers.
Example:
query_id: services_by_business
entity_id: service
visibility_scope: policy_bound
filter_set:
- business_id
- is_active
sort_set:
- sort_order_asc
- name_asc
pagination_mode: offset
preload_relations:
- business
- technician
backend_requirements:
- sqlite
- postgresql
policy
Policies declare roles, scopes, capabilities, and role-to-capability edges. Routes and generated surface operations use these capabilities for access control.
Current capabilities:
account_loginaccount_logoutaccount_password_reset_completeaccount_password_reset_requestaccount_registeraccount_verify_emailcancel_appointmentcomplete_appointmentcreate_appointmentcreate_businesscustomerexport_builder_sourceframework_internalmanage_availabilitymanage_builder_settingsmanage_businessmanage_business_membershipsmanage_business_paymentsmanage_business_visibilitymanage_google_calendar_connectionmanage_job_queuemanage_payment_provider_connectionmanage_personal_bookingmanage_profilemanage_servicesmanage_techniciansownerpublicrate_businessrelease_builder_apprequest_cancel_appointmentrequest_reschedule_appointmentreschedule_appointmentreview_builder_planrun_appointment_maintenancescan_business_qrsubmit_builder_tasksubscribe_businessunsubscribe_businessview_appointment_detailview_appointment_diagnosticsview_appointmentsview_business_calendarview_business_detailview_business_landingview_exploreview_job_queueview_owned_businessesview_personal_booking_detailview_personal_bookings
generated_surface
Generated surfaces are derived build artifacts for framework-owned CRUD behavior. They are requested from entity metadata such as generated_surfaces: [admin, api] and assembled from entity, form, query, and route contracts.
Current generated surface kinds:
generated_admingenerated_api
Generated admin operations: manage, create, edit, update, delete, and restore when the entity supports soft delete.
Generated API operations: list, schema, create, update, delete, and restore when the entity supports soft delete.
See Generated Surfaces for the focused generated-surface contract.
Update Contract
Run scripts/check.sh docs reference to verify this checked-in Markdown against the current repo contracts. Run tests/check/docs_reference.py --write after changing contract surfaces so this file stays synchronized with the app-owned declarations.