@codyswann/lisa 4.84.6 → 4.84.8
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/all/copy-overwrite/scripts/lib/completion-authorization.mjs +282 -0
- package/all/copy-overwrite/scripts/lib/completion-proof-adapters.mjs +213 -0
- package/all/copy-overwrite/scripts/lib/completion-proof-conformance.mjs +115 -0
- package/all/copy-overwrite/scripts/lib/completion-proof-content.mjs +408 -0
- package/all/copy-overwrite/scripts/lib/completion-proof-errors.mjs +16 -0
- package/all/copy-overwrite/scripts/lib/completion-proof-github.mjs +233 -0
- package/all/copy-overwrite/scripts/lib/completion-proof-markdown.mjs +70 -0
- package/all/copy-overwrite/scripts/lib/completion-proof-projection.mjs +169 -0
- package/all/copy-overwrite/scripts/lib/completion-proof-publisher.mjs +238 -0
- package/all/copy-overwrite/scripts/lib/completion-proof-reader.mjs +175 -0
- package/all/copy-overwrite/scripts/lib/completion-proof-shape.mjs +374 -0
- package/all/copy-overwrite/scripts/lib/completion-proof-source.mjs +174 -0
- package/all/copy-overwrite/scripts/lib/history-secret-scanner.mjs +20 -5
- package/all/copy-overwrite/scripts/lib/npm-update-helper-inventory.mjs +15 -0
- package/all/copy-overwrite/scripts/lib/usage-effectiveness.d.mts +27 -0
- package/all/copy-overwrite/scripts/lib/usage-effectiveness.mjs +156 -0
- package/all/copy-overwrite/scripts/lib/usage-ledger-integrity.d.mts +8 -0
- package/all/copy-overwrite/scripts/lib/usage-ledger-integrity.mjs +141 -0
- package/all/copy-overwrite/scripts/lib/usage-ledger.d.mts +89 -0
- package/all/copy-overwrite/scripts/lib/usage-ledger.mjs +206 -0
- package/all/copy-overwrite/scripts/lisa-hooks/parity-safety-net.sh +3 -1
- package/all/copy-overwrite/scripts/lisa-work-item.mjs +255 -39
- package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +141 -3
- package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
- package/dist/core/lisa-owned-hash-ledger.js +186 -0
- package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
- package/dist/core/upstream-evidence-manifest.js +108 -15
- package/dist/core/upstream-evidence-manifest.js.map +1 -1
- package/dist/opencode/plugin-templates/parity-safety-net.sh +3 -1
- package/dist/utils/effectiveness.d.ts +4 -41
- package/dist/utils/effectiveness.d.ts.map +1 -1
- package/dist/utils/effectiveness.js +2 -126
- package/dist/utils/effectiveness.js.map +1 -1
- package/dist/utils/usage-accounting.d.ts +5 -100
- package/dist/utils/usage-accounting.d.ts.map +1 -1
- package/dist/utils/usage-accounting.js +4 -287
- package/dist/utils/usage-accounting.js.map +1 -1
- package/package.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-drive-pr-to-merge/SKILL.md +15 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-tracker-evidence/SKILL.md +7 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-tracker-evidence/references/completion-authorization.md +193 -0
- package/plugins/lisa/hooks/block-host-name-leak.mjs +25 -13
- package/plugins/lisa/hooks/host-name-command-context.mjs +16 -4
- package/plugins/lisa/hooks/parity-safety-net.sh +3 -1
- package/plugins/lisa/rules/eager/00-rule-index.md +1 -0
- package/plugins/lisa/rules/reference/completion-authorization.md +10 -0
- package/plugins/lisa/skills/lisa-drive-pr-to-merge/SKILL.md +15 -1
- package/plugins/lisa/skills/lisa-tracker-evidence/SKILL.md +7 -1
- package/plugins/lisa/skills/lisa-tracker-evidence/references/completion-authorization.md +193 -0
- package/plugins/lisa-agy/hooks/block-host-name-leak.mjs +25 -13
- package/plugins/lisa-agy/hooks/host-name-command-context.mjs +16 -4
- package/plugins/lisa-agy/hooks/parity-safety-net.sh +3 -1
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/skills/lisa-drive-pr-to-merge/SKILL.md +15 -1
- package/plugins/lisa-agy/skills/lisa-tracker-evidence/SKILL.md +7 -1
- package/plugins/lisa-agy/skills/lisa-tracker-evidence/references/completion-authorization.md +193 -0
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/hooks/block-host-name-leak.mjs +25 -13
- package/plugins/lisa-copilot/hooks/host-name-command-context.mjs +16 -4
- package/plugins/lisa-copilot/hooks/parity-safety-net.sh +3 -1
- package/plugins/lisa-copilot/rules/eager/00-rule-index.md +1 -0
- package/plugins/lisa-copilot/rules/reference/completion-authorization.md +10 -0
- package/plugins/lisa-copilot/skills/lisa-drive-pr-to-merge/SKILL.md +15 -1
- package/plugins/lisa-copilot/skills/lisa-tracker-evidence/SKILL.md +7 -1
- package/plugins/lisa-copilot/skills/lisa-tracker-evidence/references/completion-authorization.md +193 -0
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/hooks/block-host-name-leak.mjs +25 -13
- package/plugins/lisa-cursor/hooks/host-name-command-context.mjs +16 -4
- package/plugins/lisa-cursor/hooks/parity-safety-net.sh +3 -1
- package/plugins/lisa-cursor/rules/00-rule-index.mdc +1 -0
- package/plugins/lisa-cursor/rules/completion-authorization-reference.mdc +15 -0
- package/plugins/lisa-cursor/skills/lisa-drive-pr-to-merge/SKILL.md +15 -1
- package/plugins/lisa-cursor/skills/lisa-tracker-evidence/SKILL.md +7 -1
- package/plugins/lisa-cursor/skills/lisa-tracker-evidence/references/completion-authorization.md +193 -0
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/hooks/block-host-name-leak.mjs +25 -13
- package/plugins/lisa-devin/hooks/host-name-command-context.mjs +16 -4
- package/plugins/lisa-devin/hooks/parity-safety-net.sh +3 -1
- package/plugins/lisa-devin/rules/eager/00-rule-index.md +1 -0
- package/plugins/lisa-devin/rules/reference/completion-authorization.md +10 -0
- package/plugins/lisa-devin/skills/lisa-drive-pr-to-merge/SKILL.md +15 -1
- package/plugins/lisa-devin/skills/lisa-tracker-evidence/SKILL.md +7 -1
- package/plugins/lisa-devin/skills/lisa-tracker-evidence/references/completion-authorization.md +193 -0
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-agy/plugin.json +1 -1
- package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/hooks/block-host-name-leak.mjs +25 -13
- package/plugins/src/base/hooks/host-name-command-context.mjs +16 -4
- package/plugins/src/base/hooks/parity-safety-net.sh +3 -1
- package/plugins/src/base/rules/eager/00-rule-index.md +1 -0
- package/plugins/src/base/rules/reference/completion-authorization.md +10 -0
- package/plugins/src/base/skills/lisa-drive-pr-to-merge/SKILL.md +15 -1
- package/plugins/src/base/skills/lisa-tracker-evidence/SKILL.md +7 -1
- package/plugins/src/base/skills/lisa-tracker-evidence/references/completion-authorization.md +193 -0
- package/scripts/lib/host-name-expanded-command-cases.mjs +286 -0
- package/scripts/lib/host-name-field-occurrence-cases.mjs +60 -0
- package/scripts/two-channel-couplings.json +2 -2
- package/scripts/verify-host-name-target-scope.mjs +27 -1
- package/typescript/copy-overwrite/.prettierignore +15 -0
- package/typescript/copy-overwrite/scripts/check-skipped-required-checks.mjs +32 -0
|
@@ -3475,8 +3475,10 @@ if [ -f "$rules_file" ]; then
|
|
|
3475
3475
|
# here — before the remaining rules ran, and with an exit status that is
|
|
3476
3476
|
# not a refusal. The `||` puts the pipeline in a condition context, where
|
|
3477
3477
|
# a non-zero status is expected rather than fatal.
|
|
3478
|
+
# Consume the whole input: grep -q can close an early match while printf
|
|
3479
|
+
# is still writing, making pipefail report SIGPIPE instead of the match.
|
|
3478
3480
|
rule_status=0
|
|
3479
|
-
printf '%s' "$custom_command_str" | grep -
|
|
3481
|
+
printf '%s' "$custom_command_str" | grep -Ei -- "$rule" >/dev/null || rule_status=$?
|
|
3480
3482
|
case "$rule_status" in
|
|
3481
3483
|
0) block "matched a project custom safety rule (${rules_file##*/}): $rule" ;;
|
|
3482
3484
|
1) ;; # no match
|
|
@@ -1,44 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly workerConfigRevision: string | null;
|
|
6
|
-
readonly workerWallMs: number | null;
|
|
7
|
-
readonly feedbackMs: readonly number[] | null;
|
|
8
|
-
readonly workerSource: string | null;
|
|
9
|
-
readonly attention: readonly {
|
|
10
|
-
readonly id: string;
|
|
11
|
-
readonly source: string;
|
|
12
|
-
}[] | null;
|
|
13
|
-
readonly readyAt: string | null;
|
|
14
|
-
readonly acceptedAt: string | null;
|
|
15
|
-
readonly lifecycleSources: readonly string[] | null;
|
|
16
|
-
readonly reworkSources: readonly string[] | null;
|
|
17
|
-
}
|
|
1
|
+
import { isEvidenceString, isEvidenceTime, parseEffectiveness, parseEffectivenessTokens } from "../../all/copy-overwrite/scripts/lib/usage-effectiveness.mjs";
|
|
2
|
+
import type { EffectivenessObservation } from "../../all/copy-overwrite/scripts/lib/usage-effectiveness.mjs";
|
|
3
|
+
export { isEvidenceString, isEvidenceTime, parseEffectiveness, parseEffectivenessTokens, };
|
|
4
|
+
export type { EffectivenessObservation };
|
|
18
5
|
/**
|
|
19
6
|
* Normalize and hash exactly as the gardener does, independent of ledger entry versions.
|
|
20
7
|
* @param invariant - Rule whose recurrence is being measured
|
|
21
8
|
* @returns Twelve-character SHA-256 prefix
|
|
22
9
|
*/
|
|
23
10
|
export declare function invariantFingerprint(invariant: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Require a nonempty evidence identifier.
|
|
26
|
-
* @param value - Untrusted field
|
|
27
|
-
* @returns Whether this is a nonempty string
|
|
28
|
-
*/
|
|
29
|
-
export declare function isEvidenceString(value: unknown): value is string;
|
|
30
|
-
/**
|
|
31
|
-
* Require an unambiguous UTC instant rather than a locale-dependent date.
|
|
32
|
-
* @param value - Untrusted timestamp
|
|
33
|
-
* @returns Whether this is a canonical UTC instant
|
|
34
|
-
*/
|
|
35
|
-
export declare function isEvidenceTime(value: unknown): value is string;
|
|
36
|
-
/**
|
|
37
|
-
* Parse additive observation data, refusing malformed measurements rather than guessing.
|
|
38
|
-
* @param value - JSON-compatible input
|
|
39
|
-
* @returns Validated observation
|
|
40
|
-
*/
|
|
41
|
-
export declare function parseEffectiveness(value: unknown): EffectivenessObservation;
|
|
42
11
|
/**
|
|
43
12
|
* Summarize a run without combining distinct clocks or extrapolating missing evidence.
|
|
44
13
|
* @param observation - Validated run observations
|
|
@@ -63,10 +32,4 @@ export declare function summarizeEffectiveness(observation: EffectivenessObserva
|
|
|
63
32
|
* @returns Extension token or empty text for legacy entries
|
|
64
33
|
*/
|
|
65
34
|
export declare function renderEffectivenessToken(entryId: string, observation?: EffectivenessObservation): string;
|
|
66
|
-
/**
|
|
67
|
-
* Read correlated extensions and reject ambiguous repeated values.
|
|
68
|
-
* @param section - Managed usage markdown
|
|
69
|
-
* @returns Observation keyed by usage entry identity
|
|
70
|
-
*/
|
|
71
|
-
export declare function parseEffectivenessTokens(section: string): ReadonlyMap<string, EffectivenessObservation>;
|
|
72
35
|
//# sourceMappingURL=effectiveness.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effectiveness.d.ts","sourceRoot":"","sources":["../../src/utils/effectiveness.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"effectiveness.d.ts","sourceRoot":"","sources":["../../src/utils/effectiveness.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,8DAA8D,CAAC;AACtE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8DAA8D,CAAC;AAC7G,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,wBAAwB,GACzB,CAAC;AACF,YAAY,EAAE,wBAAwB,EAAE,CAAC;AAIzC;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAK9D;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,wBAAwB;;;;;;;;;;;EAgC3E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,wBAAwB,GACrC,MAAM,CAGR"}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
+
import { isEvidenceString, isEvidenceTime, parseEffectiveness, parseEffectivenessTokens, } from "../../all/copy-overwrite/scripts/lib/usage-effectiveness.mjs";
|
|
2
|
+
export { isEvidenceString, isEvidenceTime, parseEffectiveness, parseEffectivenessTokens, };
|
|
1
3
|
/** Observations, not scores. Unknown clocks stay null and evidence stays explicit. */
|
|
2
4
|
import { createHash } from "node:crypto";
|
|
3
|
-
const FIELDS = [
|
|
4
|
-
"schema",
|
|
5
|
-
"lisaVersion",
|
|
6
|
-
"workerConfigRevision",
|
|
7
|
-
"workerWallMs",
|
|
8
|
-
"feedbackMs",
|
|
9
|
-
"workerSource",
|
|
10
|
-
"attention",
|
|
11
|
-
"readyAt",
|
|
12
|
-
"acceptedAt",
|
|
13
|
-
"lifecycleSources",
|
|
14
|
-
"reworkSources",
|
|
15
|
-
];
|
|
16
5
|
/**
|
|
17
6
|
* Normalize and hash exactly as the gardener does, independent of ledger entry versions.
|
|
18
7
|
* @param invariant - Rule whose recurrence is being measured
|
|
@@ -24,99 +13,6 @@ export function invariantFingerprint(invariant) {
|
|
|
24
13
|
.digest("hex")
|
|
25
14
|
.slice(0, 12);
|
|
26
15
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Require a nonempty evidence identifier.
|
|
29
|
-
* @param value - Untrusted field
|
|
30
|
-
* @returns Whether this is a nonempty string
|
|
31
|
-
*/
|
|
32
|
-
export function isEvidenceString(value) {
|
|
33
|
-
return typeof value === "string" && value.trim().length > 0;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Require an unambiguous UTC instant rather than a locale-dependent date.
|
|
37
|
-
* @param value - Untrusted timestamp
|
|
38
|
-
* @returns Whether this is a canonical UTC instant
|
|
39
|
-
*/
|
|
40
|
-
export function isEvidenceTime(value) {
|
|
41
|
-
return (typeof value === "string" &&
|
|
42
|
-
Number.isFinite(Date.parse(value)) &&
|
|
43
|
-
new Date(value).toISOString() === value);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Validate a duration without converting missing values to zero.
|
|
47
|
-
* @param value - Untrusted duration
|
|
48
|
-
* @returns Whether duration is finite and nonnegative
|
|
49
|
-
*/
|
|
50
|
-
function isDuration(value) {
|
|
51
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Validate optional source lists.
|
|
55
|
-
* @param value - Untrusted sources
|
|
56
|
-
* @returns Whether sources are valid or explicitly unavailable
|
|
57
|
-
*/
|
|
58
|
-
function isSources(value) {
|
|
59
|
-
return (value === null || (Array.isArray(value) && value.every(isEvidenceString)));
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Validate observed human interventions; timestamps cannot imply minutes of work.
|
|
63
|
-
* @param value - Untrusted events
|
|
64
|
-
* @returns Whether all events carry stable identity and source
|
|
65
|
-
*/
|
|
66
|
-
function isAttention(value) {
|
|
67
|
-
return (value === null ||
|
|
68
|
-
(Array.isArray(value) &&
|
|
69
|
-
value.every(event => event !== null &&
|
|
70
|
-
typeof event === "object" &&
|
|
71
|
-
Object.keys(event).length === 2 &&
|
|
72
|
-
isEvidenceString(event.id) &&
|
|
73
|
-
isEvidenceString(event.source))));
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Check nullable clock fields and the evidence needed to interpret them.
|
|
77
|
-
* @param row - Candidate observation
|
|
78
|
-
* @returns Whether clocks are valid and sourced
|
|
79
|
-
*/
|
|
80
|
-
function validClocks(row) {
|
|
81
|
-
const durations = (row.workerWallMs === null || isDuration(row.workerWallMs)) &&
|
|
82
|
-
(row.feedbackMs === null ||
|
|
83
|
-
(Array.isArray(row.feedbackMs) && row.feedbackMs.every(isDuration)));
|
|
84
|
-
const sourcedWorker = (row.workerWallMs === null && row.feedbackMs === null) ||
|
|
85
|
-
isEvidenceString(row.workerSource);
|
|
86
|
-
const times = [row.readyAt, row.acceptedAt].every(value => value === null || isEvidenceTime(value));
|
|
87
|
-
const sourcedLifecycle = (row.readyAt === null && row.acceptedAt === null) ||
|
|
88
|
-
(Array.isArray(row.lifecycleSources) && row.lifecycleSources.length > 0);
|
|
89
|
-
const ordered = !isEvidenceTime(row.readyAt) ||
|
|
90
|
-
!isEvidenceTime(row.acceptedAt) ||
|
|
91
|
-
Date.parse(row.acceptedAt) >= Date.parse(row.readyAt);
|
|
92
|
-
return durations && sourcedWorker && times && sourcedLifecycle && ordered;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Parse additive observation data, refusing malformed measurements rather than guessing.
|
|
96
|
-
* @param value - JSON-compatible input
|
|
97
|
-
* @returns Validated observation
|
|
98
|
-
*/
|
|
99
|
-
export function parseEffectiveness(value) {
|
|
100
|
-
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
101
|
-
throw new Error("Invalid effectiveness observation");
|
|
102
|
-
const row = value;
|
|
103
|
-
const shape = Object.keys(row).length === FIELDS.length &&
|
|
104
|
-
FIELDS.every(key => Object.hasOwn(row, key));
|
|
105
|
-
const tags = [
|
|
106
|
-
row.lisaVersion,
|
|
107
|
-
row.workerConfigRevision,
|
|
108
|
-
row.workerSource,
|
|
109
|
-
].every(tag => tag === null || isEvidenceString(tag));
|
|
110
|
-
if (!shape ||
|
|
111
|
-
row.schema !== 1 ||
|
|
112
|
-
!tags ||
|
|
113
|
-
!isAttention(row.attention) ||
|
|
114
|
-
!isSources(row.lifecycleSources) ||
|
|
115
|
-
!isSources(row.reworkSources) ||
|
|
116
|
-
!validClocks(row))
|
|
117
|
-
throw new Error("Invalid or unsourced effectiveness observation");
|
|
118
|
-
return value;
|
|
119
|
-
}
|
|
120
16
|
/**
|
|
121
17
|
* Summarize a run without combining distinct clocks or extrapolating missing evidence.
|
|
122
18
|
* @param observation - Validated run observations
|
|
@@ -160,24 +56,4 @@ export function renderEffectivenessToken(entryId, observation) {
|
|
|
160
56
|
return "";
|
|
161
57
|
return ` <!-- lisa:usage-effectiveness entry_id=${encodeURIComponent(entryId)} data=${encodeURIComponent(JSON.stringify(parseEffectiveness(observation)))} -->`;
|
|
162
58
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Read correlated extensions and reject ambiguous repeated values.
|
|
165
|
-
* @param section - Managed usage markdown
|
|
166
|
-
* @returns Observation keyed by usage entry identity
|
|
167
|
-
*/
|
|
168
|
-
export function parseEffectivenessTokens(section) {
|
|
169
|
-
const rows = Array.from(section.matchAll(/<!-- lisa:usage-effectiveness [^\r\n]*? -->/gu), token => {
|
|
170
|
-
const match = /^<!-- lisa:usage-effectiveness entry_id=(\S+) data=(\S+) -->$/u.exec(token[0]);
|
|
171
|
-
if (match === null)
|
|
172
|
-
throw new Error("Invalid effectiveness extension");
|
|
173
|
-
return [
|
|
174
|
-
decodeURIComponent(match[1] ?? ""),
|
|
175
|
-
parseEffectiveness(JSON.parse(decodeURIComponent(match[2] ?? ""))),
|
|
176
|
-
];
|
|
177
|
-
});
|
|
178
|
-
const entries = new Map(rows);
|
|
179
|
-
if (rows.some(([id, row]) => JSON.stringify(entries.get(id)) !== JSON.stringify(row)))
|
|
180
|
-
throw new Error("Conflicting effectiveness extensions");
|
|
181
|
-
return entries;
|
|
182
|
-
}
|
|
183
59
|
//# sourceMappingURL=effectiveness.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effectiveness.js","sourceRoot":"","sources":["../../src/utils/effectiveness.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"effectiveness.js","sourceRoot":"","sources":["../../src/utils/effectiveness.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,64 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface LisaUsageEntry {
|
|
7
|
-
artifactRef: string;
|
|
8
|
-
cachedInputTokens: number | null;
|
|
9
|
-
cost: number | null;
|
|
10
|
-
currency: string | null;
|
|
11
|
-
entryId: string;
|
|
12
|
-
effectiveness?: EffectivenessObservation;
|
|
13
|
-
flow: string;
|
|
14
|
-
inputTokens: number | null;
|
|
15
|
-
measuredSubsetTokens?: number | null;
|
|
16
|
-
model: string;
|
|
17
|
-
outputTokens: number | null;
|
|
18
|
-
parentArtifactRef: string | null;
|
|
19
|
-
pricingSource: string | null;
|
|
20
|
-
pricingStatus: string;
|
|
21
|
-
provider: string;
|
|
22
|
-
reasoningTokens: number | null;
|
|
23
|
-
runId: string;
|
|
24
|
-
source: string;
|
|
25
|
-
totalTokens: number | null;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
export interface LisaUsageRollup {
|
|
31
|
-
childCost: number | null;
|
|
32
|
-
childCurrency: string | null;
|
|
33
|
-
childEntryIds: readonly string[];
|
|
34
|
-
childRefs: readonly string[];
|
|
35
|
-
childTokens: number | null;
|
|
36
|
-
childTokensIncomplete?: boolean;
|
|
37
|
-
currency: string | null;
|
|
38
|
-
directCost: number | null;
|
|
39
|
-
directEntryIds: readonly string[];
|
|
40
|
-
directTokens: number | null;
|
|
41
|
-
totalCost: number | null;
|
|
42
|
-
totalTokens: number | null;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
*/
|
|
47
|
-
export interface LisaUsageChildArtifact {
|
|
48
|
-
artifactRef: string;
|
|
49
|
-
entries: readonly LisaUsageEntry[];
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
*/
|
|
54
|
-
export interface ParsedLisaUsageSection {
|
|
55
|
-
entries: readonly LisaUsageEntry[];
|
|
56
|
-
range: {
|
|
57
|
-
end: number;
|
|
58
|
-
start: number;
|
|
59
|
-
} | null;
|
|
60
|
-
rollup: LisaUsageRollup | null;
|
|
61
|
-
}
|
|
1
|
+
import { LISA_USAGE_HEADING, parseLisaUsageSection } from "../../all/copy-overwrite/scripts/lib/usage-ledger.mjs";
|
|
2
|
+
import { verifyLisaUsageSectionIntegrity } from "../../all/copy-overwrite/scripts/lib/usage-ledger-integrity.mjs";
|
|
3
|
+
import type { LisaUsageEntry, LisaUsageRollup, LisaUsageChildArtifact, ParsedLisaUsageSection, LisaUsageSectionIntegrityIssue, LisaUsageSectionIntegrityResult } from "../../all/copy-overwrite/scripts/lib/usage-ledger.mjs";
|
|
4
|
+
export { LISA_USAGE_HEADING, parseLisaUsageSection, verifyLisaUsageSectionIntegrity, };
|
|
5
|
+
export type { LisaUsageEntry, LisaUsageRollup, LisaUsageChildArtifact, ParsedLisaUsageSection, LisaUsageSectionIntegrityIssue, LisaUsageSectionIntegrityResult, };
|
|
62
6
|
/**
|
|
63
7
|
* Merge new usage entries into an existing ledger while keeping stable order for
|
|
64
8
|
* previously recorded entries and replacing matching `entry_id` rows in place.
|
|
@@ -115,45 +59,6 @@ export declare function renderLisaUsageSection(input: {
|
|
|
115
59
|
entries: readonly LisaUsageEntry[];
|
|
116
60
|
rollup: LisaUsageRollup;
|
|
117
61
|
}): string;
|
|
118
|
-
/**
|
|
119
|
-
* Parse the managed usage section out of an artifact body or comment.
|
|
120
|
-
*
|
|
121
|
-
* @param document Artifact markdown to inspect.
|
|
122
|
-
* @returns Parsed direct entries, rollup token, and the located section range.
|
|
123
|
-
*/
|
|
124
|
-
export declare function parseLisaUsageSection(document: string): ParsedLisaUsageSection;
|
|
125
|
-
/**
|
|
126
|
-
* Describe one way a stored managed usage section fails to be a readable ledger.
|
|
127
|
-
*/
|
|
128
|
-
export interface LisaUsageSectionIntegrityIssue {
|
|
129
|
-
code: "missing-entry-token" | "missing-rollup-token" | "missing-section" | "unrecorded-entry";
|
|
130
|
-
entryIds: readonly string[];
|
|
131
|
-
message: string;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
*
|
|
135
|
-
*/
|
|
136
|
-
export interface LisaUsageSectionIntegrityResult {
|
|
137
|
-
issues: readonly LisaUsageSectionIntegrityIssue[];
|
|
138
|
-
ok: boolean;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Verify that a STORED managed usage section is still a readable ledger.
|
|
142
|
-
*
|
|
143
|
-
* This exists because a write surface can accept a section, report success, and
|
|
144
|
-
* silently destroy part of it. Callers must run this against the bytes read back
|
|
145
|
-
* from the host, never against the payload they sent and never against the
|
|
146
|
-
* mutation's return value — trusting the mutation result is precisely what let a
|
|
147
|
-
* Linear description strip every entry token while reporting `success: true`.
|
|
148
|
-
*
|
|
149
|
-
* @param storedDocument Artifact body or comment body as read back from the host.
|
|
150
|
-
* @param expected Optional expectations from the write that was just performed.
|
|
151
|
-
* @param expected.entryIds Entry ids the caller believes it just persisted.
|
|
152
|
-
* @returns Whether the stored ledger is enumerable, plus every issue found.
|
|
153
|
-
*/
|
|
154
|
-
export declare function verifyLisaUsageSectionIntegrity(storedDocument: string, expected?: {
|
|
155
|
-
entryIds?: readonly string[];
|
|
156
|
-
}): LisaUsageSectionIntegrityResult;
|
|
157
62
|
/**
|
|
158
63
|
* Append or replace the canonical `## Lisa Usage` section in a markdown
|
|
159
64
|
* artifact while preserving prior entries that are not being refreshed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-accounting.d.ts","sourceRoot":"","sources":["../../src/utils/usage-accounting.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usage-accounting.d.ts","sourceRoot":"","sources":["../../src/utils/usage-accounting.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,+BAA+B,EAAE,MAAM,iEAAiE,CAAC;AAClH,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,8BAA8B,EAC9B,+BAA+B,EAChC,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,+BAA+B,GAChC,CAAC;AACF,YAAY,EACV,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,8BAA8B,EAC9B,+BAA+B,GAChC,CAAC;AA4JF;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,SAAS,cAAc,EAAE,EAC1C,WAAW,EAAE,SAAS,cAAc,EAAE,GACrC,SAAS,cAAc,EAAE,CAsB3B;AA+FD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,cAAc,CAAC,EAAE,eAAe,GAAG,IAAI,EACvC,cAAc,CAAC,EAAE,SAAS,sBAAsB,EAAE,GACjD,eAAe,CAoDjB;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAIvE;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAK1E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IACnC,MAAM,EAAE,eAAe,CAAC;CACzB,GAAG,MAAM,CAyBT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE;IACL,cAAc,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAC;IACnD,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IACnC,MAAM,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;CACjC,GACA,MAAM,CAkCR"}
|