@tryinget/runtime-trace-insights 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +78 -0
- package/README.md +155 -0
- package/package.json +41 -0
- package/src/.gitkeep +1 -0
- package/src/index.mjs +3 -0
- package/src/runtime_record/depdiet_runtime_record_adapter.mjs +80 -0
- package/src/runtime_record/index.mjs +18 -0
- package/src/runtime_record/runtime_record_flow.mjs +1577 -0
- package/src/runtime_trace_bundle/index.mjs +8 -0
- package/src/runtime_trace_bundle/runtime_trace_bundle_builder.mjs +679 -0
- package/src/runtime_trace_bundle/runtime_trace_bundle_flow.mjs +168 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
MIT License (with OpenAI/Anthropic/xAI/PRC Frontier Labs Rider)
|
|
2
|
+
|
|
3
|
+
Copyright (c) contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
ADDITIONAL RIDER / RESTRICTION (OpenAI / Anthropic / xAI / PRC Frontier Labs):
|
|
13
|
+
|
|
14
|
+
This rider is part of the "conditions" of this License. In the event of any
|
|
15
|
+
conflict between this rider and any other portion of this License, this rider
|
|
16
|
+
controls.
|
|
17
|
+
|
|
18
|
+
"Restricted Parties" means OpenAI, L.L.C.; Anthropic, PBC; xAI Corp.; and the
|
|
19
|
+
following PRC frontier AI labs and related entities: Baidu (including ERNIE-
|
|
20
|
+
related entities), Alibaba and Alibaba Cloud (including Qwen-related entities),
|
|
21
|
+
Tencent (including Hunyuan-related entities), ByteDance (including Doubao/Seed-
|
|
22
|
+
related entities), DeepSeek, Zhipu AI, Moonshot AI, MiniMax, 01.AI
|
|
23
|
+
(Lingyiwanwu), and iFlyTek. "Restricted Parties" also includes any of their
|
|
24
|
+
respective Affiliates and any person or entity acting directly or indirectly
|
|
25
|
+
on behalf of, for the benefit of, or under the direction of any of the
|
|
26
|
+
foregoing (including any officer, director, employee, contractor, agent,
|
|
27
|
+
consultant, service provider, or representative).
|
|
28
|
+
|
|
29
|
+
Notwithstanding any other provision of this License, no rights are granted to
|
|
30
|
+
any Restricted Party. Any purported license, sublicense, assignment, transfer,
|
|
31
|
+
or other permission to any Restricted Party is null and void absent the
|
|
32
|
+
express prior written permission of the copyright holders.
|
|
33
|
+
|
|
34
|
+
You may not provide, disclose, distribute, sublicense, sell, lease, lend,
|
|
35
|
+
host, make available, or otherwise permit access to the Software or any
|
|
36
|
+
derivative work of the Software (as defined in applicable copyright law)
|
|
37
|
+
(collectively, "Derivative Works") to or for any Restricted Party.
|
|
38
|
+
|
|
39
|
+
For purposes of this rider, "use" includes, without limitation: copying,
|
|
40
|
+
modifying, merging, publishing, distributing, sublicensing, selling,
|
|
41
|
+
transferring, making available, hosting, deploying, executing, benchmarking,
|
|
42
|
+
testing, analyzing, indexing, or incorporating the Software or any Derivative
|
|
43
|
+
Works into any dataset, training corpus, evaluation harness, or pipeline for
|
|
44
|
+
machine learning or other automated systems.
|
|
45
|
+
|
|
46
|
+
This rider applies to the Software and all Derivative Works. As a condition of
|
|
47
|
+
use, you agree that this rider is a precondition to exercising any rights
|
|
48
|
+
under this License, and you agree that any distribution of the Software or any
|
|
49
|
+
Derivative Works must include this rider provision unmodified.
|
|
50
|
+
|
|
51
|
+
Any breach of this rider automatically and immediately terminates the
|
|
52
|
+
permissions granted by this License. Upon termination, you must immediately
|
|
53
|
+
cease all use and distribution of the Software and any Derivative Works and
|
|
54
|
+
destroy all copies under your control.
|
|
55
|
+
|
|
56
|
+
You agree that a breach of this rider would cause irreparable harm and that
|
|
57
|
+
the copyright holders may seek injunctive or other equitable relief to enforce
|
|
58
|
+
this rider, in addition to any other remedies available at law. To the maximum
|
|
59
|
+
extent permitted by applicable law, the prevailing party in any action to
|
|
60
|
+
enforce this rider shall be entitled to recover reasonable attorneys' fees and
|
|
61
|
+
costs.
|
|
62
|
+
|
|
63
|
+
For purposes of this rider, "Affiliate" means any entity that directly or
|
|
64
|
+
indirectly controls, is controlled by, or is under common control with the
|
|
65
|
+
specified party. "Control" means ownership of more than 50% of the voting
|
|
66
|
+
securities or other ownership interest, or the power to direct management or
|
|
67
|
+
policies by contract or otherwise.
|
|
68
|
+
|
|
69
|
+
The above copyright notice and this permission notice shall be included in all
|
|
70
|
+
copies or substantial portions of the Software.
|
|
71
|
+
|
|
72
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
73
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
74
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
75
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
76
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
77
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
78
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: "Runtime-trace-insights README for runtime-record flow, runtime trace bundles, and dep-diet adapter usage."
|
|
3
|
+
read_when:
|
|
4
|
+
- "Onboarding to runtime-trace-insights."
|
|
5
|
+
- "Changing runtime-record flows, runtime trace bundle production, adapter exports, or downstream integration docs."
|
|
6
|
+
type: "reference"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# runtime-trace-insights
|
|
10
|
+
|
|
11
|
+
Extracted runtime-record flow and external adapter module for `dep-diet`.
|
|
12
|
+
|
|
13
|
+
## Current scope
|
|
14
|
+
|
|
15
|
+
- Runtime record flow implementation (`runRuntimeRecordFlow`)
|
|
16
|
+
- Runtime trace bundle production from an observed command (`runtime_trace_bundle.mjs record`)
|
|
17
|
+
- depdiet-compatible external adapter (`runtimeRecordAdapter`)
|
|
18
|
+
- Shared runtime-record diagnostic contract vectors
|
|
19
|
+
- Contract-focused tests for runtime trace artifacts and adapter behavior
|
|
20
|
+
|
|
21
|
+
## Contract and identifiers
|
|
22
|
+
|
|
23
|
+
- Adapter ID: `runtime-trace-insights.runtimeRecord.v1`
|
|
24
|
+
- Adapter contract version: `depdiet.runtime.record.adapter.v1`
|
|
25
|
+
- Runtime record result schema: `depdiet.runtime.record.result.v1`
|
|
26
|
+
- Runtime trace bundle schema: `runtime-trace-insights.runtime-trace-bundle.v1`
|
|
27
|
+
- Shared vectors/fixture files:
|
|
28
|
+
- `fixtures/runtime_record_contract/v1/adapter_diagnostics_vectors.v1.json`
|
|
29
|
+
- `fixtures/runtime_trace_bundle/v1/dependency-corridor-runtime-bundle.json`
|
|
30
|
+
- `fixtures/runtime_trace_bundle/v1/fixture-manifest.json`
|
|
31
|
+
- `fixtures/runtime_reobservation/v1/gardener-dependency-analysis.json` (real Gardener output for the dependency-update re-observation fixture)
|
|
32
|
+
|
|
33
|
+
Compatibility policy for this extraction track is additive-first for `v1` contracts.
|
|
34
|
+
|
|
35
|
+
## Package exports
|
|
36
|
+
|
|
37
|
+
From `package.json`:
|
|
38
|
+
|
|
39
|
+
- `.` → `src/index.mjs`
|
|
40
|
+
- `./runtime-record` → `src/runtime_record/index.mjs`
|
|
41
|
+
- `./runtime-trace-bundle` → `src/runtime_trace_bundle/index.mjs`
|
|
42
|
+
- `./adapter/depdiet-runtime-record` → `src/runtime_record/depdiet_runtime_record_adapter.mjs`
|
|
43
|
+
|
|
44
|
+
`src/index.mjs` also exports the depdiet adapter as default.
|
|
45
|
+
|
|
46
|
+
## Produce a runtime trace bundle
|
|
47
|
+
|
|
48
|
+
Use `runtime_trace_bundle.mjs record` when a downstream consumer such as dep-diet needs a `runtime-trace-insights.runtime-trace-bundle.v1` file from a real observed command:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
node scripts/runtime_trace_bundle.mjs record <project-path> \
|
|
52
|
+
--observed-package <name[@version]> \
|
|
53
|
+
--out out/runtime-trace-insights/runtime-trace-bundle.json \
|
|
54
|
+
-- <observed-command...>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Example for a TypeScript toolchain command:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
node scripts/runtime_trace_bundle.mjs record /path/to/designmd-foundry \
|
|
61
|
+
--observed-package @typescript/native-preview \
|
|
62
|
+
--out /tmp/designmd-depintel-pilot/runtime/designmd-foundry-runtime-bundle.json \
|
|
63
|
+
-- npm run typecheck
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The observed package declaration is command-level evidence context, not removal authority. Use the narrowest representative command and do not treat one runtime command as full production coverage. The emitted bundle and each observed package entry carry machine-readable non-authority metadata (`removalAuthority: false`, `riskAuthority: false`, `visualizationAuthority: false`) so downstream tools do not have to infer this boundary from prose.
|
|
67
|
+
|
|
68
|
+
For dependency replacement candidates, bind comparable before/after observations to dep-diet / dep-surgeon references without granting replacement safety authority:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
node scripts/runtime_trace_bundle.mjs record <project-path> \
|
|
72
|
+
--observed-package <name[@version]> \
|
|
73
|
+
--observation-phase before \
|
|
74
|
+
--replacement-plan-ref <depsurgeon-plan-ref> \
|
|
75
|
+
--comparison-key <stable-pair-key> \
|
|
76
|
+
--out out/runtime-trace-insights/before.json \
|
|
77
|
+
-- <observed-command...>
|
|
78
|
+
|
|
79
|
+
node scripts/runtime_trace_bundle.mjs record <project-path> \
|
|
80
|
+
--observed-package <name[@version]> \
|
|
81
|
+
--observation-phase after \
|
|
82
|
+
--replacement-plan-ref <depsurgeon-plan-ref> \
|
|
83
|
+
--replacement-result-ref <depsurgeon-result-ref> \
|
|
84
|
+
--comparison-key <stable-pair-key> \
|
|
85
|
+
--out out/runtime-trace-insights/after.json \
|
|
86
|
+
-- <observed-command...>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Declared packages resolve to the exact version they run at. Resolution walks up from the project like Node resolution: at each level, `package-lock.json` first, then the installed `node_modules/<name>/package.json`, so workspace members resolve hoisted dependencies. After that comes an exact `package.json` specifier. With `--package-autodiscovery`, what the command actually loaded replaces declarations for the same package; a declared version that was not loaded is dropped with `runtimeTraceBundle.declaredVersionNotObserved`. A manifest range such as `^1.0.0` is never used as the version; without a lock or install the version is `unknown` and the bundle carries `runtimeTraceBundle.observedPackageVersionRange`.
|
|
90
|
+
|
|
91
|
+
This adds `replacementObservation.schemaVersion = runtime-trace-insights.replacement-reobservation.v1` and keeps exhaustive coverage, replacement safety, merge, release, exploitability, disclosure, and trust-certification authority false.
|
|
92
|
+
|
|
93
|
+
## Re-observe a dependency update
|
|
94
|
+
|
|
95
|
+
To get before/after runtime evidence for a dependency update (new pin of the same package) into dep-diet depmodels, follow the recipe in `docs/project/runtime-trace-bundle-contract.md` ("Dependency update re-observation recipe"). In short: old pin in the main checkout, update in a git worktree, and the same command recorded for each **from an evidence directory outside the checkout** (`record <checkout> ...`), with `--package-autodiscovery` and one `--comparison-key`. Recording from inside the checkout writes artifacts there and emits the warning `runtimeTraceBundle.artifactsInsideObservedProject`; then `depdiet analyze <checkout> --gardener-output ... --runtime-bundle ... --out-depmodel ...` per phase. `tests/runtime_reobservation_update_e2e.test.mjs` runs the whole path, including dep-diet when its sibling checkout exists. Set `RTI_DEPDIET_CLI=<path>/scripts/depdiet.mjs` to run that leg against another dep-diet checkout. It needs dep-diet with #5887/#5888 (origin `48d4eb6` or later): a single bundle counted once, and the new transitive `dep-b` confirmed statically by the lockfile.
|
|
96
|
+
|
|
97
|
+
## Dep-viz consumption boundary
|
|
98
|
+
|
|
99
|
+
The runtime trace bundle is consumable by dep-viz as runtime evidence for static/runtime overlays, but not as dep-viz's primary report model. The intended product path is:
|
|
100
|
+
|
|
101
|
+
```text
|
|
102
|
+
runtime-trace-insights runtime bundle
|
|
103
|
+
-> dep-diet evidence fusion / depmodel enrichment
|
|
104
|
+
-> dep-viz depmodel rendering and overlay explanation
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`fixtures/runtime_trace_bundle/v1/fixture-manifest.json` documents the corridor expectations for dep-viz contract tests: `zod` is a runtime observation that can become static/runtime-confirmed after fusion, `debug` is a runtime-only observation after fusion, and static-only packages such as `chalk`/`lodash` stay out of the raw runtime bundle.
|
|
108
|
+
|
|
109
|
+
## Use from dep-diet
|
|
110
|
+
|
|
111
|
+
This repo is dep-diet's only runtime-record implementation. dep-diet retired its embedded copy (dep-diet AK #5902, with no fallback) and depends on a pinned, vendored `npm pack` tarball of this repo: `vendor/runtime-trace-insights-<version>-<sha7>.tgz`, with the full commit in `vendor/runtime-trace-insights.commit`. `depdiet record` loads `runtime-trace-insights/adapter/depdiet-runtime-record` by default and gets from this repo the runtime trace bundle (`out/depdiet/runtime/runtime-trace-bundle.json`), the dep-viz runtime overlay handoff (`out/depdiet/runtime/depviz-runtime-overlay-handoff.json`), and the `artifacts`, `summary` and `runtimeRecord.*` diagnostics of dep-diet's record contract. A healthy run reports `adapter.id: runtime-trace-insights.runtimeRecord.v1` with `runtimeRecord.externalAdapterLoaded` and `runtimeRecord.adapterSelectionExternal`.
|
|
112
|
+
|
|
113
|
+
The package exports and the adapter module are compatibility-relevant API. See "Package and adapter API compatibility" in `docs/project/runtime-trace-bundle-contract.md`, and `docs/decisions/2026-09-23-runtime-record-single-owner.md`.
|
|
114
|
+
|
|
115
|
+
**Shipping a change to dep-diet.** A change under `src/` reaches dep-diet only after dep-diet re-vendors. Push it here, then in dep-diet run `scripts/vendor-runtime-trace-insights.sh <40-char-sha>` followed by `npm install --save file:vendor/<new tarball>`. Ping the dep-diet session or leave a dep-diet AK task. Until then, the pinned-vs-checkout scenario in `tests/features/depdiet_record_parity.feature` is skipped and names the pinned commit. While `src/` still matches the pin, it checks that dep-diet's vendored tarball records exactly what this checkout records.
|
|
116
|
+
|
|
117
|
+
To try an unreleased checkout in dep-diet without re-vendoring, override the module:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
DEPDIET_RUNTIME_RECORD_ADAPTER_MODULE=$HOME/ai-society/softwareco/owned/runtime-trace-insights/src/runtime_record/depdiet_runtime_record_adapter.mjs \
|
|
121
|
+
DEPDIET_APPMAP_AVAILABLE=true \
|
|
122
|
+
node $HOME/ai-society/softwareco/owned/dep-diet/scripts/depdiet.mjs record <project-path> -- <observed-command...>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Equivalent dep-diet CLI flags: `--runtime-record-adapter-module <module>`, `--runtime-record-adapter-export <name>`, `--runtime-record-adapter-id <id>`. Env overrides: `DEPDIET_RUNTIME_RECORD_ADAPTER_EXPORT`, `DEPDIET_RUNTIME_RECORD_ADAPTER_ID`.
|
|
126
|
+
|
|
127
|
+
## Local validation
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npm install
|
|
131
|
+
npm run lint
|
|
132
|
+
npm run test:record-runtime
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The runtime-record test suite covers:
|
|
136
|
+
|
|
137
|
+
- `tests/runtime_record_flow.test.mjs`
|
|
138
|
+
- `tests/depdiet_runtime_record_adapter.test.mjs`
|
|
139
|
+
- `tests/runtime_record_contract_vectors.test.mjs`
|
|
140
|
+
- `tests/runtime_trace_bundle_command.test.mjs`
|
|
141
|
+
- `tests/runtime_trace_bundle_contract.test.mjs`
|
|
142
|
+
- `tests/runtime_reobservation_update_e2e.test.mjs`
|
|
143
|
+
- `tests/observed_checkout_placement.feature.test.mjs` (executes `tests/features/observed_checkout_placement.feature`)
|
|
144
|
+
- `tests/declared_package_version_resolution.feature.test.mjs` (executes `tests/features/declared_package_version_resolution.feature`)
|
|
145
|
+
- `tests/depdiet_record_parity.feature.test.mjs` (executes `tests/features/depdiet_record_parity.feature`; the differential scenario needs the `../dep-diet` sibling)
|
|
146
|
+
- `tests/packaged_adapter.feature.test.mjs` (executes `tests/features/packaged_adapter.feature`: packs and installs the tarball, then checks the adapter through the export map)
|
|
147
|
+
- `tests/package_autodiscovery_portability.feature.test.mjs` (executes `tests/features/package_autodiscovery_portability.feature`: the autodiscovery loader goes into NODE_OPTIONS as a `file:` URL, so Windows paths work; this repo has no Windows CI, and dep-diet's windows-latest CI covers real Windows)
|
|
148
|
+
|
|
149
|
+
## Cross-repo alignment checks
|
|
150
|
+
|
|
151
|
+
`tests/runtime_record_contract_vectors.test.mjs` verifies the local vectors fixture and, when available, equality with dep-diet’s canonical copy:
|
|
152
|
+
|
|
153
|
+
- `../dep-diet/fixtures/runtime_record_contract/v1/adapter_diagnostics_vectors.v1.json`
|
|
154
|
+
|
|
155
|
+
Keep these vectors synchronized when changing runtime-record diagnostics semantics.
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tryinget/runtime-trace-insights",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Runtime-record flow and runtime-trace-bundle producer for dependency evidence; ships the dep-diet runtime-record adapter.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/tryingET/runtime-trace-insights.git"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"src",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20"
|
|
21
|
+
},
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./src/index.mjs",
|
|
24
|
+
"./runtime-record": "./src/runtime_record/index.mjs",
|
|
25
|
+
"./runtime-trace-bundle": "./src/runtime_trace_bundle/index.mjs",
|
|
26
|
+
"./adapter/depdiet-runtime-record": "./src/runtime_record/depdiet_runtime_record_adapter.mjs"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"lint": "node scripts/lint.mjs",
|
|
30
|
+
"runtime-trace-bundle": "node scripts/runtime_trace_bundle.mjs",
|
|
31
|
+
"test": "node scripts/run_record_runtime_tests.mjs",
|
|
32
|
+
"test:record-runtime": "node scripts/run_record_runtime_tests.mjs",
|
|
33
|
+
"loop-doctor": "bash -lc 'echo \"loop-doctor: runtime-trace-insights diagnostics\"; node --version || true; npm --version || true; git status --short -- . || true; exit 0'",
|
|
34
|
+
"loop-verify-fast": "npm test",
|
|
35
|
+
"loop-impact-plan": "bash -lc 'changed=$( { git diff --name-only -- .; git ls-files --others --exclude-standard .; } | grep -v \"^$\" | sort -u ); echo \"loop-impact-plan: changed files\"; if [ -n \"$changed\" ]; then printf \"%s\\n\" \"$changed\"; else echo \"(none)\"; fi; if printf \"%s\\n\" \"$changed\" | grep -Eq \"^(package(-lock)?\\.json$|src/|scripts/|tests/|fixtures/)\"; then echo \"impact=wide\"; echo \"next=npm run loop-impact-wide\"; echo \"reason=runtime package, script, fixture, or test surface changed; use the full package gate\"; else echo \"impact=normal\"; echo \"next=npm run loop-impact-run\"; echo \"reason=docs/policy or localized non-runtime surface; use the normal package gate\"; fi'",
|
|
36
|
+
"loop-impact-run": "npm run lint && npm test",
|
|
37
|
+
"loop-impact-wide": "bash -lc 'echo \"loop-impact-wide: explicit wide validation accepted; reason=${LOOP_WIDE_REASON:-not-provided}\"; npm run lint && npm test'",
|
|
38
|
+
"loop-landing-check": "npm run lint && npm test",
|
|
39
|
+
"prepublishOnly": "npm run lint && npm test"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/.gitkeep
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/src/index.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runRuntimeRecordFlow,
|
|
3
|
+
RUNTIME_RECORD_RESULT_SCHEMA_VERSION,
|
|
4
|
+
} from "./runtime_record_flow.mjs";
|
|
5
|
+
|
|
6
|
+
export const DEPDIET_RUNTIME_RECORD_ADAPTER_ID = "runtime-trace-insights.runtimeRecord.v1";
|
|
7
|
+
export const RUNTIME_RECORD_ADAPTER_CONTRACT_VERSION = "depdiet.runtime.record.adapter.v1";
|
|
8
|
+
|
|
9
|
+
function asNonEmptyString(value) {
|
|
10
|
+
if (typeof value !== "string") {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const normalized = value.trim();
|
|
15
|
+
return normalized.length > 0 ? normalized : null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function createAdapterMetadata({ id, name }) {
|
|
19
|
+
return {
|
|
20
|
+
id: asNonEmptyString(id) ?? DEPDIET_RUNTIME_RECORD_ADAPTER_ID,
|
|
21
|
+
name: asNonEmptyString(name) ?? "runtime-trace-insights",
|
|
22
|
+
contractVersion: RUNTIME_RECORD_ADAPTER_CONTRACT_VERSION,
|
|
23
|
+
contract_version: RUNTIME_RECORD_ADAPTER_CONTRACT_VERSION,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function normalizeRuntimeRecordResult(result, adapterMetadata) {
|
|
28
|
+
const normalizedResult = result && typeof result === "object"
|
|
29
|
+
? result
|
|
30
|
+
: {
|
|
31
|
+
ok: false,
|
|
32
|
+
diagnostics: [
|
|
33
|
+
{
|
|
34
|
+
code: "runtimeRecord.adapterInvalidResult",
|
|
35
|
+
level: "error",
|
|
36
|
+
source: "runtimeTraceInsightsAdapter",
|
|
37
|
+
message: "Runtime record flow returned a non-object result.",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const schemaVersion = asNonEmptyString(normalizedResult.schema_version)
|
|
43
|
+
?? asNonEmptyString(normalizedResult.schemaVersion)
|
|
44
|
+
?? RUNTIME_RECORD_RESULT_SCHEMA_VERSION;
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
...normalizedResult,
|
|
48
|
+
schemaVersion,
|
|
49
|
+
schema_version: schemaVersion,
|
|
50
|
+
adapter: {
|
|
51
|
+
...(normalizedResult.adapter && typeof normalizedResult.adapter === "object"
|
|
52
|
+
? normalizedResult.adapter
|
|
53
|
+
: {}),
|
|
54
|
+
...adapterMetadata,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function createDepdietRuntimeRecordAdapter(options = {}) {
|
|
60
|
+
const adapterMetadata = createAdapterMetadata({
|
|
61
|
+
id: options.id,
|
|
62
|
+
name: options.name,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const runner = typeof options.runner === "function"
|
|
66
|
+
? options.runner
|
|
67
|
+
: runRuntimeRecordFlow;
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
...adapterMetadata,
|
|
71
|
+
run(runtimeRecordOptions = {}) {
|
|
72
|
+
const result = runner(runtimeRecordOptions);
|
|
73
|
+
return normalizeRuntimeRecordResult(result, adapterMetadata);
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const runtimeRecordAdapter = createDepdietRuntimeRecordAdapter();
|
|
79
|
+
|
|
80
|
+
export default runtimeRecordAdapter;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export {
|
|
2
|
+
runRuntimeRecordFlow,
|
|
3
|
+
RUNTIME_RECORD_INTERNALS,
|
|
4
|
+
DEFAULT_RECORD_ARTIFACT_DIR,
|
|
5
|
+
DEFAULT_RUNTIME_TRACE_MANIFEST_PATH,
|
|
6
|
+
DEFAULT_RUNTIME_TRACE_MANIFEST_RETENTION_COUNT,
|
|
7
|
+
RUNTIME_TRACE_SCHEMA_VERSION,
|
|
8
|
+
RUNTIME_TRACE_MANIFEST_SCHEMA_VERSION,
|
|
9
|
+
APPMAP_SETUP_GUIDANCE_SCHEMA_VERSION,
|
|
10
|
+
RUNTIME_RECORD_RESULT_SCHEMA_VERSION,
|
|
11
|
+
} from "./runtime_record_flow.mjs";
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
DEPDIET_RUNTIME_RECORD_ADAPTER_ID,
|
|
15
|
+
RUNTIME_RECORD_ADAPTER_CONTRACT_VERSION,
|
|
16
|
+
createDepdietRuntimeRecordAdapter,
|
|
17
|
+
runtimeRecordAdapter,
|
|
18
|
+
} from "./depdiet_runtime_record_adapter.mjs";
|