Add @spec annotations to source files so specgraph's AnnotationProvider can scan them and produce E0 evidence.
Annotation syntax
/**
* @spec SPEC-ID @implements ComponentName
*/
Or inline:
/** @spec SPEC-ID @implements ComponentName */
Multiple specs on one component — use separate blocks:
/** @spec AUTH-001 @implements TokenValidator */
/** @spec AUTH-002 @implements SessionStore */
export class AuthService { ... }
Relation types
| Annotation | Evidence relation | Use when |
|---|---|---|
@implements |
IMPLEMENTS | This code directly implements the spec |
@verifies |
VERIFIED_BY | This is a test that verifies the spec |
@satisfies |
IMPLEMENTS | Alias for @implements |
@model |
MODEL | This symbol is a data model referenced by the spec |
@test |
VERIFIED_BY | This file is a test file for the spec |
@api |
IMPLEMENTS | This is an API endpoint implementing the spec |
Placement rules
- Functions/methods — annotate the JSDoc block immediately above the function.
- Classes — annotate the class JSDoc block; all public methods are covered.
- Files — annotate the top-level
exportif the whole file implements one spec. - Tests — use
@verifieson test functions ordescribeblocks.
TypeScript examples
/**
* Validates a JWT token and returns the decoded payload.
* @spec AUTH-001 @implements TokenValidator
*/
export function validateToken(token: string): Payload { ... }
/**
* @spec TASK-003 @verifies TodoFiltering
*/
describe('todo filters', () => { ... });
/**
* @spec USER-002 @model UserModel
* @spec USER-002 @api POST /users
*/
export class UserController { ... }
JavaScript (CommonJS) example
/**
* @spec API-002 @implements RateLimiter
*/
module.exports.rateLimiter = function(req, res, next) { ... };
Multi-language support
Python, Go, Rust, Java, C#, Ruby, and most languages are supported via #, //, /* */, and """ comment styles.
# @spec AUTH-001 @implements TokenValidator
def validate_token(token: str) -> dict: ...
// @spec API-002 @implements RateLimiter
func RateLimiter(next http.Handler) http.Handler { ... }
Rules
- Use the exact spec ID as it appears in the spec file frontmatter (
id:field). - One annotation per
@spectag — do not chain multiple@spectags in one block. ComponentNameafter@implementsis free text — use something meaningful to the reader.- After adding annotations, run
specgraph verifyto confirm the claims are detected. - If claims are not appearing, check that the file extension is in
annotationProvider.extensionsin.specgraph/config.json(defaults:.ts,.js,.tsx,.jsx,.mjs,.cjs). - Config file is
.specgraph/config.json(falls back to.agent-docs/config.json).