You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(soci): add local CSV member-book previews - #152
Adds a local-only Libro Soci CSV preview with explicit column, delimiter, date and source-scope mappings. It reuses the Soci validators, blocks duplicate numbers and conflicting active admissions, and preserves historical admissions and unreviewed fee evidence without guessing account links or payments.
The command does not load configured services, contact the database/Microsoft 365 or send mail. Every candidate remains unresolved pending later local snapshot reconciliation. Console output contains only counts and coded diagnostics; an optional detailed plaintext report is created exclusively with private permissions outside Git worktrees. Includes synthetic examples and operator documentation. No apply option, schema change or new dependency.
Targets main directly. It was first stacked on #151, but it uses nothing from the lifecycle work: its only Soci imports (END_REASONS, memberNumberSchema, optionalDetailsSchema) are already on main. The dashboard documentation for this command moved to its own admin PR.
Validation: 481 tests passed, 17 skipped, including 32 new parser/preview/CLI tests; typecheck, full Biome check and production build passed. Coverage includes quoted/multiline CSV, dates and tax codes, duplicates, financial non-inference, redacted errors, bounded inputs, and private/non-overwriting outputs. The full test suite passed when run separately from other heavyweight checks; an earlier simultaneous run hit the existing Secret Santa mailer test's 5-second timeout. No timeout or test assertion was changed. Optional database suites were not enabled. No real books, production reads, writes or deployment were involved.
Reviewing files that changed from the base of the PR and between 21a027e and cadbe6d.
Files ignored due to path filters: 1
scripts/examples/soci-import.synthetic.csv is excluded by !**/*.csv
Files selected for processing: 8
README.md
package.json
scripts/examples/soci-import.mapping.json
scripts/soci-import-preview.ts
src/soci/import-csv.ts
src/soci/import-preview.ts
tests/soci-import-cli.test.ts
tests/soci-import.test.ts
Walkthrough
Adds a local SOCI CSV preview pipeline. The pipeline validates mappings, parses CSV records, and reports normalized candidates, diagnostics, and row counts. The CLI supports optional private report output and does not perform reconciliation or application.
Changes
SOCI CSV preview
Layer / File(s)
Summary
CSV parsing and records src/soci/import-csv.ts, tests/soci-import.test.ts
Adds CSV record and error types, parsing for comma- and semicolon-delimited input, and limits for cells, columns, and records. Tests cover quoting, line endings, blank records, and malformed or oversized input.
Mapping and preview normalization src/soci/import-preview.ts, tests/soci-import.test.ts
Adds mapping and header validation, candidate normalization, row and cross-row diagnostics, and preview status and counts. Tests cover field validation, history scope, duplicates, and unresolved fee and account evidence.
Local CLI and preview reporting scripts/soci-import-preview.ts, scripts/examples/soci-import.mapping.json, package.json, README.md, tests/soci-import-cli.test.ts
Adds the Bun CLI, bounded UTF-8 input reads, optional exclusive report creation with mode 0600, summary output, and exit codes. Adds an example mapping, invocation documentation, and CLI tests for output handling, errors, and input limits.
Sequence Diagram(s)
sequenceDiagram
participant CLI as soci-import-preview.ts
participant Files as Local files
participant Preview as previewBookCsv
CLI->>Files: Read mapping and CSV as UTF-8
CLI->>Preview: Submit CSV text and mapping
Preview-->>CLI: Return preview rows and counts
opt Optional report output
CLI->>Files: Create report exclusively with mode 0600
end
CLI-->>Files: Print summary and diagnostics
Path filters excluded changed files. This rating applies only to the assessed changes.
Pre-merge checks: 3
Check name
Status
Explanation
Title check
The title "feat(soci): add local CSV member-book previews" matches the main change: an offline CSV preview command for Libro Soci member-book files. The raw summary covers the new preview script, the …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "feat(soci): add local CSV member-book previews" matches the main change: an offline CSV preview command for Libro Soci member-book files. The raw summary covers the new preview script, the CSV parser, the preview pipeline, and the tests, all of which fit the title. The title is specific and follows a conventional commit style.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Rebased onto main and retargeted from feat/soci-manual-lifecycle to main.
#151 is on hold until the Consiglio Direttivo decides how the automatic lapse should act on its behalf (see the review on #151). This PR doesn't depend on it: it calls none of the lifecycle code, and its only Soci imports (END_REASONS, memberNumberSchema, optionalDetailsSchema from src/soci/contract.ts) are already on main. So it can be reviewed and merged on its own.
The rebase is the same single commit (52db6b7 → 21a027e), with the same author and content: 9 files, +793. It applied without conflicts.
On the rebased tree, the 26 parser and preview tests pass, Biome is clean on the changed files, and the command runs offline on the synthetic example.
The 6 tests in tests/soci-import-cli.test.ts failed on my machine both before and after the rebase. They run bun with an empty environment in a temporary folder, so the failure looks local; CI will confirm.
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
tests/soci-import-cli.test.ts-67-67: 1
67-67: Minor · Functional Correctness · Quick win
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Guard the permission-bit assertion to POSIX platforms.
On Windows, a file written with mode 0o600 reports a different mode, usually 0o666. This assertion then fails even when the command works. Run the check only when process.platform !== "win32", and keep a file-existence check on Windows.
Reviewing files that changed from the base of the PR and between ab6530e and 21a027e.
Files ignored due to path filters: 1
scripts/examples/soci-import.synthetic.csv is excluded by !**/*.csv
Files selected for processing: 8
README.md
package.json
scripts/examples/soci-import.mapping.json
scripts/soci-import-preview.ts
src/soci/import-csv.ts
src/soci/import-preview.ts
tests/soci-import-cli.test.ts
tests/soci-import.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
* docs(soci): plan local member-book import preview
* docs(soci): document local CSV preview and reconciliation scope
* docs(people): point the import preview docs at backend #152
The CSV preview is in review in PoliNetworkOrg/backend#152, which targets main on its own. List soci-import.md in the People docs index.
---------
Co-authored-by: Bianca <ianoselbiancaroberta02@gmail.com>
- List errors before warnings on the console and count the warnings every
row carries, so blocked rows late in a long book are named without --out.
- Block admissions sharing a tax code that were in force at the same time
(overlapping_admissions), not only multiple active ones.
- Delete a partially written report when writing fails, and report
output_partial if it cannot be removed.
- Skip lines of only spaces or tabs as blank lines.
- Refuse endReasonValues keys with leading or trailing spaces.
- Count the per-cell limit in characters rather than UTF-16 units.
- Give the CLI tests a 60 s timeout, since each test spawns Bun several times.
- Document which blocked rows keep their candidate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a local-only Libro Soci CSV preview with explicit column, delimiter, date and source-scope mappings. It reuses the Soci validators, blocks duplicate numbers and conflicting active admissions, and preserves historical admissions and unreviewed fee evidence without guessing account links or payments.
The command does not load configured services, contact the database/Microsoft 365 or send mail. Every candidate remains unresolved pending later local snapshot reconciliation. Console output contains only counts and coded diagnostics; an optional detailed plaintext report is created exclusively with private permissions outside Git worktrees. Includes synthetic examples and operator documentation. No apply option, schema change or new dependency.
Targets
maindirectly. It was first stacked on #151, but it uses nothing from the lifecycle work: its only Soci imports (END_REASONS,memberNumberSchema,optionalDetailsSchema) are already onmain. The dashboard documentation for this command moved to its own admin PR.Validation: 481 tests passed, 17 skipped, including 32 new parser/preview/CLI tests; typecheck, full Biome check and production build passed. Coverage includes quoted/multiline CSV, dates and tax codes, duplicates, financial non-inference, redacted errors, bounded inputs, and private/non-overwriting outputs. The full test suite passed when run separately from other heavyweight checks; an earlier simultaneous run hit the existing Secret Santa mailer test's 5-second timeout. No timeout or test assertion was changed. Optional database suites were not enabled. No real books, production reads, writes or deployment were involved.