@carecard/jwt-read 3.18.0 → 3.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,10 +15,13 @@ Non-negotiable test order invariance rule: Every test must pass independently of
15
15
 
16
16
  Non-negotiable parallel test execution rule: Run independent test files in parallel with repository-native worker support wherever resource isolation makes parallel execution safe. Tests that share a mutable database, application server, browser state, filesystem fixture, port, or cluster resource must remain in an explicitly isolated serial group until every worker owns a separate resource. Parallel execution must preserve ordinary test selection and must never use randomized ordering, retries, locks, or error suppression to conceal coupling.
17
17
 
18
- Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, add or update the relevant validation check before changing the prose.
18
+ Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, run the relevant focused non-test
19
+ validation before changing the prose; do not add automated tests that inspect
20
+ prose, files, or repository structure.
19
21
 
20
- This requirement is non-negotiable and may be overridden only with the user's
21
- explicit, direct approval.
22
+ The TDD and validation requirements are non-negotiable and cannot be
23
+ overridden. The separate pre-existing-test protection still requires the
24
+ user's fresh, explicit permission for each exact proposed test modification.
22
25
 
23
26
  A pre-existing test—defined as any test present before work on the current task
24
27
  begins—must not be deleted, disabled, skipped, weakened, excluded from execution,
@@ -30,6 +33,11 @@ precise proposed modification, provide detailed technical justification, and
30
33
  explain all known or reasonably foreseeable regression risks. Until approval is
31
34
  granted, leave every pre-existing test unchanged.
32
35
 
36
+ An implementation-detail test remains invalid under the authoritative TDD and
37
+ validation policy. Identify the exact test and obtain the user's explicit
38
+ approval before rewriting or removing it. Until approval is granted, leave the
39
+ test unchanged and report the blocked correction.
40
+
33
41
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
34
42
 
35
43
  Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
@@ -70,8 +78,10 @@ Use before modifying, testing, reviewing, or debugging any CareCard workspace re
70
78
 
71
79
  ## Testing Expectations
72
80
 
73
- - Write or update package tests before behavior or public API changes.
74
- - Include type/export compatibility tests where the package already has them.
81
+ - Write a new failing consumer-facing test through the supported package root
82
+ before behavior or public API changes. Modify a pre-existing test only after
83
+ the user grants fresh, explicit permission for that exact change.
84
+ - Include consumer-facing runtime and compilation tests through the supported package root. Exercise public behavior and realistic type usage without inspecting export objects, source files, or module layout.
75
85
  - Run package test, lint, type, and Husky validation commands required by the changed area.
76
86
 
77
87
  ## Safety Constraints
@@ -106,9 +116,10 @@ config.
106
116
  - Follow the owner's coding style, naming conventions, and project structure.
107
117
  - Put code, tests, docs, services, validation, transforms, components, and
108
118
  helpers where the current repository expects them.
109
- - Use Test-Driven Development for behavior changes: write or update focused
110
- tests first, verify they fail for the missing behavior when practical, then
111
- implement.
119
+ - Use Test-Driven Development for behavior changes: write a focused
120
+ functional test first or, after fresh permission for the exact change,
121
+ update a pre-existing test. Run the selected test, confirm it fails for the
122
+ missing behavior, then implement.
112
123
  - Never suppress errors, TypeScript errors, linter warnings, authorization
113
124
  failures, RLS failures, build failures, hydration issues, or failing tests.
114
125
  Do not add `eslint-disable`, `@ts-ignore`, broad catches, empty catches, or
@@ -309,10 +320,11 @@ existing TypeScript style.
309
320
  ## Tests
310
321
 
311
322
  - Testing is mandatory before finalizing code changes.
312
- - Code coverage percentage must not decrease from the previous commit; it can
313
- stay the same or increase. When coverage tooling exists, compare against the
314
- previous commit or recorded baseline, add tests to maintain or improve
315
- coverage, and never reduce coverage thresholds to pass checks.
323
+ - Use coverage reports only as diagnostics for potentially untested observable
324
+ behavior. Percentages for lines, branches, functions, and statements are not
325
+ functional evidence and must not determine test assertions. Never add
326
+ implementation-detail tests to preserve a metric or lower thresholds to hide
327
+ a failing check; report any conflict with the behavior-only policy.
316
328
  - Keep tests readable and domain-specific.
317
329
  - Tests must cover desired or happy paths and prevention or rejection of
318
330
  undesired behavior.
@@ -324,14 +336,14 @@ existing TypeScript style.
324
336
  Selenium for end-to-end flows.
325
337
  - For database tests, use existing seed, migration, rollback, and cleanup
326
338
  patterns.
327
- - In database `rls_logic.test.js` files, assert RLS logic only by calling
328
- `carecard.can_access_row(...)` and checking the intended boolean. Put table
329
- CRUD and lower RLS helper checks in query/enforcement tests.
339
+ - Test row-level security through app-equivalent SQL operations under the
340
+ intended caller context. Assert returned rows, successful writes, and
341
+ authorization denials without calling internal RLS helpers or inspecting SQL
342
+ text.
330
343
  - Add tests for API success responses, validation errors, auth/authz errors,
331
344
  JWT errors, not-found/conflict cases, and unexpected error handling when
332
345
  those paths change.
333
- - For frontend changes, test validation, transforms, query/mutation wrappers,
334
- components, and user-visible flows at the narrowest practical level first.
346
+ - For frontend changes, test rendered UI, public HTTP or network outcomes, navigation, accessibility, and user-visible flows at the narrowest practical level first. Use focused non-test dependency checks for validation, transform, query, mutation, hook, and module organization.
335
347
  - If a test or repository check fails, fix the issue and rerun the failing
336
348
  command. Only finalize with failing checks when the failure is unrelated or
337
349
  blocked by environment constraints, and document that explicitly.
@@ -370,9 +382,7 @@ Dashboard service and test conventions:
370
382
  - Profile, settings, notifications, institutions, and user authorization UI
371
383
  prefer service snackbar helpers for user-friendly fallback errors, technical
372
384
  error filtering, mutation result handling, and duplicate error suppression.
373
- - `tests/app/dashboard/profile/page.test.tsx` keeps dynamic profile children
374
- inert in the shell-level page test to avoid async imports resolving after
375
- Vitest tears down jsdom in CI.
385
+ - Profile page tests assert visible loading, navigation, form, and error behavior through the rendered route. They must not depend on dynamic-import structure or a specific mocking strategy.
376
386
 
377
387
  ## Public Website Frontends
378
388
 
@@ -441,3 +451,22 @@ the authenticated dashboard.
441
451
  intact unless a task explicitly changes them.
442
452
  - Document remaining security concerns that require product, infrastructure, or
443
453
  deployment decisions.
454
+
455
+ ## TDD And Validation
456
+
457
+ Test Driven Development is a non-negotiable requirement.
458
+
459
+ The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
460
+ Tests must validate what the system does through its public interfaces and expected outcomes.
461
+
462
+ Tests must not assert, inspect, or depend on implementation details, including but not limited to:
463
+
464
+ - The existence of specific lines of code, statements, functions, classes, files, or modules.
465
+ - Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
466
+ - Any internal structure that can change without changing externally observable behavior.
467
+
468
+ A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
469
+
470
+ Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
471
+
472
+ This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
@@ -7,7 +7,9 @@ Non-negotiable root-cause solution rule: Always identify and solve the verified
7
7
 
8
8
  # Pull Request Create
9
9
 
10
- Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, add or update the relevant validation check before changing the prose.
10
+ Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, run the relevant focused non-test
11
+ validation before changing the prose; do not add automated tests that inspect
12
+ prose, files, or repository structure.
11
13
 
12
14
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
13
15
 
@@ -181,3 +183,22 @@ Do not continue automatically when:
181
183
  10. Final response should include the PR URL, selected base branch, whether a
182
184
  rebase was performed, whether an existing PR was reused or marked ready,
183
185
  and any validation that could not be run.
186
+
187
+ ## TDD And Validation
188
+
189
+ Test Driven Development is a non-negotiable requirement.
190
+
191
+ The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
192
+ Tests must validate what the system does through its public interfaces and expected outcomes.
193
+
194
+ Tests must not assert, inspect, or depend on implementation details, including but not limited to:
195
+
196
+ - The existence of specific lines of code, statements, functions, classes, files, or modules.
197
+ - Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
198
+ - Any internal structure that can change without changing externally observable behavior.
199
+
200
+ A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
201
+
202
+ Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
203
+
204
+ This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
@@ -7,7 +7,9 @@ Non-negotiable root-cause solution rule: Always identify and solve the verified
7
7
 
8
8
  # Pull Request Merge Close
9
9
 
10
- Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, add or update the relevant validation check before changing the prose.
10
+ Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, run the relevant focused non-test
11
+ validation before changing the prose; do not add automated tests that inspect
12
+ prose, files, or repository structure.
11
13
 
12
14
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
13
15
 
@@ -233,3 +235,22 @@ completion.
233
235
  cleanup commit was added, whether the remote target branch was deleted or
234
236
  protected, whether the local target branch was deleted, and whether local
235
237
  base branch is up to date.
238
+
239
+ ## TDD And Validation
240
+
241
+ Test Driven Development is a non-negotiable requirement.
242
+
243
+ The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
244
+ Tests must validate what the system does through its public interfaces and expected outcomes.
245
+
246
+ Tests must not assert, inspect, or depend on implementation details, including but not limited to:
247
+
248
+ - The existence of specific lines of code, statements, functions, classes, files, or modules.
249
+ - Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
250
+ - Any internal structure that can change without changing externally observable behavior.
251
+
252
+ A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
253
+
254
+ Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
255
+
256
+ This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
@@ -5,6 +5,19 @@ description: 'Mandatory for every pkg-jwt-read task, including analysis, clarifi
5
5
 
6
6
  # Pkg JWT Read Coding Standards And Best Practices
7
7
 
8
+ ## JavaScript And TypeScript Style Contract
9
+
10
+ - Require braces around every optional control-flow body through ESLint core
11
+ `curly: ['error', 'all']`. Single-expression arrow functions may remain
12
+ expression-bodied.
13
+ - Require semicolons on every applicable statement through Prettier's
14
+ `semi: true` option. Do not add a second semicolon linter.
15
+ - Keep the shared Prettier baseline and lint-staged command order consistent
16
+ across CareCard repositories: run ESLint fixes before Prettier writes.
17
+ - Use `lint`, `lint:fix`, `format`, `format:check`, and `lint-staged` as the
18
+ direct script names. Whole-repository lint and formatting checks must fail on
19
+ warnings or style drift.
20
+
8
21
  Non-negotiable root-cause solution rule: Always identify and solve the verified
9
22
  root cause, use the stronger solution, and deliver a correct, durable,
10
23
  production-quality result. Never treat a temporary workaround, resource
@@ -65,9 +78,11 @@ completion rules below without weakening those companion skills.
65
78
 
66
79
  - Treat every workspace repository as independent and validate it from its own
67
80
  root.
68
- - Update every skill, document, source, runtime test, type test, export,
69
- declaration, consumer, and package version genuinely required for a coherent
70
- task.
81
+ - Update every skill, document, source, export, declaration, consumer, and
82
+ package version genuinely required for a coherent task, and add every new
83
+ consumer-facing runtime or type test the behavior requires. Modify a
84
+ pre-existing test only after the user grants fresh, explicit permission for
85
+ that exact change.
71
86
  - Do not broaden the task into unrelated cleanup.
72
87
  - Preserve CommonJS, middleware, request-context, role, declaration, naming,
73
88
  and test conventions unless the task explicitly replaces them.
@@ -102,8 +117,8 @@ overloads, duplicate exports, dual auth paths, transitional names, or fallback
102
117
  behavior solely to preserve the superseded contract.
103
118
 
104
119
  Delete obsolete functions and exports after all intended consumers have
105
- migrated and repository-native search, runtime tests, and type tests prove them
106
- unused. This does not authorize unrelated API removal. If an existing
120
+ migrated and repository-native search proves them unused, while runtime and type tests
121
+ verify the remaining public contract. This does not authorize unrelated API removal. If an existing
107
122
  published or security contract requires compatibility and the request does not
108
123
  clearly supersede it, explain the conflict and ask first.
109
124
 
@@ -111,8 +126,9 @@ clearly supersede it, explain the conflict and ask first.
111
126
 
112
127
  Follow `$carecard-workspace-standards` and
113
128
  `$pkg-jwt-read-jwt-middleware-library` for the complete failing-test-first and
114
- root-cause workflow. Documentation and skill changes require a focused
115
- structural validation before prose changes. Do not accept retries, suppressed
129
+ root-cause workflow. Documentation and skill changes require focused non-test validation before
130
+ prose changes; do not add automated tests that inspect prose, files, or
131
+ repository structure. Do not accept retries, suppressed
116
132
  diagnostics, weakened types, disabled tests, forced success, compatibility
117
133
  patches, or symptom-only workarounds as completion.
118
134
 
@@ -160,3 +176,22 @@ them unused and replaced.
160
176
  5. Fix every in-scope failure at its root cause and rerun the exact command.
161
177
  6. Report exact commands, results, limitations, and remaining risk.
162
178
  7. Do not perform remote Git or GitHub operations unless explicitly requested.
179
+
180
+ ## TDD And Validation
181
+
182
+ Test Driven Development is a non-negotiable requirement.
183
+
184
+ The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
185
+ Tests must validate what the system does through its public interfaces and expected outcomes.
186
+
187
+ Tests must not assert, inspect, or depend on implementation details, including but not limited to:
188
+
189
+ - The existence of specific lines of code, statements, functions, classes, files, or modules.
190
+ - Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
191
+ - Any internal structure that can change without changing externally observable behavior.
192
+
193
+ A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
194
+
195
+ Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
196
+
197
+ This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
@@ -7,7 +7,9 @@ Non-negotiable root-cause solution rule: Always identify and solve the verified
7
7
 
8
8
  # Package JWT Read
9
9
 
10
- Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, add or update the relevant validation check before changing the prose.
10
+ Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, run the relevant focused non-test
11
+ validation before changing the prose; do not add automated tests that inspect
12
+ prose, files, or repository structure.
11
13
 
12
14
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
13
15
 
@@ -51,8 +53,10 @@ CareCard JWT read package for parsing, request attachment, visitor tokens, role
51
53
 
52
54
  ## Testing Expectations
53
55
 
54
- - Write or update package tests before behavior or public API changes.
55
- - Include type/export compatibility tests where the package already has them.
56
+ - Write a new failing consumer-facing test through the supported package root
57
+ before behavior or public API changes. Modify a pre-existing test only after
58
+ the user grants fresh, explicit permission for that exact change.
59
+ - Include consumer-facing runtime and compilation tests through the supported package root. Exercise public behavior and realistic type usage without inspecting export objects, source files, or module layout.
56
60
  - Run package test, lint, type, and Husky validation commands required by the changed area.
57
61
 
58
62
  ## Safety Constraints
@@ -82,8 +86,10 @@ depend on those folders being present.
82
86
  header, role, generic, or `unknown` types with narrowing.
83
87
  - Follow this repository's coding style, naming conventions, and CommonJS
84
88
  project structure.
85
- - Use Test-Driven Development: add or update relevant Mocha or type tests before
86
- changing behavior.
89
+ - Use Test-Driven Development: add a new failing consumer-facing Mocha or type
90
+ test through the supported package root before changing behavior. Modify a
91
+ pre-existing test only after the user grants fresh, explicit permission for
92
+ that exact change.
87
93
  - Never suppress errors, linter warnings, TypeScript errors, or failing tests.
88
94
  Handle the underlying issue.
89
95
  - Do not add dependencies unless absolutely needed. Ask for confirmation first
@@ -209,17 +215,19 @@ role names, such as `ad` and `admin`.
209
215
  - When existing declarations are too loose, improve them with specific types as
210
216
  part of the touched change instead of adding new loose types.
211
217
  - Keep overloads for context-bound helpers such as `jwtIsExpired` readable and
212
- covered by type tests.
213
- - Update `test/types.test.ts` whenever public types, exports, overloads, or
214
- attached request methods change.
218
+ verify them by compiling realistic consumer usage through the package root.
219
+ - When public types, overloads, or attached request behavior changes, compile
220
+ the supported consumer contract without asserting that named exports or
221
+ declaration nodes exist.
215
222
 
216
223
  ## Tests
217
224
 
218
225
  - Use Mocha for runtime tests under `test`.
219
- - `lib` modules should have corresponding test files under `test`.
220
- - `test/attachedMethods.test.js` covers methods attached to objects or used as
221
- context.
222
- - `test/types.test.ts` verifies TypeScript declarations with `tsc`.
226
+ - Exercise runtime behavior only through the package's supported root exports;
227
+ tests must not mirror `lib` modules or depend on internal file layout.
228
+ - Verify request-attachment and context-bound behavior through those public
229
+ exports without asserting internal method calls.
230
+ - Compile realistic consumer code through the package root with `tsc` to verify externally visible declaration behavior.
223
231
  - Add focused tests for valid JWTs, invalid JWTs, missing headers, role checks,
224
232
  visitor token extraction, expiration behavior, request attachment behavior,
225
233
  server-auth introspection success/failure, NoThrow behavior, and
@@ -307,3 +315,22 @@ immediately when no helper remains, allow only a bounded 250 ms settlement
307
315
  window for already-stopping helpers, fail persistent descendants, preserve
308
316
  failures and output, use exit code `124` only for a real outer deadline, and
309
317
  remain a final guard rather than a substitute for explicit cleanup.
318
+
319
+ ## TDD And Validation
320
+
321
+ Test Driven Development is a non-negotiable requirement.
322
+
323
+ The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
324
+ Tests must validate what the system does through its public interfaces and expected outcomes.
325
+
326
+ Tests must not assert, inspect, or depend on implementation details, including but not limited to:
327
+
328
+ - The existence of specific lines of code, statements, functions, classes, files, or modules.
329
+ - Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
330
+ - Any internal structure that can change without changing externally observable behavior.
331
+
332
+ A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
333
+
334
+ Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
335
+
336
+ This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
@@ -9,7 +9,9 @@ Non-negotiable root-cause solution rule: Always identify and solve the verified
9
9
 
10
10
  Non-negotiable test order invariance rule: Every test must pass independently of which tests run before or after it, and the suite must pass in every execution order. Each test must establish the state it needs, isolate mutable state, and clean up state it owns; it must never rely on another test's setup, mutations, or cleanup. Default test, CI, and Husky commands must use the test framework's ordinary ordering and must not force randomized ordering. Random-order execution is an explicit diagnostic only, and every failure it exposes must be fixed at the root cause.
11
11
 
12
- Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, add or update the relevant validation check before changing the prose.
12
+ Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, run the relevant focused non-test
13
+ validation before changing the prose; do not add automated tests that inspect
14
+ prose, files, or repository structure.
13
15
 
14
16
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
15
17
 
@@ -123,3 +125,22 @@ For each changed repository:
123
125
  Finish by verifying that all five packages are published at the same target
124
126
  version and every declared `@carecard/*` dependency in `pkg-*`, `ms-*`, and
125
127
  `app-dashboard` is pinned to that version.
128
+
129
+ ## TDD And Validation
130
+
131
+ Test Driven Development is a non-negotiable requirement.
132
+
133
+ The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
134
+ Tests must validate what the system does through its public interfaces and expected outcomes.
135
+
136
+ Tests must not assert, inspect, or depend on implementation details, including but not limited to:
137
+
138
+ - The existence of specific lines of code, statements, functions, classes, files, or modules.
139
+ - Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
140
+ - Any internal structure that can change without changing externally observable behavior.
141
+
142
+ A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
143
+
144
+ Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
145
+
146
+ This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
@@ -7,7 +7,9 @@ Non-negotiable root-cause solution rule: Always identify and solve the verified
7
7
 
8
8
  # Software Design Patterns And Clean Code
9
9
 
10
- Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, add or update the relevant validation check before changing the prose.
10
+ Non-negotiable TDD rule: Always write the failing test first, run it to confirm it fails for the intended reason, then implement the code and rerun the test until it passes. Test Driven Development is required for all coding work and must not be skipped. For documentation- or skill-only edits, run the relevant focused non-test
11
+ validation before changing the prose; do not add automated tests that inspect
12
+ prose, files, or repository structure.
11
13
 
12
14
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
13
15
 
@@ -41,8 +43,7 @@ validation commands, and API contracts.
41
43
  - Keep side effects minimal, localized, and easy to identify.
42
44
  - Use explicit error handling. Do not swallow failures or hide actionable
43
45
  error context.
44
- - Design code so behavior can be tested through focused unit, integration, or
45
- service tests without fragile setup.
46
+ - Design code so behavior can be tested through focused public interfaces, integration boundaries, and observable outcomes without fragile setup or internal-module assertions.
46
47
  - Avoid unnecessary dependencies. Use existing language, framework, and local
47
48
  helper capabilities before adding packages.
48
49
 
@@ -83,3 +84,22 @@ async function loadProfile(...) { ... }
83
84
  only have one trivial implementation unless they clarify a boundary.
84
85
  - Preserve the repository's existing style, naming, module system, and testing
85
86
  approach.
87
+
88
+ ## TDD And Validation
89
+
90
+ Test Driven Development is a non-negotiable requirement.
91
+
92
+ The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
93
+ Tests must validate what the system does through its public interfaces and expected outcomes.
94
+
95
+ Tests must not assert, inspect, or depend on implementation details, including but not limited to:
96
+
97
+ - The existence of specific lines of code, statements, functions, classes, files, or modules.
98
+ - Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
99
+ - Any internal structure that can change without changing externally observable behavior.
100
+
101
+ A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
102
+
103
+ Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
104
+
105
+ This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
package/.prettierrc.js CHANGED
@@ -4,7 +4,9 @@ module.exports = {
4
4
  bracketSpacing: true,
5
5
  singleQuote: true,
6
6
  trailingComma: 'all',
7
- printWidth: 140,
7
+ printWidth: 100,
8
+ semi: true,
9
+ tabWidth: 2,
8
10
  useTabs: false,
9
- endOfLine: 'auto',
11
+ endOfLine: 'lf',
10
12
  };
package/AGENTS.md CHANGED
@@ -13,3 +13,22 @@
13
13
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
14
14
 
15
15
  Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
16
+
17
+ ## TDD And Validation
18
+
19
+ Test Driven Development is a non-negotiable requirement.
20
+
21
+ The sole purpose of automated tests is to verify observable functionality and externally visible behavior.
22
+ Tests must validate what the system does through its public interfaces and expected outcomes.
23
+
24
+ Tests must not assert, inspect, or depend on implementation details, including but not limited to:
25
+
26
+ - The existence of specific lines of code, statements, functions, classes, files, or modules.
27
+ - Specific algorithms, control flow, variable names, method calls, code snippets, or internal implementation choices.
28
+ - Any internal structure that can change without changing externally observable behavior.
29
+
30
+ A correct implementation may be completely rewritten or refactored without requiring changes to functional tests, provided its externally observable behavior remains unchanged.
31
+
32
+ Any test that fails solely because the implementation changed while the externally observable behavior remained correct is incorrectly designed and must be rewritten or removed.
33
+
34
+ This requirement is mandatory for all new tests and must be applied whenever existing tests are modified.
package/eslint.config.mjs CHANGED
@@ -1,4 +1,7 @@
1
+ import js from '@eslint/js';
2
+ import tsParser from '@typescript-eslint/parser';
1
3
  import { defineConfig, globalIgnores } from 'eslint/config';
4
+ import globals from 'globals';
2
5
 
3
6
  const eslintConfig = defineConfig([
4
7
  globalIgnores([
@@ -8,7 +11,56 @@ const eslintConfig = defineConfig([
8
11
  'build/**',
9
12
  'next-env.d.ts',
10
13
  'node_modules/**',
14
+ 'coverage/**',
15
+ 'dist/**',
11
16
  ]),
17
+ {
18
+ name: 'carecard/braced-control-flow',
19
+ files: ['**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}'],
20
+ languageOptions: {
21
+ ecmaVersion: 'latest',
22
+ parserOptions: {
23
+ ecmaFeatures: {
24
+ jsx: true,
25
+ },
26
+ },
27
+ },
28
+ rules: {
29
+ curly: ['error', 'all'],
30
+ },
31
+ },
32
+ {
33
+ name: 'carecard/javascript-recommended',
34
+ files: ['**/*.{js,jsx,mjs,cjs}'],
35
+ languageOptions: {
36
+ ecmaVersion: 'latest',
37
+ sourceType: 'commonjs',
38
+ globals: {
39
+ ...globals.node,
40
+ ...globals.mocha,
41
+ },
42
+ },
43
+ rules: {
44
+ ...js.configs.recommended.rules,
45
+ eqeqeq: ['error', 'smart'],
46
+ 'no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
47
+ 'no-var': 'error',
48
+ },
49
+ },
50
+ {
51
+ name: 'carecard/esm-source-type',
52
+ files: ['**/*.mjs'],
53
+ languageOptions: {
54
+ sourceType: 'module',
55
+ },
56
+ },
57
+ {
58
+ name: 'carecard/typescript-parser',
59
+ files: ['**/*.{ts,tsx,mts,cts}'],
60
+ languageOptions: {
61
+ parser: tsParser,
62
+ },
63
+ },
12
64
  ]);
13
65
 
14
66
  export default eslintConfig;
package/index.d.ts CHANGED
@@ -380,7 +380,11 @@ export function jwtValidateAndExtractWebToken(
380
380
  /**
381
381
  * Validates the JWT from the Authorization header and extracts it into req.jwt (no-throw).
382
382
  */
383
- export function jwtValidateAndExtractNoThrow(req: AuthenticatedRequest, publicKey: string, options?: UserAuthorizationReadOptions): void;
383
+ export function jwtValidateAndExtractNoThrow(
384
+ req: AuthenticatedRequest,
385
+ publicKey: string,
386
+ options?: UserAuthorizationReadOptions,
387
+ ): void;
384
388
 
385
389
  /**
386
390
  * Validates the JWT from a custom header and extracts it into req.jwt (no-throw).
package/index.js CHANGED
@@ -21,7 +21,8 @@ module.exports = {
21
21
  jwtGetContext: jwtRoles.getContext,
22
22
  jwtValidateAndExtract: jwtLib.validateAndExtractJwtObject,
23
23
  jwtValidateAndExtractUserAuthorization: jwtLib.validateAndExtractUserAuthorizationObject,
24
- jwtValidateAndExtractUserAuthorizationNoThrow: jwtLib.validateAndExtractUserAuthorizationObjectNoThrow,
24
+ jwtValidateAndExtractUserAuthorizationNoThrow:
25
+ jwtLib.validateAndExtractUserAuthorizationObjectNoThrow,
25
26
  jwtValidateAndExtractService: jwtLib.validateAndExtractServiceJwtObject,
26
27
  jwtValidateAndExtractOrServerAuth: jwtLib.validateAndExtractJwtOrServerAuthObject,
27
28
  jwtValidateAndExtractWebToken: jwtLib.validateAndExtractWebToken,