Nexora SAGEView source document

External Target Runbook

Nexora SAGE is developed and stored centrally, but it can analyze another repository or folder without being copied into that repository.

This is the preferred product mode for AI-assisted IDEs:

SAGE local install
  -> MCP server
  -> target_root repository
  -> isolated external target artifacts
  -> Markdown/YAML agent briefs

The AI coding agent should edit the target repository. It does not need to read SAGE source files.

Canonical Execution Identity

SAGE execution identity has two independent axes:

Subject scope Acquisition mode Meaning
SAGE_ON_REPOSITORY DEFAULT_WORKSPACE Analyze the explicitly configured default repository and project scope.
SAGE_ON_REPOSITORY EXPLICIT_TARGET Analyze an explicitly supplied repository in an isolated namespace.
SAGE_ON_SAGE DEFAULT_WORKSPACE Private maintainers evaluate SAGE product governance, release, lessons, debt and proof.
SAGE_ON_SAGE EXPLICIT_TARGET Private maintainers use an explicitly authorized sage_self profile with isolated acquisition.

SAGE on default repo and SAGE on external repo are not separate repository semantics. They are two acquisition modes of SAGE_ON_REPOSITORY. They MUST use the same canonical topology producer, engine semantics, applicability rules and claim boundaries.

Acquisition mode may change only repository-root selection, artifact and SQLite namespace, cache/freshness lifecycle, permission routing and acquisition provenance. For the same root, snapshot, config projection, project scope and pipeline profile, default and explicit-target results must be semantically equivalent. Differences are parity findings, not an alternative ontology.

Every scoped runtime artefact is resolved from the declarative artifact registry and projected beneath the active target .raw storage root. An explicit-target watchdog MUST NOT read from or write to the default workspace namespace. Scoped Audit and graph evidence bind both the target descriptor and the committed Atlas snapshot identity; a missing, cross-target or stale generation identity is invalid evidence and MUST NOT fall back to another namespace.

The same target boundary applies to executable follow-up guidance. Watchdog proof-debt actions are derived from declared refresh modes as structured argv. For explicit-target acquisition every emitted daily, full, or release-deep action includes the exact --target-root <subject_root> binding. If that identity is unavailable, SAGE blocks command emission instead of presenting a target-agnostic command. Copying a recommended command must therefore preserve the repository that produced the debt.

Current development-source behavior: MCP call timing and bounded fallback diagnostics use the product-global output/.operational/mcp/ namespace. They do not write into default or explicit-target evidence databases, retain target paths or response bodies, or authorize evidence fallback. The raw state-payload and payload-fingerprint readers used by this boundary close their SQLite connections explicitly; the dedicated subprocess authority validator compares default, target-A and target-B manifests and fails if target namespaces or SQLite sidecars remain changed after process exit. This is a v1.1 roadmap delivery and does not retroactively expand the published v1.0.3 claim.

The public distribution exposes only SAGE_ON_REPOSITORY. It may analyze the SAGE source tree as an ordinary target repository, but that does not grant release, lesson, debt, roadmap, seal or publication authority. Folder names, source markers, target-root equality and repository identity are observations; none may auto-escalate an actor to SAGE_ON_SAGE.

SAGE_ON_SAGE is a private maintainer subject. It requires both an explicit sage_operator_debug actor/tool profile and an explicit sage_self reality target profile. Acquisition can be default-workspace or explicit-target, but neither acquisition mode supplies that authority by itself.

Private SAGE lesson, debt, work-item, execution-wave and roadmap registries are not part of the public distribution. Reusable target-bound lesson projection and action-memory contracts remain in the source as bounded components; they consume target-scoped evidence and do not expose or inherit SAGE's private institutional memory. Version 1.0.0 does not claim a general-purpose learning product or a public self-governance surface.

Configured Default Mode

After an explicit init --target-root <repository>, an embedded/default installation may analyze that compiled workspace without repeating the target argument. Current default root comes from:

External Target Mode

Use --target-root to analyze another folder without copying SAGE into that folder and without rewriting config:

python .\sage.py run --full --target-root "<absolute-path-to-target-repo>"

SAGE runs a preflight automatically before the external target analysis. To skip only that preflight:

python .\sage.py run --full --target-root "<absolute-path-to-target-repo>" --skip-target-preflight

The promoted generation records this choice as preflight_status: SKIPPED_BY_OPERATOR; it is never reported as a validated Preflight observation. Pipeline-receipt, Audit (unless separately skipped) and authoritative SQLite Atlas identity checks still apply before promotion.

Targeted step example:

python .\sage.py run --step react-support --target-root "<absolute-path-to-target-repo>"

After artifacts exist, focused inspection belongs to the public MCP profiles. Use inspect_file, inspect_folder or inspect_symbol with an explicit target_root. The legacy targetless inspection CLI is private until it has the same target-root and provenance contract; do not redirect it to internal raw artifact paths as a workaround.

Watch-once example:

python .\sage.py watch --once --target-root "<absolute-path-to-target-repo>"

Add --path "<exact-source-file>" for a one-file surgical pulse. A directory path is a deterministic smoke sample and reports omitted candidates; it is not a freshness claim for every file in that directory. run --scope remains a directory-only Scoped Host Analyzer report filter and does not bound Atlas or pipeline execution.

MCP Product Flow

When SAGE is exposed as a local MCP server to Cursor or another MCP-capable IDE, use this target-repository flow:

1. external_target_preflight(target_root)
2. If current target artifacts do not exist, run the bounded public CLI flow:
   python sage.py run --target-root <target_root> --profile daily --projects MAIN
3. get_surgical_operation_packet(target_root=target_root)
4. inspect_file(file_path, target_root=target_root)
   - If a source snippet is marked `partial_included_span_too_large`, call the suggested `inspect_file(file_path=..., line_start=..., line_end=..., target_root=target_root)` before editing omitted lines.
   - `source_grounded_for_inspection=true` proves current source identity, not edit authority. Mutate from this response only when `one_shot_edit_ready=true` and `inspection_authority=bounded_edit_context`; partial, omitted or ordinary file-level excerpts remain `orientation_only` until the required source range is inspected.
5. inspect_symbol(symbol, target_root=target_root, project="MAIN")
6. get_impact_radius(target_node, target_root=target_root, depth=2)
7. get_test_impact(target_file, target_root=target_root)
8. get_confidence_score(target_file, target_root=target_root)
9. trace_upstream_cause(target_node, target_root=target_root)
10. get_active_signals(target_root=target_root)
11. For cooperating agents editing the same file, switch to the
    `target_repository_followup` MCP profile and acquire
    `manage_target_write_lease(action="acquire", target_file=..., actor_id=..., target_root=target_root)`.
12. Return to `target_repository_default`, then call
    `validate_patch(target_file, patch_content, target_root=target_root, actor_id=...)`.
13. After applying the approved patch externally, use the follow-up profile to
    release `manage_target_write_lease(action="release", target_file=..., actor_id=..., target_root=target_root)` immediately.
14. get_dead_code(path, target_root=target_root)
15. get_state_flow(target_root=target_root)
16. get_ui_architecture(component, target_root=target_root)

run_external_target_analysis is a declared heavy server capability, not a tool exposed by the compact public MCP profiles. Public agents dispatch the repository analysis through the visible sage.py CLI, then consume its target-bound artifacts through MCP. Guessing the hidden tool name must fail closed rather than widen the active profile.

Use refresh=true when source grounding reports stale, missing or drifted evidence and cache reuse must be bypassed without escalating to release-deep claim semantics. A cached full run is not freshness proof. In private maintainer operation, the explicit sage_self profile requires refresh after SAGE source changes.

Fail-closed agent queries return consumer-specific recovery when available. For example, get_violation_work_queue consumes Atlas and Audit evidence, so its structured recovery_plan.command_argv requests a project-bounded --step Audit run rather than a global Quality Gates refresh. The plan names its authority chain, reports the currently required Nuclear Sequencing dependency, and leaves duration unavailable when no current run-receipt estimate exists. Actors must not widen or retry that operation merely because their transport timed out.

The surgical packet has an additional required-input generation gate. A legacy generation may fail the broader artifact-trust summary or pass that summary while its signals receipt is bound to an older Atlas snapshot. In either state, get_surgical_operation_packet returns INVALID_CONTEXT with the same executable daily --projects MAIN --refresh recovery plan. It does not first prescribe Quality Gates and then require a second command. The plan identifies the daily profile and requested project closure; measured duration remains unavailable until the terminal-receipt contract exists. already_current, a blocked required input, and an empty command are not a valid combination.

Defaults are agent-facing:

The default brief must describe target-repository files and actions, not SAGE internals. Internal graph identifiers belong only in debug output. When a required artifact is missing for the selected external target, SAGE should say that explicitly instead of answering from the central SAGE workspace artifacts.

Agent Path And Safety Rules

Runtime Contract

External target mode sets CODEMAPS_TARGET_ROOT only for the subprocess run.

The active runtime config becomes:

External acquisition does not define a second repository ontology. Normal workspace discovery and external target discovery use the same canonical candidate and role producer. The external path adds target-root acquisition, runtime isolation, and an isolated output namespace; it does not flatten nested projects into MAIN.

MAIN remains the safely inferred host project scope, such as src for a root application. A nested candidate with its own recognized config/manifest, a declared workspace edge, a policy-recognized relation container, or strong independent structure is promoted to a separate project key for repository coverage. Coverage selection does not invent its relationship role: a candidate without relationship evidence remains unresolved. Every discovered project boundary owns its subtree even when an explicit caller filter bounds it out. Parent Atlas walks therefore exclude all nested discovered project roots: a bounded-out embedded project cannot leak back into MAIN, and a selected child cannot be counted under multiple project keys.

Architecture-shaped source containers remain different from project boundaries. When a manifest-bearing parent owns a conventional architecture directory such as src or app, the directory's internal components, pages, or feature structure remains parent-owned orientation evidence. It becomes a nested project boundary only when it carries its own config/manifest, matches a declared workspace edge, or is otherwise discovered as an independent structural root rather than merely a named source container.

Preflight exposes:

Discovery and execution are separate authorities. A project may be visible in project_candidates or auto_selected_projects without belonging to the current run. Claims about analyzed scope must use effective_runtime_projects, not the broader topology inventory. Preflight language and framework inventory remains conservatively topology-wide and is labelled with inventory_project_scope; it may warn about a discovered project outside the requested runtime filter but cannot expand the runtime claim. A requested project absent from discovered topology fails closed.

After Atlas is materialized, the orchestrator writes one immutable POST_ATLAS analysis_scope_authority artifact. Audit, Architecture Oracle, Validation Oracle, and Quality Gate consume that exact authority rather than deriving a competing repository scope. Their scope identities are reconciled in the terminal run receipt, but terminal reconciliation does not rewrite the post-Atlas authority or its lineage receipt.

Agent-facing action surfaces additionally require the SQLite-primary content digests for the scope authority, Audit, and Quality Gate to match COMPLETE lineage receipts bound to the current Atlas snapshot. Matching project names, timestamps, or embedded authority IDs alone are not sufficient action evidence.

The authority distinguishes three outcomes:

A zero process exit reports execution completion. It does not upgrade bounded or incomplete scope into complete-repository evidence.

Automatic repository coverage includes the host scope plus evidence-bearing nested candidates discovered from declared workspace matches, policy-recognized containers, candidate-local config/manifests, or strong independent structure. Config, manifest, or structural evidence proves a boundary and grants analysis coverage; it does not by itself prove that the candidate belongs to the host's comparative topology. A candidate without relationship evidence remains unresolved, is exposed under coverage_only_projects, and is denied as a host-merge source. This prevents both silent omission and fabricated companion or variant semantics. It also avoids file-count promotion: source volume alone does not establish a repository relationship. A single-project projection is a bounded selection, not evidence that no nested project exists. Semantic depth still follows the language/framework capability matrix; multi-project discovery does not grant unsupported-language authority.

host, variant, and companion are governance relationship roles. They do not claim that a project is an application, library, tool, or microservice. Technical system-kind inference requires a separate evidence-bearing classification stage. V1 keeps that inference conservative; a future two-pass Topology Oracle may consume candidate-local fingerprints or bounded scout Atlases before full Atlas materialization. Until then an otherwise unproven candidate remains unresolved and coverage-only; a policy-recognized container role remains a medium-confidence inference rather than a resolved relationship, and its technical system kind remains unknown.

The compiled SAGE config files are not modified.

External target outputs are isolated under:

output/external_targets/<target-name-and-hash>/
├── current.json
└── generations/
    └── <run-id>/
        ├── generation.json
        ├── .raw/
        ├── reports/
        └── logs/

This keeps quality-control runs from overwriting the default analysis artifacts. Each material external run writes into its own generation directory. A run becomes current only after its pipeline receipt, required report shadows and authoritative SQLite Atlas identity validate for that exact run. Promotion replaces current.json atomically; readers therefore resolve either the previous validated generation or the newly validated generation, never a partially replaced mixture.

Interrupted, failed, validation-failed and Watchdog-only generations remain inspectable under generations/, but they do not replace the current pointer. If current.json or its bound manifest identity is invalid, SAGE reports the target as unvalidated instead of falling back to mixed current truth.

output/external_targets/ is runtime evidence, not a durable archive. Before cleaning runtime artifacts or packaging a release, promote any external-corpus result that matters to a current evidence document or a versioned corpus manifest. A release claim should cite the promoted summary/manifest, not only a volatile output/ path.

Generate the external target run index:

python .\sage.py external-targets

The index keeps validated_current separate from the observed latest_attempt, latest_completed, and latest_validated roles. Generation manifests and returned history are bounded by config/runtime_output_retention_policy.json; omitted scan/history counts and invalid manifests stay visible. This is an index projection only. It never deletes a user-scoped generation and a bounded scan cannot claim complete latest-role coverage.

Build bounded proof from the already validated current generation without starting another analysis:

python .\sage.py target-proof --target-root "<absolute-path-to-target-repo>" --projects MAIN --mode baseline --refresh-policy current

--refresh-policy if-missing starts one claim-owned target-quality, target-bound refresh only when a validated current generation does not exist. --refresh-policy always starts the same dependency-complete target-quality refresh first. Merge, UI-runtime, comparative Oracle and broad review/proof producers remain outside that bounded claim and their old artifacts are not read by its Quality Gate. Neither policy retries after a failed refresh. When --projects is present, the requested keys must exactly match the current generation's analysis_scope_authority; a missing, incomplete, or mismatched scope blocks proof construction. The command delegates to the existing target_repository_proof_bundle builder and emits a structured terminal status. That bundle is target evidence only, not SAGE release authority, a human seal, or target mutation permission.

Clean only external target outputs:

python .\sage.py purge --mode external-targets

Boundary

External target mode is for repository-independent analysis, target-repository AI coding, and quality-control runs.

Do not copy SAGE into target repositories. Keep SAGE central and pass the target path as input.

Legacy embedded/default layouts remain observable rather than silently rewritten. When the running SAGE checkout is physically inside the analyzed repository, sage.py init emits an embedded_sage_host_footprint_v1 projection in the installation plan. The projection names one exact embedded root, inventories source/cache/database/log/output surfaces, probes declared paths for host traversal, and provides non-mutating review guidance for detected ESLint, Biome, Stylelint, Prettier, TypeScript, Vitest and Jest surfaces plus search and packaging discovery. Apply any exclusion through the target repository's own tool configuration and version-specific syntax. SAGE does not edit those files or filesystem permissions. Self-analysis and a central SAGE checkout analyzing an external target report this guidance as not applicable.

The target repository should receive:

The target repository agent should not need: