feat(cli): harden operator command contract - #58
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR adds typed CLI parsing, categorized exit codes, audit-log snapshot/follow processing with redaction, centralized runtime secret resolution, reusable package verification, expanded installed-CLI contract tests, and updated CLI documentation. ChangesCLI parsing and dispatch
Audit reading and runtime redaction
Package verification and installed CLI contract
CLI reference documentation
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant miftah
participant RuntimeConfig
participant AuditReader
participant AuditLog
participant stdout
User->>miftah: invoke logs or logs --follow
miftah->>RuntimeConfig: resolve config and secrets
miftah->>AuditReader: readAuditJsonl or followAuditJsonl
AuditReader->>AuditLog: poll, hash, and stage records
AuditReader->>stdout: write normalized redacted JSONL
User->>miftah: send SIGINT or SIGTERM
miftah->>AuditReader: abort follow operation
Possibly related issues
Possibly related PRs
Poem
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error, 1 warning)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 8
🤖 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 `@package.json`:
- Around line 45-48: Update the test:cli script in package.json to run the
project build before executing test:package and smoke:cli, ensuring
dist/cli/main.js is freshly generated when the compatibility job invokes
test:cli directly.
In `@scripts/pack-verifier.mjs`:
- Around line 56-57: Update the duplicate-path calculation in the pack-verifier
flow to use toSorted() instead of creating a Set, spreading it, and calling
sort(). Preserve the existing duplicate filtering and sorted output, and leave
the unexpected-path calculation unchanged.
In `@src/cli/audit-jsonl.ts`:
- Around line 510-528: Make readAuditJsonl’s snapshot retry loop tolerate
transient concurrent writes by adding a short backoff between unsuccessful
pollAuditFile attempts, reusing the existing waitForNextPoll mechanism used by
followAuditJsonl. Keep the current stable return and final error behavior, while
ensuring no delay is added after the final attempt.
- Around line 286-326: The non-idle follow path in stageAuditSnapshot currently
rehashes the entire consumed prefix on every poll, causing cost to grow with
cursor size. Add a bounded or incremental integrity-validation strategy for
follow-mode polls, while retaining full-prefix validation where required for
finite reads and preserving rotation/copytruncate detection before emitting
deltas.
In `@src/cli/parse.ts`:
- Around line 115-120: Update the description for the follow option in the
follow configuration to clearly state that --follow continuously watches the
audit log and displays newly appended or rotated entries, rather than describing
generic audit-log reading.
In `@src/runtime/resolve-runtime-config.ts`:
- Around line 62-77: Update the returned configuration in resolveRuntimeConfig
so resolvedConfig.upstream is replaced with the resolved upstream value before
returning. Preserve the existing top-level upstream field and ensure
ResolvedRuntimeConfig.config.upstream contains resolved env and headers for
single-upstream configurations.
In `@tests/audit-log-reader.test.ts`:
- Around line 676-681: Update the record construction in the test around
recordCount to replace the constant-returning Array.from callbacks for
originalContents and replacementContents with Array.from(...).fill(...) while
preserving the existing newline joining and output.
In `@tests/cli-parse.test.ts`:
- Around line 23-34: Add direct parseCli coverage for the logs command’s
--follow boolean option in the existing CLI parser tests, asserting it produces
the expected run command and options shape. Keep the test focused on logs
--follow and preserve the existing option-order and equals-value coverage.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d71a6f34-3b96-431d-82ca-2c89f0b4e990
📒 Files selected for processing (21)
CHANGELOG.mdREADME.mddocs/cli.mdpackage.jsonscripts/check-pack.mjsscripts/pack-verifier.mjssrc/cli/audit-jsonl.tssrc/cli/exit-codes.tssrc/cli/logs.tssrc/cli/main.tssrc/cli/parse.tssrc/runtime/create-runtime.tssrc/runtime/resolve-runtime-config.tssrc/secrets/redact.tstests/audit-log-reader.test.tstests/cli-exit-codes.test.tstests/cli-parse.test.tstests/logs-writer.test.tstests/package-contract.test.tstests/release-config.test.tstests/tooling-config.test.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
logs --followlifecycle handling.Validation
npm run lintnpm run typechecknpm run test:coveragenpm run buildnpm run smoke:clinpm run test:clinpm run check:packAddresses #18
Summary by CodeRabbit
miftahCLI reference and help/version/schema output, including--json, additional commands/flags, and documented stable exit-status categories.miftah logswith stronger snapshot vs--followbehavior, normalized JSONL, rotation/copytruncate handling, and graceful SIGINT/SIGTERM shutdown.