@md-code/follow-architecture 0.3.0 → 0.3.2
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.
- package/CHANGELOG.md +21 -0
- package/README.md +1310 -472
- package/dist/args.d.ts +4 -0
- package/dist/args.js +18 -1
- package/dist/bin/follow-architecture.js +3 -3
- package/dist/closure-project.d.ts +4 -0
- package/dist/closure-project.js +132 -0
- package/dist/code-entities/classify.d.ts +11 -0
- package/dist/code-entities/classify.js +45 -0
- package/dist/code-entities/connector.d.ts +8 -0
- package/dist/code-entities/connector.js +119 -0
- package/dist/code-entities/entities.d.ts +9 -0
- package/dist/{code-roles/roles.js → code-entities/entities.js} +98 -61
- package/dist/code-entities/project.d.ts +21 -0
- package/dist/code-entities/project.js +259 -0
- package/dist/code-entities/walk.d.ts +31 -0
- package/dist/code-entities/walk.js +105 -0
- package/dist/config-options.d.ts +23 -0
- package/dist/config-options.js +18 -1
- package/dist/config-project.js +27 -9
- package/dist/config-report.d.ts +1 -1
- package/dist/config-report.js +37 -10
- package/dist/config-rule.d.ts +25 -0
- package/dist/config-rule.js +106 -13
- package/dist/config-state.d.ts +14 -3
- package/dist/config-state.js +197 -24
- package/dist/config.d.ts +25 -0
- package/dist/css/index.d.ts +11 -7
- package/dist/css/index.js +141 -30
- package/dist/css/syntax/css/gate.js +5 -5
- package/dist/css/syntax/css/index.d.ts +1 -1
- package/dist/css/syntax/css/index.js +18 -8
- package/dist/css/syntax/css/reference.d.ts +1 -1
- package/dist/css/syntax/css/reference.js +15 -3
- package/dist/css/syntax/language.d.ts +1 -1
- package/dist/css/syntax/language.js +21 -9
- package/dist/css/syntax/scss/index.d.ts +2 -2
- package/dist/css/syntax/scss/index.js +18 -8
- package/dist/css/syntax/scss/reference.d.ts +1 -1
- package/dist/css/syntax/scss/reference.js +7 -1
- package/dist/css/syntax/styled/document.d.ts +3 -3
- package/dist/css/syntax/styled/document.js +34 -14
- package/dist/css/syntax/styled/markup.d.ts +1 -1
- package/dist/css/syntax/styled/markup.js +22 -14
- package/dist/css/syntax/styled/tags.d.ts +2 -0
- package/dist/css/syntax/styled/tags.js +22 -0
- package/dist/css/syntax/styled/template.js +10 -4
- package/dist/css/syntax/tailwind/tailwind.js +4 -4
- package/dist/css/value/check.d.ts +1 -1
- package/dist/css/value/check.js +1 -1
- package/dist/css/value/expression/arithmetic.d.ts +2 -2
- package/dist/css/value/expression/arithmetic.js +7 -3
- package/dist/css/value/expression/block.d.ts +2 -2
- package/dist/css/value/expression/block.js +4 -3
- package/dist/css/value/expression/conditional.d.ts +2 -2
- package/dist/css/value/expression/conditional.js +1 -1
- package/dist/css/value/expression/index.d.ts +2 -2
- package/dist/css/value/expression/index.js +10 -6
- package/dist/css/value/expression/map.d.ts +2 -2
- package/dist/css/value/expression/map.js +2 -2
- package/dist/css/value/object/index.d.ts +2 -2
- package/dist/css/value/object/index.js +14 -4
- package/dist/css/value/object/members.d.ts +2 -2
- package/dist/css/value/object/node.js +9 -4
- package/dist/css/value/object/path.d.ts +3 -3
- package/dist/css/value/object/path.js +10 -4
- package/dist/css/value/pieces.d.ts +3 -3
- package/dist/css/value/pieces.js +14 -4
- package/dist/css/value/resolve.js +15 -5
- package/dist/css/value/scope.d.ts +3 -2
- package/dist/css/value/scope.js +25 -7
- package/dist/css/value/substitute.js +43 -11
- package/dist/entities/architecture.d.ts +28 -25
- package/dist/entities/ast/assignments-raw.d.ts +1 -1
- package/dist/entities/ast/assignments-raw.js +61 -8
- package/dist/entities/ast/assignments-tagged.d.ts +1 -1
- package/dist/entities/ast/assignments-tagged.js +22 -7
- package/dist/entities/ast/assignments.d.ts +1 -1
- package/dist/entities/ast/assignments.js +6 -4
- package/dist/entities/ast/branches.d.ts +1 -1
- package/dist/entities/ast/calls.d.ts +1 -1
- package/dist/entities/ast/calls.js +19 -3
- package/dist/entities/ast/classes.d.ts +1 -1
- package/dist/entities/ast/classes.js +5 -1
- package/dist/entities/ast/comments.d.ts +3 -2
- package/dist/entities/ast/comments.js +47 -17
- package/dist/entities/ast/declaration.d.ts +1 -1
- package/dist/entities/ast/depth.d.ts +2 -2
- package/dist/entities/ast/depth.js +32 -15
- package/dist/entities/ast/enums.d.ts +1 -1
- package/dist/entities/ast/export-chain.d.ts +15 -0
- package/dist/entities/ast/export-chain.js +171 -0
- package/dist/entities/ast/file-exports.d.ts +1 -1
- package/dist/entities/ast/file-exports.js +26 -3
- package/dist/entities/ast/file-facts.d.ts +6 -3
- package/dist/entities/ast/file-facts.js +33 -4
- package/dist/entities/ast/file-imports.d.ts +1 -1
- package/dist/entities/ast/file-imports.js +26 -3
- package/dist/entities/ast/file.d.ts +2 -2
- package/dist/entities/ast/file.js +2 -1
- package/dist/entities/ast/functions.d.ts +1 -1
- package/dist/entities/ast/functions.js +13 -4
- package/dist/entities/ast/heritage.d.ts +1 -1
- package/dist/entities/ast/heritage.js +9 -1
- package/dist/entities/ast/index.d.ts +6 -3
- package/dist/entities/ast/index.js +82 -26
- package/dist/entities/ast/kind.d.ts +1 -1
- package/dist/entities/ast/kind.js +7 -1
- package/dist/entities/ast/modifiers.d.ts +1 -1
- package/dist/entities/ast/modifiers.js +4 -4
- package/dist/entities/ast/project.js +33 -2
- package/dist/entities/ast/properties.d.ts +1 -1
- package/dist/entities/ast/properties.js +10 -5
- package/dist/entities/ast/resolve.d.ts +1 -1
- package/dist/entities/ast/resolve.js +21 -11
- package/dist/entities/ast/tree.d.ts +4 -2
- package/dist/entities/ast/tree.js +184 -17
- package/dist/entities/ast/types.d.ts +1 -1
- package/dist/entities/ast/types.js +2 -1
- package/dist/entities/ast/usage.d.ts +1 -1
- package/dist/entities/ast/usage.js +1 -1
- package/dist/entities/ast/variables.d.ts +1 -1
- package/dist/entities/context.d.ts +4 -4
- package/dist/entities/facts.d.ts +36 -13
- package/dist/entities/findings.d.ts +3 -3
- package/dist/entities/kinds.d.ts +1 -1
- package/dist/entities/kinds.js +148 -37
- package/dist/entities/location/homes.d.ts +10 -10
- package/dist/entities/location/homes.js +74 -48
- package/dist/entities/location/place.d.ts +1 -1
- package/dist/entities/location/place.js +10 -3
- package/dist/entities/location/where.d.ts +10 -8
- package/dist/entities/location/where.js +89 -30
- package/dist/entities/location.d.ts +3 -3
- package/dist/entities/location.js +17 -17
- package/dist/entities/operators.js +1 -1
- package/dist/entities/overview/data.d.ts +6 -6
- package/dist/entities/overview/decision.d.ts +11 -11
- package/dist/entities/overview/finding.d.ts +10 -10
- package/dist/entities/overview/graph.d.ts +28 -11
- package/dist/entities/overview/input.d.ts +2 -2
- package/dist/entities/overview/summaries.d.ts +17 -15
- package/dist/entities/queries.d.ts +1 -1
- package/dist/entities/queries.js +89 -19
- package/dist/entities/repair.d.ts +1 -1
- package/dist/entities/repair.js +8 -2
- package/dist/entities/schema.d.ts +17 -3
- package/dist/entities/schema.js +74 -16
- package/dist/entities/story.d.ts +5 -5
- package/dist/entities/structure-facts.d.ts +1 -1
- package/dist/entities/token.d.ts +4 -4
- package/dist/entities/tree/build.d.ts +4 -3
- package/dist/entities/tree/build.js +112 -51
- package/dist/entities/tree/entries.d.ts +4 -4
- package/dist/entities/tree/entries.js +41 -16
- package/dist/entities/tree/index.d.ts +2 -2
- package/dist/entities/tree/index.js +1 -1
- package/dist/entities/tree/match.d.ts +2 -2
- package/dist/entities/tree/match.js +26 -12
- package/dist/fa-index.d.ts +16 -0
- package/dist/fa-index.js +165 -0
- package/dist/fa-open.d.ts +51 -0
- package/dist/fa-open.js +242 -0
- package/dist/fa-store.d.ts +22 -0
- package/dist/fa-store.js +232 -0
- package/dist/fa-values.d.ts +37 -0
- package/dist/fa-values.js +104 -0
- package/dist/facts-record.d.ts +45 -0
- package/dist/facts-record.js +297 -0
- package/dist/frameworks/angular/index.d.ts +2 -2
- package/dist/frameworks/angular/index.js +2 -1
- package/dist/frameworks/facet.d.ts +3 -1
- package/dist/frameworks/facet.js +13 -0
- package/dist/frameworks/index.d.ts +1 -1
- package/dist/frameworks/index.js +25 -11
- package/dist/frameworks/react/index.d.ts +2 -2
- package/dist/frameworks/react/index.js +33 -10
- package/dist/frameworks/test/index.d.ts +6 -0
- package/dist/frameworks/test/index.js +157 -0
- package/dist/frameworks/vue/index.d.ts +2 -2
- package/dist/frameworks/vue/index.js +2 -1
- package/dist/ignore.d.ts +3 -0
- package/dist/ignore.js +62 -0
- package/dist/index-file.d.ts +43 -0
- package/dist/index-file.js +218 -0
- package/dist/index-run.d.ts +39 -0
- package/dist/index-run.js +217 -0
- package/dist/index-zone.d.ts +25 -0
- package/dist/index-zone.js +219 -0
- package/dist/main.d.ts +5 -2
- package/dist/main.js +223 -41
- package/dist/nodes/child-entities.d.ts +3 -0
- package/dist/nodes/child-entities.js +12 -0
- package/dist/nodes/children.d.ts +4 -4
- package/dist/nodes/children.js +64 -11
- package/dist/nodes/finally/emit.d.ts +4 -4
- package/dist/nodes/finally/emit.js +26 -10
- package/dist/nodes/finally/entities.d.ts +13 -0
- package/dist/nodes/finally/entities.js +42 -0
- package/dist/nodes/finally/index.d.ts +6 -6
- package/dist/nodes/finally/index.js +8 -8
- package/dist/nodes/finally/queries.d.ts +2 -2
- package/dist/nodes/finally/queries.js +7 -4
- package/dist/nodes/finally/relations-access.d.ts +2 -2
- package/dist/nodes/finally/relations-access.js +22 -18
- package/dist/nodes/finally/relations-edge.d.ts +5 -5
- package/dist/nodes/finally/relations-edge.js +67 -44
- package/dist/nodes/finally/relations-group.d.ts +7 -7
- package/dist/nodes/finally/relations-group.js +28 -25
- package/dist/nodes/finally/relations.d.ts +2 -2
- package/dist/nodes/finally/relations.js +16 -12
- package/dist/nodes/finally/required.d.ts +3 -3
- package/dist/nodes/finally/required.js +9 -7
- package/dist/nodes/finally/violation.d.ts +2 -2
- package/dist/nodes/similar.d.ts +3 -3
- package/dist/nodes/similar.js +78 -56
- package/dist/piece-forms.d.ts +9 -0
- package/dist/piece-forms.js +68 -0
- package/dist/{pipeline-roles.d.ts → pipeline-entities.d.ts} +2 -2
- package/dist/{pipeline-roles.js → pipeline-entities.js} +32 -28
- package/dist/pipeline-facts.d.ts +4 -3
- package/dist/pipeline-facts.js +64 -62
- package/dist/{pipeline-unroled.d.ts → pipeline-unclassified.d.ts} +2 -2
- package/dist/{pipeline-unroled.js → pipeline-unclassified.js} +58 -63
- package/dist/pipeline.d.ts +1 -1
- package/dist/pipeline.js +19 -64
- package/dist/release-file.d.ts +3 -0
- package/dist/release-file.js +13 -0
- package/dist/report/asks.d.ts +3 -3
- package/dist/report/asks.js +16 -6
- package/dist/report/configErrors.d.ts +55 -27
- package/dist/report/configErrors.js +81 -35
- package/dist/report/errorTypes/codes/structure.d.ts +1 -1
- package/dist/report/errorTypes/codes/structure.js +9 -9
- package/dist/report/errorTypes/decision-maker.d.ts +5 -5
- package/dist/report/errorTypes/decision-maker.js +21 -11
- package/dist/report/errorTypes/destinations.d.ts +5 -5
- package/dist/report/errorTypes/destinations.js +52 -34
- package/dist/report/errorTypes/finding-type.d.ts +3 -3
- package/dist/report/errorTypes/index.d.ts +1 -1
- package/dist/report/errorTypes/index.js +17 -7
- package/dist/report/errorTypes/types/fileContents.d.ts +4 -4
- package/dist/report/errorTypes/types/fileContents.js +11 -5
- package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
- package/dist/report/errorTypes/types/{unknownRole.js → unknownEntity.js} +12 -7
- package/dist/report/errorTypes/types/wrongAction.d.ts +5 -5
- package/dist/report/errorTypes/types/wrongAction.js +18 -13
- package/dist/report/errorTypes/types/wrongPlacement.d.ts +4 -4
- package/dist/report/errorTypes/types/wrongPlacement.js +19 -9
- package/dist/report/errorTypes/vocabulary/ids.d.ts +2 -2
- package/dist/report/errorTypes/vocabulary/ids.js +3 -3
- package/dist/report/errorTypes/vocabulary/phrases.d.ts +2 -2
- package/dist/report/errorTypes/vocabulary/phrases.js +39 -26
- package/dist/report/errorTypes/vocabulary/places.d.ts +3 -3
- package/dist/report/errorTypes/vocabulary/places.js +13 -13
- package/dist/report/finding-from.d.ts +3 -3
- package/dist/report/finding-from.js +14 -9
- package/dist/report/notices.d.ts +6 -1
- package/dist/report/notices.js +46 -20
- package/dist/report/observed.d.ts +19 -0
- package/dist/report/observed.js +87 -0
- package/dist/report/render-report.d.ts +1 -1
- package/dist/report/render-report.js +33 -30
- package/dist/report/user-report/build/bundle.js +26 -7
- package/dist/report/user-report/build/bundle.prebuilt.js +799 -297
- package/dist/report/user-report/data/collect.d.ts +2 -2
- package/dist/report/user-report/data/collect.js +32 -19
- package/dist/report/user-report/data/entities.d.ts +7 -0
- package/dist/report/user-report/data/{roles.js → entities.js} +27 -22
- package/dist/report/user-report/data/{role-examples.d.ts → entity-examples.d.ts} +3 -3
- package/dist/report/user-report/data/entity-examples.js +136 -0
- package/dist/report/user-report/data/{role-filters.d.ts → entity-filters.d.ts} +2 -2
- package/dist/report/user-report/data/{role-filters.js → entity-filters.js} +7 -7
- package/dist/report/user-report/data/entity-marks.d.ts +5 -0
- package/dist/report/user-report/data/{role-marks.js → entity-marks.js} +11 -11
- package/dist/report/user-report/data/file-tree.d.ts +3 -3
- package/dist/report/user-report/data/file-tree.js +13 -5
- package/dist/report/user-report/data/finding-boundary.d.ts +4 -4
- package/dist/report/user-report/data/finding-boundary.js +2 -2
- package/dist/report/user-report/data/finding-plan.d.ts +5 -5
- package/dist/report/user-report/data/finding-plan.js +10 -10
- package/dist/report/user-report/data/finding-title.d.ts +2 -2
- package/dist/report/user-report/data/finding-title.js +8 -8
- package/dist/report/user-report/data/findings.d.ts +4 -4
- package/dist/report/user-report/data/findings.js +30 -20
- package/dist/report/user-report/data/graph-edges.d.ts +4 -4
- package/dist/report/user-report/data/graph-edges.js +19 -19
- package/dist/report/user-report/data/graph-entities.d.ts +6 -0
- package/dist/report/user-report/data/graph-entities.js +158 -0
- package/dist/report/user-report/data/graph-helpers.d.ts +5 -5
- package/dist/report/user-report/data/graph-helpers.js +15 -15
- package/dist/report/user-report/data/graph.d.ts +5 -4
- package/dist/report/user-report/data/graph.js +28 -21
- package/dist/report/user-report/data/nodes.d.ts +2 -2
- package/dist/report/user-report/data/nodes.js +33 -23
- package/dist/report/user-report/data/rules.d.ts +7 -0
- package/dist/report/user-report/data/{invariants.js → rules.js} +13 -13
- package/dist/report/user-report/data/scan.d.ts +1 -1
- package/dist/report/user-report/data/scan.js +19 -9
- package/dist/report/user-report/html/shell.d.ts +1 -1
- package/dist/report/user-report/html/shell.js +1 -1
- package/dist/report/user-report/index.d.ts +1 -1
- package/dist/report/user-report/index.js +17 -7
- package/dist/report/user-report/shared/describe.d.ts +1 -1
- package/dist/report/user-report/shared/describe.js +6 -6
- package/dist/rules/index.d.ts +7 -0
- package/dist/{invariants → rules}/index.js +85 -57
- package/dist/{invariants → rules}/list-vars.d.ts +2 -2
- package/dist/{invariants → rules}/list-vars.js +9 -3
- package/dist/{invariants → rules}/name.js +2 -2
- package/dist/rules/normalize.d.ts +5 -0
- package/dist/rules/normalize.js +108 -0
- package/dist/{invariants → rules}/vars.d.ts +9 -7
- package/dist/{invariants → rules}/vars.js +5 -5
- package/dist/scan-run.d.ts +20 -0
- package/dist/scan-run.js +130 -0
- package/dist/scripts/audit-report.js +19 -9
- package/dist/usage-index.d.ts +4 -0
- package/dist/usage-index.js +282 -0
- package/dist/usage-mode.d.ts +7 -0
- package/dist/usage-mode.js +16 -0
- package/dist/usage-pass.d.ts +19 -0
- package/dist/usage-pass.js +136 -0
- package/dist/usage-prepare.d.ts +2 -0
- package/dist/usage-prepare.js +22 -0
- package/dist/usage-sweep.d.ts +10 -0
- package/dist/usage-sweep.js +264 -0
- package/dist/utils/aliases.d.ts +22 -0
- package/dist/utils/aliases.js +173 -0
- package/dist/utils/classify.d.ts +2 -2
- package/dist/utils/classify.js +4 -4
- package/dist/utils/configs.js +17 -7
- package/dist/utils/distinct.js +4 -2
- package/dist/utils/files.js +41 -37
- package/dist/utils/fixpoint.js +2 -2
- package/dist/utils/host.d.ts +1 -1
- package/dist/utils/host.js +4 -1
- package/dist/utils/imports.js +83 -19
- package/dist/utils/keyed.js +2 -2
- package/dist/utils/map-record.js +2 -2
- package/dist/utils/packages.d.ts +15 -0
- package/dist/utils/packages.js +207 -0
- package/dist/utils/path-label.js +3 -1
- package/dist/utils/pattern.d.ts +5 -4
- package/dist/utils/pattern.js +55 -15
- package/dist/utils/permission.d.ts +3 -3
- package/dist/utils/permission.js +4 -2
- package/dist/utils/plural.js +2 -2
- package/dist/utils/qualified.js +4 -4
- package/dist/utils/rank.js +2 -2
- package/dist/utils/record.js +1 -1
- package/dist/utils/search.js +7 -2
- package/dist/utils/speak.js +1 -1
- package/dist/utils/split.js +14 -1
- package/dist/utils/template.d.ts +1 -1
- package/dist/utils/template.js +1 -1
- package/dist/utils/tokenize.js +6 -1
- package/dist/utils/typed-field.js +2 -2
- package/dist/utils/verdicts.js +1 -1
- package/entities/operators.ts +1 -1
- package/package.json +101 -90
- package/report/errorTypes/vocabulary/ids.ts +7 -2
- package/report/errorTypes/vocabulary/phrases.ts +47 -27
- package/report/errorTypes/vocabulary/places.ts +21 -16
- package/report/user-report/shared/describe.ts +7 -7
- package/dist/code-roles/classify.d.ts +0 -11
- package/dist/code-roles/classify.js +0 -43
- package/dist/code-roles/connector.d.ts +0 -5
- package/dist/code-roles/connector.js +0 -114
- package/dist/code-roles/project.d.ts +0 -12
- package/dist/code-roles/project.js +0 -122
- package/dist/code-roles/roles.d.ts +0 -8
- package/dist/invariants/index.d.ts +0 -6
- package/dist/invariants/normalize.d.ts +0 -4
- package/dist/invariants/normalize.js +0 -95
- package/dist/nodes/child-roles.d.ts +0 -3
- package/dist/nodes/child-roles.js +0 -12
- package/dist/nodes/finally/roles.d.ts +0 -13
- package/dist/nodes/finally/roles.js +0 -41
- package/dist/report/errorTypes/types/unknownRole.d.ts +0 -9
- package/dist/report/user-report/data/graph-roles.d.ts +0 -5
- package/dist/report/user-report/data/graph-roles.js +0 -71
- package/dist/report/user-report/data/invariants.d.ts +0 -7
- package/dist/report/user-report/data/role-examples.js +0 -94
- package/dist/report/user-report/data/role-marks.d.ts +0 -5
- package/dist/report/user-report/data/roles.d.ts +0 -7
- /package/dist/{invariants → rules}/name.d.ts +0 -0
package/dist/fa-index.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prune = exports.finish = exports.settle = exports.keepUsage = exports.keepVerdict = exports.keepFacts = exports.CHUNK = exports.USAGE_VERSION = exports.OUT_VERSION = exports.SECTION_VERSION = exports.USAGE_NAME = exports.OUT_NAME = exports.SECTION_NAME = exports.handleOf = exports.openFactsIndex = exports.scanChunks = exports.usageAt = exports.pieceFiles = exports.readPeers = exports.recordAt = exports.lightAt = exports.readLight = void 0;
|
|
4
|
+
// WHERE A FILE'S FACTS AND ITS VERDICTS LIVE BETWEEN RUNS: two sections of the
|
|
5
|
+
// shared repo index, one record per file. `@md-code/utils/node/index-cache` owns
|
|
6
|
+
// the file, the lock, the header and the freshness test; this module names the
|
|
7
|
+
// sections, reads them back one file at a time, and re-exports the write side
|
|
8
|
+
// (`fa-store.ts`) and the stored shapes (`fa-values.ts`) so a caller has one door.
|
|
9
|
+
//
|
|
10
|
+
// THE TWO SECTIONS, AND WHY: `fa` holds the file's record — its facts, its
|
|
11
|
+
// candidates, the places of its literals (data only, see `facts-record.ts`) — and
|
|
12
|
+
// `fa-out` holds what the checks concluded from it: the findings, the notices the
|
|
13
|
+
// reading produced, and the SUMMARY, the little a run must know about a file it
|
|
14
|
+
// does not check (its classified pieces, its literals' places, its entities, its
|
|
15
|
+
// deps). A record is ~130 kB and a summary ~2 kB, so a run that read every record
|
|
16
|
+
// to answer questions about OTHER files would hold the whole repo in heap: that is
|
|
17
|
+
// why the heavy section is only ever decoded one file at a time, while that file
|
|
18
|
+
// is being checked, and dropped with the chunk it came in.
|
|
19
|
+
//
|
|
20
|
+
// WHEN A VALUE IS STALE: the index says the file changed (`status`), the
|
|
21
|
+
// section's own stamp disagrees with the file (the stat the value was computed
|
|
22
|
+
// from, taken before it was read: another tool refreshing the record header of a
|
|
23
|
+
// changed file does not make these values fresh), the section schema version
|
|
24
|
+
// moved, or the fingerprint moved — package version, a hash of the config that
|
|
25
|
+
// shapes facts and findings, and a content hash of this package's own compiled
|
|
26
|
+
// code. `tree` is deliberately NOT in the fingerprint: it is the architecture's
|
|
27
|
+
// own file and already hashed as config.
|
|
28
|
+
//
|
|
29
|
+
// NOTHING HERE THROWS AND NOTHING HERE IS THE SOURCE OF TRUTH: no index, a
|
|
30
|
+
// foreign root, a broken line or a lock somebody else holds leaves the caller on
|
|
31
|
+
// its cold path. A failed write is a warning line, never a failed run.
|
|
32
|
+
const index_cache_1 = require("@md-code/utils/node/index-cache");
|
|
33
|
+
const fa_open_1 = require("./fa-open");
|
|
34
|
+
const fa_store_1 = require("./fa-store");
|
|
35
|
+
const fa_values_1 = require("./fa-values");
|
|
36
|
+
// The stat every plan of this run took before it read anything, kept for the write
|
|
37
|
+
// side: a value is true for the bytes its stamp describes, and for no others
|
|
38
|
+
// (index-cache, THE STAMP ON A SECTION VALUE). The FIRST stat of a run wins — a later
|
|
39
|
+
// one could only be newer than the bytes a value was computed from, and a stamp that
|
|
40
|
+
// is too fresh is exactly the bug this prevents.
|
|
41
|
+
const keepStamps = (index, stamps) => {
|
|
42
|
+
for (const [file, stamp] of stamps)
|
|
43
|
+
if (!index.stamps.has(file))
|
|
44
|
+
index.stamps.set(file, stamp);
|
|
45
|
+
};
|
|
46
|
+
// The light section of every asked-for file, in one open and one decode each: a
|
|
47
|
+
// warm run reads nothing else. A file the index cannot answer for is simply
|
|
48
|
+
// absent, and the zone treats it as changed.
|
|
49
|
+
const readLight = (index, files) => {
|
|
50
|
+
const out = new Map();
|
|
51
|
+
const opened = (0, fa_open_1.handleOf)(index);
|
|
52
|
+
if (opened === null)
|
|
53
|
+
return out;
|
|
54
|
+
const plan = (0, index_cache_1.planSection)({
|
|
55
|
+
index: opened.handle,
|
|
56
|
+
name: fa_open_1.OUT_NAME,
|
|
57
|
+
v: fa_open_1.OUT_VERSION,
|
|
58
|
+
tool: index.tool,
|
|
59
|
+
files,
|
|
60
|
+
});
|
|
61
|
+
keepStamps(index, plan.stamps);
|
|
62
|
+
for (const [file, value] of plan.cached) {
|
|
63
|
+
const light = (0, fa_values_1.lightOf)(value);
|
|
64
|
+
if (light !== null)
|
|
65
|
+
out.set(file, light);
|
|
66
|
+
}
|
|
67
|
+
(0, fa_open_1.endChunk)(index);
|
|
68
|
+
return out;
|
|
69
|
+
};
|
|
70
|
+
exports.readLight = readLight;
|
|
71
|
+
// One file's light value, or null when the index cannot answer for it. Used for
|
|
72
|
+
// the files that are gone, which no scan names any more.
|
|
73
|
+
const lightAt = (index, file) => readLight(index, [file]).get(file) ?? null;
|
|
74
|
+
exports.lightAt = lightAt;
|
|
75
|
+
// One value of one section, or undefined when the index cannot answer for it.
|
|
76
|
+
const valueAt = (index, name, v, file) => {
|
|
77
|
+
const opened = (0, fa_open_1.handleOf)(index);
|
|
78
|
+
if (opened === null)
|
|
79
|
+
return undefined;
|
|
80
|
+
const plan = (0, index_cache_1.planSection)({ index: opened.handle, name, v, tool: index.tool, files: [file] });
|
|
81
|
+
keepStamps(index, plan.stamps);
|
|
82
|
+
return plan.cached.get(file);
|
|
83
|
+
};
|
|
84
|
+
// One file's record, read while the file is being checked: the facts from `fa` and
|
|
85
|
+
// the pieces from `fa-peers`. The caller's chunk is the unit that keeps them alive.
|
|
86
|
+
// A stored record whose pieces are gone is no record at all: the file is read again.
|
|
87
|
+
const recordAt = (index, file) => {
|
|
88
|
+
const value = valueAt(index, fa_open_1.SECTION_NAME, fa_open_1.SECTION_VERSION, file);
|
|
89
|
+
if (value === undefined)
|
|
90
|
+
return null;
|
|
91
|
+
const record = (0, fa_values_1.recordOf)(value);
|
|
92
|
+
const pieces = valueAt(index, fa_open_1.PEERS_NAME, fa_open_1.PEERS_VERSION, file);
|
|
93
|
+
const candidates = pieces === undefined ? null : (0, fa_values_1.candidatesOf)(pieces);
|
|
94
|
+
if (record === null || candidates === null)
|
|
95
|
+
return null;
|
|
96
|
+
record.candidates = candidates;
|
|
97
|
+
return record;
|
|
98
|
+
};
|
|
99
|
+
exports.recordAt = recordAt;
|
|
100
|
+
// One file's checker answers, as the run's usage pass stored them. A file the pass
|
|
101
|
+
// did not ask about — or an index that predates the section — answers `null`, and
|
|
102
|
+
// the record's own `null`s stand: that is what "not asked" has always meant.
|
|
103
|
+
const usageAt = (index, file) => {
|
|
104
|
+
const value = valueAt(index, fa_open_1.USAGE_NAME, fa_open_1.USAGE_VERSION, file);
|
|
105
|
+
return value === undefined ? null : (0, fa_values_1.usageOf)(value);
|
|
106
|
+
};
|
|
107
|
+
exports.usageAt = usageAt;
|
|
108
|
+
// The pieces of the files that have a given entity, in one decode: the `entity`
|
|
109
|
+
// scope needs them all at once, and nothing else asks for them at all. A run whose
|
|
110
|
+
// rules never name a code entity never reads this section, and one that names a
|
|
111
|
+
// slug reads the files carrying it (`pieceFiles`).
|
|
112
|
+
const readPeers = (index, files) => {
|
|
113
|
+
const out = new Map();
|
|
114
|
+
const opened = (0, fa_open_1.handleOf)(index);
|
|
115
|
+
if (opened === null)
|
|
116
|
+
return out;
|
|
117
|
+
const plan = (0, index_cache_1.planSection)({ index: opened.handle, name: fa_open_1.PEERS_NAME, v: fa_open_1.PEERS_VERSION, tool: index.tool, files });
|
|
118
|
+
keepStamps(index, plan.stamps);
|
|
119
|
+
for (const [file, value] of plan.cached) {
|
|
120
|
+
const list = (0, fa_values_1.candidatesOf)(value);
|
|
121
|
+
if (list !== null)
|
|
122
|
+
out.set(file, list);
|
|
123
|
+
}
|
|
124
|
+
(0, fa_open_1.endChunk)(index);
|
|
125
|
+
return out;
|
|
126
|
+
};
|
|
127
|
+
exports.readPeers = readPeers;
|
|
128
|
+
// Walk the scan in chunks: `visit` sees one chunk's range, may read the records it
|
|
129
|
+
// needs, and the chunk's light values are written and its handle dropped after it.
|
|
130
|
+
const scanChunks = (index, files, visit, size = fa_open_1.CHUNK) => {
|
|
131
|
+
for (let from = 0; from < files.length; from += size) {
|
|
132
|
+
// A refused index has no handle to open; the caller's records came from the
|
|
133
|
+
// extraction instead, and the values it queues are dropped by `keepVerdict`.
|
|
134
|
+
(0, fa_open_1.handleOf)(index);
|
|
135
|
+
visit(from, Math.min(from + size, files.length));
|
|
136
|
+
(0, fa_store_1.flushChunk)(index);
|
|
137
|
+
(0, fa_open_1.endChunk)(index);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
exports.scanChunks = scanChunks;
|
|
141
|
+
// The files whose pieces a registry decodes: only those whose summary names one of
|
|
142
|
+
// the slugs the config reads the scope for. A slug no rule names is never read from
|
|
143
|
+
// the scope, so decoding its pieces buys nothing. No named slug at all (a filter
|
|
144
|
+
// asking only whether the scope has any keys) keeps the answer for every file.
|
|
145
|
+
const pieceFiles = (light, named) => named.size === 0
|
|
146
|
+
? [...light.keys()]
|
|
147
|
+
: [...light.entries()].filter(([, entry]) => entry.summary.entities.some((slug) => named.has(slug))).map(([abs]) => abs);
|
|
148
|
+
exports.pieceFiles = pieceFiles;
|
|
149
|
+
var fa_open_2 = require("./fa-open");
|
|
150
|
+
Object.defineProperty(exports, "openFactsIndex", { enumerable: true, get: function () { return fa_open_2.openFactsIndex; } });
|
|
151
|
+
Object.defineProperty(exports, "handleOf", { enumerable: true, get: function () { return fa_open_2.handleOf; } });
|
|
152
|
+
Object.defineProperty(exports, "SECTION_NAME", { enumerable: true, get: function () { return fa_open_2.SECTION_NAME; } });
|
|
153
|
+
Object.defineProperty(exports, "OUT_NAME", { enumerable: true, get: function () { return fa_open_2.OUT_NAME; } });
|
|
154
|
+
Object.defineProperty(exports, "USAGE_NAME", { enumerable: true, get: function () { return fa_open_2.USAGE_NAME; } });
|
|
155
|
+
Object.defineProperty(exports, "SECTION_VERSION", { enumerable: true, get: function () { return fa_open_2.SECTION_VERSION; } });
|
|
156
|
+
Object.defineProperty(exports, "OUT_VERSION", { enumerable: true, get: function () { return fa_open_2.OUT_VERSION; } });
|
|
157
|
+
Object.defineProperty(exports, "USAGE_VERSION", { enumerable: true, get: function () { return fa_open_2.USAGE_VERSION; } });
|
|
158
|
+
Object.defineProperty(exports, "CHUNK", { enumerable: true, get: function () { return fa_open_2.CHUNK; } });
|
|
159
|
+
var fa_store_2 = require("./fa-store");
|
|
160
|
+
Object.defineProperty(exports, "keepFacts", { enumerable: true, get: function () { return fa_store_2.keepFacts; } });
|
|
161
|
+
Object.defineProperty(exports, "keepVerdict", { enumerable: true, get: function () { return fa_store_2.keepVerdict; } });
|
|
162
|
+
Object.defineProperty(exports, "keepUsage", { enumerable: true, get: function () { return fa_store_2.keepUsage; } });
|
|
163
|
+
Object.defineProperty(exports, "settle", { enumerable: true, get: function () { return fa_store_2.settle; } });
|
|
164
|
+
Object.defineProperty(exports, "finish", { enumerable: true, get: function () { return fa_store_2.finish; } });
|
|
165
|
+
Object.defineProperty(exports, "prune", { enumerable: true, get: function () { return fa_store_2.prune; } });
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type FileStamp, type Opened, type SectionEntry } from "@md-code/utils/node/index-cache";
|
|
2
|
+
import type { Arch } from "@md-code/follow-architecture/entities/architecture";
|
|
3
|
+
declare const SECTION_NAME = "fa";
|
|
4
|
+
declare const PEERS_NAME = "fa-peers";
|
|
5
|
+
declare const OUT_NAME = "fa-out";
|
|
6
|
+
declare const USAGE_NAME = "fa-usage";
|
|
7
|
+
declare const SECTION_VERSION = 7;
|
|
8
|
+
declare const OUT_VERSION = 1;
|
|
9
|
+
declare const PEERS_VERSION = 1;
|
|
10
|
+
declare const USAGE_VERSION = 1;
|
|
11
|
+
declare const CHUNK = 500;
|
|
12
|
+
type ScanScope = {
|
|
13
|
+
exts: readonly string[];
|
|
14
|
+
ignoreDirs: readonly string[];
|
|
15
|
+
ignoreGlobs: readonly string[];
|
|
16
|
+
};
|
|
17
|
+
type OpenArgs = {
|
|
18
|
+
root: string;
|
|
19
|
+
option: string | boolean | null | undefined;
|
|
20
|
+
arch: Arch;
|
|
21
|
+
scope: ScanScope;
|
|
22
|
+
hold?: boolean;
|
|
23
|
+
};
|
|
24
|
+
type Index = {
|
|
25
|
+
root: string;
|
|
26
|
+
option: string | boolean | null | undefined;
|
|
27
|
+
tool: string;
|
|
28
|
+
hold: boolean;
|
|
29
|
+
opened: Opened | null;
|
|
30
|
+
stamps: Map<string, FileStamp>;
|
|
31
|
+
pending: SectionEntry[];
|
|
32
|
+
peers: SectionEntry[];
|
|
33
|
+
out: SectionEntry[];
|
|
34
|
+
usage: SectionEntry[];
|
|
35
|
+
written: number;
|
|
36
|
+
bytes: number;
|
|
37
|
+
chunks: number;
|
|
38
|
+
compactions: number;
|
|
39
|
+
warning: string | null;
|
|
40
|
+
warned: boolean;
|
|
41
|
+
compactionWarning: string | null;
|
|
42
|
+
compactionWarned: boolean;
|
|
43
|
+
refused: boolean;
|
|
44
|
+
};
|
|
45
|
+
declare const openFactsIndex: (args: OpenArgs) => Index | null;
|
|
46
|
+
declare const handleOf: (index: Index) => Opened | null;
|
|
47
|
+
declare const endChunk: (index: Index) => void;
|
|
48
|
+
declare const takeWarning: (index: Index, warning: string | null) => void;
|
|
49
|
+
declare const takeCompactionWarning: (index: Index, warning: string | null) => void;
|
|
50
|
+
export { openFactsIndex, handleOf, endChunk, takeWarning, takeCompactionWarning, SECTION_NAME, PEERS_NAME, OUT_NAME, USAGE_NAME, SECTION_VERSION, PEERS_VERSION, OUT_VERSION, USAGE_VERSION, CHUNK, };
|
|
51
|
+
export type { Index, OpenArgs, ScanScope };
|
package/dist/fa-open.js
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.CHUNK = exports.USAGE_VERSION = exports.OUT_VERSION = exports.PEERS_VERSION = exports.SECTION_VERSION = exports.USAGE_NAME = exports.OUT_NAME = exports.PEERS_NAME = exports.SECTION_NAME = exports.takeCompactionWarning = exports.takeWarning = exports.endChunk = exports.handleOf = exports.openFactsIndex = void 0;
|
|
37
|
+
// OPENING THE FACTS INDEX AND KNOWING WHETHER A STORED VALUE IS STILL OURS: the
|
|
38
|
+
// section names and schema versions, the fingerprint (package version, config
|
|
39
|
+
// hash, code hash), the handle that is dropped between chunks, and the one warning
|
|
40
|
+
// a run is allowed to carry. What goes into the sections is `fa-store.ts`.
|
|
41
|
+
const fs = __importStar(require("node:fs"));
|
|
42
|
+
const path = __importStar(require("node:path"));
|
|
43
|
+
const index_cache_1 = require("@md-code/utils/node/index-cache");
|
|
44
|
+
const pattern_1 = require("@md-code/follow-architecture/utils/pattern");
|
|
45
|
+
const SECTION_NAME = "fa";
|
|
46
|
+
exports.SECTION_NAME = SECTION_NAME;
|
|
47
|
+
// The file's classified pieces: the bulk of the index, and the one part a run
|
|
48
|
+
// needs about OTHER files only when a rule names a code entity.
|
|
49
|
+
const PEERS_NAME = "fa-peers";
|
|
50
|
+
exports.PEERS_NAME = PEERS_NAME;
|
|
51
|
+
// The verdicts and the summary. One value per file, decoded whole by a warm run.
|
|
52
|
+
const OUT_NAME = "fa-out";
|
|
53
|
+
exports.OUT_NAME = OUT_NAME;
|
|
54
|
+
// The checker's answers (`references`, `implementations`) for the files a run read
|
|
55
|
+
// again. They are statements about EVERY file, so they are asked in a pass of their
|
|
56
|
+
// own, on one project over the whole repo, and kept here by position: the checks
|
|
57
|
+
// then read a number instead of opening a project.
|
|
58
|
+
const USAGE_NAME = "fa-usage";
|
|
59
|
+
exports.USAGE_NAME = USAGE_NAME;
|
|
60
|
+
// The package's own version, read at run time: importing the manifest would make
|
|
61
|
+
// the compiler COPY it into `dist/`, where a self-reference resolves against a
|
|
62
|
+
// second package root and every `@md-code/follow-architecture/…` import breaks.
|
|
63
|
+
let version = null;
|
|
64
|
+
const packageVersion = () => {
|
|
65
|
+
if (version !== null)
|
|
66
|
+
return version;
|
|
67
|
+
version = "0";
|
|
68
|
+
// Compiled: `dist/`, so the manifest is one level up. Run from source (tests,
|
|
69
|
+
// vitest): this file sits in the package root, and the manifest is right here.
|
|
70
|
+
for (const dir of [path.join(__dirname, ".."), __dirname]) {
|
|
71
|
+
const file = path.join(dir, "package.json");
|
|
72
|
+
if (!fs.existsSync(file))
|
|
73
|
+
continue;
|
|
74
|
+
const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
75
|
+
if (parsed.name !== "@md-code/follow-architecture" || typeof parsed.version !== "string")
|
|
76
|
+
continue;
|
|
77
|
+
version = parsed.version;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
return version;
|
|
81
|
+
};
|
|
82
|
+
// Bump when the stored shape changes meaning: every record then reads as stale.
|
|
83
|
+
// 2, 3: a record's `deps` also name the modules its re-exports read from, and
|
|
84
|
+
// only paths the scan covers. 4: a record carries the notices its reading
|
|
85
|
+
// produced, so a run that reads it back repeats them instead of losing them.
|
|
86
|
+
// 5: the findings moved to their own section — a run no longer decodes a record
|
|
87
|
+
// to answer a question about other files. 6: an import/export fact also names the
|
|
88
|
+
// file that DECLARES each name it carries (`declaring`) — a record read back from an
|
|
89
|
+
// older index would answer the barrel law with silence.
|
|
90
|
+
const SECTION_VERSION = 7;
|
|
91
|
+
exports.SECTION_VERSION = SECTION_VERSION;
|
|
92
|
+
// The light section's own schema, bumped on its own: a warm run may keep the
|
|
93
|
+
// records of every file and recompute the verdicts alone.
|
|
94
|
+
const OUT_VERSION = 1;
|
|
95
|
+
exports.OUT_VERSION = OUT_VERSION;
|
|
96
|
+
// The pieces' own schema. Their shape is `Candidate` — the same one a check reads —
|
|
97
|
+
// so this moves only when the section does.
|
|
98
|
+
const PEERS_VERSION = 1;
|
|
99
|
+
exports.PEERS_VERSION = PEERS_VERSION;
|
|
100
|
+
// The usage section's own schema: `{answers, notices}` per file, keyed by the
|
|
101
|
+
// declaration's start position.
|
|
102
|
+
const USAGE_VERSION = 1;
|
|
103
|
+
exports.USAGE_VERSION = USAGE_VERSION;
|
|
104
|
+
// Files handed to one write. The index keeps the values it was given until the
|
|
105
|
+
// handle is dropped, so a run that stored a whole repo at once would hold every
|
|
106
|
+
// record in heap next to the very data it was meant to release. One chunk at a
|
|
107
|
+
// time — flushed, then the handle dropped — bounds that.
|
|
108
|
+
const CHUNK = 500;
|
|
109
|
+
exports.CHUNK = CHUNK;
|
|
110
|
+
// One fingerprint per root and config: the CLI and the rule path run in the same
|
|
111
|
+
// process and must agree, or every run would invalidate the other's records.
|
|
112
|
+
const toolCache = new Map();
|
|
113
|
+
// The compiled package is flat under `dist/` (rootDir "."), so `__dirname` holds
|
|
114
|
+
// the code these facts come from. A source run (vitest) hashes the `.ts` files
|
|
115
|
+
// instead and gets a DIFFERENT fingerprint on purpose: facts built by one are not
|
|
116
|
+
// claimed to be valid for the other.
|
|
117
|
+
let codeHash = null;
|
|
118
|
+
const codeSnapshot = () => {
|
|
119
|
+
if (codeHash === null)
|
|
120
|
+
codeHash = (0, index_cache_1.hashSnapshot)([__dirname], [".js", ".ts"]);
|
|
121
|
+
return codeHash;
|
|
122
|
+
};
|
|
123
|
+
// Everything that changes a finding, hashed: the architecture, the scan scope,
|
|
124
|
+
// and the similarity threshold a "no entity" finding offers folders by. A value
|
|
125
|
+
// that only two callers fill in differently must be normalised here, or the same
|
|
126
|
+
// repo gets two fingerprints — the CLI leaves `similarity` to the rule's default.
|
|
127
|
+
const configSnapshot = (args) => {
|
|
128
|
+
const { arch, scope } = args;
|
|
129
|
+
const raw = {
|
|
130
|
+
arch: arch.raw ?? null,
|
|
131
|
+
aliases: arch.aliases ?? {},
|
|
132
|
+
similarity: arch.similarity ?? pattern_1.DEFAULT_SIMILARITY,
|
|
133
|
+
scope,
|
|
134
|
+
};
|
|
135
|
+
const copy = JSON.parse(JSON.stringify(raw));
|
|
136
|
+
return copy;
|
|
137
|
+
};
|
|
138
|
+
// ONE CONFIG HASH per architecture object and scope. The rule asks for the
|
|
139
|
+
// fingerprint once per linted file, and the snapshot it is taken over deep-copies
|
|
140
|
+
// the whole architecture (every section, shape and rule) and hashes it — thousands
|
|
141
|
+
// of copies of the same bytes in one run (measured: `configSnapshot` alone 1.1 s of a
|
|
142
|
+
// 6:44 products pass, plus the hashing). The architecture object is per (root,
|
|
143
|
+
// config) — the rule path caches it that way — so its IDENTITY is the key; the values
|
|
144
|
+
// that are not in the object travel in the inner key, or a second config block would
|
|
145
|
+
// read the first one's hash.
|
|
146
|
+
const configHashes = new WeakMap();
|
|
147
|
+
const configHashOf = (args) => {
|
|
148
|
+
const key = `${args.root}\u0000${args.arch.similarity ?? pattern_1.DEFAULT_SIMILARITY}\u0000${JSON.stringify(args.scope)}`;
|
|
149
|
+
let perArch = configHashes.get(args.arch);
|
|
150
|
+
if (perArch === undefined) {
|
|
151
|
+
perArch = new Map();
|
|
152
|
+
configHashes.set(args.arch, perArch);
|
|
153
|
+
}
|
|
154
|
+
const known = perArch.get(key);
|
|
155
|
+
if (known !== undefined)
|
|
156
|
+
return known;
|
|
157
|
+
const value = (0, index_cache_1.hashJson)(configSnapshot(args));
|
|
158
|
+
perArch.set(key, value);
|
|
159
|
+
return value;
|
|
160
|
+
};
|
|
161
|
+
const toolFingerprintFor = (args) => {
|
|
162
|
+
const configHash = configHashOf(args);
|
|
163
|
+
const key = `${args.root}\u0000${configHash}`;
|
|
164
|
+
const known = toolCache.get(key);
|
|
165
|
+
if (known !== undefined)
|
|
166
|
+
return known;
|
|
167
|
+
const value = (0, index_cache_1.toolFingerprint)({ version: packageVersion(), configHash, codeHash: codeSnapshot() });
|
|
168
|
+
toolCache.set(key, value);
|
|
169
|
+
return value;
|
|
170
|
+
};
|
|
171
|
+
// The run's index, or null when this run has none (option off, no index file we
|
|
172
|
+
// may use, foreign header root). The caller then stays cold.
|
|
173
|
+
const openFactsIndex = (args) => {
|
|
174
|
+
const first = (0, index_cache_1.openIndexSection)({ root: args.root, option: args.option });
|
|
175
|
+
if (first === null)
|
|
176
|
+
return null;
|
|
177
|
+
// A file this module itself reports as damaged is not a source of facts and not
|
|
178
|
+
// a place to write: one line, then the cold path. Silence would be worse than
|
|
179
|
+
// the slowdown — a damaged index that keeps being read is a wrong answer.
|
|
180
|
+
const issues = first.handle.issues;
|
|
181
|
+
const broken = issues.length > 0;
|
|
182
|
+
return {
|
|
183
|
+
root: args.root,
|
|
184
|
+
option: args.option,
|
|
185
|
+
tool: toolFingerprintFor(args),
|
|
186
|
+
hold: args.hold === true,
|
|
187
|
+
opened: broken ? null : first,
|
|
188
|
+
stamps: new Map(),
|
|
189
|
+
pending: [],
|
|
190
|
+
peers: [],
|
|
191
|
+
out: [],
|
|
192
|
+
usage: [],
|
|
193
|
+
written: 0,
|
|
194
|
+
bytes: 0,
|
|
195
|
+
chunks: 0,
|
|
196
|
+
compactions: 0,
|
|
197
|
+
warning: broken ? `index file ${first.file}: ${issues[0]} — reading cold, not writing` : null,
|
|
198
|
+
warned: broken,
|
|
199
|
+
compactionWarning: null,
|
|
200
|
+
compactionWarned: false,
|
|
201
|
+
refused: broken,
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
exports.openFactsIndex = openFactsIndex;
|
|
205
|
+
const handleOf = (index) => {
|
|
206
|
+
if (index.refused)
|
|
207
|
+
return null;
|
|
208
|
+
if (index.opened !== null)
|
|
209
|
+
return index.opened;
|
|
210
|
+
index.opened = (0, index_cache_1.openIndexSection)({ root: index.root, option: index.option });
|
|
211
|
+
return index.opened;
|
|
212
|
+
};
|
|
213
|
+
exports.handleOf = handleOf;
|
|
214
|
+
// Let the handle go: everything it decoded goes with it. This is what keeps a run
|
|
215
|
+
// from holding the records of every file it has read.
|
|
216
|
+
const endChunk = (index) => {
|
|
217
|
+
if (index.hold)
|
|
218
|
+
return;
|
|
219
|
+
index.opened = null;
|
|
220
|
+
(0, index_cache_1.forgetIndexes)();
|
|
221
|
+
};
|
|
222
|
+
exports.endChunk = endChunk;
|
|
223
|
+
const takeWarning = (index, warning) => {
|
|
224
|
+
if (warning === null)
|
|
225
|
+
return;
|
|
226
|
+
if (index.warned)
|
|
227
|
+
return;
|
|
228
|
+
index.warned = true;
|
|
229
|
+
index.warning = warning;
|
|
230
|
+
};
|
|
231
|
+
exports.takeWarning = takeWarning;
|
|
232
|
+
// A deferred compaction is not a write failure: the records are in the file. One
|
|
233
|
+
// line per run — the same reason for every chunk that hit it.
|
|
234
|
+
const takeCompactionWarning = (index, warning) => {
|
|
235
|
+
if (warning === null)
|
|
236
|
+
return;
|
|
237
|
+
if (index.compactionWarned)
|
|
238
|
+
return;
|
|
239
|
+
index.compactionWarned = true;
|
|
240
|
+
index.compactionWarning = warning;
|
|
241
|
+
};
|
|
242
|
+
exports.takeCompactionWarning = takeCompactionWarning;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Light, type Usage } from "./fa-values";
|
|
2
|
+
import { type Index } from "./fa-open";
|
|
3
|
+
import type { FileRecord } from "@md-code/follow-architecture/facts-record";
|
|
4
|
+
declare const flushChunk: (index: Index) => void;
|
|
5
|
+
declare const keepFacts: (index: Index, file: string, record: FileRecord, light: Light) => boolean;
|
|
6
|
+
declare const keepVerdict: (index: Index, file: string, light: Light) => boolean;
|
|
7
|
+
declare const keepUsage: (index: Index, file: string, usage: Usage) => boolean;
|
|
8
|
+
declare const settle: (index: Index) => void;
|
|
9
|
+
declare const finish: (index: Index) => {
|
|
10
|
+
written: number;
|
|
11
|
+
bytes: number;
|
|
12
|
+
warning: string | null;
|
|
13
|
+
chunks: number;
|
|
14
|
+
compactions: number;
|
|
15
|
+
compactionWarning: string | null;
|
|
16
|
+
};
|
|
17
|
+
declare const compactionLine: (file: string, reason: string) => string;
|
|
18
|
+
declare const prune: (index: Index, keep: readonly string[]) => {
|
|
19
|
+
marked: number;
|
|
20
|
+
dropped: number;
|
|
21
|
+
};
|
|
22
|
+
export { flushChunk, keepFacts, keepVerdict, keepUsage, settle, finish, prune, compactionLine };
|