Skip to content

Add Genesis 2.0 discovery pipeline#1

Merged
zee-cpu merged 18 commits into
mainfrom
agent/cli-discovery-pipeline-design
Jul 18, 2026
Merged

Add Genesis 2.0 discovery pipeline#1
zee-cpu merged 18 commits into
mainfrom
agent/cli-discovery-pipeline-design

Conversation

@zee-cpu

@zee-cpu zee-cpu commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Genesis CLI discovery pipeline

What changed

  • Added offline CLI documentation and operator guidance.
  • Added offline network-guard and recovery tests.
  • Added a local start script and documentation assertions.

Validation

  • node --test tests/no-network.test.mjs tests/recovery.test.mjs tests/cli-integration.test.mjs
  • npm run check
  • npm ci
  • node bin/genesis.mjs --help
  • git diff --check

Notes

  • The branch is pushed and ready for review.

Summary by CodeRabbit

  • New Features

    • Added an interactive genesis CLI for starting businesses, adding evidence, planning experiments, checking status, and rebuilding indexes.
    • Added local-first YAML records with a recoverable SQLite index, workspace locking, atomic writes, and projection consistency reporting.
    • Added offline suggestions, structured error messages, privacy safeguards, and human confirmation before changes.
    • Added workflow gates requiring complete evidence, preregistration, active approvals, and validated closure records.
  • Documentation

    • Added comprehensive Genesis 2.0 usage, workflow, command, troubleshooting, and governance guidance.
  • Validation

    • Strengthened record, approval, privacy, and workflow validation rules.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Genesis 2.0 adds an interactive local-first CLI backed by versioned YAML records and a SQLite projection. It introduces schema-driven lifecycle validation, approval and privacy checks, workspace locking, recovery behavior, metrics, experiment preregistration, structured errors, documentation, and end-to-end test coverage.

Changes

Genesis lifecycle platform

Layer / File(s) Summary
Record contracts and lifecycle validation
config/workflows/..., schemas/..., scripts/validate-genesis.mjs, templates/..., records/approvals/..., tests/records.test.mjs, tests/invariants.test.mjs
Schemas and workflow contracts now validate dotted field paths, canonical experiment records, active approvals, approval envelopes, privacy classes, required customers, and closure fields.
Core record construction and workflow status
src/core/..., tests/discovery-workflow.test.mjs, tests/record-builders.test.mjs, tests/cli-core.test.mjs
Adds structured errors, ID/version helpers, schema registries, record builders, suggestions, metrics, discovery gates, completeness calculations, and status generation.
YAML storage and SQLite projection
src/storage/..., tests/storage.test.mjs, tests/projection.test.mjs
Adds private workspaces, exclusive locks, atomic versioned YAML writes, SQLite projections, blocked-command records, consistency checks, and safe rebuilds.
Genesis service orchestration
src/application/genesis-service.mjs, tests/genesis-service.test.mjs, tests/recovery.test.mjs
Adds proposal-driven business, evidence, and experiment commands with confirmation, lifecycle gating, projection updates, stale-projection reporting, cancellation, and recovery behavior.
Interactive CLI entrypoint
src/cli/..., bin/genesis.mjs, package.json, tests/cli-integration.test.mjs, tests/no-network.test.mjs
Adds prompting, rendering, command dispatch, structured exit handling, package exposure, offline suggestions, and no-network CLI verification.
Documentation and configuration support
README.md, Genesis Configuration.md, .gitignore, tests/configuration.test.mjs
Documents the Genesis 2.0 workflow, storage model, safety rules, commands, troubleshooting, architecture, and runtime configuration; ignores generated workspace and coverage directories.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant GenesisCLI
  participant GenesisService
  participant YAMLRecords
  participant SQLiteIndex
  Operator->>GenesisCLI: run start-business or lifecycle command
  GenesisCLI->>GenesisService: submit confirmed command input
  GenesisService->>YAMLRecords: persist immutable versioned records
  GenesisService->>SQLiteIndex: project records and update status
  SQLiteIndex-->>GenesisService: return consistency or stale projection state
  GenesisService-->>GenesisCLI: return command result
  GenesisCLI-->>Operator: render status, warnings, or structured errors
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: introducing the Genesis 2.0 discovery pipeline and related CLI, docs, and tests.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/cli-discovery-pipeline-design

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zee-cpu
zee-cpu marked this pull request as ready for review July 18, 2026 15:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 13

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@schemas/records/experiment-record.schema.json`:
- Line 27: Update the experiment record schema’s data_classes property to
reference an experiment-specific allowed-data-class definition, and define that
restriction at the referenced definition so restricted is excluded. In
schemas/records/experiment-record.schema.json at lines 27-27 and 70-71, make
both schema changes; retain the early restricted-data validation in
src/core/record-builders.mjs at lines 32-39 and its invocation before
construction at line 131 without modification.

In `@scripts/validate-genesis.mjs`:
- Around line 556-561: Update the passed-validation check in the validation gate
to require each candidate record to pass the existing Experiment Record schema
validation before matching its type, subtype, status, and outcome fields. Reuse
the same schema-validation helper used by the other transition gates, and add a
regression case covering a forged object with only those four fields so it
cannot satisfy the Build gate.

In `@src/application/genesis-service.mjs`:
- Around line 388-400: Update the multi-record write flow around writeRecord so
a command publishes all records atomically at the canonical YAML layer: stage
the complete batch before making it visible, then commit it transactionally; if
staging or publication fails, ensure no partial records remain and support
recovery for interrupted publication. Preserve the existing written results only
after the full batch succeeds.

In `@src/cli/prompter.mjs`:
- Around line 21-38: The choose function must not fall back to
normalized[0]?.value for unrecognized non-empty answers. Update its
invalid-input path to reject or reprompt until the user provides a valid numeric
index, label, or value, while preserving the existing empty-answer behavior and
valid-choice handling.

In `@src/cli/run-cli.mjs`:
- Around line 43-56: Update parseNumber to use Number(text) instead of
Number.parseFloat(text), ensuring the entire trimmed input must be numeric while
preserving the existing finite-value validation and GenesisError behavior.

In `@src/core/discovery-workflow.mjs`:
- Around line 162-167: Update the lifecycle mapping in the state and nextCommand
logic around hasExperiment to preserve experiment statuses active, closed, and
superseded instead of reporting them as discover or routing incomplete records
to plan-experiment. Reserve approval_pending exclusively for complete draft
experiments, retain the existing discover behavior only where appropriate, and
add test coverage for active and closed status cases.

In `@src/core/metrics.mjs`:
- Around line 9-12: Validate WORKFLOW.preregistration_required_fields during
startup before constructing PREREGISTRATION_REQUIRED_FIELDS, requiring a
non-empty array whose every element is a string; reject missing, malformed, or
empty values instead of defaulting to []. Ensure invalid configuration prevents
initialization and the valid frozen string array remains available to
experimentCompleteness().

In `@src/storage/projection.mjs`:
- Around line 293-300: Update src/storage/projection.mjs lines 293-300 in
projectionConsistency to compare exact (kind, id, version, relativePath)
descriptor and record_versions identity sets, rather than global counts alone,
while preserving the returned consistency fields as appropriate. Update
src/application/genesis-service.mjs lines 111-115 so the workspace-global check
receives all descriptors from listRecords(projectRoot), not only one business’s
descriptors.
- Around line 248-258: Update upsertRecordVersion and projectRecord so
upsertRecordVersion reports whether a new record_versions row was inserted, and
only apply evidence aggregate mutations for newly inserted versions; preserve
existing projection behavior for new records and add a regression test
confirming replaying the same evidence descriptor does not increment
support_count or contradict_count twice.

In `@src/storage/workspace.mjs`:
- Around line 42-55: Update the workspace lock acquisition flow around fsp.open
and the EEXIST handler to read and validate the existing lock’s PID and
timestamp, determine whether the owning process is no longer active, and
atomically reclaim only confirmed stale locks before retrying acquisition.
Preserve WORKSPACE_LOCKED for active or ambiguous locks, and provide an explicit
manual-recovery correction for cases that cannot be safely classified.
- Around line 61-70: Move the paths.lock unlink handling out of the finally
block so it cannot override the operation’s result or trigger noUnsafeFinally.
Keep handle.close() in finally, then perform the unlink afterward and rethrow
only when operationError is absent and the unlink error is not ENOENT.

In `@src/storage/yaml-record-store.mjs`:
- Around line 109-117: Update the version publication flow around
writeAtomicYaml so it uses an atomic no-replace operation, such as linking the
synced temporary file into finalPath, rather than relying on existsSync followed
by rename. Map an EEXIST failure to the existing GenesisError with code
RECORD_VERSION_EXISTS, preserve cleanup and other error handling, and add
coverage for concurrent writes to the same version.

In `@tests/no-network.test.mjs`:
- Around line 10-18: Strengthen the no-network test around FORBIDDEN_IMPORTS by
using syntax-aware inspection that detects static imports, require calls,
dynamic imports, and bare Node module names such as "http" and "net". During the
runtime validation flow, intercept direct socket connection APIs so calls such
as http.request() and net.Socket.connect() fail, while preserving the existing
fetch/network guard behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 95503b7f-259e-4ddb-8a69-e5b8fcd8f72c

📥 Commits

Reviewing files that changed from the base of the PR and between dbb732b and 9bdc684.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (43)
  • .gitignore
  • Genesis Configuration.md
  • README.md
  • bin/genesis.mjs
  • config/workflows/experiment-lifecycle.yaml
  • docs/superpowers/plans/2026-07-17-genesis-operating-system.md
  • docs/superpowers/specs/2026-07-17-genesis-operating-system-design.md
  • package.json
  • records/approvals/approval-cli-discovery-pipeline-2026-07-17.yaml
  • schemas/records/approval-record.schema.json
  • schemas/records/decision-record.schema.json
  • schemas/records/experiment-record.schema.json
  • schemas/runtime/evidence-entry.schema.json
  • schemas/workflow.schema.json
  • scripts/validate-genesis.mjs
  • src/application/genesis-service.mjs
  • src/cli/prompter.mjs
  • src/cli/render.mjs
  • src/cli/run-cli.mjs
  • src/core/discovery-workflow.mjs
  • src/core/errors.mjs
  • src/core/ids.mjs
  • src/core/metrics.mjs
  • src/core/record-builders.mjs
  • src/core/schema-registry.mjs
  • src/core/suggestions.mjs
  • src/storage/projection.mjs
  • src/storage/workspace.mjs
  • src/storage/yaml-record-store.mjs
  • templates/decision-record.yaml
  • templates/experiment-record.yaml
  • tests/cli-core.test.mjs
  • tests/cli-integration.test.mjs
  • tests/configuration.test.mjs
  • tests/discovery-workflow.test.mjs
  • tests/genesis-service.test.mjs
  • tests/invariants.test.mjs
  • tests/no-network.test.mjs
  • tests/projection.test.mjs
  • tests/record-builders.test.mjs
  • tests/records.test.mjs
  • tests/recovery.test.mjs
  • tests/storage.test.mjs
💤 Files with no reviewable changes (2)
  • docs/superpowers/specs/2026-07-17-genesis-operating-system-design.md
  • docs/superpowers/plans/2026-07-17-genesis-operating-system.md

Comment thread schemas/records/experiment-record.schema.json Outdated
Comment thread scripts/validate-genesis.mjs
Comment thread src/application/genesis-service.mjs Outdated
Comment thread src/cli/prompter.mjs
Comment thread src/cli/run-cli.mjs
Comment thread src/storage/projection.mjs
Comment thread src/storage/workspace.mjs Outdated
Comment thread src/storage/workspace.mjs Outdated
Comment thread src/storage/yaml-record-store.mjs Outdated
Comment thread tests/no-network.test.mjs
@zee-cpu zee-cpu changed the title Document Genesis discovery pipeline Add Genesis 2.0 discovery pipeline Jul 18, 2026
@zee-cpu
zee-cpu merged commit 0262b64 into main Jul 18, 2026
2 checks passed
@zee-cpu
zee-cpu deleted the agent/cli-discovery-pipeline-design branch July 18, 2026 16:23
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