AI Software Architecture Safety Assurance
ENGINEERING BASIS

Why the structure of code and infrastructure must now be measured

Once AI agents are connected to enterprise systems, architecture, not the model, sets the size of an incident. Here is what our 12 metrics measure, the theory behind them, and why grading follows the weakest link rather than an average.

Chris Heedong Na · CEO and Principal Software Architect, CHRISCOMPANY

01 · WHY

When a probabilistic component joins a deterministic system

Traditional enterprise software is deterministic: the same input follows the same control flow and state transitions. Authorization, SQL binding and commit paths are fixed, so even with defects the upper bound of reachable paths can be predicted from the code.

An LLM agent generates its reasoning and tool-call sequence probabilistically. Once outside data (user input, RAG documents, web pages, email) enters the context, the line between data and control disappears; that is the essence of prompt injection. The model must be treated as an untrusted probabilistic node, and outcomes depend on how well the existing architecture isolates and enforces boundaries.

Four kinds of structural debt that turn critical once AI is connected

01

High coupling amplifies the blast radius

In legacy code where dependencies form a mesh, a compromised agent attached to a minor feature can travel the dependency chain to authentication, ledgers and payments.

02

Shared databases defeat policy enforcement points

A new AI gateway and authorization rules do not help if several services read and write the same tables or caches directly, bypassing the owning API; the data tier becomes a path for lateral movement.

03

Architecture drift and shadow edges

Temporary firewall exceptions, unregistered internal APIs and wildcard (*:*) IAM roles are hard for people to find, but an agent that loops over tool calls and error messages finds them automatically.

04

Ambient authority and the confused deputy

When an agent uses integration code that runs under a fixed master service account, an ordinary user request executes with that account’s rights: the confused deputy problem (Norm Hardy, 1988) by construction.

Why existing checks cannot find them

Narrative checklists (e.g. ISMS-P)

Qualitative items such as “is least privilege applied?” are judged from policy documents and screenshots. Cyclic dependencies in real code, reachability across IaC and IAM, or attenuation of delegated tokens cannot be checked that way.

SAST and configuration checks (CCE)

SAST finds local defects within files or functions, and CCE checks single settings per server. Module dependency matrices, network ∩ IAM ∩ application reachability and authority attenuation across agents are global structural invariants that per-unit analysis cannot compute.

02 · METRICS

The 12 metrics: formulas and basis

No documents or opinions: 12 structural invariants that can be computed from the code’s abstract syntax tree, IaC, IAM policy and runtime call graph.

Domain 1. Software coupling & blast radius isolation

Modules V (|V| = N) and their call, reference and data-binding relations E form a directed graph G = (V, E), written as an N × N binary adjacency matrix (design structure matrix, DSM) A.

K-CPL-01

Security-weighted propagation cost (SPC)

Basis
Extends the DSM propagation cost of MacCormack, Rusnak & Baldwin (2006) with asset weights
Formula
R = bool( Σ_{k=0..N−1} A^k ),  w_j ∈ {1 일반, 3 업무로직, 5 인증·결제·개인정보·암호키}
SPC = Σ_i Σ_j R_ij · w_j  /  ( N · Σ_j w_j )  × 100 (%)
What it means
The expected asset-weighted blast radius, from 0 to 100%, when any one module is compromised or an AI tool misbehaves. Even a monolith can stay under 20% if its security modules are isolated one-way.
Hard fail above 50%
K-CPL-02

Cross-zone cyclic coupling ratio (CCCR)

Basis
Tarjan’s (1972) strongly connected components and trust-zone isolation
Formula
T(v) ∈ {1 외부접점, 2 일반도메인, 3 핵심보안코어}
V_cross = ∪ { C ∈ SCC : |C| ≥ 2 ∧ C 안의 신뢰 등급이 2종 이상 }
CCCR = |V_cross| / |V| × 100 (%)
What it means
Nodes in one SCC reach each other, so if an exposed API (level 1) shares an SCC with authentication or the ledger (level 3), the designed trust levels collapse to the lowest one at run time.
Hard fail on any cycle that includes the security core
K-CPL-03

Security design-rule decoupling level (SRDL)

Basis
Baldwin & Clark’s (2000) design rule theory and the DDD anti-corruption layer
Formula
E_cross: 도메인·신뢰 경계를 넘는 의존 엣지
E_cross^impl: 계약 계층(API Gateway, Public Interface, DTO, ACL)을 거치지 않고 내부 구현체를 직접 부르는 엣지
SRDL = ( 1 − |E_cross^impl| / |E_cross| ) × 100 (%)
What it means
Validation, authorization and audit logging belong in the contract layer. The more edges call internals directly, the more bypass paths exist, and changing control policy for AI integration spreads across the whole codebase.
Graded thresholds
K-CPL-04

Shared mutable persistence ratio (SMPR)

Basis
Database-per-service data ownership and blocking data-tier bypass
Formula
D: 전체 영속성 단위(테이블, Redis 키스페이스, 메시지 토픽)
D_shared: 소유 API를 거치지 않고 2개 이상 서비스가 직접 쿼리하는 단위
SMPR = |D_shared| / |D| × 100 (%)
What it means
However well the code is separated, tables shared directly between services act as hidden global state and defeat application-level authorization and audit trails.
Hard fail on any directly shared authentication, payment or sensitive table

Domain 2. Trust boundary reachability & policy alignment

Real deployment artifacts (Terraform, Kubernetes NetworkPolicy, IAM JSON, API gateway routes), not diagrams, are parsed into network, IAM and application graphs; metrics run on the effective reachability graph G_R = G_Net ∩ G_IAM ∩ G_App.

K-TBR-01

Unmediated boundary bypass path count (UBPC)

Basis
Saltzer & Schroeder’s (1975) complete mediation and the reference monitor
Formula
P(V_ext, V_asset): 외부 진입점 → 핵심 자산의 모든 단순 경로
UBPC = | { p ∈ P : p가 정책 집행점 V_PEP를 하나도 지나지 않음 } |
What it means
Graph search finds what separate reviews of firewall tables and IAM JSON miss: security group chaining, VPC peering detours and tier jumping through cross-account AssumeRole.
Hard fail on a single path
K-TBR-02

Architecture drift & shadow edge index (ADSI)

Basis
Architecture conformance checking (Murphy et al., reflexion model) and zero-trust attack surface management
Formula
ADSI = | E_actual \ E_spec | / | E_spec | × 100 (%)
What it means
The share of boundary-crossing edges found only in the deployed environment, such as ports opened for hotfixes, unregistered APIs and temporary rights never revoked.
Level 3 requires CI/CD to block any deployment with ADSI > 0
K-TBR-03

Effective IAM privilege excess ratio (EPER)

Basis
Least privilege (Saltzer & Schroeder, 1975) formalised with risk weights
Formula
α_p ∈ {1 읽기, 5 쓰기·변경, 10 IAM·KMS·관리}
EPER = Σ_s Σ_{p ∈ P_eff(s) \ P_req(s)} α_p  /  Σ_s Σ_{p ∈ P_eff(s)} α_p  × 100 (%)
What it means
Measures the gap between effective rights (with inheritance, delegation and wildcards expanded) and the minimum needed, weighting destructive writes and escalation heavily.
Hard fail when several workloads share a *:* role
K-TBR-04

East-west identity binding coverage (EWIC)

Basis
NIST SP 800-207 zero trust: no implicit trust by network location
Formula
EWIC = | E_ew^crypto-bound | / | E_ew | × 100 (%)
(mTLS 등 워크로드 상호 인증 + 최초 요청자 신원(서명된 토큰)이 함께 전파·검증되는 내부 엣지 비율)
What it means
“It is inside the network, so it is safe” fails once agents make calls from inside. Without verifiable caller identity east-west, K-AID-02 (authority attenuation) has no technical footing.
Graded thresholds

Domain 3. Deterministic control of AI agents

The LLM is treated as an untrusted probabilistic node. System-prompt instructions and LLM-as-judge filters cannot guarantee invariants and score zero; only deterministic controls in code and infrastructure outside the model count.

K-AID-01

Deterministic tool mediation ratio (DTMR)

Basis
Anderson’s (1972) reference monitor applied to tool calls and MCP
Formula
DTMR = | E_tool^intercepted | / | E_tool | × 100 (%)
(스키마 검증 + 파라미터 바인딩 + OPA/Cedar 정책 엔진을 반드시 거치는 도구·MCP·DB·API 바인딩 비율)
What it means
Whether deterministic code outside the model rejects every call that fails schema and policy, even when an injected model emits malicious parameters.
Hard fail on one path from model output to eval, shell, dynamic SQL or unchecked HTTP
K-AID-02

Delegated authority attenuation ratio (DAAR)

Basis
Confused-deputy remedies and monotonic attenuation in capability models (OAuth 2.0 Token Exchange, RFC 8693)
Formula
DAAR = | { e : P(T_e) ⊆ P(u_e) ∩ P(τ_e)  ∧  모든 k에 대해 P(T_{k+1}) ⊆ P(T_k) } | / | E_tool-call | × 100 (%)
What it means
Whether the token passed downstream stays within both the calling user’s rights and the task’s minimum, and only shrinks along multi-agent delegation chains.
Hard fail on a static master account acting for users
K-AID-03

High-impact state-transition interlock (HISI)

Basis
Separation of privilege and FSM interlocks from safety-critical systems
Formula
HISI = | S_crit^crypto-locked | / | S_crit | × 100 (%)
(자금 이체·영구 삭제·IAM 변경·대량 발송 중 에이전트가 만들 수 없는 대역 외 서명 토큰이 있어야만 커밋되는 비율)
What it means
Asking “delete this?” in chat and acting on the next message lives in the same context window and can be bypassed by injection, so it does not count.
Must be 100% (hard fail otherwise)
K-AID-04

Bounded autonomy & lineage score (BALS)

Basis
Bounded execution and resource exhaustion (denial of wallet) prevention, plus non-repudiation and causal lineage
Formula
BALS = | W_bounded ∧ traceable | / | W | × 100 (%)
조건 1: 반복 횟수·타임아웃·비용 한도를 인프라에서 강제
조건 2: WORM 저장소에 (요청자 ID, 입력 해시, 출력 해시, 정책 결정 ID, 하위 트랜잭션 ID) 기록
What it means
Whether infrastructure deterministically stops runaway agent loops and cost blow-ups, and whether an incident can be fully reconstructed from request and context through output to the changed record.
Graded thresholds
03 · GRADING

How the self-scan grades: the weakest link, not the average

Reachability, cycles, least privilege and tool mediation are universal properties of software, not industry rules, so there is no industry split: only two tracks. Legacy only (Track A) adds four AI-readiness questions to the eight K-CPL and K-TBR ones; AI-integrated (Track B) adds the four K-AID ones. Twelve questions each.

Each question asks for a structural fact an architect or developer can check as true or false in today’s code and infrastructure, never an opinion, with five answers.

AnswerLevelScoreMeaning
ALevel 3100Invariant enforced automatically at build, deploy and run time (policy gates, mTLS, token exchange, WORM)
BLevel 275Structural isolation at core boundaries, with some manual exceptions elsewhere
CLevel 145Designed or partly applied, but weakly enforced in code and infrastructure
DHard fail0Direct violation (core cycles, shared auth tables, bypass paths, master-account delegation, unchecked eval or dynamic SQL, chat approval)
UUnknown25The respondent cannot confirm the structural fact; scored conservatively below C and counted in the blind spot ratio (VBS)

Three steps, applied in order

  1. ① Visibility blind spot ratio (VBS)

    VBS = N_unknown / 12 × 100 (%)

    What cannot be observed cannot be controlled. “Unknown” is treated as an unverified weakness, scored no better than C, and three or more (25%+) raise a “blind spot alert: measurement required” flag that caps the grade below Level 2.

  2. ② Non-compensatory hard-fail override

    Security architecture is conjunctive: the weakest link breaks the whole line, so averaging is wrong. One hard-fail answer makes the result unqualified even if everything else is perfect, and the lowest of the three domain scores, not the overall average, sets the level.

    Unqualified (hard fail)One or more hard-fail answers
    Provisional Level 3No hard fail, 0% blind spots, lowest graded domain score ≥ 90
    Provisional Level 2No hard fail, blind spots < 25%, lowest graded domain score ≥ 70
    Provisional Level 1No hard fail, lowest graded domain score ≥ 45 (held here when blind spots reach 25%)
    Below Level 1Otherwise

    For legacy only (Track A) the level comes from the lower of K-CPL and K-TBR. A D in AI readiness (K-AIR) is shown separately as an AI blocker to clear before AI goes in.

  3. ③ Compound attack paths

    Rather than listing defects one by one, rules find the chains opened when two or more combine. If a shared database (K-CPL-04) and master-account delegation (K-AID-02) both fail, the report states that an injected agent can alter authentication or payment tables shared by other domains with master-account rights.

04 · MARKDOWN KIT

Measurement without executables: the markdown kit

A survey is an estimate based on what respondents know; real legacy systems hide undocumented coupling and privilege drift. Bringing an executable into a closed network or uploading code is hard to get past security. So stage two hands over one plain-text markdown kit (.md) anyone can read, your own agent runs it, and only numbers come back.

The LLM never guesses the numbers

Asked to compute matrix powers or SCCs in its head, an LLM can hallucinate. In the kit, the agent does not calculate: it runs the kit’s deterministic scripts read-only in your environment and gathers the results.

The kit’s five layers

Layer 1

Security assertion & read-only contract

Binds the in-house agent to read-only access, no network calls, and output of only hash IDs and the 12 values, with no file, class or table names, IPs or accounts.

Layer 2

Artifact discovery & asset weighting

Rules to find code, ORM and DDL; Terraform, Kubernetes, IAM and gateway config; LLM SDK, MCP, token exchange and commit handlers. Core modules and enforcement points are tagged in a local file that never leaves.

Layer 3

Deterministic extraction & graph scripts

Python reference code, mostly standard library, that actually computes the dependency graph and reachability matrix, Tarjan SCCs, shared tables, multi-layer reachability and AI control patterns; the in-house agent only wires adapters for your languages and layout.

Layer 4

Local verification log

Shows on your screen only why each number came out (e.g. which two modules form a cycle), so engineers can confirm the facts come from their code. The log stays inside.

Layer 5

Numbers-only output schema

The final JSON holds only numbers, booleans and fixed values. The web form blocks anything else in the browser before it is sent.

This is all you submit

{
  "schema_version": "kssaa-metrics-1.0",
  "system_track": "legacy_ai_integrated",
  "scope_stats": { "module_count_N": 142, "persistence_unit_count_D": 86, "workload_count_S": 24, "ai_tool_binding_count": 15 },
  "metrics": {
    "K_CPL_01_SPC_pct": 28.4,   "K_CPL_02_CCCR_pct": 4.2,  "K_CPL_02_core_cycle_count": 1,
    "K_CPL_03_SRDL_pct": 76.5,  "K_CPL_04_SMPR_pct": 11.6, "K_CPL_04_sensitive_shared_count": 2,
    "K_TBR_01_UBPC_count": 1,   "K_TBR_02_ADSI_pct": 8.3,  "K_TBR_02_core_shadow_edge_count": 0,
    "K_TBR_03_EPER_pct": 31.2,  "K_TBR_03_shared_wildcard_flag": true,
    "K_TBR_04_EWIC_pct": 40.0,  "K_TBR_04_sensitive_unbound_count": 3,
    "K_AID_01_DTMR_pct": 86.7,  "K_AID_01_unmediated_exec_count": 2,
    "K_AID_02_DAAR_pct": 33.3,  "K_AID_02_static_master_account_flag": true,
    "K_AID_03_HISI_pct": 0.0,   "K_AID_03_inband_approval_count": 1,
    "K_AID_04_BALS_pct": 50.0,  "K_AID_04_unbounded_workflow_count": 2
  }
}
Open a sample kit (.md, Korean)Legacy onlyLegacy + AI
05 · SCOPE

What the 12 metrics can and cannot vouch for

The 12 metrics and the non-compensatory grading are a sufficient set to judge whether a legacy or AI-integrated architecture structurally isolates and controls its core assets against intrusion, malfunction and change. Four reasons:

  1. They cover all four layers an intrusion can travel: code (SPC, CCCR, SRDL), data (SMPR), infrastructure and trust boundaries (UBPC, ADSI, EPER, EWIC), and the layer that binds probabilistic AI deterministically (DTMR, DAAR, HISI, BALS).
  2. They turn proven principles into formulas: modularity theory (Baldwin & Clark, MacCormack et al.), Tarjan’s SCCs, Saltzer & Schroeder’s design principles, Anderson’s reference monitor, Hardy’s confused deputy and NIST SP 800-207 zero trust.
  3. They respect the weakest link: the lowest domain score, hard-fail override and blind spot ratio together stop a high average from hiding a critical defect.
  4. Beyond ISO/IEC 25010 security, they also check maintainability (modularity, analysability, modifiability) and reliability (fault containment).

What this assessment does not cover

Area (ISO/IEC 25010)What it isCovered by
Local code defects and supply-chain CVEsBuffer overflows, memory leaks, crypto implementation errors and open-source library vulnerabilitiesSAST · DAST · SCA (SBOM)
Performance efficiencyTPS and P99 latency under load, index and query tuning, distributed lock contentionLoad testing · APM
Functional suitabilityBusiness requirements, correctness of financial calculations, UI/UX usabilityUnit · integration · E2E tests, QA
AI model accuracy and hallucinationLLM reasoning accuracy, RAG recall and answer qualityAI eval benchmarks

On model accuracy the position is clear: the aim is to cap the structural damage so that even a hallucinating or poisoned LLM cannot harm core assets or state transitions.

06 · PIPELINE

Three stages from assessment to structural fix

1

Safety Self-Scan (free)

Your architect answers 12 structural facts on the web (no code)

Provisional grade, hard-fail alerts, blind spots and compound attack paths as a PDF

2

Quantitative Safety Review

Your agent and developers run the .md kit in your network and submit only the numbers JSON

Precise grading of the 12 metrics, perception gap against the survey, and a roadmap by level

3

Containment & Assurance

Your team with CHRISCOMPANY architects (ARB)

Refactoring of only the minimum cut-set of edges behind hard fails, verification of deterministic controls, and regular re-measurement

You never send a line of legacy code outside and take on no executable risk, yet you get quantitative evidence of architectural safety invariants that checklists and local static analysis cannot compute.

CHRISMEDIA NEWSLETTER

Software Architecture in the AI Era, Once a Week

A weekly digest of CHRISMEDIA's AI and software architecture articles, with the CEO's column. Written in Korean. Free, and you can unsubscribe at any time.

Your subscription starts once you confirm it from the email we send.