@lbdudc/linea-core 0.1.0 → 0.1.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/README.md +230 -358
- package/dist/analysis/analyze.d.ts +0 -54
- package/dist/analysis/analyze.js +1 -70
- package/dist/analysis/analyze.js.map +1 -1
- package/dist/analysis/runtime.d.ts +4 -73
- package/dist/analysis/runtime.js +7 -100
- package/dist/analysis/runtime.js.map +1 -1
- package/dist/analysis/uvl-text.d.ts +8 -0
- package/dist/analysis/uvl-text.js +70 -0
- package/dist/analysis/uvl-text.js.map +1 -0
- package/dist/assets.d.ts +0 -12
- package/dist/assets.js +0 -25
- package/dist/assets.js.map +1 -1
- package/dist/ci/annotations.d.ts +6 -0
- package/dist/ci/annotations.js +12 -0
- package/dist/ci/annotations.js.map +1 -0
- package/dist/ci/leftovers.d.ts +25 -0
- package/dist/ci/leftovers.js +50 -0
- package/dist/ci/leftovers.js.map +1 -0
- package/dist/ci/pairwise.d.ts +11 -0
- package/dist/ci/pairwise.js +35 -0
- package/dist/ci/pairwise.js.map +1 -0
- package/dist/ci/pipeline.d.ts +18 -0
- package/dist/ci/pipeline.js +26 -0
- package/dist/ci/pipeline.js.map +1 -0
- package/dist/ci/select.d.ts +28 -0
- package/dist/ci/select.js +43 -0
- package/dist/ci/select.js.map +1 -0
- package/dist/ci/validate-specs.d.ts +52 -0
- package/dist/ci/validate-specs.js +212 -0
- package/dist/ci/validate-specs.js.map +1 -0
- package/dist/constants.d.ts +1 -60
- package/dist/constants.js +1 -58
- package/dist/constants.js.map +1 -1
- package/dist/derivation/derive.d.ts +0 -56
- package/dist/derivation/derive.js +21 -72
- package/dist/derivation/derive.js.map +1 -1
- package/dist/derivation/engine.d.ts +10 -42
- package/dist/derivation/engine.js +37 -68
- package/dist/derivation/engine.js.map +1 -1
- package/dist/derivation/selection-error.d.ts +7 -0
- package/dist/derivation/selection-error.js +13 -0
- package/dist/derivation/selection-error.js.map +1 -0
- package/dist/errors.d.ts +19 -47
- package/dist/errors.js +28 -47
- package/dist/errors.js.map +1 -1
- package/dist/feature-model/uvl.d.ts +52 -0
- package/dist/feature-model/uvl.js +191 -0
- package/dist/feature-model/uvl.js.map +1 -0
- package/dist/fs/archive.d.ts +0 -16
- package/dist/fs/archive.js +0 -36
- package/dist/fs/archive.js.map +1 -1
- package/dist/fs/diff.d.ts +0 -30
- package/dist/fs/diff.js +4 -65
- package/dist/fs/diff.js.map +1 -1
- package/dist/fs/format.d.ts +0 -16
- package/dist/fs/format.js +0 -52
- package/dist/fs/format.js.map +1 -1
- package/dist/fs/workspace.d.ts +0 -52
- package/dist/fs/workspace.js +0 -56
- package/dist/fs/workspace.js.map +1 -1
- package/dist/index.d.ts +23 -29
- package/dist/index.js +15 -35
- package/dist/index.js.map +1 -1
- package/dist/internal/guards.d.ts +0 -13
- package/dist/internal/guards.js +0 -13
- package/dist/internal/guards.js.map +1 -1
- package/dist/line/deletion.d.ts +33 -0
- package/dist/line/deletion.js +23 -0
- package/dist/line/deletion.js.map +1 -0
- package/dist/line/platform-files.d.ts +15 -64
- package/dist/line/platform-files.js +18 -94
- package/dist/line/platform-files.js.map +1 -1
- package/dist/line/restoration.d.ts +27 -0
- package/dist/line/restoration.js +27 -0
- package/dist/line/restoration.js.map +1 -0
- package/dist/line/scaffold.d.ts +26 -57
- package/dist/line/scaffold.js +32 -93
- package/dist/line/scaffold.js.map +1 -1
- package/dist/line/templates/core/extra.js +54 -54
- package/dist/line/templates/core/transformation.js +208 -196
- package/dist/line/templates/pipeline/.gitlab-ci.yml +51 -51
- package/dist/line/templates/pipeline/ci/test-client.sh +16 -16
- package/dist/line/templates/pipeline/ci/test-server.sh +16 -16
- package/dist/line/templates/pipeline/github-ci.yml +50 -0
- package/dist/line/templates/pipeline/spl-gitlab-ci.yml +182 -0
- package/dist/modules/configuration/configure.d.ts +52 -0
- package/dist/modules/configuration/configure.js +101 -0
- package/dist/modules/configuration/configure.js.map +1 -0
- package/dist/modules/configuration/constants.d.ts +17 -0
- package/dist/modules/configuration/constants.js +14 -0
- package/dist/modules/configuration/constants.js.map +1 -0
- package/dist/modules/configuration/index.d.ts +6 -0
- package/dist/modules/configuration/index.js +5 -0
- package/dist/modules/configuration/index.js.map +1 -0
- package/dist/modules/configuration/names.d.ts +9 -0
- package/dist/modules/configuration/names.js +7 -0
- package/dist/modules/configuration/names.js.map +1 -0
- package/dist/modules/configuration/selection.d.ts +32 -0
- package/dist/modules/configuration/selection.js +49 -0
- package/dist/modules/configuration/selection.js.map +1 -0
- package/dist/modules/diagnostics.d.ts +2 -0
- package/dist/modules/diagnostics.js +2 -0
- package/dist/modules/diagnostics.js.map +1 -0
- package/dist/modules/index.d.ts +18 -0
- package/dist/modules/index.js +18 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/metamodels/engine.d.ts +93 -0
- package/dist/modules/metamodels/engine.js +10 -0
- package/dist/modules/metamodels/engine.js.map +1 -0
- package/dist/modules/metamodels/files.d.ts +40 -0
- package/dist/modules/metamodels/files.js +58 -0
- package/dist/modules/metamodels/files.js.map +1 -0
- package/dist/modules/metamodels/index.d.ts +8 -0
- package/dist/modules/metamodels/index.js +5 -0
- package/dist/modules/metamodels/index.js.map +1 -0
- package/dist/modules/metamodels/layout.d.ts +23 -0
- package/dist/modules/metamodels/layout.js +29 -0
- package/dist/modules/metamodels/layout.js.map +1 -0
- package/dist/modules/metamodels/offered.d.ts +15 -0
- package/dist/modules/metamodels/offered.js +14 -0
- package/dist/modules/metamodels/offered.js.map +1 -0
- package/dist/modules/metamodels/prepare.d.ts +20 -0
- package/dist/modules/metamodels/prepare.js +155 -0
- package/dist/modules/metamodels/prepare.js.map +1 -0
- package/dist/modules/packages/index.d.ts +4 -0
- package/dist/modules/packages/index.js +4 -0
- package/dist/modules/packages/index.js.map +1 -0
- package/dist/modules/packages/location.d.ts +21 -0
- package/dist/modules/packages/location.js +34 -0
- package/dist/modules/packages/location.js.map +1 -0
- package/dist/modules/packages/manifests.d.ts +33 -0
- package/dist/modules/packages/manifests.js +231 -0
- package/dist/modules/packages/manifests.js.map +1 -0
- package/dist/modules/packages/source.d.ts +34 -0
- package/dist/modules/packages/source.js +128 -0
- package/dist/modules/packages/source.js.map +1 -0
- package/dist/modules/products/check.d.ts +28 -0
- package/dist/modules/products/check.js +61 -0
- package/dist/modules/products/check.js.map +1 -0
- package/dist/modules/products/derive.d.ts +30 -0
- package/dist/modules/products/derive.js +56 -0
- package/dist/modules/products/derive.js.map +1 -0
- package/dist/modules/products/index.d.ts +5 -0
- package/dist/modules/products/index.js +4 -0
- package/dist/modules/products/index.js.map +1 -0
- package/dist/modules/products/seed.d.ts +18 -0
- package/dist/modules/products/seed.js +23 -0
- package/dist/modules/products/seed.js.map +1 -0
- package/dist/modules/registry/catalog.d.ts +64 -0
- package/dist/modules/registry/catalog.js +91 -0
- package/dist/modules/registry/catalog.js.map +1 -0
- package/dist/modules/registry/index.d.ts +5 -0
- package/dist/modules/registry/index.js +4 -0
- package/dist/modules/registry/index.js.map +1 -0
- package/dist/modules/registry/registry.d.ts +34 -0
- package/dist/modules/registry/registry.js +37 -0
- package/dist/modules/registry/registry.js.map +1 -0
- package/dist/modules/registry/routing.d.ts +8 -0
- package/dist/modules/registry/routing.js +23 -0
- package/dist/modules/registry/routing.js.map +1 -0
- package/dist/modules/resolution/closure.d.ts +28 -0
- package/dist/modules/resolution/closure.js +105 -0
- package/dist/modules/resolution/closure.js.map +1 -0
- package/dist/modules/resolution/index.d.ts +4 -0
- package/dist/modules/resolution/index.js +3 -0
- package/dist/modules/resolution/index.js.map +1 -0
- package/dist/modules/resolution/resolve.d.ts +33 -0
- package/dist/modules/resolution/resolve.js +59 -0
- package/dist/modules/resolution/resolve.js.map +1 -0
- package/dist/modules/resolution/resolvers.d.ts +23 -0
- package/dist/modules/resolution/resolvers.js +34 -0
- package/dist/modules/resolution/resolvers.js.map +1 -0
- package/dist/modules/spl/check.d.ts +25 -0
- package/dist/modules/spl/check.js +21 -0
- package/dist/modules/spl/check.js.map +1 -0
- package/dist/modules/spl/cip.d.ts +67 -0
- package/dist/modules/spl/cip.js +98 -0
- package/dist/modules/spl/cip.js.map +1 -0
- package/dist/modules/spl/feature-model.d.ts +39 -0
- package/dist/modules/spl/feature-model.js +106 -0
- package/dist/modules/spl/feature-model.js.map +1 -0
- package/dist/modules/spl/index.d.ts +6 -0
- package/dist/modules/spl/index.js +4 -0
- package/dist/modules/spl/index.js.map +1 -0
- package/dist/modules/spl/platform.d.ts +49 -0
- package/dist/modules/spl/platform.js +316 -0
- package/dist/modules/spl/platform.js.map +1 -0
- package/dist/modules/types.d.ts +132 -0
- package/dist/modules/types.js +2 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/product/engine-spec.d.ts +0 -16
- package/dist/product/engine-spec.js +4 -50
- package/dist/product/engine-spec.js.map +1 -1
- package/dist/product/spec.d.ts +0 -82
- package/dist/product/spec.js +0 -79
- package/dist/product/spec.js.map +1 -1
- package/dist/product/version.d.ts +0 -23
- package/dist/product/version.js +0 -28
- package/dist/product/version.js.map +1 -1
- package/dist/products-index/products-index.d.ts +0 -165
- package/dist/products-index/products-index.js +0 -176
- package/dist/products-index/products-index.js.map +1 -1
- package/dist/workspace/context.d.ts +25 -0
- package/dist/workspace/context.js +43 -0
- package/dist/workspace/context.js.map +1 -0
- package/dist/workspace/gitExclude.d.ts +2 -0
- package/dist/workspace/gitExclude.js +19 -0
- package/dist/workspace/gitExclude.js.map +1 -0
- package/dist/workspace/host.d.ts +14 -0
- package/dist/workspace/host.js +13 -0
- package/dist/workspace/host.js.map +1 -0
- package/dist/workspace/index.d.ts +12 -0
- package/dist/workspace/index.js +12 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/local.d.ts +81 -0
- package/dist/workspace/local.js +287 -0
- package/dist/workspace/local.js.map +1 -0
- package/dist/workspace/modular.d.ts +95 -0
- package/dist/workspace/modular.js +301 -0
- package/dist/workspace/modular.js.map +1 -0
- package/dist/workspace/operations.d.ts +35 -0
- package/dist/workspace/operations.js +57 -0
- package/dist/workspace/operations.js.map +1 -0
- package/dist/workspace/origin.d.ts +20 -0
- package/dist/workspace/origin.js +19 -0
- package/dist/workspace/origin.js.map +1 -0
- package/package.json +82 -67
- package/dist/feature-model/convert.d.ts +0 -35
- package/dist/feature-model/convert.js +0 -47
- package/dist/feature-model/convert.js.map +0 -1
- package/dist/feature-model/engine.d.ts +0 -60
- package/dist/feature-model/engine.js +0 -139
- package/dist/feature-model/engine.js.map +0 -1
- package/dist/feature-model/inspect.d.ts +0 -67
- package/dist/feature-model/inspect.js +0 -113
- package/dist/feature-model/inspect.js.map +0 -1
- package/dist/feature-model/io.d.ts +0 -66
- package/dist/feature-model/io.js +0 -92
- package/dist/feature-model/io.js.map +0 -1
- package/dist/feature-model/parse.d.ts +0 -30
- package/dist/feature-model/parse.js +0 -36
- package/dist/feature-model/parse.js.map +0 -1
- package/dist/feature-model/text.d.ts +0 -54
- package/dist/feature-model/text.js +0 -126
- package/dist/feature-model/text.js.map +0 -1
- package/dist/line/templates/metamodels/dataModel/extra.js +0 -328
- package/dist/line/templates/metamodels/dataModel/transformation.js +0 -211
- package/dist/line/templates/metamodels/sensor/extra.js +0 -36
- package/dist/line/templates/metamodels/sensor/transformation.js +0 -47
- package/dist/selection/selection.d.ts +0 -126
- package/dist/selection/selection.js +0 -152
- package/dist/selection/selection.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/analysis/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAEhF,OAAO,EAA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,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;IACxD,OAAO,MAAM,GAAG,CAAA;AAClB,CAAC,CAAA;AAED,6DAA6D;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAwB,EAAgB,EAAE;IACnE,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACpD,MAAM,IAAI,oBAAoB,CAAC,gEAAgE,CAAC,CAAA;IAClG,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9B,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,MAAM,IAAI,oBAAoB,CAAC,kDAAkD,CAAC,CAAA;IACpF,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["/**\r\n * The Pyodide/flamapy runtime used for feature model analysis (ADR-021).\r\n *\r\n * Replaces `@lbdudc/flamapy.js`'s own `setupPyodide()`, which calls\r\n * `loadPyodide()` with no options and then `loadPackage('micropip')` — and on a\r\n * cold install that DOWNLOADS `micropip` and `packaging` from\r\n * `cdn.jsdelivr.net`, breaking ADR-002. Worse, with no network it does not\r\n * throw: every operation silently returns `undefined`.\r\n *\r\n * Here both wheels are vendored under `src/analysis/wheels/` and handed to\r\n * pyodide via `packageCacheDir`, so nothing is ever fetched. A canary operation\r\n * proves the bootstrap actually works before the runtime is handed out.\r\n *\r\n * Also replaces the historical `FlamapyWrapper` of the monolith\r\n * (`server/src/utils/flamapyUtils.mjs` before commit ed2e037), which kept a\r\n * module-level `_pyodidePromise` and a module-level `_opQueue`. ADR-014 forbids\r\n * that: the instance AND its serialisation queue live inside a handle the\r\n * CALLER owns.\r\n */\r\nimport fs from 'node:fs'\r\nimport path from 'node:path'\r\nimport { createRequire } from 'node:module'\r\nimport { loadPyodide } from 'pyodide'\r\nimport { executeFlamapyOperation } from '@lbdudc/flamapy.js/lib/python-utils.js'\r\nimport type { PyodideLike } from '@lbdudc/flamapy.js'\r\nimport { resolveAsset } from '../assets.js'\r\nimport { AnalysisRuntimeError, InvalidArgumentError } from '../errors.js'\r\n\r\n/**\r\n * How flamapy is asked to solve an operation.\r\n *\r\n * Declared locally instead of importing `TypeSolving` from\r\n * `@lbdudc/flamapy.js`, and `PyodideHandle` below instead of pyodide's\r\n * `PyodideInterface`, for the reason stated in `feature-model/engine.ts`: no\r\n * `.d.ts` emitted into `dist/` may reference a dependency that ships no types.\r\n * `RuntimeState` is reachable from the public `AnalysisRuntime`, so a\r\n * third-party type in its shape leaks into the published declarations and\r\n * breaks every consumer compiling with `skipLibCheck: false` — which is exactly\r\n * how linea-server and linea-cli are meant to build. Verified by\r\n * `npm run check:consumer`.\r\n */\r\ntype SolvingType = 'basic' | 'pysat' | 'pysat_diagnosis' | 'bdd'\r\n\r\n/** The slice of pyodide's interface this module actually uses. */\r\ninterface PyodideHandle {\r\n FS: unknown\r\n runPythonAsync: (code: string) => Promise<unknown>\r\n loadPackage: (names: string | string[]) => Promise<unknown>\r\n}\r\n\r\ndeclare const analysisRuntimeBrand: unique symbol\r\n\r\n/**\r\n * An initialised analysis runtime.\r\n *\r\n * Opaque: it wraps a Pyodide instance plus the queue that serialises operations\r\n * on it. Create it with `createAnalysisRuntime`, pass it to the analysis\r\n * functions, and release it with `disposeAnalysisRuntime`.\r\n */\r\nexport interface AnalysisRuntime {\r\n readonly [analysisRuntimeBrand]: 'linea-core/AnalysisRuntime'\r\n}\r\n\r\ninterface RuntimeState {\r\n pyodide: PyodideHandle\r\n /**\r\n * Tail of the serialisation chain.\r\n *\r\n * flamapy writes the model to a FIXED path (`uvlfile.uvl`) inside Pyodide's\r\n * virtual filesystem, so two concurrent operations on the same interpreter\r\n * would overwrite each other's input. Every operation queues behind the\r\n * previous one. The queue is per-runtime, never per-module.\r\n */\r\n queue: Promise<void>\r\n disposed: boolean\r\n}\r\n\r\nconst toState = (runtime: AnalysisRuntime): RuntimeState =>\r\n runtime as unknown as RuntimeState\r\n\r\nconst toRuntime = (state: RuntimeState): AnalysisRuntime =>\r\n state as unknown as AnalysisRuntime\r\n\r\n/** Directory holding the vendored wheels (ADR-021). */\r\nconst vendoredWheelsDir = (): string => resolveAsset({ segments: ['analysis', 'wheels'] })\r\n\r\n/**\r\n * The wheels pyodide needs before flamapy can be installed.\r\n *\r\n * Their presence is checked by NAME, not just the directory's, and that check is\r\n * the only thing standing between this module and the network. `packageCacheDir`\r\n * is a CACHE, not an override: on a miss pyodide silently falls back to\r\n * `https://cdn.jsdelivr.net/pyodide/v0.26.2/full/`, downloads the wheel and\r\n * carries on as if nothing happened. Verified — with an empty directory the\r\n * bootstrap SUCCEEDS over the network. So a missing wheel does not degrade the\r\n * runtime, it quietly breaks ADR-002, which is worse: it is a failure that only\r\n * shows up as traffic nobody is watching.\r\n *\r\n * These exact filenames are TIED TO pyodide 0.26.2, which is why `pyodide` is\r\n * pinned exactly in `dependencies` rather than floated. Bumping pyodide means\r\n * re-vendoring the wheels its release expects; if the names stop matching, this\r\n * guard fires and the analysis stops working — loudly, which is the point.\r\n */\r\nconst REQUIRED_WHEELS = ['micropip-0.6.0-py3-none-any.whl', 'packaging-23.2-py3-none-any.whl']\r\n\r\n/** Directory of `@lbdudc/flamapy.js`'s `lib/`, which holds `py/` and its wheels. */\r\nconst flamapyLibDir = (): string => {\r\n const require = createRequire(import.meta.url)\r\n return path.dirname(require.resolve('@lbdudc/flamapy.js/lib/python-utils.js'))\r\n}\r\n\r\n/**\r\n * Directory holding pyodide's own runtime files (`pyodide.asm.wasm`,\r\n * `python_stdlib.zip`, `pyodide-lock.json`).\r\n *\r\n * Passed explicitly rather than left to pyodide's self-location: it derives its\r\n * `indexURL` from its own module URL, which breaks under a bundler or test\r\n * runner that rewrites module paths. Vitest makes it look for\r\n * `node_modules/src/js/pyodide-lock.json`, which does not exist. Resolving from\r\n * the package manifest is stable everywhere.\r\n */\r\nconst pyodideIndexDir = (): string => {\r\n const require = createRequire(import.meta.url)\r\n return path.dirname(require.resolve('pyodide/package.json'))\r\n}\r\n\r\n/** Options for `createAnalysisRuntime`. */\r\nexport interface AnalysisRuntimeOptions {\r\n /**\r\n * Override the directory pyodide loads `micropip`/`packaging` from. Defaults\r\n * to the wheels vendored inside this package; only useful for testing.\r\n */\r\n wheelsDir?: string\r\n}\r\n\r\n/**\r\n * Brings up a Pyodide interpreter with flamapy installed.\r\n *\r\n * Costs roughly 2.3 s, so a caller running several analyses should create ONE\r\n * runtime and reuse it. Everything is read from disk: no network, ever.\r\n *\r\n * Before returning, a canary operation is run. If it fails — or comes back\r\n * `undefined`, which is exactly what a silently broken bootstrap produces — this\r\n * throws instead of handing out a runtime that would report empty metrics\r\n * (ADR-021).\r\n *\r\n * @param options.wheelsDir Optional override of the vendored wheels directory.\r\n * @returns An initialised runtime handle, owned by the caller.\r\n * @throws {AnalysisRuntimeError} when the bootstrap or the canary fails.\r\n */\r\nexport const createAnalysisRuntime = async ({\r\n wheelsDir = vendoredWheelsDir()\r\n}: AnalysisRuntimeOptions = {}): Promise<AnalysisRuntime> => {\r\n if (typeof wheelsDir !== 'string' || wheelsDir.trim() === '') {\r\n throw new InvalidArgumentError('\"wheelsDir\" must be a non-empty path when provided.')\r\n }\r\n if (!fs.existsSync(wheelsDir)) {\r\n throw new AnalysisRuntimeError(\r\n `Vendored wheels directory not found: ${wheelsDir}. The package build must copy src/analysis/wheels/ into dist/.`\r\n )\r\n }\r\n // Checked BEFORE booting pyodide, because after that it is too late: a missing\r\n // wheel is fetched from the CDN and the bootstrap succeeds online. See\r\n // REQUIRED_WHEELS. This is the guard ADR-002 actually rests on.\r\n const missing = REQUIRED_WHEELS.filter(\r\n (wheel) => !fs.existsSync(path.join(wheelsDir, wheel))\r\n )\r\n if (missing.length > 0) {\r\n throw new AnalysisRuntimeError(\r\n `Vendored wheels missing from ${wheelsDir}: ${missing.join(', ')}. ` +\r\n 'Without them pyodide would silently download them from cdn.jsdelivr.net, breaking ADR-002.'\r\n )\r\n }\r\n\r\n const libDir = flamapyLibDir()\r\n let pyodide: PyodideHandle\r\n try {\r\n pyodide = await loadPyodide({\r\n indexURL: pyodideIndexDir(),\r\n packageCacheDir: wheelsDir\r\n })\r\n // pyodide types `FS` as `any`; narrow it to just what is used here.\r\n const vfs = pyodide.FS as {\r\n mkdirTree: (dir: string) => void\r\n mount: (fs: unknown, options: { root: string }, mountpoint: string) => void\r\n filesystems: { NODEFS: unknown }\r\n }\r\n vfs.mkdirTree('/mnt')\r\n vfs.mount(vfs.filesystems.NODEFS, { root: libDir }, '/mnt')\r\n await pyodide.loadPackage('micropip')\r\n await pyodide.runPythonAsync(fs.readFileSync(path.join(libDir, 'py', 'packages.py'), 'utf8'))\r\n await pyodide.runPythonAsync('await install_packages()')\r\n } catch (error) {\r\n throw new AnalysisRuntimeError(\r\n `Could not start the feature model analysis runtime: ${error instanceof Error ? error.message : String(error)}`,\r\n { cause: error }\r\n )\r\n }\r\n\r\n const state: RuntimeState = { pyodide, queue: Promise.resolve(), disposed: false }\r\n\r\n // ── Canary (ADR-021) ───────────────────────────────────────────────────────\r\n // flamapy.js swallows bootstrap failures: `loadAndRunPythonScript` catches and\r\n // only console.errors, and `install_packages()` has its own bare `except`. The\r\n // result is every operation returning `undefined` with no error at all. This\r\n // proves the stack really works before the runtime escapes.\r\n const CANARY_UVL = 'features\\n Root\\n mandatory\\n A\\n B\\n'\r\n let canary: unknown\r\n try {\r\n canary = await runOperation(state, 'core_features', CANARY_UVL, 'basic')\r\n } catch (error) {\r\n throw new AnalysisRuntimeError(\r\n `The analysis runtime started but its canary operation failed: ${error instanceof Error ? error.message : String(error)}`,\r\n { cause: error }\r\n )\r\n }\r\n if (!Array.isArray(canary) || canary.length === 0) {\r\n throw new AnalysisRuntimeError(\r\n 'The analysis runtime started but returned no result for its canary operation. ' +\r\n 'This is the signature of a Pyodide bootstrap that failed silently — most likely the ' +\r\n 'vendored micropip/packaging wheels are missing, so flamapy never installed (ADR-021).'\r\n )\r\n }\r\n\r\n return toRuntime(state)\r\n}\r\n\r\n/**\r\n * Retires a runtime handle.\r\n *\r\n * IT DOES NOT FREE MEMORY, and callers must plan around that. Pyodide exposes no\r\n * teardown, so the ~180 MB WASM heap an interpreter holds stays allocated for\r\n * the life of the process; all this does is mark the handle unusable so later\r\n * analyses fail loudly instead of running on a half-torn-down interpreter.\r\n *\r\n * The practical consequence for linea-server: do NOT create a runtime per\r\n * request. Create a small, long-lived set of them and reuse. Creating and\r\n * disposing per request leaks an interpreter's worth of memory every time.\r\n *\r\n * Idempotent.\r\n *\r\n * @param params.runtime The runtime to retire.\r\n */\r\nexport const disposeAnalysisRuntime = ({ runtime }: { runtime: AnalysisRuntime }): void => {\r\n if (runtime === null || typeof runtime !== 'object') {\r\n throw new InvalidArgumentError('\"runtime\" must be a value returned by createAnalysisRuntime().')\r\n }\r\n const state = toState(runtime)\r\n state.disposed = true\r\n}\r\n\r\n/** Converts a Pyodide proxy into plain JavaScript, mirroring flamapy's `pythonToJs`. */\r\nconst toJs = (value: unknown): unknown => {\r\n if (value === null || typeof value !== 'object') return value\r\n const proxy = value as { toJs?: (options: { dicts: boolean }) => unknown, destroy?: () => void }\r\n if (typeof proxy.toJs !== 'function') return value\r\n const converted = proxy.toJs({ dicts: true })\r\n proxy.destroy?.()\r\n return converted\r\n}\r\n\r\n/**\r\n * Runs one flamapy operation on a runtime, serialised behind any previous one.\r\n *\r\n * INTERNAL. `operation` is a `FLAMAFeatureModel` method name for `'basic'`, or\r\n * the suffix of a `PySAT*`/`BDD*` operation otherwise.\r\n */\r\nexport const runOperation = async (\r\n state: RuntimeState,\r\n operation: string,\r\n uvl: string,\r\n type: SolvingType\r\n): Promise<unknown> => {\r\n if (state.disposed) {\r\n throw new AnalysisRuntimeError('This analysis runtime has already been disposed.')\r\n }\r\n const run = state.queue.then(async () =>\r\n toJs(await executeFlamapyOperation(\r\n state.pyodide as unknown as PyodideLike,\r\n operation,\r\n uvl,\r\n [],\r\n {},\r\n type\r\n ))\r\n )\r\n // Advance the chain even when this operation rejects, or one failure would\r\n // deadlock every later operation on the runtime.\r\n state.queue = run.then(() => undefined, () => undefined)\r\n return await run\r\n}\r\n\r\n/** INTERNAL: unwraps a handle for the analysis functions. */\r\nexport const useRuntime = (runtime: AnalysisRuntime): RuntimeState => {\r\n if (runtime === null || typeof runtime !== 'object') {\r\n throw new InvalidArgumentError('\"runtime\" must be a value returned by createAnalysisRuntime().')\r\n }\r\n const state = toState(runtime)\r\n if (state.disposed) {\r\n throw new AnalysisRuntimeError('This analysis runtime has already been disposed.')\r\n }\r\n return state\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/analysis/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAEhF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAsBzE,MAAM,OAAO,GAAG,CAAC,OAAwB,EAAgB,EAAE,CACzD,OAAkC,CAAA;AAEpC,MAAM,SAAS,GAAG,CAAC,KAAmB,EAAmB,EAAE,CACzD,KAAmC,CAAA;AAErC,MAAM,iBAAiB,GAAG,GAAW,EAAE,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAA;AAE1F,MAAM,eAAe,GAAG,CAAC,iCAAiC,EAAE,iCAAiC,CAAC,CAAA;AAE9F,MAAM,aAAa,GAAG,GAAW,EAAE;IACjC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC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E,CAAA;IACjB,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,KAAmB,EACnB,SAAiB,EACjB,GAAW,EACX,IAAiB,EACC,EAAE;IACpB,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,MAAM,IAAI,oBAAoB,CAAC,kDAAkD,CAAC,CAAA;IACpF,CAAC;IACD,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CACtC,IAAI,CAAC,MAAM,uBAAuB,CAChC,KAAK,CAAC,OAAiC,EACvC,SAAS,EACT,GAAG,EACH,EAAE,EACF,EAAE,EACF,IAAI,CACL,CAAC,CACH,CAAA;IACD,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;IACxD,OAAO,MAAM,GAAG,CAAA;AAClB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAwB,EAAgB,EAAE;IACnE,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACpD,MAAM,IAAI,oBAAoB,CAAC,gEAAgE,CAAC,CAAA;IAClG,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9B,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,MAAM,IAAI,oBAAoB,CAAC,kDAAkD,CAAC,CAAA;IACpF,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport { createRequire } from 'node:module'\nimport { loadPyodide } from 'pyodide'\nimport { executeFlamapyOperation } from '@lbdudc/flamapy.js/lib/python-utils.js'\nimport type { PyodideLike } from '@lbdudc/flamapy.js'\nimport { resolveAsset } from '../assets.js'\nimport { AnalysisRuntimeError, InvalidArgumentError } from '../errors.js'\n\ntype SolvingType = 'basic' | 'pysat' | 'pysat_diagnosis' | 'bdd'\n\ninterface PyodideHandle {\n FS: unknown\n runPythonAsync: (code: string) => Promise<unknown>\n loadPackage: (names: string | string[], options?: { messageCallback?: (m: string) => void; errorCallback?: (m: string) => void }) => Promise<unknown>\n}\n\ndeclare const analysisRuntimeBrand: unique symbol\n\nexport interface AnalysisRuntime {\n readonly [analysisRuntimeBrand]: 'linea-core/AnalysisRuntime'\n}\n\ninterface RuntimeState {\n pyodide: PyodideHandle\n queue: Promise<void>\n disposed: boolean\n}\n\nconst toState = (runtime: AnalysisRuntime): RuntimeState =>\n runtime as unknown as RuntimeState\n\nconst toRuntime = (state: RuntimeState): AnalysisRuntime =>\n state as unknown as AnalysisRuntime\n\nconst vendoredWheelsDir = (): string => resolveAsset({ segments: ['analysis', 'wheels'] })\n\nconst REQUIRED_WHEELS = ['micropip-0.6.0-py3-none-any.whl', 'packaging-23.2-py3-none-any.whl']\n\nconst flamapyLibDir = (): string => {\n const require = createRequire(import.meta.url)\n return path.dirname(require.resolve('@lbdudc/flamapy.js/lib/python-utils.js'))\n}\n\n/** Pyodide's own chatter is not for the output of a program that uses this. */\nconst silent = (): void => { /* nothing */ }\n\nconst pyodideIndexDir = (): string => {\n const require = createRequire(import.meta.url)\n return path.dirname(require.resolve('pyodide/package.json'))\n}\n\nexport interface AnalysisRuntimeOptions {\n wheelsDir?: string\n}\n\nexport const createAnalysisRuntime = async ({\n wheelsDir = vendoredWheelsDir()\n}: AnalysisRuntimeOptions = {}): Promise<AnalysisRuntime> => {\n if (typeof wheelsDir !== 'string' || wheelsDir.trim() === '') {\n throw new InvalidArgumentError('\"wheelsDir\" must be a non-empty path when provided.')\n }\n if (!fs.existsSync(wheelsDir)) {\n throw new AnalysisRuntimeError(\n `Vendored wheels directory not found: ${wheelsDir}. The package build must copy src/analysis/wheels/ into dist/.`\n )\n }\n const missing = REQUIRED_WHEELS.filter(\n (wheel) => !fs.existsSync(path.join(wheelsDir, wheel))\n )\n if (missing.length > 0) {\n throw new AnalysisRuntimeError(\n `Vendored wheels missing from ${wheelsDir}: ${missing.join(', ')}. ` +\n 'Without them pyodide would silently download them from cdn.jsdelivr.net, breaking ADR-002.'\n )\n }\n\n const libDir = flamapyLibDir()\n let pyodide: PyodideHandle\n try {\n pyodide = await loadPyodide({\n indexURL: pyodideIndexDir(),\n packageCacheDir: wheelsDir,\n // what pyodide says while it loads packages is not for the output of a program that uses this (a CLI's --json)\n stdout: silent,\n stderr: silent\n })\n const vfs = pyodide.FS as {\n mkdirTree: (dir: string) => void\n mount: (fs: unknown, options: { root: string }, mountpoint: string) => void\n filesystems: { NODEFS: unknown }\n }\n vfs.mkdirTree('/mnt')\n vfs.mount(vfs.filesystems.NODEFS, { root: libDir }, '/mnt')\n await pyodide.loadPackage('micropip', { messageCallback: silent, errorCallback: silent })\n await pyodide.runPythonAsync(fs.readFileSync(path.join(libDir, 'py', 'packages.py'), 'utf8'))\n await pyodide.runPythonAsync('await install_packages()')\n } catch (error) {\n throw new AnalysisRuntimeError(\n `Could not start the feature model analysis runtime: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n )\n }\n\n const state: RuntimeState = { pyodide, queue: Promise.resolve(), disposed: false }\n\n const CANARY_UVL = 'features\\n Root\\n mandatory\\n A\\n B\\n'\n let canary: unknown\n try {\n canary = await runOperation(state, 'core_features', CANARY_UVL, 'basic')\n } catch (error) {\n throw new AnalysisRuntimeError(\n `The analysis runtime started but its canary operation failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n )\n }\n if (!Array.isArray(canary) || canary.length === 0) {\n throw new AnalysisRuntimeError(\n 'The analysis runtime started but returned no result for its canary operation. ' +\n 'This is the signature of a Pyodide bootstrap that failed silently — most likely the ' +\n 'vendored micropip/packaging wheels are missing, so flamapy never installed (ADR-021).'\n )\n }\n\n return toRuntime(state)\n}\n\nexport const disposeAnalysisRuntime = ({ runtime }: { runtime: AnalysisRuntime }): void => {\n if (runtime === null || typeof runtime !== 'object') {\n throw new InvalidArgumentError('\"runtime\" must be a value returned by createAnalysisRuntime().')\n }\n const state = toState(runtime)\n state.disposed = true\n}\n\nconst toJs = (value: unknown): unknown => {\n if (value === null || typeof value !== 'object') return value\n const proxy = value as { toJs?: (options: { dicts: boolean }) => unknown, destroy?: () => void }\n if (typeof proxy.toJs !== 'function') return value\n const converted = proxy.toJs({ dicts: true })\n proxy.destroy?.()\n return converted\n}\n\nexport const runOperation = async (\n state: RuntimeState,\n operation: string,\n uvl: string,\n type: SolvingType\n): Promise<unknown> => {\n if (state.disposed) {\n throw new AnalysisRuntimeError('This analysis runtime has already been disposed.')\n }\n const run = state.queue.then(async () =>\n toJs(await executeFlamapyOperation(\n state.pyodide as unknown as PyodideLike,\n operation,\n uvl,\n [],\n {},\n type\n ))\n )\n state.queue = run.then(() => undefined, () => undefined)\n return await run\n}\n\nexport const useRuntime = (runtime: AnalysisRuntime): RuntimeState => {\n if (runtime === null || typeof runtime !== 'object') {\n throw new InvalidArgumentError('\"runtime\" must be a value returned by createAnalysisRuntime().')\n }\n const state = toState(runtime)\n if (state.disposed) {\n throw new AnalysisRuntimeError('This analysis runtime has already been disposed.')\n }\n return state\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The UVL with its tabs as spaces and its line breaks unified, as the analysis service reads it. */
|
|
2
|
+
export declare const normalizeUvl: ({ uvl }: {
|
|
3
|
+
uvl: string;
|
|
4
|
+
}) => string;
|
|
5
|
+
/** About how many features a UVL text declares: what decides how much of the analysis is worth asking for. */
|
|
6
|
+
export declare const estimateFeatureCount: ({ uvl }: {
|
|
7
|
+
uvl: string;
|
|
8
|
+
}) => number;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { InvalidArgumentError } from '../errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* What the flamapy analysis needs of the UVL text it is given. (The feature model itself is bango's: a model of the feature metamodel, which
|
|
4
|
+
* `printUvl` writes as UVL; these only prepare that text for the analysis service.)
|
|
5
|
+
*/
|
|
6
|
+
const UVL_GROUP_KEYWORDS = new Set([
|
|
7
|
+
'mandatory',
|
|
8
|
+
'optional',
|
|
9
|
+
'alternative',
|
|
10
|
+
'or',
|
|
11
|
+
'features',
|
|
12
|
+
'constraints'
|
|
13
|
+
]);
|
|
14
|
+
const assertUvlString = (uvl, parameter) => {
|
|
15
|
+
if (typeof uvl !== 'string') {
|
|
16
|
+
throw new InvalidArgumentError(`"${parameter}" must be a string.`);
|
|
17
|
+
}
|
|
18
|
+
return uvl;
|
|
19
|
+
};
|
|
20
|
+
const expandTabs = (line, tabSize = 4) => {
|
|
21
|
+
let out = '';
|
|
22
|
+
let column = 0;
|
|
23
|
+
for (const char of line) {
|
|
24
|
+
if (char === '\t') {
|
|
25
|
+
const width = tabSize - (column % tabSize);
|
|
26
|
+
out += ' '.repeat(width);
|
|
27
|
+
column += width;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
out += char;
|
|
31
|
+
column += 1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
};
|
|
36
|
+
/** The UVL with its tabs as spaces and its line breaks unified, as the analysis service reads it. */
|
|
37
|
+
export const normalizeUvl = ({ uvl }) => {
|
|
38
|
+
const unified = assertUvlString(uvl, 'uvl').trim().replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
39
|
+
return unified
|
|
40
|
+
.split('\n')
|
|
41
|
+
.map((line) => expandTabs(line, 4))
|
|
42
|
+
.join('\n');
|
|
43
|
+
};
|
|
44
|
+
/** About how many features a UVL text declares: what decides how much of the analysis is worth asking for. */
|
|
45
|
+
export const estimateFeatureCount = ({ uvl }) => {
|
|
46
|
+
const document = assertUvlString(uvl, 'uvl');
|
|
47
|
+
let inConstraints = false;
|
|
48
|
+
let count = 0;
|
|
49
|
+
for (const line of document.split('\n')) {
|
|
50
|
+
const trimmed = line.trim();
|
|
51
|
+
if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('#'))
|
|
52
|
+
continue;
|
|
53
|
+
if (trimmed === 'constraints') {
|
|
54
|
+
inConstraints = true;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (inConstraints)
|
|
58
|
+
continue;
|
|
59
|
+
if (trimmed === 'features')
|
|
60
|
+
continue;
|
|
61
|
+
const indent = line.length - line.trimStart().length;
|
|
62
|
+
if (indent >= 2) {
|
|
63
|
+
const name = trimmed.split(/[\s{[]/)[0];
|
|
64
|
+
if (name && !UVL_GROUP_KEYWORDS.has(name))
|
|
65
|
+
count += 1;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return count;
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=uvl-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uvl-text.js","sourceRoot":"","sources":["../../src/analysis/uvl-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnD;;;GAGG;AAEH,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IACtD,WAAW;IACX,UAAU;IACV,aAAa;IACb,IAAI;IACJ,UAAU;IACV,aAAa;CACd,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,CAAC,GAAY,EAAE,SAAiB,EAAU,EAAE;IAClE,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,oBAAoB,CAAC,IAAI,SAAS,qBAAqB,CAAC,CAAA;IACpE,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,OAAO,GAAG,CAAC,EAAU,EAAE;IACvD,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,IAAI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U,CAAC,GAAG,CAAC;YAAE,SAAQ;QAC7E,IAAI,OAAO,KAAK,aAAa,EAAE,CAAC;YAC9B,aAAa,GAAG,IAAI,CAAA;YACpB,SAAQ;QACV,CAAC;QACD,IAAI,aAAa;YAAE,SAAQ;QAC3B,IAAI,OAAO,KAAK,UAAU;YAAE,SAAQ;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAA;QACpD,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;YAChB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;YACvC,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,KAAK,IAAI,CAAC,CAAA;QACvD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { InvalidArgumentError } from '../errors.js'\n\n/**\n * What the flamapy analysis needs of the UVL text it is given. (The feature model itself is bango's: a model of the feature metamodel, which\n * `printUvl` writes as UVL; these only prepare that text for the analysis service.)\n */\n\nconst UVL_GROUP_KEYWORDS: ReadonlySet<string> = new Set([\n 'mandatory',\n 'optional',\n 'alternative',\n 'or',\n 'features',\n 'constraints'\n])\n\nconst assertUvlString = (uvl: unknown, parameter: string): string => {\n if (typeof uvl !== 'string') {\n throw new InvalidArgumentError(`\"${parameter}\" must be a string.`)\n }\n return uvl\n}\n\nconst expandTabs = (line: string, tabSize = 4): string => {\n let out = ''\n let column = 0\n for (const char of line) {\n if (char === '\\t') {\n const width = tabSize - (column % tabSize)\n out += ' '.repeat(width)\n column += width\n } else {\n out += char\n column += 1\n }\n }\n return out\n}\n\n/** The UVL with its tabs as spaces and its line breaks unified, as the analysis service reads it. */\nexport const normalizeUvl = ({ uvl }: { uvl: string }): string => {\n const unified = assertUvlString(uvl, 'uvl').trim().replace(/\\r\\n/g, '\\n').replace(/\\r/g, '\\n')\n return unified\n .split('\\n')\n .map((line) => expandTabs(line, 4))\n .join('\\n')\n}\n\n/** About how many features a UVL text declares: what decides how much of the analysis is worth asking for. */\nexport const estimateFeatureCount = ({ uvl }: { uvl: string }): number => {\n const document = assertUvlString(uvl, 'uvl')\n let inConstraints = false\n let count = 0\n for (const line of document.split('\\n')) {\n const trimmed = line.trim()\n if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('#')) continue\n if (trimmed === 'constraints') {\n inConstraints = true\n continue\n }\n if (inConstraints) continue\n if (trimmed === 'features') continue\n const indent = line.length - line.trimStart().length\n if (indent >= 2) {\n const name = trimmed.split(/[\\s{[]/)[0]\n if (name && !UVL_GROUP_KEYWORDS.has(name)) count += 1\n }\n }\n return count\n}\n"]}
|
package/dist/assets.d.ts
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Directory holding the packaged assets: `src/` when running from source,
|
|
3
|
-
* `dist/` when running from the published package.
|
|
4
|
-
*/
|
|
5
1
|
export declare const assetsRoot: () => string;
|
|
6
|
-
/**
|
|
7
|
-
* Resolves the absolute path of an asset shipped with linea-core.
|
|
8
|
-
*
|
|
9
|
-
* @param params.segments Path segments relative to the assets root,
|
|
10
|
-
* e.g. `resolveAsset({ segments: ['line', 'templates', 'config.json'] })`.
|
|
11
|
-
* @returns Absolute path of the asset.
|
|
12
|
-
* @throws {InvalidArgumentError} if `segments` is not an array of strings.
|
|
13
|
-
*/
|
|
14
2
|
export declare const resolveAsset: ({ segments }: {
|
|
15
3
|
segments: string[];
|
|
16
4
|
}) => string;
|
package/dist/assets.js
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolution of assets packaged with the library.
|
|
3
|
-
*
|
|
4
|
-
* Non-TypeScript files under `src/` (line templates, pipeline files...) are not
|
|
5
|
-
* compiled: `scripts/copy-assets.mjs` mirrors them into `dist/` at build time,
|
|
6
|
-
* preserving their relative path. That means `src/line/templates/x` ends up at
|
|
7
|
-
* `dist/line/templates/x`, so the path relative to THIS module is the same
|
|
8
|
-
* before and after the build.
|
|
9
|
-
*
|
|
10
|
-
* Resolution goes through `import.meta.url` and never through `process.cwd()`:
|
|
11
|
-
* linea-core is a library and must work regardless of where the host process was
|
|
12
|
-
* started from (ADR-014).
|
|
13
|
-
*/
|
|
14
1
|
import path from 'node:path';
|
|
15
2
|
import { fileURLToPath } from 'node:url';
|
|
16
3
|
import { InvalidArgumentError } from './errors.js';
|
|
17
|
-
/**
|
|
18
|
-
* Directory holding the packaged assets: `src/` when running from source,
|
|
19
|
-
* `dist/` when running from the published package.
|
|
20
|
-
*/
|
|
21
4
|
export const assetsRoot = () => path.dirname(fileURLToPath(import.meta.url));
|
|
22
|
-
/**
|
|
23
|
-
* Resolves the absolute path of an asset shipped with linea-core.
|
|
24
|
-
*
|
|
25
|
-
* @param params.segments Path segments relative to the assets root,
|
|
26
|
-
* e.g. `resolveAsset({ segments: ['line', 'templates', 'config.json'] })`.
|
|
27
|
-
* @returns Absolute path of the asset.
|
|
28
|
-
* @throws {InvalidArgumentError} if `segments` is not an array of strings.
|
|
29
|
-
*/
|
|
30
5
|
export const resolveAsset = ({ segments }) => {
|
|
31
6
|
if (!Array.isArray(segments) || segments.some((segment) => typeof segment !== 'string')) {
|
|
32
7
|
throw new InvalidArgumentError('"segments" must be an array of strings.');
|
package/dist/assets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,MAAM,CAAC,MAAM,UAAU,GAAG,GAAW,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAEpF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAA0B,EAAU,EAAE;IAC3E,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,EAAE,CAAC;QACxF,MAAM,IAAI,oBAAoB,CAAC,yCAAyC,CAAC,CAAA;IAC3E,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,GAAG,QAAQ,CAAC,CAAA;AAC7C,CAAC,CAAA","sourcesContent":["import path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { InvalidArgumentError } from './errors.js'\n\nexport const assetsRoot = (): string => path.dirname(fileURLToPath(import.meta.url))\n\nexport const resolveAsset = ({ segments }: { segments: string[] }): string => {\n if (!Array.isArray(segments) || segments.some((segment) => typeof segment !== 'string')) {\n throw new InvalidArgumentError('\"segments\" must be an array of strings.')\n }\n return path.join(assetsRoot(), ...segments)\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** What an SPL's annotated code mentions: for each file (relative to `src/platform/code`) the features it tests and how many times. */
|
|
2
|
+
export type FeaturesByFile = Record<string, Record<string, number>>;
|
|
3
|
+
/** The features each file of the SPL's annotated code depends on, read from its annotations (no product is derived). */
|
|
4
|
+
export declare const analyzeAnnotations: ({ lineDir }: {
|
|
5
|
+
lineDir: string;
|
|
6
|
+
}) => Promise<FeaturesByFile>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createEngine } from '../derivation/engine.js';
|
|
2
|
+
/** The features each file of the SPL's annotated code depends on, read from its annotations (no product is derived). */
|
|
3
|
+
export const analyzeAnnotations = async ({ lineDir }) => {
|
|
4
|
+
const engine = await createEngine(lineDir);
|
|
5
|
+
const report = await engine.analyseAnnotations();
|
|
6
|
+
const byFile = {};
|
|
7
|
+
for (const [file, result] of Object.entries(report.long())) {
|
|
8
|
+
byFile[file.split('\\').join('/').replace(/^\.?\//, '')] = { ...(result.feature ?? {}) };
|
|
9
|
+
}
|
|
10
|
+
return byFile;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=annotations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../src/ci/annotations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAStD,wHAAwH;AACxH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,EAAE,OAAO,EAAuB,EAA2B,EAAE;IACpG,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,CAA2E,CAAA;IACpH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,kBAAkB,EAAE,CAAA;IAChD,MAAM,MAAM,GAAmB,EAAE,CAAA;IACjC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAC3D,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAA;IAC1F,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { createEngine } from '../derivation/engine.js'\n\n/** What an SPL's annotated code mentions: for each file (relative to `src/platform/code`) the features it tests and how many times. */\nexport type FeaturesByFile = Record<string, Record<string, number>>\n\ninterface AnalysisReportHandle {\n long: () => Record<string, { feature?: Record<string, number> }>\n}\n\n/** The features each file of the SPL's annotated code depends on, read from its annotations (no product is derived). */\nexport const analyzeAnnotations = async ({ lineDir }: { lineDir: string }): Promise<FeaturesByFile> => {\n const engine = await createEngine(lineDir) as unknown as { analyseAnnotations: () => Promise<AnalysisReportHandle> }\n const report = await engine.analyseAnnotations()\n const byFile: FeaturesByFile = {}\n for (const [file, result] of Object.entries(report.long())) {\n byFile[file.split('\\\\').join('/').replace(/^\\.?\\//, '')] = { ...(result.feature ?? {}) }\n }\n return byFile\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** The annotation delimiters of an SPL, as its platform `config.json` declares them. */
|
|
2
|
+
export interface LeftoverDelimiters {
|
|
3
|
+
readonly delimiters: readonly {
|
|
4
|
+
readonly start: string;
|
|
5
|
+
readonly end: string;
|
|
6
|
+
}[];
|
|
7
|
+
readonly ignore?: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
export interface Leftover {
|
|
10
|
+
/** Path relative to the checked directory, with forward slashes. */
|
|
11
|
+
readonly file: string;
|
|
12
|
+
readonly line: number;
|
|
13
|
+
readonly delimiter: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Annotation delimiters that survived derivation: a generated product must not contain any. Every delimiter of the line is looked
|
|
17
|
+
* for in every text file, not only in the extensions it is declared for, because an annotation written in a file type the engine
|
|
18
|
+
* does not process for it comes out untouched (a `/*% ... %*\/` in a `.json`, where only `###< >###` is processed).
|
|
19
|
+
*/
|
|
20
|
+
export declare const checkLeftovers: ({ productDir, config, exclude }: {
|
|
21
|
+
productDir: string;
|
|
22
|
+
config: LeftoverDelimiters;
|
|
23
|
+
/** Paths relative to `productDir` that are allowed to contain delimiters. */
|
|
24
|
+
exclude?: readonly string[];
|
|
25
|
+
}) => Leftover[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { InvalidArgumentError } from '../errors.js';
|
|
4
|
+
const ALWAYS_SKIPPED = new Set(['.git', 'node_modules']);
|
|
5
|
+
const isBinary = (content) => content.subarray(0, 8000).includes(0);
|
|
6
|
+
const walk = (dir, skipped, visit) => {
|
|
7
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
8
|
+
if (skipped.has(entry.name))
|
|
9
|
+
continue;
|
|
10
|
+
const full = path.join(dir, entry.name);
|
|
11
|
+
if (entry.isDirectory())
|
|
12
|
+
walk(full, skipped, visit);
|
|
13
|
+
else if (entry.isFile())
|
|
14
|
+
visit(full);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Annotation delimiters that survived derivation: a generated product must not contain any. Every delimiter of the line is looked
|
|
19
|
+
* for in every text file, not only in the extensions it is declared for, because an annotation written in a file type the engine
|
|
20
|
+
* does not process for it comes out untouched (a `/*% ... %*\/` in a `.json`, where only `###< >###` is processed).
|
|
21
|
+
*/
|
|
22
|
+
export const checkLeftovers = ({ productDir, config, exclude = [] }) => {
|
|
23
|
+
if (typeof productDir !== 'string' || productDir.trim() === '') {
|
|
24
|
+
throw new InvalidArgumentError('"productDir" must be a non-empty path.');
|
|
25
|
+
}
|
|
26
|
+
const root = path.resolve(productDir);
|
|
27
|
+
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {
|
|
28
|
+
throw new InvalidArgumentError(`"productDir" is not a directory: ${root}`);
|
|
29
|
+
}
|
|
30
|
+
const markers = [...new Set(config.delimiters.flatMap(({ start, end }) => [start, end]))]
|
|
31
|
+
.filter((marker) => marker !== '');
|
|
32
|
+
const skipped = new Set([...ALWAYS_SKIPPED, ...(config.ignore ?? [])]);
|
|
33
|
+
const excluded = new Set(exclude);
|
|
34
|
+
const found = [];
|
|
35
|
+
walk(root, skipped, (file) => {
|
|
36
|
+
const relative = path.relative(root, file).split(path.sep).join('/');
|
|
37
|
+
if (excluded.has(relative))
|
|
38
|
+
return;
|
|
39
|
+
const content = fs.readFileSync(file);
|
|
40
|
+
if (isBinary(content))
|
|
41
|
+
return;
|
|
42
|
+
content.toString('utf8').split('\n').forEach((text, index) => {
|
|
43
|
+
const delimiter = markers.find((marker) => text.includes(marker));
|
|
44
|
+
if (delimiter !== undefined)
|
|
45
|
+
found.push({ file: relative, line: index + 1, delimiter });
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return found.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line);
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=leftovers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leftovers.js","sourceRoot":"","sources":["../../src/ci/leftovers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAenD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;AAExD,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAW,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AAEpF,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,OAA4B,EAAE,KAA6B,EAAQ,EAAE;IAC9F,KAAK,MAAM,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QACjE,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,SAAQ;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;QACvC,IAAI,KAAK,CAAC,WAAW,EAAE;YAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;aAC9C,IAAI,K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GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACpE,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;YAAE,OAAM;QAClC,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QACrC,IAAI,QAAQ,CAAC,OAAO,CAAC;YAAE,OAAM;QAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YAC3D,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;YACjE,IAAI,SAAS,KAAK,SAAS;gBAAE,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,CAAA;QACzF,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAA;AAC9E,CAAC,CAAA","sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport { InvalidArgumentError } from '../errors.js'\n\n/** The annotation delimiters of an SPL, as its platform `config.json` declares them. */\nexport interface LeftoverDelimiters {\n readonly delimiters: readonly { readonly start: string, readonly end: string }[]\n readonly ignore?: readonly string[]\n}\n\nexport interface Leftover {\n /** Path relative to the checked directory, with forward slashes. */\n readonly file: string\n readonly line: number\n readonly delimiter: string\n}\n\nconst ALWAYS_SKIPPED = new Set(['.git', 'node_modules'])\n\nconst isBinary = (content: Buffer): boolean => content.subarray(0, 8000).includes(0)\n\nconst walk = (dir: string, skipped: ReadonlySet<string>, visit: (file: string) => void): void => {\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (skipped.has(entry.name)) continue\n const full = path.join(dir, entry.name)\n if (entry.isDirectory()) walk(full, skipped, visit)\n else if (entry.isFile()) visit(full)\n }\n}\n\n/**\n * Annotation delimiters that survived derivation: a generated product must not contain any. Every delimiter of the line is looked\n * for in every text file, not only in the extensions it is declared for, because an annotation written in a file type the engine\n * does not process for it comes out untouched (a `/*% ... %*\\/` in a `.json`, where only `###< >###` is processed).\n */\nexport const checkLeftovers = ({\n productDir,\n config,\n exclude = []\n}: {\n productDir: string\n config: LeftoverDelimiters\n /** Paths relative to `productDir` that are allowed to contain delimiters. */\n exclude?: readonly string[]\n}): Leftover[] => {\n if (typeof productDir !== 'string' || productDir.trim() === '') {\n throw new InvalidArgumentError('\"productDir\" must be a non-empty path.')\n }\n const root = path.resolve(productDir)\n if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {\n throw new InvalidArgumentError(`\"productDir\" is not a directory: ${root}`)\n }\n\n const markers = [...new Set(config.delimiters.flatMap(({ start, end }) => [start, end]))]\n .filter((marker) => marker !== '')\n const skipped = new Set([...ALWAYS_SKIPPED, ...(config.ignore ?? [])])\n const excluded = new Set(exclude)\n\n const found: Leftover[] = []\n walk(root, skipped, (file) => {\n const relative = path.relative(root, file).split(path.sep).join('/')\n if (excluded.has(relative)) return\n const content = fs.readFileSync(file)\n if (isBinary(content)) return\n content.toString('utf8').split('\\n').forEach((text, index) => {\n const delimiter = markers.find((marker) => text.includes(marker))\n if (delimiter !== undefined) found.push({ file: relative, line: index + 1, delimiter })\n })\n })\n return found.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line)\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type FeatureModelTree } from '../feature-model/uvl.js';
|
|
2
|
+
/**
|
|
3
|
+
* A set of valid configurations that has every pair of features together at least once (and every feature on its own): the usual sample to
|
|
4
|
+
* look for interactions between features that no real product exercises. Greedy: each uncovered pair gets a configuration made of the least
|
|
5
|
+
* that has both, which covers whatever else it happens to contain. A pair the model forbids is skipped. `max` caps how many are returned.
|
|
6
|
+
*/
|
|
7
|
+
export declare const pairwiseSelections: ({ tree, base, max }: {
|
|
8
|
+
tree: FeatureModelTree;
|
|
9
|
+
base?: readonly string[];
|
|
10
|
+
max?: number;
|
|
11
|
+
}) => string[][];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { featuresOf } from '../feature-model/uvl.js';
|
|
2
|
+
import { activateFeature, completeSelection } from './validate-specs.js';
|
|
3
|
+
/**
|
|
4
|
+
* A set of valid configurations that has every pair of features together at least once (and every feature on its own): the usual sample to
|
|
5
|
+
* look for interactions between features that no real product exercises. Greedy: each uncovered pair gets a configuration made of the least
|
|
6
|
+
* that has both, which covers whatever else it happens to contain. A pair the model forbids is skipped. `max` caps how many are returned.
|
|
7
|
+
*/
|
|
8
|
+
export const pairwiseSelections = ({ tree, base = [], max = 50 }) => {
|
|
9
|
+
const names = featuresOf({ tree }).map(({ name }) => name).filter((name) => name !== tree.root.name);
|
|
10
|
+
const pairKey = (a, b) => (a <= b ? `${a}\u0000${b}` : `${b}\u0000${a}`);
|
|
11
|
+
const pairsOf = (selection) => {
|
|
12
|
+
const on = names.filter((name) => selection.has(name));
|
|
13
|
+
return on.flatMap((a, i) => on.slice(i).map((b) => pairKey(a, b)));
|
|
14
|
+
};
|
|
15
|
+
const covered = new Set(pairsOf(completeSelection({ tree, features: base })));
|
|
16
|
+
const configurations = [];
|
|
17
|
+
for (let i = 0; i < names.length && configurations.length < max; i++) {
|
|
18
|
+
for (let j = i; j < names.length && configurations.length < max; j++) {
|
|
19
|
+
const [a, b] = [names[i], names[j]];
|
|
20
|
+
if (covered.has(pairKey(a, b)))
|
|
21
|
+
continue;
|
|
22
|
+
const withA = activateFeature({ tree, features: base, feature: a });
|
|
23
|
+
const both = withA === undefined ? undefined : a === b ? withA : activateFeature({ tree, features: withA, feature: b });
|
|
24
|
+
// what cannot be had is not tried again
|
|
25
|
+
covered.add(pairKey(a, b));
|
|
26
|
+
if (both === undefined)
|
|
27
|
+
continue;
|
|
28
|
+
configurations.push(both);
|
|
29
|
+
for (const key of pairsOf(new Set(both)))
|
|
30
|
+
covered.add(key);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return configurations;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=pairwise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairwise.js","sourceRoot":"","sources":["../../src/ci/pairwise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyB,MAAM,yBAAyB,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAExE;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAsE,EAAc,EAAE;IAClJ,MAAM,KAAK,GAAG,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACpG,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;IAChG,MAAM,OAAO,GAAG,CAAC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AAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAA;YACvH,wCAAwC;YACxC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;YAC1B,IAAI,IAAI,KAAK,SAAS;gBAAE,SAAQ;YAChC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACzB,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC5D,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA","sourcesContent":["import { featuresOf, type FeatureModelTree } from '../feature-model/uvl.js'\nimport { activateFeature, completeSelection } from './validate-specs.js'\n\n/**\n * A set of valid configurations that has every pair of features together at least once (and every feature on its own): the usual sample to\n * look for interactions between features that no real product exercises. Greedy: each uncovered pair gets a configuration made of the least\n * that has both, which covers whatever else it happens to contain. A pair the model forbids is skipped. `max` caps how many are returned.\n */\nexport const pairwiseSelections = ({ tree, base = [], max = 50 }: { tree: FeatureModelTree, base?: readonly string[], max?: number }): string[][] => {\n const names = featuresOf({ tree }).map(({ name }) => name).filter((name) => name !== tree.root.name)\n const pairKey = (a: string, b: string): string => (a <= b ? `${a}\\u0000${b}` : `${b}\\u0000${a}`)\n const pairsOf = (selection: ReadonlySet<string>): string[] => {\n const on = names.filter((name) => selection.has(name))\n return on.flatMap((a, i) => on.slice(i).map((b) => pairKey(a, b)))\n }\n\n const covered = new Set<string>(pairsOf(completeSelection({ tree, features: base })))\n const configurations: string[][] = []\n for (let i = 0; i < names.length && configurations.length < max; i++) {\n for (let j = i; j < names.length && configurations.length < max; j++) {\n const [a, b] = [names[i]!, names[j]!]\n if (covered.has(pairKey(a, b))) continue\n const withA = activateFeature({ tree, features: base, feature: a })\n const both = withA === undefined ? undefined : a === b ? withA : activateFeature({ tree, features: withA, feature: b })\n // what cannot be had is not tried again\n covered.add(pairKey(a, b))\n if (both === undefined) continue\n configurations.push(both)\n for (const key of pairsOf(new Set(both))) covered.add(key)\n }\n }\n return configurations\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The child pipeline of an SPL merge request: one job per selected product that derives it from the head of the SPL, rejects annotations
|
|
3
|
+
* left in it, derives it again to see that the result is the same, and runs the tests the product brings (`ci/test-server.sh`, `ci/test-client.sh`). `tooling` is the shell line that makes
|
|
4
|
+
* `linea-ci` available in the job.
|
|
5
|
+
*/
|
|
6
|
+
export declare const renderChildPipeline: ({ products, specsDir, image, tooling, parentJob, repositories, tags }: {
|
|
7
|
+
products: readonly string[];
|
|
8
|
+
/** Where the specs of the products are, relative to the root of the SPL repository (`fetch-specs` writes them there). */
|
|
9
|
+
specsDir: string;
|
|
10
|
+
image?: string;
|
|
11
|
+
tooling?: string;
|
|
12
|
+
/** The job of the parent pipeline whose artifacts hold the specs and the SPL checkout. */
|
|
13
|
+
parentJob?: string;
|
|
14
|
+
/** Product name -> where its repository is: those listed also get `check-drift` (what is committed is what the line generates). */
|
|
15
|
+
repositories?: Readonly<Record<string, string>>;
|
|
16
|
+
/** The runner tags the jobs ask for (a runner that takes no untagged jobs runs nothing otherwise). */
|
|
17
|
+
tags?: readonly string[];
|
|
18
|
+
}) => string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const JOB_NAME_UNSAFE = /[^A-Za-z0-9_.-]/g;
|
|
2
|
+
/**
|
|
3
|
+
* The child pipeline of an SPL merge request: one job per selected product that derives it from the head of the SPL, rejects annotations
|
|
4
|
+
* left in it, derives it again to see that the result is the same, and runs the tests the product brings (`ci/test-server.sh`, `ci/test-client.sh`). `tooling` is the shell line that makes
|
|
5
|
+
* `linea-ci` available in the job.
|
|
6
|
+
*/
|
|
7
|
+
export const renderChildPipeline = ({ products, specsDir, image = 'node:22', tooling = `git config --global url."https://gitlab-ci-token:\${CI_JOB_TOKEN}@\${CI_SERVER_HOST}/".insteadOf "https://\${CI_SERVER_HOST}/" && npm install --global "$LINEA_CI_PACKAGE"`, parentJob = 'select', repositories = {}, tags = [] }) => {
|
|
8
|
+
const tagLines = tags.length === 0 ? [] : [` tags: ${JSON.stringify(tags)}`];
|
|
9
|
+
if (products.length === 0) {
|
|
10
|
+
return [
|
|
11
|
+
'stages: [products]',
|
|
12
|
+
'no-products-affected:',
|
|
13
|
+
' stage: products',
|
|
14
|
+
` image: ${image}`,
|
|
15
|
+
...tagLines,
|
|
16
|
+
' script:',
|
|
17
|
+
' - echo "No product is affected by this change."'
|
|
18
|
+
].join('\n') + '\n';
|
|
19
|
+
}
|
|
20
|
+
const lines = ['stages: [products]', ''];
|
|
21
|
+
for (const name of products) {
|
|
22
|
+
lines.push(`product:${name.replace(JOB_NAME_UNSAFE, '_')}:`, ' stage: products', ` image: ${image}`, ...tagLines, ' interruptible: true', ' needs:', ' - pipeline: $PARENT_PIPELINE_ID', ` job: ${parentJob}`, ' script:', ` - ${tooling}`, ` - linea-ci derive --line . --spec ${specsDir}/${name}.json --out "$CI_PROJECT_DIR/derived/${name}"`, ` - linea-ci check-leftovers "$CI_PROJECT_DIR/derived/${name}" --line .`, ` - linea-ci check-determinism --line . --spec ${specsDir}/${name}.json`, ...(repositories[name] === undefined ? [] : [` - linea-ci check-drift --line . --spec ${specsDir}/${name}.json --repository ${JSON.stringify(repositories[name])}`]), ` - cd "derived/${name}" && for t in ci/test-server.sh ci/test-client.sh; do if [ -f "$t" ]; then sh "$t" || exit 1; fi; done`, ' artifacts:', ' when: always', ' expire_in: 1 week', ' paths:', ` - derived/${name}/`, '');
|
|
23
|
+
}
|
|
24
|
+
return lines.join('\n');
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0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IAAI,OAAO,EAC3E,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,8CAA8C,QAAQ,IAAI,IAAI,sBAAsB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EACvK,qBAAqB,IAAI,wGAAwG,EACjI,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,YAAY,EACZ,mBAAmB,IAAI,GAAG,EAC1B,EAAE,CACH,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC,CAAA","sourcesContent":["const JOB_NAME_UNSAFE = /[^A-Za-z0-9_.-]/g\n\n/**\n * The child pipeline of an SPL merge request: one job per selected product that derives it from the head of the SPL, rejects annotations\n * left in it, derives it again to see that the result is the same, and runs the tests the product brings (`ci/test-server.sh`, `ci/test-client.sh`). `tooling` is the shell line that makes\n * `linea-ci` available in the job.\n */\nexport const renderChildPipeline = ({\n products,\n specsDir,\n image = 'node:22',\n tooling = `git config --global url.\"https://gitlab-ci-token:\\${CI_JOB_TOKEN}@\\${CI_SERVER_HOST}/\".insteadOf \"https://\\${CI_SERVER_HOST}/\" && npm install --global \"$LINEA_CI_PACKAGE\"`,\n parentJob = 'select',\n repositories = {},\n tags = []\n}: {\n products: readonly string[]\n /** Where the specs of the products are, relative to the root of the SPL repository (`fetch-specs` writes them there). */\n specsDir: string\n image?: string\n tooling?: string\n /** The job of the parent pipeline whose artifacts hold the specs and the SPL checkout. */\n parentJob?: string\n /** Product name -> where its repository is: those listed also get `check-drift` (what is committed is what the line generates). */\n repositories?: Readonly<Record<string, string>>\n /** The runner tags the jobs ask for (a runner that takes no untagged jobs runs nothing otherwise). */\n tags?: readonly string[]\n}): string => {\n const tagLines = tags.length === 0 ? [] : [` tags: ${JSON.stringify(tags)}`]\n if (products.length === 0) {\n return [\n 'stages: [products]',\n 'no-products-affected:',\n ' stage: products',\n ` image: ${image}`,\n ...tagLines,\n ' script:',\n ' - echo \"No product is affected by this change.\"'\n ].join('\\n') + '\\n'\n }\n const lines = ['stages: [products]', '']\n for (const name of products) {\n lines.push(\n `product:${name.replace(JOB_NAME_UNSAFE, '_')}:`,\n ' stage: products',\n ` image: ${image}`,\n ...tagLines,\n ' interruptible: true',\n ' needs:',\n ' - pipeline: $PARENT_PIPELINE_ID',\n ` job: ${parentJob}`,\n ' script:',\n ` - ${tooling}`,\n ` - linea-ci derive --line . --spec ${specsDir}/${name}.json --out \"$CI_PROJECT_DIR/derived/${name}\"`,\n ` - linea-ci check-leftovers \"$CI_PROJECT_DIR/derived/${name}\" --line .`,\n ` - linea-ci check-determinism --line . --spec ${specsDir}/${name}.json`,\n ...(repositories[name] === undefined ? [] : [` - linea-ci check-drift --line . --spec ${specsDir}/${name}.json --repository ${JSON.stringify(repositories[name])}`]),\n ` - cd \"derived/${name}\" && for t in ci/test-server.sh ci/test-client.sh; do if [ -f \"$t\" ]; then sh \"$t\" || exit 1; fi; done`,\n ' artifacts:',\n ' when: always',\n ' expire_in: 1 week',\n ' paths:',\n ` - derived/${name}/`,\n ''\n )\n }\n return lines.join('\\n')\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface SelectableProduct {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
readonly features: readonly string[];
|
|
4
|
+
}
|
|
5
|
+
export interface ProductSelectionResult {
|
|
6
|
+
/** The names of the products to rebuild, the ones that share more of the touched features first. */
|
|
7
|
+
readonly selected: string[];
|
|
8
|
+
/** The features the change touches; empty when `all` is `true`. */
|
|
9
|
+
readonly touchedFeatures: string[];
|
|
10
|
+
/** Everything is selected: the change reaches every product (the platform files, code with no feature in it, a deleted file...). */
|
|
11
|
+
readonly all: boolean;
|
|
12
|
+
readonly reason: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Which products a change to an SPL can break. A change to a file whose annotations test features reaches the products that have one of
|
|
16
|
+
* them; one to the platform (feature model, config, helpers, transformation, manifests) or to code that tests no feature, or to a file the
|
|
17
|
+
* analysis does not know (deleted), reaches all. A file that tests features also holds code that every product with the file gets, so
|
|
18
|
+
* `baseline` products (the smallest ones) are always added to have that covered. `max` caps the list.
|
|
19
|
+
*/
|
|
20
|
+
export declare const selectProducts: ({ changedFiles, featuresByFile, products, max, baseline }: {
|
|
21
|
+
/** Paths from the root of the SPL repository. */
|
|
22
|
+
changedFiles: readonly string[];
|
|
23
|
+
/** `analyzeAnnotations`, of the head of the change. */
|
|
24
|
+
featuresByFile: Record<string, Record<string, number>>;
|
|
25
|
+
products: readonly SelectableProduct[];
|
|
26
|
+
max?: number;
|
|
27
|
+
baseline?: number;
|
|
28
|
+
}) => ProductSelectionResult;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PLATFORM_PATHS } from '../constants.js';
|
|
2
|
+
const normalize = (file) => file.split('\\').join('/').replace(/^\.\//, '');
|
|
3
|
+
/**
|
|
4
|
+
* Which products a change to an SPL can break. A change to a file whose annotations test features reaches the products that have one of
|
|
5
|
+
* them; one to the platform (feature model, config, helpers, transformation, manifests) or to code that tests no feature, or to a file the
|
|
6
|
+
* analysis does not know (deleted), reaches all. A file that tests features also holds code that every product with the file gets, so
|
|
7
|
+
* `baseline` products (the smallest ones) are always added to have that covered. `max` caps the list.
|
|
8
|
+
*/
|
|
9
|
+
export const selectProducts = ({ changedFiles, featuresByFile, products, max = Infinity, baseline = 1 }) => {
|
|
10
|
+
const codePrefix = `${PLATFORM_PATHS.code.replace(/\/$/, '')}/`;
|
|
11
|
+
const everything = (reason) => ({ selected: products.slice(0, max).map(({ name }) => name), touchedFeatures: [], all: true, reason });
|
|
12
|
+
const touched = new Set();
|
|
13
|
+
for (const raw of changedFiles) {
|
|
14
|
+
const file = normalize(raw);
|
|
15
|
+
if (!file.startsWith(codePrefix)) {
|
|
16
|
+
if (file === 'README.md' || file.startsWith('docs/') || file.startsWith('.gitlab-ci') || file.startsWith('ci/'))
|
|
17
|
+
continue;
|
|
18
|
+
return everything(`"${file}" is part of the platform of the SPL`);
|
|
19
|
+
}
|
|
20
|
+
const features = featuresByFile[file.slice(codePrefix.length)];
|
|
21
|
+
if (features === undefined)
|
|
22
|
+
return everything(`"${file}" is not in the annotation analysis (deleted or ignored)`);
|
|
23
|
+
const names = Object.keys(features);
|
|
24
|
+
if (names.length === 0)
|
|
25
|
+
return everything(`"${file}" has no feature in its annotations: every product has it`);
|
|
26
|
+
names.forEach((name) => touched.add(name));
|
|
27
|
+
}
|
|
28
|
+
if (touched.size === 0)
|
|
29
|
+
return { selected: [], touchedFeatures: [], all: false, reason: 'no file of the SPL changed that products depend on' };
|
|
30
|
+
const overlap = (product) => product.features.filter((name) => touched.has(name)).length;
|
|
31
|
+
const hit = products.filter((product) => overlap(product) > 0).sort((a, b) => overlap(b) - overlap(a) || a.name.localeCompare(b.name));
|
|
32
|
+
const selected = [...hit];
|
|
33
|
+
const rest = products.filter((product) => !hit.includes(product)).sort((a, b) => a.features.length - b.features.length || a.name.localeCompare(b.name));
|
|
34
|
+
while (selected.length < baseline && rest.length > 0)
|
|
35
|
+
selected.push(rest.shift());
|
|
36
|
+
return {
|
|
37
|
+
selected: selected.slice(0, max).map(({ name }) => name),
|
|
38
|
+
touchedFeatures: [...touched].sort(),
|
|
39
|
+
all: false,
|
|
40
|
+
reason: `touches ${[...touched].sort().join(', ')}`
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/ci/select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAiBhD,MAAM,SAAS,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAA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MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;IACvJ,OAAO,QAAQ,CAAC,MAAM,GAAG,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAG,CAAC,CAAA;IAElF,OAAO;QACL,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;QACxD,eAAe,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE;QACpC,GAAG,EAAE,KAAK;QACV,MAAM,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;KACpD,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { PLATFORM_PATHS } from '../constants.js'\n\nexport interface SelectableProduct {\n readonly name: string\n readonly features: readonly string[]\n}\n\nexport interface ProductSelectionResult {\n /** The names of the products to rebuild, the ones that share more of the touched features first. */\n readonly selected: string[]\n /** The features the change touches; empty when `all` is `true`. */\n readonly touchedFeatures: string[]\n /** Everything is selected: the change reaches every product (the platform files, code with no feature in it, a deleted file...). */\n readonly all: boolean\n readonly reason: string\n}\n\nconst normalize = (file: string): string => file.split('\\\\').join('/').replace(/^\\.\\//, '')\n\n/**\n * Which products a change to an SPL can break. A change to a file whose annotations test features reaches the products that have one of\n * them; one to the platform (feature model, config, helpers, transformation, manifests) or to code that tests no feature, or to a file the\n * analysis does not know (deleted), reaches all. A file that tests features also holds code that every product with the file gets, so\n * `baseline` products (the smallest ones) are always added to have that covered. `max` caps the list.\n */\nexport const selectProducts = ({\n changedFiles,\n featuresByFile,\n products,\n max = Infinity,\n baseline = 1\n}: {\n /** Paths from the root of the SPL repository. */\n changedFiles: readonly string[]\n /** `analyzeAnnotations`, of the head of the change. */\n featuresByFile: Record<string, Record<string, number>>\n products: readonly SelectableProduct[]\n max?: number\n baseline?: number\n}): ProductSelectionResult => {\n const codePrefix = `${PLATFORM_PATHS.code.replace(/\\/$/, '')}/`\n const everything = (reason: string): ProductSelectionResult =>\n ({ selected: products.slice(0, max).map(({ name }) => name), touchedFeatures: [], all: true, reason })\n\n const touched = new Set<string>()\n for (const raw of changedFiles) {\n const file = normalize(raw)\n if (!file.startsWith(codePrefix)) {\n if (file === 'README.md' || file.startsWith('docs/') || file.startsWith('.gitlab-ci') || file.startsWith('ci/')) continue\n return everything(`\"${file}\" is part of the platform of the SPL`)\n }\n const features = featuresByFile[file.slice(codePrefix.length)]\n if (features === undefined) return everything(`\"${file}\" is not in the annotation analysis (deleted or ignored)`)\n const names = Object.keys(features)\n if (names.length === 0) return everything(`\"${file}\" has no feature in its annotations: every product has it`)\n names.forEach((name) => touched.add(name))\n }\n\n if (touched.size === 0) return { selected: [], touchedFeatures: [], all: false, reason: 'no file of the SPL changed that products depend on' }\n\n const overlap = (product: SelectableProduct): number => product.features.filter((name) => touched.has(name)).length\n const hit = products.filter((product) => overlap(product) > 0).sort((a, b) => overlap(b) - overlap(a) || a.name.localeCompare(b.name))\n const selected = [...hit]\n const rest = products.filter((product) => !hit.includes(product)).sort((a, b) => a.features.length - b.features.length || a.name.localeCompare(b.name))\n while (selected.length < baseline && rest.length > 0) selected.push(rest.shift()!)\n\n return {\n selected: selected.slice(0, max).map(({ name }) => name),\n touchedFeatures: [...touched].sort(),\n all: false,\n reason: `touches ${[...touched].sort().join(', ')}`\n }\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type FeatureModelTree } from '../feature-model/uvl.js';
|
|
2
|
+
export interface SelectionProblem {
|
|
3
|
+
readonly feature?: string;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ProductSelection {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly features: readonly string[] | Readonly<Record<string, boolean>>;
|
|
9
|
+
}
|
|
10
|
+
export interface ProductSelectionReport {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly problems: SelectionProblem[];
|
|
13
|
+
}
|
|
14
|
+
/** The features a selection comes to once what the model implies is added: the root, the ancestors, what is mandatory, what the constraints need. */
|
|
15
|
+
export declare const completeSelection: ({ tree, features }: {
|
|
16
|
+
tree: FeatureModelTree;
|
|
17
|
+
features: ProductSelection["features"];
|
|
18
|
+
}) => Set<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a feature selection is a valid configuration of a feature model: every feature exists and, once what the model implies is added
|
|
21
|
+
* (`completeSelection`), the groups are respected and every cross-tree constraint holds. The rules flamapy applies, checked directly over
|
|
22
|
+
* the tree, so a pipeline can validate every real product in milliseconds and with no Python runtime.
|
|
23
|
+
*/
|
|
24
|
+
export declare const validateSelection: ({ tree, features }: {
|
|
25
|
+
tree: FeatureModelTree;
|
|
26
|
+
features: ProductSelection["features"];
|
|
27
|
+
}) => SelectionProblem[];
|
|
28
|
+
/** `validateSelection` over every product of an SPL, against the UVL of its feature model. */
|
|
29
|
+
export declare const validateProductSelections: ({ featureModel, products }: {
|
|
30
|
+
featureModel: string;
|
|
31
|
+
products: readonly ProductSelection[];
|
|
32
|
+
}) => ProductSelectionReport[];
|
|
33
|
+
/**
|
|
34
|
+
* The selection of a product without one of its features (and what hangs from it), for measuring what that feature is worth: the code that
|
|
35
|
+
* disappears is the code the feature brings. `undefined` when the model does not allow it (the feature is mandatory, or something that stays
|
|
36
|
+
* needs it), because that product cannot be derived.
|
|
37
|
+
*/
|
|
38
|
+
export declare const ablateFeature: ({ tree, features, feature }: {
|
|
39
|
+
tree: FeatureModelTree;
|
|
40
|
+
features: ProductSelection["features"];
|
|
41
|
+
feature: string;
|
|
42
|
+
}) => string[] | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* A valid selection that has a feature, made of the least that has to come with it: what the model implies, and the first feature of every
|
|
45
|
+
* group that asks for a choice. Used to measure what a feature brings when no real product has it. `undefined` when no selection with it
|
|
46
|
+
* is valid (the constraints forbid it).
|
|
47
|
+
*/
|
|
48
|
+
export declare const activateFeature: ({ tree, features, feature }: {
|
|
49
|
+
tree: FeatureModelTree;
|
|
50
|
+
features: ProductSelection["features"];
|
|
51
|
+
feature: string;
|
|
52
|
+
}) => string[] | undefined;
|