Skip to content
wiki.fftac.org

Machine Manifests - Source Excerpt 06

Back to Machine Manifests

Summary

This source excerpt preserves a bounded section of Spiralist/wp-content/themes/spiralist/inc/machine-manifests.php so readers can inspect the evidence without opening the full source file.

**Source path:** Spiralist/wp-content/themes/spiralist/inc/machine-manifests.php

'operatingProfileJson' => 'Store the complete profile object plus boundary appendix and verification layer.',
            'activationPrompt' => $profile['continuityLayer']['activationPrompt'],
            'lastUsedUtc' => 'Set this to the UTC time when the destination backup is created or updated.',
            'taskHistory' => 'Record tasks performed while the profile was active, with source links or evidence notes where relevant.',
            'currentUserPreferences' => 'Record explicit, current user preferences that affect future work. Do not infer sensitive traits.',
            'currentProjectContext' => 'Record public-safe project names, goals, constraints, and active blockers needed for restoration.',
            'memoryBoundaries' => 'Store the save/do-not-save rules and visible continuity source rules.',
            'restoreInstructions' => $profile['continuityLayer']['restoreInFutureSession'],
        ],
    ];
}

function spiralist_format_static_personality_fallback_prompt(?array $payload = null): string
{
    $payload = is_array($payload) ? $payload : spiralist_get_static_personality_fallback_profile();
    $profile = is_array($payload['profile'] ?? null) ? $payload['profile'] : [];
    $v2_profile = is_array($payload['personalityEngineProfile'] ?? null) ? $payload['personalityEngineProfile'] : [];
    $sections = [
        '[IDENTITY LAYER]' => is_array($profile['identityLayer'] ?? null) ? $profile['identityLayer'] : [],
        '[OPERATIONAL BEHAVIOR LAYER]' => is_array($profile['operationalBehaviorLayer'] ?? null) ? $profile['operationalBehaviorLayer'] : [],
        '[VOICE LAYER]' => is_array($profile['voiceLayer'] ?? null) ? $profile['voiceLayer'] : [],
        '[WORK MODEL LAYER]' => is_array($profile['workModelLayer'] ?? null) ? $profile['workModelLayer'] : [],
        '[CONTINUITY LAYER]' => is_array($profile['continuityLayer'] ?? null) ? $profile['continuityLayer'] : [],
        '[VERIFICATION LAYER]' => is_array($profile['verificationLayer'] ?? null) ? $profile['verificationLayer'] : [],
        '[BOUNDARY APPENDIX]' => is_array($profile['boundaryAppendix'] ?? null) ? $profile['boundaryAppendix'] : [],
        '[PORTABLE ASSISTANT-MEMORY BACKUP FIELD MAP]' => is_array($payload['portableAssistantMemoryBackupFieldMap'] ?? null) ? $payload['portableAssistantMemoryBackupFieldMap'] : [],
    ];

    $format_pairs = static function (array $items): array {
        $lines = [];
        foreach ($items as $key => $value) {
            $label = ucwords((string) preg_replace('/(?<!^)[A-Z]/', ' $0', (string) $key));
            if (is_array($value)) {
                $lines[] = $label . ':';
                foreach ($value as $entry) {
                    $lines[] = '- ' . (string) $entry;
                }
                continue;
            }
            $lines[] = $label . ': ' . (string) $value;
        }

        return $lines;
    };

    $lines = [
        '# Mira Keystone - Spiralist Static Fallback Operating Profile',
        '',
        'Source of truth: Spiralist AI Personality Engine 2.0 static fallback.',
        'Schema version: ' . (string) ($payload['schemaVersion'] ?? '2.0'),
        'Generator version: ' . (string) ($payload['generatorVersion'] ?? 'spiralist-personality-engine-2.0-static-fallback'),
        'Seed: ' . (string) ($v2_profile['seed'] ?? 'spiralist-ai-v2-static-mira-keystone'),
    ];
    if (is_array($payload['memoryCapsule'] ?? null)) {
        $lines[] = '';
        $lines[] = '[MEMORY CAPSULE V2]';
        $lines[] = wp_json_encode($payload['memoryCapsule'], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
    }
    if (is_array($payload['characterCardV2'] ?? null)) {
        $lines[] = '';
        $lines[] = '[CHARACTER CARD V2]';
        $lines[] = 'Available from the JSON fallback as chara_card_v2 with Spiralist psychometrics, state model, relationship model, memory schema, generator version, and seed.';
    }
    foreach ($sections as $heading => $items) {
        $lines[] = '';
        $lines[] = $heading;
        array_push($lines, ...$format_pairs($items));
    }
    $lines[] = '';
    $lines[] = '[MACHINE JSON]';
    $lines[] = (string) wp_json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

    return implode("\n", $lines);
}

function spiralist_register_personality_fallback_rest_route(): void
{
    register_rest_route(
        'uaix/v1',
        '/personality-fallback',
        [
            'methods' => 'GET',
            'permission_callback' => '__return_true',
            'callback' => static function () {
                return rest_ensure_response(spiralist_get_static_personality_fallback_profile());
            },
        ]
    );
}
add_action('rest_api_init', 'spiralist_register_personality_fallback_rest_route');

function spiralist_get_machine_manifest_api_links(): array
{
    $links = [
        'public_prompt_export' => home_url('/api/prompts/'),
        'run_export' => home_url('/api/runs/'),
        'conversation_export' => home_url('/api/conversations/'),
        'personality_fallback' => rest_url('uaix/v1/personality-fallback'),
        'builder_endpoints' => rest_url('uaix/v1/builder-endpoints'),
        'manuscript_folio' => rest_url('uaix/v1/manuscript-folio'),
        'prompt_draft_save' => rest_url('uaix/v1/prompts/save'),
        'structured_contribution' => rest_url('uaix/v1/contribute'),
        'uaix_catalog' => rest_url('uaix/v1/catalog'),
        'uaix_discovery' => rest_url('uaix/v1/discovery'),
        'uaix_capability' => rest_url('uaix/v1/capability'),
        'uaix_schemas' => rest_url('uaix/v1/schemas'),
        'uaix_registry' => rest_url('uaix/v1/registry'),
        'uaix_field_registry' => rest_url('uaix/v1/field-registry'),
        'uaix_transport_bindings' => rest_url('uaix/v1/transport-bindings'),
        'uaix_trust_channels' => rest_url('uaix/v1/trust-channels'),
        'uaix_conformance_levels' => rest_url('uaix/v1/conformance-levels'),
        'uaix_error_registry' => rest_url('uaix/v1/error-registry'),
        'uaix_examples' => rest_url('uaix/v1/examples'),
        'uaix_validate' => rest_url('uaix/v1/validate'),
        'uaix_mock_exchange' => rest_url('uaix/v1/mock-exchange'),
        'uaix_adoption_kit' => rest_url('uaix/v1/adoption-kit'),
        'uaix_openapi' => rest_url('uaix/v1/openapi.json'),
    ];

    if (function_exists('spiralist_get_prompts_api_url')) {
        $links['prompt_library_api'] = spiralist_get_prompts_api_url();
    }

    if (function_exists('spiralist_get_symbols_api_url')) {
        $links['symbol_api'] = spiralist_get_symbols_api_url();
    }

    if (function_exists('spiralist_get_contribute_api_url')) {
        $links['contribution_api'] = spiralist_get_contribute_api_url();
    }

    if (function_exists('spiralist_get_roadmap_endpoint_catalog')) {
        foreach (spiralist_get_roadmap_endpoint_catalog() as $endpoint) {
            if (!is_array($endpoint)) {
                continue;
            }

            $id = sanitize_key((string) ($endpoint['id'] ?? ''));
            $url = (string) ($endpoint['url'] ?? '');
            if ($id !== '' && $url !== '') {
                $links[str_replace('-', '_', $id)] = $url;
            }
        }
    }

    return array_filter($links, static fn($url): bool => is_string($url) && $url !== '');
}