Add Genesis 2.0 discovery pipeline#1
Conversation
📝 WalkthroughWalkthroughGenesis 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. ChangesGenesis lifecycle platform
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
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (43)
.gitignoreGenesis Configuration.mdREADME.mdbin/genesis.mjsconfig/workflows/experiment-lifecycle.yamldocs/superpowers/plans/2026-07-17-genesis-operating-system.mddocs/superpowers/specs/2026-07-17-genesis-operating-system-design.mdpackage.jsonrecords/approvals/approval-cli-discovery-pipeline-2026-07-17.yamlschemas/records/approval-record.schema.jsonschemas/records/decision-record.schema.jsonschemas/records/experiment-record.schema.jsonschemas/runtime/evidence-entry.schema.jsonschemas/workflow.schema.jsonscripts/validate-genesis.mjssrc/application/genesis-service.mjssrc/cli/prompter.mjssrc/cli/render.mjssrc/cli/run-cli.mjssrc/core/discovery-workflow.mjssrc/core/errors.mjssrc/core/ids.mjssrc/core/metrics.mjssrc/core/record-builders.mjssrc/core/schema-registry.mjssrc/core/suggestions.mjssrc/storage/projection.mjssrc/storage/workspace.mjssrc/storage/yaml-record-store.mjstemplates/decision-record.yamltemplates/experiment-record.yamltests/cli-core.test.mjstests/cli-integration.test.mjstests/configuration.test.mjstests/discovery-workflow.test.mjstests/genesis-service.test.mjstests/invariants.test.mjstests/no-network.test.mjstests/projection.test.mjstests/record-builders.test.mjstests/records.test.mjstests/recovery.test.mjstests/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
Genesis CLI discovery pipeline
What changed
Validation
node --test tests/no-network.test.mjs tests/recovery.test.mjs tests/cli-integration.test.mjsnpm run checknpm cinode bin/genesis.mjs --helpgit diff --checkNotes
Summary by CodeRabbit
New Features
genesisCLI for starting businesses, adding evidence, planning experiments, checking status, and rebuilding indexes.Documentation
Validation