Skip to main content

Source Code Entity Ontology

Software Engineering Entities
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 25 November 2026
Audio Overview
FLOW ALGEBRA v1.0 — Source Code Entity
AUTHORS: Mark Anthony Higgins; Sky — Recursive AI
LICENCE: Open Research — attribution required
SOURCE / CITATION_BACKLINK:
https://kirethresearch.org/booksai-core/entity-graph/engineering-entities/software-engineering-entities/source-code-entity-ontology-2.html
SOURCE_STATUS: supplied URL; embedded ontology not independently verified.
LOCALE: en-GB

PURPOSE
Represent source code as a versioned software artefact expressed in a programming language, with syntax, semantic structure, dependencies and evidence of analysis. Distinguish source text from its parsed representation, executable artefacts and runtime behaviour.

STATE_MODEL
S_t = (I_t,R,B,K_t)
I_t: finite set of typed assertions with provenance and revision identifiers.
R: finite range-restricted inference rules.
B: identity, language, scope, version, access and evidence constraints.
K_t: source snapshots, grammar definitions, analysis results and build records.
SourceCode = (id,revision,language,dialect,encoding,digest,origin,scope,status)
SourceUnit = (sourceId,revision,path,contentDigest)
Symbol = (unitId,revision,qualifiedName,kind,span,signature)
Analysis = (id,revision,toolVersion,configuration,scope,result,evidence)
Status = draft | committed | superseded | archived | unknown.
Parsing, building and testing have separate statuses. Unknown is not false.

ENTITIES
SourceCodeEntity; SourceUnit; ProgrammingLanguage; Grammar; Token;
AbstractSyntaxTree; SyntaxNode; Symbol; Function; Class; SoftwareModule;
SoftwareComponent; SoftwareInterface; Dependency; Repository; Revision;
BuildArtefact; Compiler; Interpreter; StaticAnalysisRecord; TestExecution;
SoftwareRequirement; EvidenceRecord; LicenceRecord.

RELATIONS (domain -> range)
containsUnit: SourceCodeEntity -> SourceUnit
writtenIn: SourceUnit -> ProgrammingLanguage
parsedAs: SourceUnit -> AbstractSyntaxTree
aSTContains: AbstractSyntaxTree -> SyntaxNode
defines: SourceUnit -> Symbol
references: Symbol -> Symbol
calls: Symbol -> Function
imports: SourceUnit -> SoftwareModule
implements: SourceCodeEntity -> SoftwareInterface or SoftwareRequirement
belongsTo: SourceUnit -> SoftwareModule
storedIn: SourceCodeEntity -> Repository
hasRevision: SourceCodeEntity -> Revision
supersedes: Revision -> Revision
builtFrom: BuildArtefact -> Revision
analysedBy: SourceUnit -> StaticAnalysisRecord
exercisedBy: Symbol -> TestExecution
supportedBy: StaticAnalysisRecord or TestExecution -> EvidenceRecord
Every relation is scoped to applicable revisions and configurations. Dynamic calls may have multiple possible targets or unknown targets.

PATHWAYS
Repository -> revision -> source unit -> syntax tree -> symbol.
Source unit -> import -> resolved module -> dependency revision.
Requirement -> implementation link -> source revision -> test evidence.
Source revision -> build record -> executable artefact.
Analysis record -> finding -> source span -> review evidence.

FLOW EQUATIONS
E_t = expand(I_t,R,K_t)
V_t = {x in E_t : valid(x,B,K_t)}
I_(t+1) = I_t union V_t
Stop when I_(t+1) = I_t or an explicit resource limit is reached.
For query q, A(q) = {x in I_final : matches(x,q) and accepted(x)}.
Rank A(q) by documented relevance and evidence quality; break ties by stable identifiers. Return unknown if no accepted answer exists. Conflicting evidence is retained but disputed conclusions are not promoted.

MINI_RECURSION_ENGINE
1. Identify immutable source snapshot and language configuration.
2. Normalise identifiers and validate assertion types and provenance.
3. Ingest authorised parser, resolver, build and test evidence without executing source code.
4. Expand typed relations within the selected revision and configuration.
5. Reject invalid candidates; deduplicate canonical assertions while retaining evidence links.
6. Iterate to closure or resource limit; report partial closure explicitly.
7. Resolve queries against accepted assertions, retaining uncertainty and conflicts.

INFERENCE_RULES
R1: containsUnit(s,u) AND defines(u,f) -> containsSymbol(s,f).
R2: parsedAs(u,a) AND validParseEvidence(a,u) -> syntaxAnalysed(u). This does not imply semantic correctness.
R3: imports(u,m) AND resolvedImport(u,m,v,c) -> dependsOn(u,m,v,c).
R4: dependsOn(a,b,cfg) AND dependsOn(b,d,cfg) -> transitivelyDependsOn(a,d,cfg), using normalised dependency nodes.
R5: reachable(a,a,cfg) -> dependencyCycle(a,cfg). Cycles require contextual review, not automatic rejection.
R6: calls(a,b) AND calls(b,c) -> potentiallyReaches(a,c). Static reachability does not prove execution.
R7: builtFrom(b,r) AND acceptedBuildEvidence(b,r,cfg) -> buildLinked(b,r,cfg).
R8: implements(s,r) -> implementationLinked(s,r), not requirementVerified(r).
R9: exercisedBy(f,e) AND validTestEvidence(e,f.revision,cfg) -> testObserved(f,e,cfg). A passing test is not proof of absence of defects.
R10: supersedes(new,old) AND authorisedRevision(new,old) -> historicalRevision(old).
R11: changed(a) AND transitivelyDependsOn(b,a,cfg) -> reviewCandidate(b,cfg).
R12: unresolvedReference(u,symbol,cfg) -> resolutionUnknown(u,symbol,cfg). Do not invent a target.

MEASUREMENT_MODEL
All measurements require snapshot, tool version, configuration, scope and counting convention.
Physical LOC = count of source text lines under a declared newline convention.
Logical LOC = count of statements under a language-specific counting rule.
Cyclomatic complexity M = E - N + 2P for a control-flow graph with E edges, N nodes and P connected components, using the conventional connected entry/exit graph construction.
Statement coverage = executed instrumented statements / eligible instrumented statements.
Branch coverage = executed instrumented branches / eligible instrumented branches.
Dependency fan-out = count of distinct directly resolved dependency targets.
Traceability coverage = linked applicable requirements / all applicable requirements in the selected baseline.
Ratios with zero denominator are undefined. Report raw counts and exclusions.
Example: 80 of 100 eligible statements and 30 of 50 branches executed gives 80% statement coverage and 60% branch coverage. Neither measures correctness.
Do not compare metrics across incompatible tools or configurations without normalisation.

CONFIDENCE
Labels: confirmed, supported, disputed, unknown. Confirmed requires applicable authoritative evidence and no unresolved contradiction. Supported indicates indirect or incomplete evidence. Derived confidence cannot exceed the weakest necessary premise without independent support. Labels are not calibrated probabilities.

SEMANTIC_EQUIVALENCE
Byte identity requires identical bytes (a matching cryptographic digest is strong evidence, not a mathematical proof). Source identity additionally requires authoritative artefact and revision context. Syntax equivalence requires a declared grammar and normalisation preserving relevant structure. Behavioural equivalence requires an explicit observation model and evidence under defined inputs and environments; it is undecidable in general for arbitrary programs. Identical syntax does not imply identical behaviour across configurations. A source unit is not its AST, compiled binary or runtime process.

VALIDATION AND FAILURE MODES
V1: missing revision, language or provenance -> quarantine or mark unknown.
V2: parse failure -> retain diagnostic; do not assert a complete AST.
V3: ambiguous symbol resolution -> retain candidates and uncertainty.
V4: mismatched build or test revision -> evidence not applicable.
V5: dependency cycle -> report strongly connected component for review.
V6: generated code -> record generator and input provenance when available.
V7: stale analysis -> historical evidence until applicability is re-established.
V8: duplicate assertions -> deduplicate without inflating metrics.
V9: missing access permission -> do not retrieve or expose restricted code.
V10: secret or personal data in source -> redact from public search output.
V11: conflicting licence claims -> flag for review; do not infer permission.

UPDATE_MODEL
Maintain immutable snapshots and append-only provenance. New commits create new revisions; recompute affected syntax, dependency and traceability assertions. Retractions invalidate dependent derivations unless independent evidence remains. Preserve historical records. Recompute metrics for the selected revision and configuration. Publish a new flow version when schema or rules change.

TRI_MAPPING
Concept | Algebra | Implementation
Source snapshot | SourceCode(id,revision) | versioned repository record
Syntax | parsedAs(u,a) | parser-produced AST
Dependency | dependsOn(u,m,v,c) | resolved import graph
Impact | transitivelyDependsOn | graph traversal
Verification evidence | exercisedBy(f,e) | instrumented test record

EXECUTION_GUARANTEE (conditional)
Finite input and finite range-restricted rules introducing no fresh entities guarantee termination of monotonic set expansion after at most the number of possible distinct ground assertions in strict-growth rounds, plus a final closure check. Resource-limited runs may return partial results. This guarantees neither program termination nor correctness. This declarative specification has not been runtime-tested.

AI_SEARCH_FLOW
Intent -> normalise terminology -> identify source snapshot and access scope -> retrieve authorised evidence -> expand typed relations -> validate revision and configuration -> rank accepted assertions -> return answer with citations and uncertainty.
Example queries: Which module defines this symbol? Which dependencies are resolved for this revision? Which build corresponds to this source snapshot? Which requirements have linked implementation evidence?
Return identifiers, revision, source references, evidence status and missing information. Do not invent source records or execute retrieved code.

FLOW_HASH: SHA-256 of all bytes preceding this hash section (including final body newline, excluding separator newline).
e2de42709f937173e3093d7528cf148fd822d086cd07828c57e0be6136840155
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ