Skip to content

feat(openspec): backport existing functionality into baseline specs#21

Merged
jim80net merged 1 commit intomainfrom
backport-openspec-specs
Apr 9, 2026
Merged

feat(openspec): backport existing functionality into baseline specs#21
jim80net merged 1 commit intomainfrom
backport-openspec-specs

Conversation

@jim80net
Copy link
Copy Markdown
Owner

@jim80net jim80net commented Apr 9, 2026

Summary

Backports all existing memex-core functionality into 15 OpenSpec specification files under openspec/specs/, organized by module for maintainability. These specs document current behavior as baseline requirements using the WHEN/THEN scenario format, serving as the authoritative reference for future change proposals.

Specs Added (15 modules, 89 requirements, 161 scenarios)

Spec Requirements Scenarios
embeddings 4 8
skill-index 11 21
cache 4 7
config 2 5
session 4 5
telemetry 7 13
traces 7 10
sync 8 22
sync-migration 8 18
project-mapping 6 18
project-registry 4 4
file-lock 2 7
git-helpers 5 11
path-encoder 1 4
types 18 19

Key Decisions

  • Organized by module — each source file gets its own spec directory under openspec/specs/, making it easy to find and update specs alongside the code they describe
  • Baseline format — uses ## Requirements (not ## ADDED Requirements) since these document existing behavior, not new features
  • Scenario-driven — every requirement has concrete WHEN/THEN scenarios that can serve as test specifications
  • Comprehensive coverage — all public and internal APIs are documented, including edge cases like stale lock detection, empty cache fallbacks, and migration idempotency

Relationship to Existing Specs

The openspec/changes/lowercase-project-ids/specs/ directory contains specs that were written as ADDED requirements for that specific change. These new baseline specs in openspec/specs/ document the current state including all the lowercase-project-ids functionality. Future changes will reference these baseline specs and mark their modifications as ## MODIFIED Requirements or ## ADDED Requirements.


Summary by cubic

Backports existing memex-core behavior into 15 baseline OpenSpec files under openspec/specs/. These specs are the source of truth for current functionality and will anchor future changes (89 requirements, 161 scenarios).

  • New Specs
    • Indexing and search: parsing (parseFrontmatter, parseMemoryFile), SkillIndex build/search, batching embeddings, sectioned memories.
    • Sync and migrations: repo init/pull/push with conflict resolution, lowercase project ID migration, version markers, project path encoding.
    • Storage and safety: cache v2 schema with atomic writes, advisory file locks, project registry load/save, git helpers.
    • Telemetry and traces: match/observation tracking with caps, formatted reports, per-session trace accumulation and persistence.
    • Config and types: DEFAULT_CORE_CONFIG, guarded resolveCoreConfig, full type surface (skills, scoring, telemetry, paths).
    • Note: Baseline includes lowercase project IDs; future changes will mark specs as ADDED/MODIFIED.

Written for commit fb3d24f. Summary will update on new commits.

Add 15 OpenSpec specification files under openspec/specs/ that document
the existing behavior of all memex-core modules as baseline requirements.
These specs serve as the authoritative reference for current functionality
and will be the foundation for future change proposals.

Specs organized by module:
- embeddings: EmbeddingProvider, Local/OpenAI providers, cosineSimilarity
- skill-index: SkillIndex, parseFrontmatter, parseMemoryFile, search
- cache: Cache v2 schema, atomic writes, mtime-gating
- config: DEFAULT_CORE_CONFIG, resolveCoreConfig
- session: SessionTracker, InMemorySessionTracker
- telemetry: recordMatch, recordObservation, formatTelemetryReport
- traces: TraceAccumulator, writeTrace
- sync: initSyncRepo, syncPull, syncCommitAndPush, conflict resolution
- sync-migration: version markers, migrateProjectIdsToLowercase, runSyncMigrations
- project-mapping: resolveProjectId, normalizeGitUrl, findMatchingProjectMemoryDirs
- project-registry: loadRegistry, saveRegistry, registerProject
- file-lock: acquireLock, withFileLock
- git-helpers: git wrapper, isGitRepo, hasRemote, hasCommits, getDefaultBranch
- path-encoder: encodeProjectPath
- types: all TypeScript interfaces and type definitions
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 15 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="openspec/specs/file-lock/spec.md">

<violation number="1" location="openspec/specs/file-lock/spec.md:5">
P2: The requirement says "exponential backoff" but the implementation uses a fixed 50ms retry interval. This mismatch could mislead future implementers into adding exponential backoff where none currently exists. Change to "fixed-interval retry" to match the actual code.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.


### Requirement: Advisory file locking via mkdir

`acquireLock(filePath)` SHALL create an advisory lock directory at `${filePath}.lock` using `mkdir`, which is atomic on all platforms. It returns an unlock function that removes the lock directory. If the lock already exists, it retries with exponential backoff until a timeout is reached.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The requirement says "exponential backoff" but the implementation uses a fixed 50ms retry interval. This mismatch could mislead future implementers into adding exponential backoff where none currently exists. Change to "fixed-interval retry" to match the actual code.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At openspec/specs/file-lock/spec.md, line 5:

<comment>The requirement says "exponential backoff" but the implementation uses a fixed 50ms retry interval. This mismatch could mislead future implementers into adding exponential backoff where none currently exists. Change to "fixed-interval retry" to match the actual code.</comment>

<file context>
@@ -0,0 +1,44 @@
+
+### Requirement: Advisory file locking via mkdir
+
+`acquireLock(filePath)` SHALL create an advisory lock directory at `${filePath}.lock` using `mkdir`, which is atomic on all platforms. It returns an unlock function that removes the lock directory. If the lock already exists, it retries with exponential backoff until a timeout is reached.
+
+#### Scenario: Lock acquired on first attempt
</file context>
Fix with Cubic

@claude
Copy link
Copy Markdown

claude Bot commented Apr 9, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@jim80net jim80net merged commit ae92945 into main Apr 9, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant