Cache File Format Specification

ACP Version: 1.0.0 Document Version: 1.2.0 Last Updated: 2025-12-22 Status: RFC-001, RFC-0002, RFC-0003 Compliant


Table of Contents

  1. Overview
  2. File Format
  3. Root Structure - Updated with documentation index (RFC-0002), provenance statistics (RFC-0003)
  4. File Entries - Updated with purpose, owner, inline, refs, style, annotations (RFC-0003)
  5. Symbol Entries - Updated with purpose, params, returns, throws, constraints, annotations (RFC-0003)
  6. Call Graph
  7. Domain Index
  8. Constraint Index - Updated with directive, auto_generated
  9. Documentation Index (RFC-0002)
  10. Provenance Index (RFC-0003)
  11. Generation
  12. Validation

1. Overview

1.1 Purpose

The cache file (.acp.cache.json) is the indexed representation of a codebase. It provides AI systems with structured access to:

  • File and module metadata with purpose descriptions
  • Symbol definitions with directives and relationships
  • Call graphs and dependencies
  • Domain classifications
  • Constraint and guardrail information with directives
  • Inline annotations for tracking items (todo, fixme, critical)

The cache enables token-efficient AI interactions by pre-computing codebase structure rather than analyzing files on every request.

1.2 Design Principles

  • Query Optimized: Structure enables efficient queries via jq or programmatic access
  • Self-Contained: All information needed for AI context in one file
  • Deterministic: Same codebase always produces identical cache (for diffing)
  • Incremental: Supports partial updates without full regeneration
  • Token Efficient: Minimizes context sent to AI systems

1.3 File Location

The cache file:

  • MUST be named .acp.cache.json
  • SHOULD be located in the project root
  • MAY be placed in a configured location via .acp.config.json
  • SHOULD be added to .gitignore (generated artifact)

1.4 Conformance

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.


2. File Format

2.1 Encoding

  • MUST be valid JSON (RFC 8259)
  • MUST use UTF-8 encoding
  • SHOULD use 2-space indentation for readability
  • MUST NOT include comments (standard JSON)
  • MUST use snake_case for all field names

2.2 Size Considerations

Codebase SizeTypical Cache Size
Small (<100 files)<100 KB
Medium (100-1000 files)100 KB - 1 MB
Large (1000-10000 files)1 MB - 10 MB
Very Large (>10000 files)Consider splitting

2.3 Schema

The cache file MUST conform to the JSON Schema at: https://acp-spec.org/schemas/v1/cache.schema.json


3. Root Structure

3.1 Top-Level Fields

{
  "version": "1.0.0",
  "generated_at": "2025-12-21T15:30:00Z",
  "git_commit": "abc123def456",
  "project": { },
  "stats": { },
  "source_files": { },
  "files": { },
  "symbols": { },
  "annotations": { },
  "graph": { },
  "domains": { },
  "constraints": { },
  "documentation": { },
  "provenance": { }
}

Notes:

  • The annotations section is new in RFC-001 and stores all annotations with their directives.
  • The documentation section is new in RFC-0002 and stores the project-wide documentation index.
  • The provenance section is new in RFC-0003 and stores annotation provenance statistics.

3.2 Field Definitions

version (required)

ACP specification version this cache conforms to.

  • Type: string
  • Format: Semantic version (e.g., "1.0.0")
  • MUST match major version of ACP spec

generated_at (required)

Timestamp when cache was generated.

  • Type: string
  • Format: ISO 8601 datetime with timezone
  • Example: "2024-12-17T15:30:00Z"
  • Used for staleness detection

git_commit (optional)

Git commit SHA if project is in a git repository.

  • Type: string or null
  • Format: 40-character hex SHA
  • Example: "abc123def456789..."
  • Used for git-aware staleness detection

project (required)

Project metadata.

{
  "project": {
    "name": "my-project",
    "root": "/absolute/path/to/project",
    "description": "Optional project description"
  }
}
FieldTypeRequiredDescription
namestringYesProject name
rootstringYesAbsolute path to project root
descriptionstringNoProject description

stats (required)

Aggregate statistics.

{
  "stats": {
    "files": 127,
    "symbols": 843,
    "lines": 24521
  }
}
FieldTypeRequiredDescription
filesintegerYesTotal indexed files
symbolsintegerYesTotal indexed symbols
linesintegerYesTotal lines of code

source_files (required)

Map of file paths to modification times for staleness detection.

{
  "source_files": {
    "src/auth/session.ts": "2024-12-17T15:29:00Z",
    "src/utils/helpers.ts": "2024-12-17T14:20:00Z"
  }
}
  • Keys: Relative file paths
  • Values: ISO 8601 timestamps (last modification time)

4. File Entries

4.1 Structure

The files object maps relative file paths to file entry objects.

{
  "files": {
    "src/auth/session.ts": {
      "path": "src/auth/session.ts",
      "module": "Session Management",
      "summary": "Handles user session lifecycle and validation",
      "lines": 234,
      "language": "typescript",
      "domains": ["authentication"],
      "layer": "service",
      "stability": "stable",
      "exports": ["src/auth/session.ts:SessionService"],
      "imports": ["jsonwebtoken", "src/db/users"]
    }
  }
}

4.2 Field Definitions

FieldTypeRequiredDefaultDescription
pathstring✓ MUST-Relative path from project root
purposestring⚠ SHOULDnullFile purpose (from @acp:purpose) - RFC-001
modulestring⚠ SHOULDnullHuman-readable module name (from @acp:module)
summarystring✗ MAYnullBrief file description (legacy, use purpose)
ownerstring✗ MAYnullTeam ownership (from @acp:owner) - RFC-001
linesinteger✓ MUST-Line count
languagestring✓ MUST-Programming language
domainsarray[string]✗ MAY[]Domain classifications (from @acp:domain)
layerstring✗ MAYnullArchitectural layer (from @acp:layer)
stabilitystring✗ MAYnullStability level: stable, experimental, deprecated
exportsarray[string]⚠ SHOULD[]Exported symbols (qualified names)
importsarray[string]⚠ SHOULD[]Imported modules
inlinearray[object]✗ MAY[]Inline annotations in file - RFC-001
refsarray[object]✗ MAY[]Documentation references - RFC-0002
styleobject✗ MAYnullStyle guide configuration - RFC-0002
annotationsobject✗ MAYAnnotation provenance tracking - RFC-0003

refs Array (RFC-0002)

The refs array stores documentation references from @acp:ref and related annotations:

{
  "refs": [
    {
      "url": "https://react.dev/reference/react/hooks",
      "sourceId": "react",
      "version": "18.2",
      "section": "hooks/rules-of-hooks",
      "fetch": true,
      "scope": "file",
      "line": 5
    },
    {
      "url": "https://docs.company.com/api/auth",
      "sourceId": "company-api",
      "fetch": false,
      "scope": "symbol",
      "symbolName": "validateSession",
      "line": 45
    }
  ]
}
FieldTypeRequiredDescription
urlstringYesDocumentation URL
sourceIdstringNoApproved source ID from config (if applicable)
versionstringNoDocumentation version (from @acp:ref-version)
sectionstringNoSection within documentation (from @acp:ref-section)
fetchbooleanNoWhether AI should fetch (from @acp:ref-fetch), default: false
scopestringNoReference scope: file or symbol, default: file
symbolNamestringNoSymbol name if scope is symbol
lineintegerNoLine number where reference appears

style Object (RFC-0002)

The style object stores style guide configuration from @acp:style and related annotations:

{
  "style": {
    "name": "company-react",
    "extends": "airbnb-react",
    "source": "company-api",
    "url": "https://docs.company.com/style",
    "rules": ["prefer-function-components", "max-line-length=120"],
    "scope": "file",
    "line": 3
  }
}
FieldTypeRequiredDescription
namestringNoStyle guide name or ID
extendsstringNoParent style guide (from @acp:style-extends)
sourcestringNoDocumentation source ID for this style
urlstringNoDirect URL to style guide documentation
rulesarray[string]NoSpecific style rules applied
scopestringNoStyle scope: file or symbol, default: file
symbolNamestringNoSymbol name if scope is symbol
lineintegerNoLine number where style is declared

inline Array (RFC-001)

The inline array stores inline annotations (@acp:critical, @acp:todo, @acp:fixme, @acp:perf):

{
  "inline": [
    {
      "type": "critical",
      "line": 45,
      "directive": "Review with extreme care; errors here have severe consequences"
    },
    {
      "type": "todo",
      "value": "Add rate limiting",
      "line": 78,
      "directive": "This work is pending; consider completing before related changes",
      "ticket": "JIRA-123"
    },
    {
      "type": "fixme",
      "value": "Race condition",
      "line": 102,
      "directive": "Known issue that needs resolution; avoid relying on current behavior"
    }
  ]
}
FieldTypeRequiredDescription
typestringYesAnnotation type: critical, todo, fixme, perf, hack
valuestringNoAnnotation value (e.g., task description)
lineintegerYesLine number
directivestringYesSelf-documenting directive text
ticketstringNoRelated issue/ticket reference
expiresstringNoExpiration date (ISO 8601) for hacks
auto_generatedbooleanNoTrue if directive was auto-generated

annotations Object (RFC-0003)

The annotations object stores provenance tracking information for annotations in the file:

{
  "annotations": {
    "summary": {
      "value": "Session management utilities",
      "source": "heuristic",
      "confidence": 0.82,
      "needsReview": false,
      "reviewed": true,
      "reviewedAt": "2025-01-15T10:30:00Z",
      "generatedAt": "2025-01-10T14:22:00Z",
      "generationId": "gen-20250110-001"
    },
    "domain": {
      "value": "authentication",
      "source": "heuristic",
      "confidence": 0.75,
      "needsReview": true,
      "reviewed": false,
      "generatedAt": "2025-01-10T14:22:00Z",
      "generationId": "gen-20250110-001"
    }
  }
}
FieldTypeRequiredDescription
valuestringYesThe annotation value
sourcestringNoOrigin: explicit, converted, heuristic, refined, inferred
confidencenumberNoConfidence score (0.0-1.0)
needsReviewbooleanNoWhether annotation is flagged for review
reviewedbooleanNoWhether annotation has been reviewed
reviewedAtstringNoISO 8601 timestamp of review
generatedAtstringNoISO 8601 timestamp of generation
generationIdstringNoBatch identifier for generation run

4.3 Language Detection

Languages MUST be identified using standard identifiers:

LanguageIdentifierExtensions
TypeScripttypescript.ts, .tsx, .mts, .cts
JavaScriptjavascript.js, .jsx, .mjs, .cjs
Pythonpython.py, .pyi, .pyw
Rustrust.rs
Gogo.go
Javajava.java
C#c-sharp.cs
C++cpp.cpp, .cc, .cxx, .hpp
Cc.c, .h
Rubyruby.rb
PHPphp.php
Swiftswift.swift
Kotlinkotlin.kt, .kts

4.4 Examples

Minimal File Entry

{
  "path": "src/utils/helpers.ts",
  "lines": 45,
  "language": "typescript",
  "exports": [],
  "imports": []
}

Complete File Entry

{
  "path": "src/auth/session.ts",
  "module": "Session Management",
  "summary": "Handles user session lifecycle and validation",
  "lines": 234,
  "language": "typescript",
  "domains": ["authentication", "security"],
  "layer": "service",
  "stability": "stable",
  "exports": [
    "src/auth/session.ts:SessionService",
    "src/auth/session.ts:SessionService.validateSession"
  ],
  "imports": [
    "jsonwebtoken",
    "redis",
    "src/db/users",
    "src/utils/crypto"
  ]
}

5. Symbol Entries

5.1 Structure

The symbols object maps qualified symbol names to symbol entry objects.

{
  "symbols": {
    "src/auth/session.ts:SessionService.validateSession": {
      "name": "validateSession",
      "qualified_name": "src/auth/session.ts:SessionService.validateSession",
      "type": "method",
      "file": "src/auth/session.ts",
      "lines": [45, 89],
      "signature": "(token: string) => Promise<Session | null>",
      "summary": "Validates JWT token and returns session",
      "async": true,
      "exported": true,
      "visibility": "public",
      "calls": [
        "src/auth/jwt.ts:verifyToken",
        "src/db/sessions.ts:findSession"
      ],
      "called_by": [
        "src/api/middleware.ts:authMiddleware"
      ]
    }
  }
}

5.2 Field Definitions

FieldTypeRequiredDefaultDescription
namestring✓ MUST-Simple symbol name
qualified_namestring✓ MUST-Format: file_path:class.symbol
typestring✓ MUST-Symbol type (see below)
filestring✓ MUST-Containing file path
lines[int, int]✓ MUST-[start_line, end_line]
signaturestring⚠ SHOULDnullFunction signature if applicable
purposestring⚠ SHOULDnullSymbol purpose (from @acp:fn, @acp:class, etc.) - RFC-001
summarystring✗ MAYnullBrief description (legacy, use purpose)
paramsarray[object]✗ MAY[]Parameter descriptions - RFC-001
returnsobject✗ MAYnullReturn value description - RFC-001
throwsarray[object]✗ MAY[]Exception descriptions - RFC-001
asyncboolean✗ MAYfalseWhether async
exportedboolean✓ MUST-Whether exported
visibilitystring✗ MAY"public"public, private, protected
callsarray[string]✗ MAY[]Symbols this calls (qualified names)
called_byarray[string]✗ MAY[]Symbols calling this (qualified names)
constraintsobject✗ MAYnullSymbol-level constraints with directives - RFC-001
annotationsobject✗ MAYAnnotation provenance tracking - RFC-0003

Symbol Documentation Fields (RFC-001)

{
  "params": [
    {
      "name": "token",
      "description": "JWT token string",
      "directive": "Ensure token is a valid JWT string before calling"
    }
  ],
  "returns": {
    "description": "Session object or null if invalid",
    "directive": "Handle null case appropriately in calling code"
  },
  "throws": [
    {
      "exception": "AuthError",
      "description": "When token is malformed",
      "directive": "Handle AuthError appropriately when calling"
    }
  ],
  "constraints": {
    "lock_level": "frozen",
    "lock_reason": "Core authentication logic",
    "directive": "MUST NOT modify this function under any circumstances"
  }
}

5.3 Symbol Types

TypeDescriptionLanguages
functionStandalone functionAll
methodClass/object methodAll
classClass definitionTS, JS, Python, Java, etc.
interfaceInterface definitionTS, Java, Go
typeType aliasTS
enumEnumerationTS, Java, Rust
structStruct definitionRust, Go, C
traitTrait definitionRust
constConstantAll

5.4 Qualified Names

Qualified names MUST follow this format:

{relative_path}:{qualified_symbol}

Examples:

  • src/auth/session.ts:SessionService.validateSession - Class method
  • src/utils/helpers.ts:formatDate - Standalone function
  • lib/core.py:CoreEngine.process - Python class method
  • src/auth/session.ts:SessionService - Class itself

5.5 Examples

Function Symbol

{
  "name": "formatDate",
  "qualified_name": "src/utils/helpers.ts:formatDate",
  "type": "function",
  "file": "src/utils/helpers.ts",
  "lines": [12, 15],
  "signature": "(date: Date) => string",
  "summary": "Formats date to ISO 8601 string",
  "exported": true,
  "visibility": "public"
}

Method Symbol with Call Graph

{
  "name": "validateSession",
  "qualified_name": "src/auth/session.ts:SessionService.validateSession",
  "type": "method",
  "file": "src/auth/session.ts",
  "lines": [45, 89],
  "signature": "(token: string) => Promise<Session | null>",
  "summary": "Validates JWT token and returns session",
  "async": true,
  "exported": true,
  "visibility": "public",
  "calls": [
    "src/auth/jwt.ts:verifyToken",
    "src/db/sessions.ts:findSession"
  ],
  "called_by": [
    "src/api/middleware.ts:authMiddleware"
  ]
}

6. Call Graph

6.1 Structure

The graph object contains call relationships in both directions.

{
  "graph": {
    "forward": {
      "src/auth/session.ts:SessionService.validateSession": [
        "src/auth/jwt.ts:verifyToken",
        "src/db/sessions.ts:findSession"
      ],
      "src/api/middleware.ts:authMiddleware": [
        "src/auth/session.ts:SessionService.validateSession"
      ]
    },
    "reverse": {
      "src/auth/jwt.ts:verifyToken": [
        "src/auth/session.ts:SessionService.validateSession"
      ],
      "src/auth/session.ts:SessionService.validateSession": [
        "src/api/middleware.ts:authMiddleware"
      ]
    }
  }
}

6.2 Field Definitions

FieldTypeDescription
forwardobjectMap of symbol → symbols it calls
reverseobjectMap of symbol → symbols that call it

6.3 Graph Properties

  • Both forward and reverse MUST be present
  • They MUST be consistent (inverse of each other)
  • External calls (to libraries) MAY be included with qualified names
  • Recursive calls MUST be included (symbol appears in own list)

6.4 Construction Algorithm

See File Discovery Specification Section 8.3.3 for call graph construction details.


7. Domain Index

7.1 Structure

The domains object groups files and symbols by domain.

{
  "domains": {
    "authentication": {
      "name": "authentication",
      "description": "User authentication and session management",
      "files": [
        "src/auth/session.ts",
        "src/auth/jwt.ts",
        "src/auth/middleware.ts"
      ],
      "symbols": [
        "src/auth/session.ts:SessionService.validateSession",
        "src/auth/jwt.ts:generateToken",
        "src/auth/middleware.ts:authMiddleware"
      ]
    }
  }
}

7.2 Field Definitions

FieldTypeRequiredDescription
namestringYesDomain identifier
descriptionstringNoHuman description
filesarray[string]YesFiles in this domain
symbolsarray[string]YesSymbols in this domain (qualified names)

7.3 Domain Detection

Domains are detected via:

  1. @acp:domain annotations (Priority 1)
  2. Directory patterns in config (Priority 2)
  3. Import analysis (Priority 3)

See File Discovery Specification Section 8.3.1 for domain detection algorithm.


8. Constraint Index

8.1 Structure

The constraints object indexes all constraints for efficient lookup.

{
  "constraints": {
    "by_file": {
      "src/auth/session.ts": {
        "lock_level": "restricted",
        "lock_reason": "Security critical",
        "style": "google-typescript"
      }
    },
    "by_lock_level": {
      "frozen": ["src/config/production.ts"],
      "restricted": ["src/auth/session.ts"]
    }
  }
}

8.2 Field Definitions

FieldTypeDescription
by_fileobjectMap of file path → constraints
by_lock_levelobjectMap of lock level → file paths

8.3 Example Constraint Entry (RFC-001 Compliant)

{
  "by_file": {
    "src/auth/session.ts": {
      "lock_level": "restricted",
      "lock_reason": "Security-critical code",
      "directive": "Explain proposed changes and wait for explicit approval before modifying",
      "style": "google-typescript",
      "behavior": "conservative",
      "quality": ["security-review", "tests-required"],
      "auto_generated": false
    }
  }
}

8.4 Constraint Field Definitions (RFC-001)

FieldTypeRequiredDescription
lock_levelstringNoLock level: frozen, restricted, approval-required, etc.
lock_reasonstringNoStructured reason for lock (grepable)
directivestringYes*Self-documenting directive for AI (*required for constraints)
stylestringNoStyle guide reference
behaviorstringNoAI behavior guidance
qualityarray[string]NoQuality requirements
auto_generatedbooleanNoTrue if directive was auto-generated from defaults

Note: The directive field is REQUIRED for all constraints per RFC-001. The lock_reason provides a structured, grepable value while directive provides human/AI-readable instructions.

See Constraint System Specification for detailed constraint definitions.


9. Documentation Index (RFC-0002)

9.1 Structure

The documentation object provides a project-wide index of documentation references and styles.

{
  "documentation": {
    "sources": {
      "react": {
        "url": "https://react.dev/reference",
        "version": "18.2",
        "fileCount": 15,
        "files": ["src/components/UserProfile.tsx", "src/hooks/useAuth.ts"]
      },
      "company-api": {
        "url": "https://docs.company.com/api",
        "version": null,
        "fileCount": 8,
        "files": ["src/api/auth.ts", "src/api/users.ts"]
      }
    },
    "styles": {
      "google-typescript": {
        "fileCount": 42,
        "files": ["src/utils/helpers.ts"],
        "source": null
      },
      "company-react": {
        "fileCount": 15,
        "files": ["src/components/UserProfile.tsx"],
        "source": "company-api"
      }
    },
    "unresolvedRefs": [
      {
        "file": "src/legacy/old.ts",
        "ref": "deprecated-api",
        "reason": "Source ID not found in approved sources"
      }
    ]
  }
}

9.2 Field Definitions

sources

Map of source ID to usage information.

FieldTypeDescription
urlstringDocumentation URL
versionstringDocumentation version (if specified)
fileCountintegerNumber of files referencing this source
filesarray[string]List of files referencing this source

styles

Map of style guide name to usage information.

FieldTypeDescription
fileCountintegerNumber of files using this style
filesarray[string]List of files using this style
sourcestringAssociated documentation source ID (if any)

unresolvedRefs

Array of references that could not be resolved.

FieldTypeDescription
filestringFile containing the unresolved reference
refstringThe unresolved reference value
reasonstringWhy the reference could not be resolved

9.3 Use Cases

The documentation index enables:

  • Quick lookup of which files reference specific documentation
  • Tracking of unresolved references for validation
  • Aggregation of style guide usage across the project
  • Discovery of documentation dependencies

10. Provenance Index (RFC-0003)

10.1 Structure

The provenance object provides project-wide statistics about annotation provenance.

{
  "provenance": {
    "summary": {
      "total": 150,
      "bySource": {
        "explicit": 80,
        "converted": 20,
        "heuristic": 45,
        "refined": 5,
        "inferred": 0
      },
      "needsReview": 12,
      "reviewed": 58,
      "averageConfidence": {
        "converted": 0.92,
        "heuristic": 0.76
      }
    },
    "lowConfidence": [
      {
        "target": "src/utils/helpers.ts",
        "annotation": "domain",
        "confidence": 0.45,
        "value": "utility"
      }
    ],
    "lastGeneration": {
      "id": "gen-20251222-001",
      "timestamp": "2025-12-22T10:30:00Z",
      "annotationsGenerated": 25,
      "filesAffected": 8
    }
  }
}

10.2 Field Definitions

summary

Aggregate provenance statistics.

FieldTypeDescription
totalintegerTotal annotations tracked
bySourceobjectCount by source type (explicit, converted, heuristic, refined, inferred)
needsReviewintegerAnnotations flagged for review
reviewedintegerAnnotations that have been reviewed
averageConfidenceobjectAverage confidence by source type

lowConfidence

Array of annotations with confidence below threshold.

FieldTypeDescription
targetstringFile path or symbol qualified name
annotationstringAnnotation type (e.g., summary, domain)
confidencenumberConfidence score (0.0-1.0)
valuestringThe annotation value

lastGeneration

Information about the most recent annotation generation run.

FieldTypeDescription
idstringGeneration batch ID
timestampstringISO 8601 timestamp
annotationsGeneratedintegerNumber of annotations generated
filesAffectedintegerNumber of files modified

10.3 Use Cases

The provenance index enables:

  • Tracking annotation generation history
  • Identifying low-confidence annotations for review
  • Monitoring review progress across the project
  • Auditing annotation origins for quality assurance
  • Bulk operations on annotations by source type

11. Generation

11.1 Generation Algorithm

FUNCTION generateCache(projectRoot, config):
    cache = initializeCache(projectRoot, config)
    files = discoverFiles(projectRoot, config)
 
    FOR each file IN files:
        fileEntry = indexFile(file)
        cache.files[file.path] = fileEntry
 
        symbols = extractSymbols(file)
        FOR each symbol IN symbols:
            cache.symbols[symbol.qualified_name] = symbol
            updateGraph(cache.graph, symbol)
 
    cache.domains = buildDomainIndex(cache.files)
    cache.constraints = buildConstraintIndex(cache.files, cache.symbols)
    cache.stats = calculateStats(cache)
 
    RETURN cache

11.2 Staleness Detection

The cache includes metadata to detect when it becomes stale:

Git-Aware Detection (when .git directory exists):

  • Compare cache git_commit field with current HEAD
  • If different, cache is stale
  • Recommendation: Rebuild cache

Timestamp-Based Fallback:

  • Compare cache generated_at with source file modification times
  • If any source file newer than cache, mark stale
  • Recommendation: Warn and suggest rebuild

Always Available:

  • --force flag to rebuild regardless of staleness

Implementation Requirements:

  • Level 2+ implementations MUST implement staleness detection
  • Level 2+ implementations SHOULD use git-aware detection when available
  • Level 2+ implementations MUST fall back to timestamp-based when git unavailable

11.3 Incremental Updates

For efficiency, generators SHOULD support incremental updates:

  1. Compare file modification times with previous cache
  2. Only re-index changed files
  3. Update affected graph entries
  4. Recompute affected indexes

11.4 Determinism

Cache generation MUST be deterministic:

  • Same input MUST produce identical output
  • Object keys MUST be sorted alphabetically
  • Arrays SHOULD maintain consistent ordering (alphabetical or by line number)

12. Validation

12.1 Schema Validation

Cache files MUST validate against the JSON Schema:

ajv validate -s https://acp-spec.org/schemas/v1/cache.schema.json -d .acp.cache.json

12.2 Integrity Checks

Implementations SHOULD verify:

  • All file paths in files exist
  • All symbol files reference existing file entries
  • Graph is consistent (forward/reverse match)
  • Domain files reference existing file entries
  • Constraint files reference existing file entries
  • All qualified names follow format specification

12.3 Validation Errors

Common validation errors:

ErrorCauseFix
Invalid JSONSyntax error in JSONCheck for trailing commas, unclosed brackets
Schema violationField type mismatchCheck field types against schema
Broken referenceSymbol references non-existent fileRebuild cache
Inconsistent graphForward/reverse don't matchRebuild cache

Appendix A: Complete Example

{
  "version": "1.0.0",
  "generated_at": "2024-12-17T15:30:00Z",
  "git_commit": "abc123def456",
  "project": {
    "name": "auth-service",
    "root": "/home/user/projects/auth-service",
    "description": "Authentication microservice"
  },
  "stats": {
    "files": 3,
    "symbols": 2,
    "lines": 270
  },
  "source_files": {
    "src/auth/session.ts": "2024-12-17T15:29:00Z",
    "src/auth/jwt.ts": "2024-12-17T15:20:00Z"
  },
  "files": {
    "src/auth/session.ts": {
      "path": "src/auth/session.ts",
      "module": "Session Service",
      "summary": "User session management",
      "lines": 245,
      "language": "typescript",
      "domains": ["authentication"],
      "layer": "service",
      "stability": "stable",
      "exports": [
        "src/auth/session.ts:SessionService",
        "src/auth/session.ts:SessionService.validateSession"
      ],
      "imports": ["jsonwebtoken", "src/auth/jwt"]
    }
  },
  "symbols": {
    "src/auth/session.ts:SessionService.validateSession": {
      "name": "validateSession",
      "qualified_name": "src/auth/session.ts:SessionService.validateSession",
      "type": "method",
      "file": "src/auth/session.ts",
      "lines": [45, 89],
      "signature": "(token: string) => Promise<Session | null>",
      "summary": "Validates JWT and returns session",
      "exported": true,
      "async": true,
      "calls": ["src/auth/jwt.ts:verifyToken"],
      "called_by": []
    }
  },
  "graph": {
    "forward": {
      "src/auth/session.ts:SessionService.validateSession": [
        "src/auth/jwt.ts:verifyToken"
      ]
    },
    "reverse": {
      "src/auth/jwt.ts:verifyToken": [
        "src/auth/session.ts:SessionService.validateSession"
      ]
    }
  },
  "domains": {
    "authentication": {
      "name": "authentication",
      "description": "User authentication and session management",
      "files": ["src/auth/session.ts"],
      "symbols": ["src/auth/session.ts:SessionService.validateSession"]
    }
  },
  "constraints": {
    "by_file": {
      "src/auth/session.ts": {
        "lock_level": "restricted",
        "lock_reason": "Security critical",
        "style": "google-typescript"
      }
    },
    "by_lock_level": {
      "restricted": ["src/auth/session.ts"]
    }
  }
}

Appendix B: jq Query Examples

# Get all files
jq '.files | keys' .acp.cache.json
 
# Get symbol by name
jq '.symbols["src/auth/session.ts:SessionService.validateSession"]' .acp.cache.json
 
# Get all restricted files
jq '.constraints.by_lock_level.restricted' .acp.cache.json
 
# Get callers of a function
jq '.graph.reverse["src/auth/session.ts:SessionService.validateSession"]' .acp.cache.json
 
# Get files in a domain
jq '.domains["authentication"].files' .acp.cache.json
 
# Check if file can be modified
jq '.constraints.by_file["src/auth/session.ts"].lock_level' .acp.cache.json
 
# Get all TypeScript files
jq '.files | to_entries | map(select(.value.language == "typescript")) | .[].key' .acp.cache.json
 
# Count symbols by type
jq '.symbols | to_entries | group_by(.value.type) | map({type: .[0].value.type, count: length})' .acp.cache.json

Appendix C: Related Documents


End of Cache File Format Specification