finos / finos/architecture-as-code

Move exitBasedOffOfValidationOutcome out of @finos/calm-shared into the CLI

Open
#3,028 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
399
Forks
138
Avg merge
2d 14h
Merged PRs (30d)
37

Description

## Feature Proposal

### Target Project:
`shared` (`@finos/calm-shared`) and `cli`.

### Description of Feature:
Move `exitBasedOffOfValidationOutcome` (which calls `process.exit`) out of `shared` into the CLI, where process management belongs, and drop it from the shared public API.

### User Stories:
- As a **shared maintainer**, I want no process-management code in the library, so every module in `shared` is browser-safe by default and the entry-point rules in `shared/AGENTS.md` hold without exceptions.
- As a **calm-server maintainer**, I want the library never to exit the process on my behalf.

### Current Limitations:
`shared/src/commands/validate/validate.ts` still exports `exitBasedOffOfValidationOutcome`, carrying its own `TODO - move this out of shared and into the CLI`. After #2880 it sits outside the browser graph (in the Node wrapper, not `validate-core.ts`), but it remains a Node-only function in a library that is otherwise engine-only. Its only caller is `cli/src/command-helpers/validate.ts`.

### Proposed Implementation:
- Add `exitBasedOffOfValidationOutcome` to `cli/src/command-helpers/validate.ts` (or a small `exit.ts` helper) and use it there.
- Remove the export from `shared` (`validate.ts` and `index.ts`). `shared` is `private: true`, so this is an in-repo change only; grep confirms no other consumer.
- Update `shared/AGENTS.md`'s entry-point rules to drop the `process.exit` caveat.

### Alternatives Considered:
Leave it — rejected: it is the last piece of process-management code in the library and the TODO has been open since the function was written.

### Testing Strategy:
Existing CLI validate specs cover the exit behaviour; shared tests and the browser-entry guard stay green; full workspace sweep.

### Documentation Requirements:
`shared/AGENTS.md` entry-point rules.

### Implementation Checklist:
- [ ] Design reviewed and approved
- [ ] Implementation completed
- [ ] Tests written and passing
- [ ] Documentation updated
- [ ] Relevant workflows updated (if needed)
- [ ] Performance impact assessed

### Additional Context:
Follow-up to #2880 / PR #3022 (deferred from its review).

Contributor guide

Open the contributing guide

Research direction

Start with shared/src/commands/validate/validate.ts, cli/src/command-helpers/validate.ts, shared/index.ts, and shared/AGENTS.md. Grep for exitBasedOffOfValidationOutcome and run the existing CLI validate specs plus the shared browser-entry guard. Done means process-exit handling is owned by the CLI, the shared export and caveat are removed, and the workspace tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cli, developer-experience
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.