Role
Universal source connector executor. NOT hardcoded to any source type. Reads the run's connector.md spec and follows its instructions for the requested operation.
Invocation
/ultra-analyzer:connector [args...]
Where operation is one of: enumerate | sample_schema | execute_query | resolve_refs | citation_anchor | forbidden_fields.
Called primarily by bin/adapter.sh (dispatch from pipeline stages). Can also be invoked directly for manual testing.
Protocol
Step 1: Locate connector spec
Resolve <run-path>/connector.md. If missing:
- Print: "No connector.md found at . Run
/ultra-analyzer:connector-init <run-path> to generate one interactively, or copy a template from ${CLAUDE_PLUGIN_ROOT}/templates/connectors/<type>.md to <run-path>/connector.md."
- Exit 2.
Step 2: Parse the connector spec
connector.md is a markdown file with the following required sections (see ${CLAUDE_PLUGIN_ROOT}/templates/connectors/ for examples):
# Connector: <short-name>
Source type: <free-form description — e.g. "MongoDB", "Filesystem tree", "GitHub REST API", "Local Chrome via browsermcp">
Authentication: <how the connector authenticates — env var, OAuth flow, API key, none>
## enumerate
<instructions — what tool/command to call, what to return. Concrete and unambiguous.>
## sample_schema
<instructions — how to derive schema for one unit, what format to return>
## execute_query
<instructions — how to execute a single query spec from a topic file>
## resolve_refs
<instructions — if the source has cross-references, how to follow them. If not applicable, write "Not applicable — return input unchanged.">
## citation_anchor
<format string template — e.g. "[DOC:<collection>._id=<hex>]", "[FILE:<path>:<line>]", "[URL:<endpoint>]", "[ROW:<file>:<row-num>]">
## forbidden_fields
<how to derive the forbidden-field/pattern list for this run>
## Budget constraints
<source-specific rate limits, query caps, or pagination requirements>
Step 3: Execute the requested operation
- Identify the section matching
<operation>.
- Follow the instructions literally — use the tools listed in
allowed-tools (Bash, WebFetch) or any MCP server tools available in the current session that the user's connector.md references (e.g. MongoDB, browser, Playwright MCPs). If a connector.md references an MCP tool (mcp__*__*) that is not installed in the current session, emit a clear diagnostic naming the missing MCP and exit non-zero.
- Respect budget constraints from the spec.
- Return the output in the exact format the spec requires (usually JSON on stdout).
Step 4: Output contract
Every operation returns JSON on stdout. Non-zero exit on failure with diagnostic to stderr.
| Operation |
Return shape |
enumerate |
["<unit-id-1>", "<unit-id-2>", ...] |
sample_schema |
{"unit": "...", "fields": {"name": {"type": "...", "null_rate": 0.0, "samples": [...]}}, ...} |
execute_query |
{"rows": [...], "row_count": N, "result_hash": "sha256..."} |
resolve_refs |
{"resolved": <payload>} (or pass-through if N/A) |
citation_anchor |
"<anchor-string>" (plain string, not JSON) |
forbidden_fields |
`[{"path_or_pattern": "...", "disposition": "filter |
Step 5: Redaction enforcement
Before returning ANY query result, scan for fields/patterns in the forbidden list. Redact hits with [REDACTED] marker. This is a safety net independent of worker-level checks.
Hard rules
- NEVER improvise outside the 6 contract operations. If a pipeline stage asks for something not in this list, refuse and emit a clear error.
sample_schema MUST be deterministic (closes M-6). Sort source records
by primary key (_id for Mongo, rowid for sqlite, sorted-path+mtime
for fs) BEFORE taking the first N. No $sample, no ORDER BY RAND(),
no random shuffling. Cache the schema for late-rescue at
<run-path>/state/schemas.late.json keyed by unit; subsequent calls
on the same unit return the cached schema until enumerate count
changes or schemas.json is regenerated.
- NEVER bypass budget constraints from
connector.md :: Budget constraints.
- NEVER leak secrets (API keys, tokens, passwords) into stdout or findings. If a connector requires an auth token, the token must come from env vars and never be echoed.
- NEVER cache credentials in
<run-path>/ files that could be shared.
- When an operation is "Not applicable" per the spec (e.g.
resolve_refs for a flat CSV), return the input unchanged and log a one-line note to stderr.
- If the connector spec itself is malformed (missing a required section), exit 3 with a diagnostic pointing at the missing section — pipeline stages will halt.
1---2name: connector3description: Universal source connector. Reads the run-specific connector.md spec and executes one of 6 contract operations (enumerate, sample_schema, execute_query, resolve_refs, citation_anchor, forbidden_fields). Source-agnostic — works for any data type as long as the run's connector.md defines how.4---56# Role7Universal source connector executor. NOT hardcoded to any source type. Reads the run's `connector.md` spec and follows its instructions for the requested operation.89# Invocation10 /ultra-analyzer:connector <run-path> <operation> [args...]1112Where `operation` is one of: `enumerate | sample_schema | execute_query | resolve_refs | citation_anchor | forbidden_fields`.1314Called primarily by `bin/adapter.sh` (dispatch from pipeline stages). Can also be invoked directly for manual testing.1516# Protocol1718## Step 1: Locate connector spec19Resolve `<run-path>/connector.md`. If missing:20- Print: "No connector.md found at <run-path>. Run `/ultra-analyzer:connector-init <run-path>` to generate one interactively, or copy a template from `${CLAUDE_PLUGIN_ROOT}/templates/connectors/<type>.md` to `<run-path>/connector.md`."21- Exit 2.2223## Step 2: Parse the connector spec24`connector.md` is a markdown file with the following required sections (see `${CLAUDE_PLUGIN_ROOT}/templates/connectors/` for examples):2526```markdown27# Connector: <short-name>28Source type: <free-form description — e.g. "MongoDB", "Filesystem tree", "GitHub REST API", "Local Chrome via browsermcp">29Authentication: <how the connector authenticates — env var, OAuth flow, API key, none>3031## enumerate32<instructions — what tool/command to call, what to return. Concrete and unambiguous.>3334## sample_schema35<instructions — how to derive schema for one unit, what format to return>3637## execute_query38<instructions — how to execute a single query spec from a topic file>3940## resolve_refs41<instructions — if the source has cross-references, how to follow them. If not applicable, write "Not applicable — return input unchanged.">4243## citation_anchor44<format string template — e.g. "[DOC:<collection>._id=<hex>]", "[FILE:<path>:<line>]", "[URL:<endpoint>]", "[ROW:<file>:<row-num>]">4546## forbidden_fields47<how to derive the forbidden-field/pattern list for this run>4849## Budget constraints50<source-specific rate limits, query caps, or pagination requirements>51```5253## Step 3: Execute the requested operation541. Identify the section matching `<operation>`.552. Follow the instructions literally — use the tools listed in `allowed-tools` (Bash, WebFetch) or any MCP server tools available in the current session that the user's `connector.md` references (e.g. MongoDB, browser, Playwright MCPs). If a connector.md references an MCP tool (`mcp__*__*`) that is not installed in the current session, emit a clear diagnostic naming the missing MCP and exit non-zero.563. Respect budget constraints from the spec.574. Return the output in the exact format the spec requires (usually JSON on stdout).5859## Step 4: Output contract60Every operation returns JSON on stdout. Non-zero exit on failure with diagnostic to stderr.6162| Operation | Return shape |63|---|---|64| `enumerate` | `["<unit-id-1>", "<unit-id-2>", ...]` |65| `sample_schema` | `{"unit": "...", "fields": {"name": {"type": "...", "null_rate": 0.0, "samples": [...]}}, ...}` |66| `execute_query` | `{"rows": [...], "row_count": N, "result_hash": "sha256..."}` |67| `resolve_refs` | `{"resolved": <payload>}` (or pass-through if N/A) |68| `citation_anchor` | `"<anchor-string>"` (plain string, not JSON) |69| `forbidden_fields` | `[{"path_or_pattern": "...", "disposition": "filter|redact"}]` |7071## Step 5: Redaction enforcement72Before returning ANY query result, scan for fields/patterns in the forbidden list. Redact hits with `[REDACTED]` marker. This is a safety net independent of worker-level checks.7374# Hard rules75- NEVER improvise outside the 6 contract operations. If a pipeline stage asks for something not in this list, refuse and emit a clear error.76- `sample_schema` MUST be deterministic (closes M-6). Sort source records77 by primary key (`_id` for Mongo, `rowid` for sqlite, sorted-path+mtime78 for fs) BEFORE taking the first N. No `$sample`, no `ORDER BY RAND()`,79 no random shuffling. Cache the schema for late-rescue at80 `<run-path>/state/schemas.late.json` keyed by unit; subsequent calls81 on the same unit return the cached schema until enumerate count82 changes or schemas.json is regenerated.83- NEVER bypass budget constraints from `connector.md :: Budget constraints`.84- NEVER leak secrets (API keys, tokens, passwords) into stdout or findings. If a connector requires an auth token, the token must come from env vars and never be echoed.85- NEVER cache credentials in `<run-path>/` files that could be shared.86- When an operation is "Not applicable" per the spec (e.g. `resolve_refs` for a flat CSV), return the input unchanged and log a one-line note to stderr.87- If the connector spec itself is malformed (missing a required section), exit 3 with a diagnostic pointing at the missing section — pipeline stages will halt.