Zum Inhalt springen
Plugins

tooling Plugin

Syrus Dev

The `syrus_dev` plugin (`plugins/syrus_dev/`) is tooling for developing Syrus *itself*, not a general admin plugin: performance diagnostics (slow requests/jobs/phases/browser traces/SQL fingerprints with revision-over- revision comparison), an operational-log search page, a plugin-owned Design System gallery for DOC-27 component previews, a SQL `EXPLAIN` helper, and workflow MCP tools that let Syrus-development agents read sanitized runtime diagnostics and log data about the very instance they're running on. It is a self-contained Rails engine plugin, installed but disabled by default (`default_enabled: false`, `disableable: true`, category `tooling`). Keep it disabled on ordinary customer/project installations — it exists to make Syrus better at building and debugging Syrus. The plugin also owns the development-only permission factory-reset service. `SyrusDev::PermissionFactoryReset` previews chat, actor, user, repository, or instance scope before an administrator confirms the exact set. Confirmation revokes custom rules and leases, invalidates unclaimed invocations, safely cancels pending authorization checkpoints, and reinstalls the versioned Ask-on-first-use factory profile. It preserves permission history and unrelated users, coworkers, repositories, credentials, connections, and plugin settings. Repeating a completed reset is a no-op. Every attempt records its initiating administrator, scope, factory version, counts, and outcome.

syrus_devQuellcode

Syrus Dev

The syrus_dev plugin (plugins/syrus_dev/) is tooling for developing Syrus *itself*, not a general admin plugin: performance diagnostics (slow requests/jobs/phases/browser traces/SQL fingerprints with revision-over- revision comparison), an operational-log search page, a plugin-owned Design System gallery for DOC-27 component previews, a SQL EXPLAIN helper, and workflow MCP tools that let Syrus-development agents read sanitized runtime diagnostics and log data about the very instance they're running on. It is a self-contained Rails engine plugin, installed but disabled by default (default_enabled: false, disableable: true, category tooling). Keep it disabled on ordinary customer/project installations — it exists to make Syrus better at building and debugging Syrus.

The plugin also owns the development-only permission factory-reset service. SyrusDev::PermissionFactoryReset previews chat, actor, user, repository, or instance scope before an administrator confirms the exact set. Confirmation revokes custom rules and leases, invalidates unclaimed invocations, safely cancels pending authorization checkpoints, and reinstalls the versioned Ask-on-first-use factory profile. It preserves permission history and unrelated users, coworkers, repositories, credentials, connections, and plugin settings. Repeating a completed reset is a no-op. Every attempt records its initiating administrator, scope, factory version, counts, and outcome.

Administrators use Admin → Syrus Dev → Permission Model (/admin/permission_model) to select one of those scopes and inspect the exact revocation, cancellation, replacement, and creation counts before applying a reset. The preview also identifies retained history and unrelated resources. Application carries a digest of those counts and fails if the preview has gone stale; instance-wide resets additionally require typing RESET INSTANCE. Successful and already-converged resets show the immutable reset audit ID.

When the instance has an active tkadauke/syrus repository, or a repository whose upstream is tkadauke/syrus, the Admin Plugins page recommends enabling this plugin. That gives self-development instances a visible nudge to turn on the diagnostics surface used by log-sift and insight workflows without making the plugin default-on for ordinary installations.

Configuration

No credentials or config_schema. The plugin is a thin presentation/tool layer over core observability infrastructure that already exists whether or not the plugin is enabled:

  • Performance diagnostics come from PerformanceLogging /

PerformanceLogging::Store (an in-memory/short-retention event buffer, gated by the separate PerformanceLogging::FEATURE_SLUG feature flag — the plugin only adds the *surface* to read it, and reports enabled: false in its payload when that flag is off).

  • Operational logs come from OperationalLogging (gated by

OperationalLogging.enabled_for_instance?); when it's off, both the /admin/operational_logs admin page and the read_syrus_logs MCP tool are withheld/return a disabled response rather than erroring.

Every controller action and both PerformancePayload/SqlExplain calls run inside PerformanceLogging.suppress/OperationalLogging.suppress so inspecting performance/log data doesn't itself generate more performance/log events.

Admin pages

The plugin contributes internal admin pages through the plugin admin-page registry:

  • Admin → SPA Loader (/admin/spa_loader) — a live, tab-local view of the

lazy-chunk registry and warm-up queue, startup milestones and assets, service worker control/revision state, progress and recovery events. State and group filtering uses the shared FilterBar. SmartFolder persistence is deliberately omitted because the inspected state disappears with the browser tab. The testing actions warm all chunks or clear incomplete warm-up state only in the current tab. The page reads loader state exclusively through the frontend plugin host SDK; the core loader never references this plugin.

  • Admin → Performance (/admin/performance) — renders

SyrusDev::PerformancePayload: per-revision (or all-retained-revisions, via revision_scope=all) grouped summaries of slow requests (by method/path/controller/action), slow jobs (by job class/queue), slow phases (by phase/name/plugin-derived label), browser traces (by name/path, including nested API-request and span durations), and SQL fingerprints (deduplicated by a stable fingerprint, sample SQL attached). Each summary row carries count/total/average/max duration. Input-latency browser summaries additionally carry average and maximum input delay, processing duration, and presentation delay. Their companion input telemetry health traces distinguish eligible and sampled-out sessions, Event Timing support and observer initialization, rate limiting, and delivery failures; use those statuses to explain an empty latency window. When a prior app revision's data is available, baseline.comparisons diffs each current-revision row against its same-key baseline row and classifies it regressed/improved/new/unchanged (regressed: ≥250ms slower *and* ≥1.5x; improved: ≥250ms faster *and* ≤0.75x), letting operators spot regressions introduced by the latest deploy. POST /api/v1/app/admin/performance/explain runs SyrusDev::SqlExplain (below) from the same page for ad hoc query investigation.

  • Admin → Operational Logs (/admin/operational_logs) — a search UI

over Admin::OperationalLogsPayload (GET /api/v1/app/admin/operational_logs), the same indexed log search backing the read_syrus_logs MCP tool below. This page is hidden entirely from AdminPages.admin_pages when OperationalLogging.enabled_for_instance? is false, rather than rendered empty.

  • Admin → Design System (/admin/design_system) — renders Syrus's live

component gallery from the real shared frontend primitives, including the DOC-27 semantic page, section, notice, text, surface, toolbar, chip, and layout helpers. This is the plugin-owned development/internal destination for the gallery. The legacy /design_system path remains a hidden preview alias so theming tools can keep opening ?theme_id=<id> against the same real components without requiring the normal admin navigation entry.

  • Admin → Tool Cards (/admin/tool_cards) — the Tool Card Catalog:

every entry the frontend toolPresentationRegistry.ts contract knows about (core and plugin MCP cards, provider built-ins like Claude/Codex Bash/Read/Grep/WebSearch, Local Mode tools, and chat-surface components like proposal/pending-action cards), reviewable from its own registered example fixtures. FilterBar filters by tool name, owner type (core/plugin/provider), owner/plugin name, source type, renderer type (custom card vs. generic fallback), and coverage status (has examples vs. none) — entirely client-side against the compiled registry, since there is no ActiveRecord-backed collection here for Filters::Subject to query. Each example renders through the real <ToolGroup> chat component (the same collapsed row, expanded body, raw-details disclosure, and redaction a live transcript gets), so a tool with no registered card renders its actual generic-fallback body instead of being hidden from the catalog. A tool with multiple examples gets an inline example selector; each entry has a stable #tool-<name> anchor and a "Copy link" action that adds ?tool=<name>& example=<id> so operators can reference one exact example when giving feedback. A viewport switcher (phone/tablet/desktop/wide desktop) renders the selected example inside a constrained-width frame using the same rendering path, so reviewers can check responsive behavior without resizing the browser; the preset is reflected in the deep link too. Each entry's preview also carries a "Discuss this card" action (ToolCardDiscussDialog.tsx) scoped to the currently selected tool, example, and viewport: it captures a screenshot of the rendered preview with html2canvas-pro, lets the operator annotate it with the same ImageAnnotationModal shared with in-app bug reports, and collects a free-text prompt. The annotated screenshot, a human-readable summary, and the full structured payload (canonical tool name, owner/plugin/provider, renderer type, selected example id and viewport preset, input/result payload, the result's error flag, and the catalog deep link) are folded into whichever action the operator picks, as a fenced JSON block — so the assistant on the other end has everything it needs without the operator hand-pasting JSON. A failed screenshot capture shows an inline error but never blocks either action; the raw metadata stays visible (and still gets sent) either way. The dialog's footer mirrors BugReportButton's layout: Cancel | Discuss | Create Job, with Create Job as the highlighted primary action and the form's actual submit button, since it is the immediate no-review-step action; Discuss is a secondary, explicitly clicked button (never triggered by pressing Enter in the prompt textarea) that opens a brand new chat (createChat, no repository attached) carrying the same screenshot and payload as its initial message. Create Job skips the chat round-trip entirely: it posts the same screenshot and free-text prompt (folded through the same summary+JSON formatting) straight to POST /api/v1/app/admin/tool_card_jobs (SyrusDev::ToolCardJobCreator), which lands a direct Job immediately --- no operator has to relay "yes, go ahead" back to an assistant that already had everything it needed. The Job targets whichever repository BugReports::Router already resolves for "file this about Syrus itself" (the configured report_issue_repo_slug, or the operator's own fork of it); there is no separate repository picker, since the Tool Card Catalog only exists to develop Syrus. The Job's title is left pending so GenerateJobTitleJob derives one from the prompt, the same as leaving the title blank on the normal "New Job" form. Like BugReports::Creator (which this shortcut shares its Job-creation core with, via ::DirectJobs::Creator -- see below), it always advances the Job straight past triage rather than routing product owners through the needs_triage gate Api::V1::App::DirectJobsController#create_direct_job applies on the normal "New Job" form; that's intentional for this internal dev-tool surface, which exists specifically to skip friction on Syrus-about-itself jobs.

The performance and operational-log APIs are mirrored at /api/v1/admin/performance, /api/v1/admin/performance/explain, and /api/v1/admin/operational_logs for the external Bearer-token admin API. Every action 404s with { "error": "syrus_dev_plugin_disabled" } when the plugin itself is disabled.

SQL Explain (SyrusDev::SqlExplain)

A guardrailed single-statement EXPLAIN runner, callable from the Performance admin page and shared by no other surface:

  • Accepts only SELECT/WITH statements; rejects multiple statements

(;), inline comments (/* */, --, #), and any non-read-only keyword (INSERT/UPDATE/DELETE/ALTER/etc.) — even inside a plan, not just at the top level.

  • On MySQL: default mode is EXPLAIN FORMAT=JSON (parsed into

json_plan); analyze: true runs EXPLAIN ANALYZE instead (rejected if the statement contains @-prefixed user variables or unsafe executable constructs such as INTO, GET_LOCK, RELEASE_LOCK, SLEEP, BENCHMARK, LOAD_FILE, or FOR SHARE), wrapped in a session max_execution_time (default 1000ms, capped at 5000ms) that's reset to unlimited afterward.

  • On SQLite (dev/test): EXPLAIN QUERY PLAN only — analyze: true raises,

since SQLite has no equivalent — with a warning that the plan can differ from production MySQL.

  • ? placeholders are substituted with literal NULL before explaining

(placeholder_substituted: true flags this in the result) since the explain path has no bound parameter values to supply.

  • Database explain errors (for example, a sample SQL string truncated before

the end of the statement, or a table that doesn't exist in the current database) are returned as invalid explain requests with a message telling the operator to retry with the full query.

MCP tools (SyrusDev::WorkflowToolSet and SyrusDev::ChatToolSet)

Three tools, gated to Syrus-repository workflows (McpToolPolicy.syrus_repository? — the Job's repository is tkadauke/syrus or a registered fork) and to a role-scoped subset:

  • read_performance_diagnostics(limit?, revision_scope?, include_events?) —

only for WORKFLOW_IMPLEMENT agents. Returns the same summarized/baseline data as the admin page, run through an aggressive sanitizer before it ever reaches the agent: request/browser-trace paths have any segment that looks like a secret (token, password, api_key, etc., by key name or key=value pattern) replaced with [REDACTED]; SQL fingerprint rows drop sample_sql entirely (fingerprint text only); metadata keys/values and free-text fields are regex-scrubbed and byte-truncated. Raw individual events are included only when include_events: true is explicitly passed, and are sanitized the same way. Treat any diagnostics this tool returns as still process/command-shaped output — summarize findings to the operator rather than pasting raw fingerprints or paths verbatim, per the same convention as read_run_worker_health.

  • read_syrus_logs(query?, since?, level?, role?, hostname?, limit?) — for

both WORKFLOW_IMPLEMENT and AGENT_INSIGHT roles (the only tool in this plugin agent_insight runs can call). Thin wrapper over the core OperationalLogSearch service; returns a disabled-response payload instead of an error when OperationalLogging.enabled_for_instance? is false.

  • read_workspace_reuse_outcomes(since?, until_time?) — only for

WORKFLOW_IMPLEMENT agents. Returns grouped prepare reuse and grader workspace materialization outcomes for the current repository within an inclusive ISO 8601 time window. The default window is the last 30 days; skipped prepares remain visible but are excluded from the reuse-rate denominator.

These tools reject non-Syrus repositories and non-Syrus-development contexts outright (Mcp::Tools.not_authorized / .invalid) rather than silently returning empty data — a workflow on an unrelated customer repository never sees these tools offered at all (available_for_context?/ available_for? filter them out of the manifest before a call could happen).

Coworker chats are the repository-less exception. When an owner grants syrus_dev.read_diagnostics, the coworker receives exactly these two read-only tools with the same redaction and size bounds. The grant defaults to confirm and permits up to auto. Without the grant, the tools are absent; ordinary operator chats never receive them from this plugin.

Operational notes

Several surfaces here expose Syrus's own internal implementation details (request paths, job classes, SQL fingerprints, raw log lines) — useful for agents actively working on Syrus's codebase, but not something to enable on a general product installation where it would just be noise (and, for the performance/log tools specifically, a narrower information-disclosure surface than a typical admin plugin, since it's designed to hand runtime internals to an *agent*, not just a human operator).