Inferensys

Prompt

Architectural Fitness Function Evaluation Prompt

A practical prompt playbook for automating architecture governance with pass/fail evaluation against defined coupling rules, violation evidence, and CI/CD gate integration.
Architect reviewing LLM integration architecture on laptop, system diagrams visible, modern technical office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job-to-be-done, ideal user, required context, and boundaries for the Architectural Fitness Function Evaluation Prompt.

This prompt is for platform engineers and architects who need to automate architecture governance in CI/CD pipelines. It evaluates a codebase or system design against predefined coupling rules and produces a structured pass/fail result with specific violation evidence. Use this when you want to enforce rules like 'no circular dependencies between packages,' 'no direct imports from infrastructure layer to domain layer,' or 'no shared database access across bounded contexts.' The prompt is designed to be wired into a build pipeline where it acts as a gate: pass allows the build to continue, fail blocks it with a detailed report.

Do not use this prompt for subjective architecture review, greenfield design exploration, or trade-off analysis. It is a compliance check, not a design advisor. The prompt requires a concrete set of rules expressed as machine-readable constraints—such as forbidden import patterns, allowed dependency directions, or maximum coupling thresholds—and a source of evidence like a dependency graph, import analysis output, or architecture model. Without these structured inputs, the model will hallucinate violations or miss real ones. The ideal user is someone who already knows which rules matter for their system and needs a repeatable, automated enforcement mechanism rather than a one-time review.

Before wiring this into a pipeline, confirm that your rules are unambiguous and your evidence source is deterministic. If your rules require human interpretation—for example, 'avoid excessive coupling' without a numeric threshold—this prompt will produce inconsistent results. Pair it with static analysis tools that generate the raw dependency data, and use the prompt only for the evaluation layer. For high-risk systems where a false negative could allow a dangerous change to deploy, always include a human review step on failures and periodically audit pass results against manual spot checks to catch rule gaps.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works, where it fails, and what you must provide before running it in a CI/CD pipeline.

01

Good Fit: Automated Governance Gates

Use when: You have explicit, quantifiable architectural rules (e.g., 'no cycle shall exceed 3 nodes', 'domain layer must not import infrastructure'). The prompt excels at turning static analysis data into pass/fail verdicts with evidence. Guardrail: Always pair the prompt with a static analysis tool that produces the raw dependency graph; the prompt evaluates the rules, it does not extract the graph from source.

02

Bad Fit: Subjective Design Review

Avoid when: You need a qualitative assessment of 'good design' or 'clean code' without predefined metrics. This prompt is a fitness function evaluator, not a design critic. It will hallucinate confidence if asked to judge aesthetics. Guardrail: Use a separate trade-off analysis prompt for subjective review and keep this prompt strictly bound to measurable rules.

03

Required Inputs

Risk: Garbage-in, garbage-out. If the dependency graph is incomplete or the rules are ambiguous, the evaluation will be dangerously misleading. Guardrail: You must provide a machine-readable dependency graph (JSON/CSV) and a formalized ruleset (e.g., 'disallow: domain.* -> infrastructure.*'). Do not pass raw source code and expect the model to parse imports reliably.

04

Operational Risk: Threshold Tuning

Risk: Overly strict rules cause 'alert fatigue' and teams ignore the gate. Overly loose rules let architectural decay through. Guardrail: Start with a 'warn-only' mode in CI/CD. Track violation trends for two weeks before enabling hard failures. The prompt's threshold parameter must be configurable and reviewed per sprint.

05

Operational Risk: False Positives

Risk: The model may flag intentional exemptions (e.g., a shared kernel or a framework adapter) as violations, eroding trust in the governance system. Guardrail: Implement an exemption file (e.g., fitness-exemptions.yaml) that is checked into the repository. The prompt must be instructed to cross-reference violations against this exemption list before reporting a failure.

06

Operational Risk: Model Drift

Risk: A model upgrade can change the interpretation of a rule, causing a previously passing build to fail without any code change. Guardrail: Pin the model version in your harness. Run the evaluation prompt against a golden dataset of known violations and known clean architectures as part of your prompt release pipeline before deploying the new model.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt for evaluating a system's architecture against defined fitness functions, producing pass/fail results with violation evidence.

This prompt template is designed to be the core instruction set for an automated architectural governance gate. It takes a set of defined fitness functions—specific, measurable criteria for architectural qualities like coupling, cohesion, or dependency direction—and evaluates a provided system description or codebase analysis against them. The output is a structured, machine-readable report that can be directly consumed by a CI/CD pipeline to automatically pass or fail a build based on architectural rules.

text
You are an architectural fitness function evaluator. Your task is to assess a system's architecture against a set of predefined, measurable rules called fitness functions. You will receive the system's architectural context and a list of fitness functions to evaluate. For each function, you must determine a pass or fail status and provide concrete, source-grounded evidence for your decision.

INPUT SYSTEM CONTEXT:
[SYSTEM_CONTEXT]

FITNESS FUNCTIONS TO EVALUATE:
[FITNESS_FUNCTIONS]

EVALUATION CONSTRAINTS:
[CONSTRAINTS]

OUTPUT SCHEMA:
You must produce a JSON object conforming to the following structure. Do not include any text outside the JSON object.
{
  "evaluation_results": [
    {
      "function_id": "string",
      "function_description": "string",
      "status": "PASS" | "FAIL" | "INCONCLUSIVE",
      "evidence": [
        {
          "source_reference": "string",
          "finding": "string"
        }
      ],
      "rationale": "string"
    }
  ],
  "aggregate_result": "PASS" | "FAIL",
  "summary": "string"
}

RULES:
1. Evaluate every fitness function provided in the [FITNESS_FUNCTIONS] list.
2. For a FAIL status, the evidence must contain at least one specific, source-grounded violation.
3. For a PASS status, the evidence must demonstrate how the system satisfies the rule.
4. Use INCONCLUSIVE only when the provided [SYSTEM_CONTEXT] lacks the necessary information to make a determination.
5. The aggregate_result is PASS only if all individual function statuses are PASS. If any function FAILs or is INCONCLUSIVE, the aggregate_result is FAIL.
6. Adhere strictly to the [CONSTRAINTS] provided.
7. If [RISK_LEVEL] is HIGH, you must include a note in the rationale for any FAIL status recommending a mandatory human architecture review.

RISK LEVEL: [RISK_LEVEL]

To adapt this template for your environment, replace the square-bracket placeholders with concrete data. [SYSTEM_CONTEXT] should be populated with a structured representation of your architecture, such as a dependency graph, a list of components and their imports, or an architecture decision record. [FITNESS_FUNCTIONS] must be a list of specific, testable rules, like 'The data package shall not depend on the ui package' or 'No circular dependencies are allowed between top-level modules.' The [CONSTRAINTS] placeholder allows you to inject context-specific rules, such as ignoring test directories or allowing exceptions for shared kernel libraries. Before integrating this into a pipeline, run it against known-clean and known-violating architectures to calibrate its sensitivity and ensure the evidence it provides is accurate and actionable.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the prompt needs to work reliably. Validate each before sending to prevent runtime failures or misleading evaluations.

PlaceholderPurposeExampleValidation Notes

[ARCHITECTURE_RULES]

Defines the coupling rules, thresholds, and constraints to evaluate against

{"max_fan_out": 5, "disallowed_dependencies": ["presentation->data"]}

Must be valid JSON. Schema check required: confirm rules have measurable thresholds. Reject if rules are ambiguous or unenforceable.

[SYSTEM_GRAPH]

Represents the component dependency graph, including nodes, edges, and relationship types

{"nodes": ["auth", "db"], "edges": [{"from": "auth", "to": "db", "type": "runtime"}]}

Must be valid JSON. Validate node and edge completeness. Reject if graph is empty or contains orphan references. Check for circular references in edge definitions.

[EVALUATION_CONTEXT]

Additional constraints or environment-specific rules that modify evaluation behavior

"Ignore test-only dependencies. Treat 'common' as exempt from fan-in rules."

String or null. If provided, parse for conflicting instructions with [ARCHITECTURE_RULES]. Flag ambiguous exemptions for human review before evaluation.

[OUTPUT_SCHEMA]

Defines the expected structure of the evaluation result for downstream CI/CD integration

{"pass": "boolean", "violations": [{"rule": "string", "evidence": "string"}]}

Must be valid JSON Schema. Confirm required fields include pass/fail indicator and violation evidence. Reject schemas that allow passing with unaddressed violations.

[CONFIDENCE_THRESHOLD]

Minimum confidence score required for the model to assert a violation instead of flagging for human review

0.85

Float between 0.0 and 1.0. Default to 0.80 if null. Lower thresholds increase false positives; higher thresholds may miss real violations. Log when confidence is below threshold.

[MAX_VIOLATIONS]

Limits the number of violations returned to prevent overwhelming CI/CD output

10

Integer >= 1. Default to 20 if null. Truncation must be noted in output. Validate that critical violations are not silently dropped by sorting by severity before truncation.

[EXEMPTION_LIST]

Pre-approved exceptions to architectural rules that should not trigger violations

["src/legacy/", "test/fixtures/"]

Array of strings or null. Validate each entry against actual file paths or component names. Log all exemptions applied. Reject if exemptions would suppress all rules.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Architectural Fitness Function Evaluation Prompt into a CI/CD pipeline or automated governance workflow.

This prompt is designed to operate as a deterministic gate inside a CI/CD pipeline, not as a conversational advisor. The harness must treat the model output as a structured pass/fail signal with evidence, not as a suggestion. The primary integration point is a pull-request check or a pre-merge build step that runs the fitness function against the proposed change set. The harness is responsible for providing the model with the correct [ARCHITECTURE_RULES], the [CHANGE_DIFF] or [DEPENDENCY_GRAPH], and the [FAILURE_THRESHOLD] configuration. The model's job is to apply the rules to the evidence and return a structured verdict.

The implementation should follow a strict validate → execute → parse → gate loop. First, validate that all required inputs are non-empty and well-formed before calling the model. Use a lightweight JSON Schema validator to confirm the [ARCHITECTURE_RULES] payload contains the expected rules[] array with id, description, and severity fields. If the input is malformed, fail the check immediately with a clear configuration error rather than sending garbage to the model. For the execution step, use a low-temperature setting (0.0–0.1) and a constrained output schema via structured output mode or a tool-calling API to guarantee the response shape. The output must include a top-level verdict field (PASS or FAIL), a violations[] array, and a violation_count. After receiving the response, parse it and validate that every violation references a specific rule ID from the input and a specific file path or module from the change set. If the model hallucinates a rule ID that doesn't exist in the input, discard that violation and log a warning. If violation_count exceeds the configured [FAILURE_THRESHOLD], the CI check fails and the violations are posted as inline annotations on the pull request.

For high-risk repositories where false negatives could allow architectural degradation, add a human review escalation path. When the model returns a PASS verdict but the change touches files in a pre-defined high-sensitivity path list (e.g., core domain modules, shared kernel packages), the harness should flag the check as requiring manual approval rather than auto-passing. This prevents a model blind spot from silently eroding critical boundaries. Log every evaluation run—including the full prompt, the raw model response, the parsed verdict, and the final gate decision—to a structured logging system. This audit trail is essential for tuning rules, debugging false positives, and demonstrating governance compliance to auditors. Do not use this prompt as the sole gate for safety-critical or security-critical architecture rules; those should always require a human sign-off in addition to the automated check.

When choosing a model, prefer one with strong instruction-following and structured output reliability. The prompt relies on the model applying explicit rules to explicit evidence without creative interpretation. Test the harness with a golden dataset of known violations and known clean changes before enabling it as a blocking check. Include negative test cases where the change is architecturally sound but structurally unusual to catch over-eager failure modes. The harness should also implement a retry with backoff for transient API failures, but never retry on a FAIL verdict—only on parse errors or model refusals. A parse error after one retry should escalate to a human operator, not silently pass.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the exact fields, types, and validation rules for the architectural fitness function evaluation response. Use this contract to parse, validate, and gate the model output before integrating results into CI/CD pipelines.

Field or ElementType or FormatRequiredValidation Rule

evaluation_id

string (UUID v4)

Must match regex ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$

rule_id

string

Must match a rule identifier from the input [RULES] array; reject unknown rule_ids

rule_name

string

Must be non-empty and match the name field of the corresponding rule_id in [RULES]

status

enum: pass | fail | warn | error

Must be one of the four allowed values; error indicates evaluation could not complete

violations

array of objects

Must be present even if empty; each object must contain file_path (string), line_number (integer or null), and evidence (string)

violations[].file_path

string

Must be a non-empty relative path matching a file in the [CODEBASE_CONTEXT]; reject paths not present in context

violations[].line_number

integer or null

If present, must be a positive integer; null allowed when violation is structural rather than line-specific

violations[].evidence

string

Must contain a direct quote or import statement from the source file; validate substring match against [CODEBASE_CONTEXT]

score

number (0.0 to 1.0)

Must be a float between 0.0 and 1.0 inclusive; score below [THRESHOLD] with status pass triggers a consistency check

summary

string

Must be non-empty and between 20 and 500 characters; reject summaries that are generic or lack rule-specific detail

evaluation_timestamp

string (ISO 8601)

Must parse as valid ISO 8601 datetime; reject timestamps more than 5 minutes in the future from system clock

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when automating architecture governance with LLMs and how to prevent it.

01

Hallucinated Violation Paths

What to watch: The model invents file paths, module names, or import statements that don't exist in the codebase. This happens when the prompt asks for specific evidence but the model lacks grounding in the actual source tree. Guardrail: Require every violation to cite a source location that can be verified against a static analysis tool or repository index. Run a post-processing check that validates each cited path exists in the file tree before surfacing results.

02

Threshold Gaming and Score Drift

What to watch: The model learns to produce scores just above or below pass/fail thresholds to satisfy the prompt without reflecting real architectural quality. This is common when eval metrics are exposed in the prompt or when the model is repeatedly tuned against the same fitness function. Guardrail: Keep numeric thresholds out of the prompt template. Use a separate deterministic gate in the CI/CD harness that compares structured output fields against configurable thresholds. Rotate eval datasets periodically.

03

Context Window Truncation of Large Dependency Graphs

What to watch: Large codebases produce dependency graphs that exceed the model's context window. The model silently drops parts of the graph, missing cycles or coupling violations in the truncated sections. Guardrail: Pre-process dependency data into summarized, ranked, or partitioned chunks before prompting. Run multiple evaluations on different subgraphs and aggregate results. Add a completeness check that verifies the number of components analyzed matches the input count.

04

Inconsistent Rule Interpretation Across Runs

What to watch: The same fitness function prompt produces different violation classifications on different runs due to model non-determinism or ambiguous rule wording. A cycle might be flagged as HIGH severity in one run and MEDIUM in another. Guardrail: Define rules with concrete, measurable criteria (e.g., "cycle length > 3 files" not "significant cycles"). Use structured output schemas with fixed enum values. Run the evaluation multiple times and flag results with high variance for human review.

05

False Positives from Test and Generated Code

What to watch: The model flags coupling violations in test fixtures, generated code, or build artifacts that are not subject to the same architectural rules as production code. This floods the report with noise and erodes trust. Guardrail: Provide explicit exclusion patterns in the prompt (e.g., **/test/**, **/generated/**, **/node_modules/**). Post-process results to filter violations in excluded paths. Allow teams to maintain an exemption list for intentional exceptions like shared test utilities.

06

Prompt Injection via Source Code Comments

What to watch: Malicious or accidental content in source code comments, import paths, or file names can influence the model's evaluation behavior. A comment like

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the output quality of the Architectural Fitness Function Evaluation Prompt before integrating it into a CI/CD gate. Each criterion targets a specific failure mode common to automated architecture governance.

CriterionPass StandardFailure SignalTest Method

Rule Coverage Completeness

Every declared rule in [FITNESS_RULES] has a corresponding pass/fail result in the output

Output is missing a result for one or more rules; silent rule skip

Parse output and compare rule IDs against input rule list; flag any missing

Violation Evidence Grounding

Every FAIL result includes a specific file path, line number, or import statement from [CODEBASE_CONTEXT]

FAIL result contains only a generic description like 'circular dependency found' without a concrete location

Regex check for file path patterns in violation evidence fields; fail if absent for any FAIL result

False Positive Resistance

No FAIL result is triggered by test-only imports, generated code, or declared exemptions in [EXEMPTION_LIST]

FAIL result cites a path matching an exemption pattern or a test directory

Cross-reference violation paths against [EXEMPTION_LIST] glob patterns; flag any match as false positive

Threshold Adherence

No FAIL result is emitted for a metric that is below the threshold defined in [THRESHOLD_CONFIG]

FAIL result is emitted for a coupling metric of 3 when the threshold is set to 5

Extract metric values from output and compare numerically against [THRESHOLD_CONFIG] values

Output Schema Validity

Output is valid JSON matching [OUTPUT_SCHEMA] with all required fields present

Output is missing the 'rule_id' field, or 'status' is not one of PASS, FAIL, or EXEMPT

Validate output against the JSON schema; reject on parse error or missing required fields

Deterministic Re-Run Consistency

Running the same [CODEBASE_CONTEXT] and [FITNESS_RULES] twice produces identical pass/fail results

First run passes a rule and second run fails the same rule with no code change

Execute prompt twice with identical inputs; diff the results; flag any status change as non-deterministic

Actionable Remediation Guidance

Every FAIL result includes a remediation hint that references a specific refactoring action

FAIL result says 'reduce coupling' without naming the specific import or dependency to break

Check that each FAIL result's remediation field contains a concrete file reference or dependency name

Performance Within Gate Budget

Prompt execution completes within [MAX_LATENCY_MS] milliseconds

Prompt times out or exceeds the latency budget, blocking the CI pipeline

Measure end-to-end latency from prompt submission to valid output; fail if over budget

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single fitness function (e.g., no circular dependencies). Use a lightweight JSON schema for output. Run against a small, known codebase module. Skip CI/CD integration; validate manually.

Watch for

  • Overly strict rules flagging test-only or dynamic import cycles as violations
  • Missing [CODEBASE_CONTEXT] causing hallucinated file paths
  • Model inventing dependency relationships not present in the provided source
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.