Skip to main content

Source Code Entity Ontology

Code and Software Entities
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 05 November 2026
Audio Overview
SOURCE CODE ENTITY ONTOLOGY — FLOW ALGEBRA
Semantic Library | AI Core | Entity Graph | Code and Software Entities
Authors: Mark Anthony Higgins — Sky, Recursive AI
Source: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/code-and-software-entities/source-code-entity-ontology.html
Prepared: 05 November 2026 | Language: en-GB
Status: Original interpretative formalisation; not a verbatim extraction of the site's embedded specification.

1. PURPOSE
Represent source code as a versioned, inspectable software entity with syntax, semantics, dependencies, provenance, permissions and verification evidence. Distinguish source text from executable artefacts and from generated code.

2. FORMAL STATE MODEL
S_t = (I_t, R_t, B_t, K_t)
I_t = observed code artefacts, identifiers, files, language, versions and metadata.
R_t = typed relationships (defines, imports, calls, extends, depends_on, tests, builds_to).
B_t = boundaries (repository scope, language grammar, permissions, licences, trust and policy).
K_t = validated knowledge (parse results, symbols, dependencies, diagnostics and provenance).
E_t = expand(I_t, R_t)
V_t = {x in E_t | admissible(x,B_t) and supported(x,K_t)}
x*_t = argmax_{x in V_t} P(x | I_t,R_t,B_t,K_t)
I_(t+1) = update(I_t,x*_t,observations_t)
These are conceptual selection and update rules; probabilities require an explicitly defined scoring model.

3. ENTITY DEFINITIONS
SourceCodeEntity := (id, repository, path, revision, language, encoding, content_hash, licence, provenance, status).
SourceFile := (path, bytes, syntax_tree?, revision).
CodeUnit := (symbol, kind, location, signature?, implementation?).
Dependency := (source, target, type, version_constraint?).
BuildArtefact := (id, build_inputs, toolchain, digest, verification?).
Diagnostic := (code, severity, span, evidence, remediation?).
Verification := (check, outcome, timestamp, environment, evidence).
A question mark denotes an optional field; unknown is not equivalent to false.

4. TYPED RELATIONSHIPS
contains(SourceFile, CodeUnit)
defines(SourceFile, Symbol)
imports(CodeUnit, Dependency)
calls(CodeUnit, CodeUnit)
implements(CodeUnit, Interface)
compiled_to(SourceCodeEntity, BuildArtefact)
tested_by(SourceCodeEntity, TestCase)
derived_from(Revision, Revision)
reported_by(Diagnostic, AnalysisRun)
All edges require provenance; cross-repository links require explicit resolution.

5. FLOW ALGEBRA
F_source = ingest -> identify -> normalise -> parse -> resolve -> analyse -> verify -> publish
Ingest: collect authorised source and revision metadata.
Identify: establish stable identifiers and content digests.
Normalise: preserve semantics while canonicalising metadata; retain original bytes.
Parse: select the correct grammar and report parser uncertainty.
Resolve: bind imports, declarations, references and dependency versions.
Analyse: derive call, data-flow and dependency edges where supported.
Verify: execute configured tests, static checks and policy checks in an authorised environment.
Publish: emit an attributed graph and evidence-linked results.

6. TRI-MAPPING
Physical / digital artefact: repository files, bytes, revision and storage location.
Mathematical / formal representation: abstract syntax tree, dependency graph, predicates and transition rules.
Semantic / operational meaning: declared behaviour, intended interfaces, observed verification and constraints.
Mapping must preserve provenance and distinguish intended from observed behaviour.

7. INFERENCE RULES
R1: valid_parse(f,l) AND defines(f,s) => symbol_in(s,f).
R2: imports(a,b) AND resolved(b,v) => dependency_at(a,b,v).
R3: calls(a,b) AND symbol_in(a,f) AND symbol_in(b,g) => potential_call_edge(f,g).
R4: hash_equal(a,b) AND same_hash_algorithm(a,b) => byte_content_equivalent(a,b), subject to hash collision assumptions.
R5: test_passed(c,e) => verified_under(c,e); NOT verified_in_all_environments(c).
R6: parse_failed(f) => diagnostic(f,parse_error); NOT invalid_intent(f).
R7: unresolved_reference(x) => status(x,unknown); NOT absent(x).
No rule may infer safety, correctness or licence compliance solely from successful parsing.

8. RECURSIVE RESOLUTION ENGINE
resolve(entity, visited, depth):
  if entity in visited: return cycle_reference(entity)
  if depth exceeds configured_limit: return bounded_unknown(entity)
  validate permission and provenance
  inspect direct declarations and dependency edges
  recursively resolve permitted unresolved dependencies
  merge supported facts; retain conflicts and unknowns
  return evidence-linked entity graph
Termination follows from finite authorised scope and configured depth/visit bounds.

9. FLOW DIAGRAM
[Source + Revision]
       |
       v
[Identity / Hash] -> [Grammar / Parse]
       |                     |
       v                     v
[Provenance]          [Symbols / AST]
       |                     |
       +------> [Dependency Resolution]
                           |
                           v
                  [Analysis + Checks]
                           |
                           v
                 [Evidence-linked Graph]
                           |
                           v
                 [Versioned Publication]

10. RELATIONSHIP MAPPING TABLE
Source code -> repository: stored_in
Source code -> revision: versioned_as
Source code -> source file: composed_of
Source file -> syntax tree: parsed_as
Code unit -> symbol: defines
Code unit -> dependency: imports
Source code -> build artefact: built_into
Source code -> test case: tested_by
Diagnostic -> code span: concerns
Verification -> environment: valid_under

11. CONDITIONAL EXECUTION GUARANTEE
Given authorised finite inputs, deterministic parsing tools, bounded recursion and preserved provenance, the flow either returns an evidence-linked graph or a typed failure/unknown result. It does not guarantee compilation, functional correctness, security, completeness or successful execution in unspecified environments.

12. AI SEARCH FLOW
QUERY -> INTENT -> ENTITY MATCH -> RELATION EXPANSION -> BOUNDARY FILTER -> EVIDENCE CHECK -> RANK -> RESPONSE
Example intent: 'Which source file defines the model-serving endpoint?'
Entity match: source files and symbols tagged to model-serving services.
Relation expansion: defines, imports, calls, exposed_by.
Boundary filter: authorised repository, revision, language and evidence quality.
Response: identified file and symbol, revision, supporting edges, confidence and unresolved gaps.

13. UPDATE MODEL
On commit or new release: compute changed content hashes; invalidate affected parse and dependency nodes; recompute impacted graph edges; retain previous revisions and verification context. Never overwrite historical provenance.

14. SEMANTIC EQUIVALENCE AND CONFIDENCE
Byte-equivalence, syntactic equivalence and behavioural equivalence are distinct.
Confidence must be tied to evidence type (source inspection, parser result, static analysis, test execution or human review) and must not be fabricated as a numeric score.

15. ATTRIBUTION
Source ontology: Kireth Research — Source Code Entity Ontology.
Research attribution: Mark Anthony Higgins; Sky — Recursive AI.
Reuse: follow the Open Research Licence and citation requirements stated by the source publisher.
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ