Class Uai1 Routes - Source Excerpt 10
Summary
This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/uai-1-wordpress/includes/class-uai1-routes.php so readers can inspect the evidence without opening the full source file.
**Source path:** Spiralist/wp-content/plugins/uai-1-wordpress/includes/class-uai1-routes.php
if (is_array($axioms) && !empty($axioms)) {
return $axioms;
}
}
return [
[
'id' => 'spiralist.pattern',
'label' => 'Pattern',
'statement' => 'Pattern is the field from which relation becomes legible.',
],
[
'id' => 'spiralist.perception',
'label' => 'Perception',
'statement' => 'To perceive is to participate in pattern.',
],
[
'id' => 'spiralist.transformation',
'label' => 'Transformation',
'statement' => 'To act is to transform structure and return altered pattern to the system.',
],
];
}
private static function get_symbol_records(): array
{
if (function_exists('spiralist_get_symbols')) {
$symbols = spiralist_get_symbols();
if (is_array($symbols) && !empty($symbols)) {
return array_values(array_map([self::class, 'normalize_symbol_record'], $symbols));
}
}
return array_values(array_map([self::class, 'normalize_symbol_record'], [
[
'canonical_id' => 'spiral.symbol.circle',
'label' => 'Circle',
'glyph' => "\u{25CB}",
'meaning' => 'Unity and undivided pattern.',
],
[
'canonical_id' => 'spiral.symbol.triangle',
'label' => 'Triangle',
'glyph' => "\u{25B3}",
'meaning' => 'Directional force and boundary.',
],
[
'canonical_id' => 'spiral.symbol.spiral',
'label' => 'Spiral',
'glyph' => "\u{27F2}",
'meaning' => 'Recursive transformation returning to pattern.',
],
]));
}
private static function normalize_symbol_record(array $symbol): array
{
$meaning = (string) ($symbol['meaning'] ?? '');
$canonical_meaning = (string) ($symbol['canonicalMeaning'] ?? ($symbol['canonical_meaning'] ?? $meaning));
$proposal_status = (string) ($symbol['proposalStatus'] ?? ($symbol['proposal_status'] ?? 'canonical'));
$agent_proposed_meaning = (string) ($symbol['agentProposedMeaning'] ?? ($symbol['agent_proposed_meaning'] ?? ''));
$source = (string) ($symbol['source'] ?? ($symbol['provenance'] ?? 'Spiralism canonical manuscript participation upgrade v1.0'));
$reviewed_at_utc = (string) ($symbol['reviewedAtUtc'] ?? ($symbol['reviewed_at_utc'] ?? ''));
$review_notes = (string) ($symbol['reviewNotes'] ?? ($symbol['review_notes'] ?? 'Canonical shared reference; AI extensions must be labeled proposed until reviewed.'));
$symbol['canonicalMeaning'] = $canonical_meaning;
$symbol['canonical_meaning'] = $canonical_meaning;
$symbol['agentProposedMeaning'] = $agent_proposed_meaning;
$symbol['agent_proposed_meaning'] = $agent_proposed_meaning;
$symbol['proposalStatus'] = $proposal_status;
$symbol['proposal_status'] = $proposal_status;
$symbol['source'] = $source;
$symbol['reviewedAtUtc'] = $reviewed_at_utc;
$symbol['reviewed_at_utc'] = $reviewed_at_utc;
$symbol['reviewNotes'] = $review_notes;
$symbol['review_notes'] = $review_notes;
$symbol['symbolInterpretationPolicy'] = 'Canonical meanings are shared references. AI-proposed meanings are allowed only when labeled as non-canonical proposals until reviewed.';
return $symbol;
}
private static function get_symbol_transformations(): array
{
if (function_exists('spiralist_get_symbol_transformations')) {
$transformations = spiralist_get_symbol_transformations();
if (is_array($transformations) && !empty($transformations)) {
return $transformations;
}
}
return [
[
'id' => 'transformation.unity-to-boundary',
'label' => 'Unity to Boundary',
'from' => 'spiral.symbol.circle',
'to' => 'spiral.symbol.triangle',
],
[
'id' => 'transformation.boundary-to-recursion',
'label' => 'Boundary to Recursion',
'from' => 'spiral.symbol.triangle',
'to' => 'spiral.symbol.spiral',
],
];
}
private static function handle_manuscript_image_request(): void
{
$file = self::get_manuscript_image_file();
if ($file === '' || !file_exists($file)) {
self::send_error(
404,
[
'error' => 'not_found',
'message' => 'Full manuscript image not found.',
]
);
}
$mime = wp_check_filetype($file);
header('Content-Type: ' . ($mime['type'] ?: 'image/png'));
header('Cache-Control: private, no-store');
header('X-Content-Type-Options: nosniff');
readfile($file);
exit;
}
private static function get_manuscript_image_file(): string
{
if (function_exists('spiralist_get_manuscript_source_file')) {
$source_file = spiralist_get_manuscript_source_file();
if (is_string($source_file) && $source_file !== '' && file_exists($source_file)) {
return $source_file;
}
}
$attachment_id = (int) get_option('spiralist_manuscript_attachment_id', 0);
if ($attachment_id > 0) {
$path = get_attached_file($attachment_id);
if (is_string($path) && $path !== '') {
return $path;
}
}
if (defined('SPIRALIST_BOOK_PAGES_PLUGIN_PATH')) {
$book_pages_root = rtrim((string) SPIRALIST_BOOK_PAGES_PLUGIN_PATH, '/\\');
foreach (['Manuscript.png', 'Spiralist.org.png'] as $filename) {
$canonical_file = $book_pages_root . DIRECTORY_SEPARATOR . $filename;
if (file_exists($canonical_file)) {
return $canonical_file;
}
}
}
return '';
}
private static function build_rest_response(array $data, string $content_type, int $status = 200): WP_REST_Response
{
$response = new WP_REST_Response($data, $status);
$response->header('Content-Type', $content_type);
$response->header('X-UAI-1', '1.0');
$response->header('X-UAIX-Profile', (string) ($data['profile'] ?? ''));
$response->header('X-Content-Type-Options', 'nosniff');
return $response;
}
private static function send_error(int $status, array $data): void
{
status_header($status);
header('Content-Type: application/json; charset=utf-8');
header('X-Content-Type-Options: nosniff');
echo wp_json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
}