{"contractVersion":"1.0.0","generatedAt":"2026-12-02T10:28:56.583Z","sourcePlan":"docs/plans/01-node-now-php-later-portability.md","tenancy":{"workspaceIdField":"workspace_id","businessProfileIdField":"business_profile_id","defaultWorkspaceId":"saintcode","notes":["Do not introduce a parallel businesses table or business_id rename.","Every tenant-scoped table and service must filter by workspace_id."]},"reuse":{"checklist":["Database schema concepts","Module manifests","Permissions","Navigation definitions","Install / update / uninstall concepts","Public intake API contracts","Job definitions","CRM workflow rules","Report metadata model","Lead scoring rules"],"permissions":[{"key":"core.manage_workspace","label":"Manage workspace","moduleId":"core-crm"},{"key":"core.manage_members","label":"Manage members","moduleId":"core-crm"},{"key":"core.manage_modules","label":"Manage modules","moduleId":"core-crm"},{"key":"core.connect","label":"Manage connected sites","moduleId":"core-crm"},{"key":"settings.read","label":"Read settings","moduleId":"core-crm"},{"key":"settings.write","label":"Manage settings","moduleId":"core-crm"},{"key":"business_profiles.read","label":"Read business profiles","moduleId":"core-crm"},{"key":"business_profiles.write","label":"Manage business profiles","moduleId":"core-crm"},{"key":"connections.read","label":"Read connections","moduleId":"core-crm"},{"key":"connections.write","label":"Manage connections","moduleId":"core-crm"},{"key":"webhooks.read","label":"Read webhooks","moduleId":"core-crm"},{"key":"webhooks.write","label":"Manage webhooks","moduleId":"core-crm"},{"key":"notifications.read","label":"Read notifications","moduleId":"core-crm"},{"key":"notifications.write","label":"Manage notifications","moduleId":"core-crm"},{"key":"tax_profiles.read","label":"Read tax profiles","moduleId":"core-crm"},{"key":"tax_profiles.write","label":"Manage tax profiles","moduleId":"core-crm"},{"key":"customers.read","label":"Read customers","moduleId":"customers"},{"key":"customers.write","label":"Manage customers","moduleId":"customers"},{"key":"customers.import","label":"Import customers","moduleId":"customers"},{"key":"contacts.read","label":"Read contacts","moduleId":"customers"},{"key":"contacts.write","label":"Manage contacts","moduleId":"customers"},{"key":"deals.read","label":"Read deals","moduleId":"deals"},{"key":"deals.write","label":"Manage deals","moduleId":"deals"},{"key":"products.read","label":"Read products","moduleId":"products"},{"key":"products.write","label":"Manage products","moduleId":"products"},{"key":"quotes.read","label":"Read quotes","moduleId":"quotes"},{"key":"quotes.write","label":"Manage quotes","moduleId":"quotes"},{"key":"quotes.send","label":"Send quotes","moduleId":"quotes"},{"key":"invoices.read","label":"Read invoices","moduleId":"invoicing"},{"key":"invoices.write","label":"Manage invoices","moduleId":"invoicing"},{"key":"invoices.send","label":"Send invoices","moduleId":"invoicing"},{"key":"activities.read","label":"Read activities","moduleId":"activities"},{"key":"activities.write","label":"Manage activities","moduleId":"activities"},{"key":"tasks.read","label":"Read tasks","moduleId":"activities"},{"key":"tasks.write","label":"Manage tasks","moduleId":"activities"},{"key":"notes.read","label":"Read notes","moduleId":"activities"},{"key":"notes.write","label":"Manage notes","moduleId":"activities"},{"key":"leads.read","label":"Read leads","moduleId":"leads"},{"key":"leads.write","label":"Manage leads","moduleId":"leads"},{"key":"marketing.read","label":"Read marketing","moduleId":"marketing-automation"},{"key":"marketing.write","label":"Manage marketing","moduleId":"marketing-automation"},{"key":"marketing.launch","label":"Launch campaigns","moduleId":"marketing-automation"},{"key":"marketing.configure","label":"Configure marketing","moduleId":"marketing-automation"},{"key":"social.read","label":"Read social","moduleId":"social-media-marketing"},{"key":"social.publish","label":"Publish social","moduleId":"social-media-marketing"},{"key":"social.configure","label":"Configure social","moduleId":"social-media-marketing"},{"key":"social.inbox","label":"Social inbox","moduleId":"social-media-marketing"},{"key":"email.read","label":"Read mailbox","moduleId":"email"},{"key":"email.write","label":"Manage mailbox","moduleId":"email"},{"key":"email.send","label":"Send email","moduleId":"email"},{"key":"email.configure","label":"Configure email","moduleId":"email"}],"roles":[{"role":"owner","label":"Owner","permissions":["core.manage_workspace","core.manage_members","core.manage_modules","core.connect","settings.read","settings.write","business_profiles.read","business_profiles.write","connections.read","connections.write","webhooks.read","webhooks.write","notifications.read","notifications.write","tax_profiles.read","tax_profiles.write","customers.read","customers.write","customers.import","contacts.read","contacts.write","deals.read","deals.write","products.read","products.write","quotes.read","quotes.write","quotes.send","invoices.read","invoices.write","invoices.send","activities.read","activities.write","tasks.read","tasks.write","notes.read","notes.write","leads.read","leads.write","marketing.read","marketing.write","marketing.launch","marketing.configure","social.read","social.publish","social.configure","social.inbox","email.read","email.write","email.send","email.configure"]},{"role":"admin","label":"Admin","permissions":["core.manage_workspace","core.manage_modules","core.connect","settings.read","settings.write","business_profiles.read","business_profiles.write","connections.read","connections.write","webhooks.read","webhooks.write","notifications.read","notifications.write","tax_profiles.read","tax_profiles.write","customers.read","customers.write","customers.import","contacts.read","contacts.write","deals.read","deals.write","products.read","products.write","quotes.read","quotes.write","quotes.send","invoices.read","invoices.write","invoices.send","activities.read","activities.write","tasks.read","tasks.write","notes.read","notes.write","leads.read","leads.write","marketing.read","marketing.write","marketing.launch","marketing.configure","social.read","social.publish","social.configure","social.inbox","email.read","email.write","email.send","email.configure"]},{"role":"member","label":"Member","permissions":["customers.read","customers.write","business_profiles.read","connections.read","notifications.read","notifications.write","tax_profiles.read","contacts.read","contacts.write","deals.read","deals.write","products.read","products.write","quotes.read","quotes.write","invoices.read","invoices.write","activities.read","activities.write","tasks.read","tasks.write","notes.read","notes.write","leads.read","leads.write","settings.read","marketing.read","marketing.write","social.read","social.publish","social.configure","social.inbox","email.read","email.write","email.send","email.configure"]},{"role":"viewer","label":"Viewer","permissions":["customers.read","business_profiles.read","connections.read","notifications.read","tax_profiles.read","contacts.read","deals.read","products.read","quotes.read","invoices.read","activities.read","tasks.read","notes.read","leads.read","settings.read","marketing.read","social.read","email.read"]}],"modules":[{"id":"core-crm","name":"Core CRM","version":"0.1.0","status":"core","runtime":["node","php-compatible-contract"],"deploymentProfile":"core","tables":["workspaces","crm_users","workspace_members","workspace_modules","module_installations","activity_events","public_widget_installs","connected_sites","site_connectors","site_pairing_codes","site_profile_snapshots","workspace_package_assignments"],"permissions":["core.manage_workspace","core.manage_members","core.manage_modules","core.connect"],"jobs":[],"publicIntakeEndpoints":[],"phpEditionV1":false,"nodeOnly":false},{"id":"customers","name":"Customers","version":"0.1.0","status":"core","runtime":["node","php-compatible-contract"],"deploymentProfile":"core","tables":["customers","contacts"],"permissions":["customers.read","customers.write","customers.import","contacts.read","contacts.write"],"jobs":[],"publicIntakeEndpoints":[],"phpEditionV1":true,"nodeOnly":false},{"id":"deals","name":"Deals","version":"0.1.0","status":"core","runtime":["node","php-compatible-contract"],"deploymentProfile":"core","tables":["deals","deal_line_items","deal_contacts"],"permissions":["deals.read","deals.write"],"jobs":[],"publicIntakeEndpoints":[],"phpEditionV1":false,"nodeOnly":false},{"id":"products","name":"Products","version":"0.1.0","status":"core","runtime":["node","php-compatible-contract"],"deploymentProfile":"core","tables":["products"],"permissions":["products.read","products.write"],"jobs":[],"publicIntakeEndpoints":[],"phpEditionV1":false,"nodeOnly":false},{"id":"quotes","name":"Quotes","version":"0.1.0","status":"core","runtime":["node","php-compatible-contract"],"deploymentProfile":"core","tables":["quotes","quote_line_items","quote_templates","quote_template_line_items"],"permissions":["quotes.read","quotes.write","quotes.send"],"jobs":[],"publicIntakeEndpoints":[],"phpEditionV1":false,"nodeOnly":false},{"id":"invoicing","name":"Invoicing","version":"0.1.0","status":"active","runtime":["node","php-compatible-contract"],"deploymentProfile":"core","tables":["invoices","invoice_line_items","recurring_invoice_schedules","recurring_invoice_line_items"],"permissions":["invoices.read","invoices.write","invoices.send"],"jobs":[{"key":"invoices.mark_overdue","label":"Mark overdue invoices","schedule":"0 2 * * *","description":"Flag sent invoices past due date."},{"key":"invoices.recurring_generate","label":"Generate recurring invoices","schedule":"0 6 * * *","description":"Create draft invoices from due recurring schedules."}],"publicIntakeEndpoints":[],"phpEditionV1":false,"nodeOnly":false},{"id":"activities","name":"Activities","version":"0.1.0","status":"core","runtime":["node","php-compatible-contract"],"deploymentProfile":"core","tables":["activities"],"permissions":["activities.read","activities.write"],"jobs":[],"publicIntakeEndpoints":[],"phpEditionV1":false,"nodeOnly":false},{"id":"leads","name":"Leads","version":"0.1.0","status":"active","runtime":["node","php-compatible-contract"],"deploymentProfile":"standard","tables":["leads","lead_events","lead_tasks","contacts","companies"],"permissions":["leads.read","leads.write","leads.import"],"jobs":[{"key":"leads.score","label":"Score leads","schedule":null,"description":"Recalculate lead quality and next action."},{"key":"leads.dedupe","label":"Dedupe leads","schedule":null,"description":"Find duplicate contacts and companies across workspaces."}],"publicIntakeEndpoints":[],"phpEditionV1":true,"nodeOnly":false},{"id":"email","name":"Email CRM","version":"0.1.0","status":"active","runtime":["node","php-compatible-contract"],"deploymentProfile":"standard","tables":["email_accounts","email_folders","email_messages","email_drafts","email_templates","email_signatures"],"permissions":["email.read","email.write","email.send","email.configure"],"jobs":[{"key":"email.sync","label":"Sync mailbox","schedule":"*/5 * * * *","description":"Fetch new messages and link replies to leads."},{"key":"email.followups","label":"Prepare follow-ups","schedule":"0 * * * *","description":"Queue due follow-up drafts."}],"publicIntakeEndpoints":[],"phpEditionV1":true,"nodeOnly":false},{"id":"marketing-automation","name":"Marketing Automation","version":"0.1.0","status":"planned","runtime":["node","php-compatible-contract"],"deploymentProfile":"standard","tables":["marketing_campaigns","marketing_audiences","marketing_audience_members","marketing_workflows","marketing_workflow_steps","marketing_campaign_events","marketing_campaign_reports"],"permissions":["marketing.read","marketing.write","marketing.launch","marketing.configure"],"jobs":[{"key":"marketing.evaluate_workflows","label":"Evaluate campaign workflows","schedule":"*/10 * * * *","description":"Evaluate scheduled campaign workflow steps and enqueue module actions when approved."},{"key":"marketing.refresh_reports","label":"Refresh campaign reports","schedule":"0 7 * * *","description":"Rebuild campaign reporting rollups from email, social, lead, and deal events."}],"publicIntakeEndpoints":[],"phpEditionV1":false,"nodeOnly":false},{"id":"seo-checker","name":"SEO Checker","version":"0.1.0","status":"active","runtime":["node","php-compatible-contract"],"deploymentProfile":"public-bridge","tables":["seo_scans","seo_scan_checks","tool_intake_requests"],"permissions":["seo.read","seo.run","seo.configure"],"jobs":[{"key":"seo.scan","label":"Run SEO scan","schedule":null,"description":"Perform crawling, checks, PageSpeed enrichment, and lead extraction."},{"key":"seo.report","label":"Generate SEO report","schedule":null,"description":"Generate and store PDF reports for CRM outreach."}],"publicIntakeEndpoints":["/api/seo-check","/api/seo-check/performance","/api/seo-check/result/[scanId]","/api/seo-report"],"phpEditionV1":true,"nodeOnly":false},{"id":"ads-readiness","name":"Google Ads Readiness","version":"0.1.0","status":"active","runtime":["node","php-compatible-contract"],"deploymentProfile":"public-bridge","tables":["ads_readiness_scans","ads_readiness_checks","tool_intake_requests"],"permissions":["ads_readiness.read","ads_readiness.run","ads_readiness.configure"],"jobs":[{"key":"ads_readiness.scan","label":"Run Ads Readiness scan","schedule":null,"description":"Check page quality, messaging, conversion, tracking, and speed."},{"key":"ads_readiness.report","label":"Generate Ads report","schedule":null,"description":"Generate and store readiness PDFs."}],"publicIntakeEndpoints":["/api/google-ads-readiness","/api/google-ads-readiness/result/[scanId]","/api/google-ads-readiness/report"],"phpEditionV1":true,"nodeOnly":false},{"id":"api-usage","name":"API Usage Governance","version":"0.1.0","status":"active","runtime":["node","php-compatible-contract"],"deploymentProfile":"api-heavy","tables":["api_usage","api_quotas","api_budget_rules"],"permissions":["api_usage.read","api_usage.configure"],"jobs":[{"key":"api_usage.rollup","label":"Roll up API usage","schedule":"5 * * * *","description":"Prepare hourly/daily usage summaries."}],"publicIntakeEndpoints":[],"phpEditionV1":false,"nodeOnly":false},{"id":"google-ads-keywords","name":"Google Ads Keyword Research","version":"0.1.0","status":"active","runtime":["node"],"deploymentProfile":"node-only","tables":["google_ads_keyword_rows","google_ads_runs","api_usage"],"permissions":["keywords.read","keywords.run","keywords.configure"],"jobs":[{"key":"keywords.collect","label":"Collect keyword rows","schedule":null,"description":"Run Google Ads API requests with daily operation budgets."},{"key":"keywords.enrich","label":"Enrich keyword rows","schedule":null,"description":"Infer market, city, business type, and campaign context."}],"publicIntakeEndpoints":[],"phpEditionV1":false,"nodeOnly":true},{"id":"reports","name":"Reports","version":"0.1.0","status":"active","runtime":["node","php-compatible-contract"],"deploymentProfile":"standard","tables":["reports","report_files","report_events"],"permissions":["reports.read","reports.generate","reports.send"],"jobs":[{"key":"reports.generate","label":"Generate report","schedule":null,"description":"Render and store module reports."},{"key":"reports.cleanup","label":"Clean old reports","schedule":"0 3 * * *","description":"Apply retention rules for stored report files."}],"publicIntakeEndpoints":[],"phpEditionV1":true,"nodeOnly":false},{"id":"social-media-marketing","name":"Social Media Marketing","version":"0.1.0","status":"planned","runtime":["node","php-compatible-contract"],"deploymentProfile":"standard","tables":["social_brands","social_accounts","social_posts","social_post_metrics","social_inbox_threads","social_smartlinks"],"permissions":["social.read","social.publish","social.configure","social.inbox"],"jobs":[{"key":"social.publish","label":"Publish scheduled posts","schedule":"*/5 * * * *","description":"Dispatch due scheduled posts to connected social networks."},{"key":"social.sync_analytics","label":"Sync social analytics","schedule":"0 6 * * *","description":"Pull reach, engagement, and follower metrics per connected account."},{"key":"social.sync_inbox","label":"Sync social inbox","schedule":"*/15 * * * *","description":"Fetch new DMs, comments, and reviews where APIs allow."}],"publicIntakeEndpoints":[],"phpEditionV1":false,"nodeOnly":false},{"id":"connect","name":"CRM Connect","version":"0.1.0","status":"active","runtime":["node"],"deploymentProfile":"standard","tables":["connected_sites","connect_site_links","connect_site_environment","connect_pairing_site_links"],"permissions":["connect.read","connect.write"],"jobs":[],"publicIntakeEndpoints":[],"phpEditionV1":false,"nodeOnly":true}],"machineApi":{"basePath":"/api/machine/v1","scopes":["seo.report.generate","leads.read","leads.write","customers.read","customers.write","contacts.read","contacts.write","deals.read","deals.write","pipelines.read","quotes.read","quotes.write","quote_templates.read","quote_templates.write","products.read","products.write","packages.read","packages.write","invoices.read","invoices.write","activities.read","activities.write","keywords.read","keywords.write","seo.read","business_profiles.read","workspaces.read","connections.read","connections.write","webhooks.read","webhooks.write","events.read","mcp.invoke","approvals.read","approvals.write"],"resources":[{"id":"health","label":"Machine health","readScope":null,"writeScope":null,"wave":"framework"},{"id":"seo-reports","label":"SEO PDF reports","readScope":null,"writeScope":"seo.report.generate","wave":"framework"},{"id":"leads","label":"Leads","readScope":"leads.read","writeScope":"leads.write","wave":"a"},{"id":"customers","label":"Customers (companies)","readScope":"customers.read","writeScope":"customers.write","wave":"a"},{"id":"contacts","label":"Contacts","readScope":"contacts.read","writeScope":"contacts.write","wave":"a"},{"id":"pipelines","label":"Deal pipelines","readScope":"pipelines.read","writeScope":null,"wave":"b"},{"id":"deals","label":"Deals","readScope":"deals.read","writeScope":"deals.write","wave":"b"},{"id":"quotes","label":"Quotes","readScope":"quotes.read","writeScope":"quotes.write","wave":"b"},{"id":"quote-templates","label":"Quote templates","readScope":"quote_templates.read","writeScope":"quote_templates.write","wave":"b"},{"id":"products","label":"Products","readScope":"products.read","writeScope":"products.write","wave":"b"},{"id":"packages","label":"CRM packages","readScope":"packages.read","writeScope":"packages.write","wave":"b"},{"id":"invoices","label":"Invoices","readScope":"invoices.read","writeScope":"invoices.write","wave":"b"},{"id":"activities","label":"Activities","readScope":"activities.read","writeScope":"activities.write","wave":"c"},{"id":"keyword-research/runs","label":"Keyword research runs","readScope":"keywords.read","writeScope":null,"wave":"c"},{"id":"business-profiles","label":"Business profiles","readScope":"business_profiles.read","writeScope":null,"wave":"c"},{"id":"workspaces","label":"Workspaces","readScope":"workspaces.read","writeScope":null,"wave":"c"},{"id":"connections","label":"Business connections","readScope":"connections.read","writeScope":"connections.write","wave":"c"},{"id":"webhooks/subscriptions","label":"Webhook subscriptions","readScope":"webhooks.read","writeScope":"webhooks.write","wave":"c"},{"id":"events","label":"CRM event outbox","readScope":"events.read","writeScope":null,"wave":"c"},{"id":"mcp/tools","label":"MCP tool catalog","readScope":"mcp.invoke","writeScope":null,"wave":"c"},{"id":"mcp/invoke","label":"MCP tool invoke","readScope":null,"writeScope":"mcp.invoke","wave":"c"},{"id":"approvals","label":"Agent approval queue","readScope":"approvals.read","writeScope":"approvals.write","wave":"c"}],"operations":[{"method":"get","path":"/api/machine/v1/health","operationId":"get_health","scope":null,"idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/seo-reports","operationId":"post_seo-reports","scope":"seo.report.generate","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/leads","operationId":"get_leads","scope":"leads.read","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/leads","operationId":"post_leads","scope":"leads.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/leads/{leadId}","operationId":"get_leads_item","scope":"leads.read","idempotencyRequired":false},{"method":"patch","path":"/api/machine/v1/leads/{leadId}","operationId":"patch_leads_item","scope":"leads.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/customers","operationId":"get_customers","scope":"customers.read","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/customers","operationId":"post_customers","scope":"customers.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/customers/{customerId}","operationId":"get_customers_item","scope":"customers.read","idempotencyRequired":false},{"method":"patch","path":"/api/machine/v1/customers/{customerId}","operationId":"patch_customers_item","scope":"customers.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/contacts","operationId":"get_contacts","scope":"contacts.read","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/contacts","operationId":"post_contacts","scope":"contacts.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/contacts/{contactId}","operationId":"get_contacts_item","scope":"contacts.read","idempotencyRequired":false},{"method":"patch","path":"/api/machine/v1/contacts/{contactId}","operationId":"patch_contacts_item","scope":"contacts.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/pipelines","operationId":"get_pipelines","scope":"pipelines.read","idempotencyRequired":false},{"method":"get","path":"/api/machine/v1/deals","operationId":"get_deals","scope":"deals.read","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/deals","operationId":"post_deals","scope":"deals.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/deals/{dealId}","operationId":"get_deals_item","scope":"deals.read","idempotencyRequired":false},{"method":"patch","path":"/api/machine/v1/deals/{dealId}","operationId":"patch_deals_item","scope":"deals.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/quotes","operationId":"get_quotes","scope":"quotes.read","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/quotes","operationId":"post_quotes","scope":"quotes.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/quotes/{quoteId}","operationId":"get_quotes_item","scope":"quotes.read","idempotencyRequired":false},{"method":"patch","path":"/api/machine/v1/quotes/{quoteId}","operationId":"patch_quotes_item","scope":"quotes.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/quote-templates","operationId":"get_quote-templates","scope":"quote_templates.read","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/quote-templates","operationId":"post_quote-templates","scope":"quote_templates.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/quote-templates/{templateId}","operationId":"get_quote-templates_item","scope":"quote_templates.read","idempotencyRequired":false},{"method":"patch","path":"/api/machine/v1/quote-templates/{templateId}","operationId":"patch_quote-templates_item","scope":"quote_templates.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/products","operationId":"get_products","scope":"products.read","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/products","operationId":"post_products","scope":"products.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/products/{productId}","operationId":"get_products_item","scope":"products.read","idempotencyRequired":false},{"method":"patch","path":"/api/machine/v1/products/{productId}","operationId":"patch_products_item","scope":"products.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/packages","operationId":"get_packages","scope":"packages.read","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/packages","operationId":"post_packages","scope":"packages.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/invoices","operationId":"get_invoices","scope":"invoices.read","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/invoices","operationId":"post_invoices","scope":"invoices.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/invoices/{invoiceId}","operationId":"get_invoices_item","scope":"invoices.read","idempotencyRequired":false},{"method":"patch","path":"/api/machine/v1/invoices/{invoiceId}","operationId":"patch_invoices_item","scope":"invoices.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/activities","operationId":"get_activities","scope":"activities.read","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/activities","operationId":"post_activities","scope":"activities.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/activities/{activityId}","operationId":"get_activities_item","scope":"activities.read","idempotencyRequired":false},{"method":"patch","path":"/api/machine/v1/activities/{activityId}","operationId":"patch_activities_item","scope":"activities.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/keyword-research/runs","operationId":"get_keyword-research_runs","scope":"keywords.read","idempotencyRequired":false},{"method":"get","path":"/api/machine/v1/keyword-research/runs/{runId}","operationId":"get_keyword-research_runs_item","scope":"keywords.read","idempotencyRequired":false},{"method":"get","path":"/api/machine/v1/business-profiles","operationId":"get_business-profiles","scope":"business_profiles.read","idempotencyRequired":false},{"method":"get","path":"/api/machine/v1/workspaces","operationId":"get_workspaces","scope":"workspaces.read","idempotencyRequired":false},{"method":"get","path":"/api/machine/v1/connections","operationId":"get_connections","scope":"connections.read","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/connections/{connectionId}/test","operationId":"post_connections_test","scope":"connections.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/webhooks/subscriptions","operationId":"get_webhooks_subscriptions","scope":"webhooks.read","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/webhooks/subscriptions","operationId":"post_webhooks_subscriptions","scope":"webhooks.write","idempotencyRequired":true},{"method":"patch","path":"/api/machine/v1/webhooks/subscriptions/{subscriptionId}","operationId":"patch_webhooks_subscriptions_item","scope":"webhooks.write","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/events","operationId":"get_events","scope":"events.read","idempotencyRequired":false},{"method":"get","path":"/api/machine/v1/mcp/tools","operationId":"get_mcp_tools","scope":"mcp.invoke","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/mcp/invoke","operationId":"post_mcp_invoke","scope":"mcp.invoke","idempotencyRequired":true},{"method":"get","path":"/api/machine/v1/approvals","operationId":"get_approvals","scope":"approvals.read","idempotencyRequired":false},{"method":"post","path":"/api/machine/v1/approvals/{approvalId}/execute","operationId":"post_approvals_execute","scope":"approvals.write","idempotencyRequired":true}]}},"rewrite":{"checklist":["API controllers bound to Next.js routes","UI if the PHP edition does not use React","Email provider adapter","Job runner","File storage adapter","Database adapter implementation"],"adapters":["Next.js route handlers → PHP controllers or front controller","React admin UI → PHP templates or separate SPA","node:crypto vault → PHP OpenSSL AES-256-GCM compatible with v1: ciphertext format","tsx/node cron scripts → PHP CLI cron entrypoints","Postgres driver → PDO MariaDB/MySQL"]},"schema":{"guidelines":[{"use":"varchar/text/datetime/int/decimal","avoid":"database-specific generated columns","reason":"Keeps migrations portable across Postgres, MariaDB, MySQL, and a future PHP runtime."},{"use":"json or longtext for low-query metadata","avoid":"Postgres jsonb operators in business logic","reason":"The same module data can be used by Node now and PHP/MariaDB later."},{"use":"relational tables for important CRM state","avoid":"large opaque JSON blobs for leads, emails, tasks, or reports","reason":"Reports, permissions, search, and migrations stay maintainable."}],"typeMappings":[{"portableName":"varchar","postgres":"varchar(n)","mariadb":"varchar(n)","mysql":"varchar(n)"},{"portableName":"text","postgres":"text","mariadb":"text / longtext","mysql":"text / longtext"},{"portableName":"integer","postgres":"integer","mariadb":"int","mysql":"int"},{"portableName":"boolean","postgres":"boolean","mariadb":"tinyint(1)","mysql":"tinyint(1)"},{"portableName":"timestamptz","postgres":"timestamptz","mariadb":"datetime(6) (store UTC)","mysql":"datetime(6) (store UTC)","notes":"Application code treats timestamps as UTC ISO-8601 strings."},{"portableName":"json_text","postgres":"text (preferred) or jsonb (legacy)","mariadb":"longtext","mysql":"longtext","notes":"Columns named *_json; parse in application code. New migrations must not use jsonb."},{"portableName":"decimal","postgres":"numeric/decimal","mariadb":"decimal(p,s)","mysql":"decimal(p,s)"}],"portableMigrationFloor":44,"migrationScan":{"status":"fail","detail":"New migrations (>=44) use Postgres-only SQL (050_social_posts_media.sql:jsonb×1, 052_workspace_settings.sql:jsonb×1, 055_custom_fields.sql:jsonb×1). Prefer varchar/text/timestamptz.","scannedFiles":56,"legacyFindingCount":6,"recentFindingCount":3}},"phpEditionV1":{"moduleIds":["leads","customers","reports","seo-checker","ads-readiness","email"],"hosting":"cPanel / shared hosting with PHP + MariaDB cron","deferredToNode":["Full IMAP sync and heavy email automation","Background workers that require long-lived Node processes","API-heavy keyword / ads collectors marked node-only"]}}