bailinghub 0.9.0 → 0.9.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.
Files changed (139) hide show
  1. package/.dockerignore +6 -0
  2. package/.npmignore +6 -0
  3. package/CONTRIBUTING.md +4 -0
  4. package/GOVERNANCE.md +9 -0
  5. package/README.en.md +7 -6
  6. package/README.md +7 -6
  7. package/SECURITY.md +8 -2
  8. package/THIRD_PARTY_NOTICES.md +17 -17
  9. package/docker-compose.images.yml +2 -2
  10. package/docs/CHANGELOG.en.md +22 -1
  11. package/docs/CHANGELOG.md +22 -1
  12. package/docs/COMPATIBILITY.en.md +4 -0
  13. package/docs/CORE_RELIABILITY.en.md +59 -0
  14. package/docs/CORE_RELIABILITY.md +59 -0
  15. package/docs/DEPLOYMENT_DIAGNOSTICS.en.md +78 -0
  16. package/docs/DEPLOYMENT_DIAGNOSTICS.md +78 -0
  17. package/docs/IMPLEMENTATION_STATUS.en.md +81 -0
  18. package/docs/IMPLEMENTATION_STATUS.md +81 -0
  19. package/docs/INDEPENDENT_VALIDATION.en.md +4 -4
  20. package/docs/INDEPENDENT_VALIDATION.md +4 -4
  21. package/docs/KERNEL_HOST_API.en.md +20 -0
  22. package/docs/KERNEL_HOST_API.md +20 -0
  23. package/docs/MODEL_BILLING.en.md +4 -0
  24. package/docs/MODEL_BILLING.md +4 -0
  25. package/docs/MODEL_PROCESS_RECOVERY.en.md +32 -0
  26. package/docs/MODEL_PROCESS_RECOVERY.md +37 -0
  27. package/docs/README.en.md +8 -0
  28. package/docs/README.md +8 -0
  29. package/docs/RELEASE_NOTES_NEXT.en.md +3 -3
  30. package/docs/RELEASE_NOTES_NEXT.md +3 -3
  31. package/docs/RELEASE_NOTES_v0.9.1.en.md +38 -0
  32. package/docs/RELEASE_NOTES_v0.9.1.md +38 -0
  33. package/docs/RELEASE_NOTES_v0.9.2.en.md +45 -0
  34. package/docs/RELEASE_NOTES_v0.9.2.md +45 -0
  35. package/docs/UPGRADE_v0.9.1.en.md +39 -0
  36. package/docs/UPGRADE_v0.9.1.md +39 -0
  37. package/docs/UPGRADE_v0.9.2.en.md +62 -0
  38. package/docs/UPGRADE_v0.9.2.md +62 -0
  39. package/docs//345/205/274/345/256/271/346/200/247/344/270/216/345/215/207/347/272/247.md +4 -0
  40. package/package.json +10 -5
  41. package/scripts/check-doc-links.mjs +4 -0
  42. package/scripts/check-image-tags.sh +1 -1
  43. package/scripts/check-release-consistency.test.mjs +2 -2
  44. package/scripts/dependency-audit.mjs +134 -0
  45. package/scripts/dependency-audit.test.mjs +125 -0
  46. package/scripts/doctor-deployment.test.ts +419 -0
  47. package/scripts/doctor-deployment.ts +357 -0
  48. package/scripts/doctor.ts +8 -1
  49. package/scripts/install-secrets.test.mjs +185 -0
  50. package/scripts/install.sh +10 -6
  51. package/scripts/osps-results.py +114 -0
  52. package/scripts/publish-images.sh +1 -1
  53. package/scripts/release-audit.mjs +5 -0
  54. package/scripts/verify-github-repo.mjs +5 -0
  55. package/security/dependency-audit-exceptions.json +192 -0
  56. package/sql/065_usage_reconciliation_scan.sql +4 -0
  57. package/sql/066_approval_continuations.sql +15 -0
  58. package/sql/README.md +9 -0
  59. package/src/app/approval-continuations.mysql.test.ts +138 -0
  60. package/src/app/approval-continuations.test.ts +325 -0
  61. package/src/app/approval-continuations.ts +107 -0
  62. package/src/app/http-server.ts +3 -0
  63. package/src/app/kernel-model-process-crash.mysql.test.ts +377 -0
  64. package/src/app/kernel-usage-lifecycle.mysql.test.ts +325 -0
  65. package/src/app/kernel.ts +23 -0
  66. package/src/app/runtime-evidence-maintenance.test.ts +55 -0
  67. package/src/app/runtime-lifecycle-default.ts +7 -0
  68. package/src/app/runtime-lifecycle.ts +39 -0
  69. package/src/core/contracts/approval-continuation.ts +43 -0
  70. package/src/core/contracts/types.ts +2 -0
  71. package/src/core/state/approval-continuation.ts +22 -0
  72. package/src/core/state/state-codec.ts +1 -0
  73. package/src/core/state/state-contracts.ts +3 -0
  74. package/src/infrastructure/config/config-approval-ledger.ts +75 -0
  75. package/src/infrastructure/config/configstore.ts +2 -2
  76. package/src/infrastructure/state/state-jsonl.ts +41 -11
  77. package/src/infrastructure/state/state-mysql.ts +27 -0
  78. package/src/modules/usage/background-work.test.ts +144 -0
  79. package/src/modules/usage/background-work.ts +50 -0
  80. package/src/modules/usage/billing-reconciliation.mysql.test.ts +163 -0
  81. package/src/modules/usage/billing-reconciliation.test.ts +71 -0
  82. package/src/modules/usage/billing-repository.ts +60 -15
  83. package/src/modules/usage/maintenance.test.ts +62 -0
  84. package/src/modules/usage/maintenance.ts +31 -0
  85. package/src/modules/usage/model-gateway.ts +11 -3
  86. package/src/modules/usage/model-tool-gateway.mysql.test.ts +1 -1
  87. package/src/modules/usage/pricing.ts +3 -2
  88. package/src/modules/usage/repository.ts +2 -0
  89. package/src/modules/usage/test-harness.ts +2 -1
  90. package/src/routes/admin-default.ts +2 -2
  91. package/src/routes/admin-runtime-default.ts +2 -2
  92. package/src/routes/admin-runtime.test.ts +1 -1
  93. package/src/routes/admin-runtime.ts +25 -18
  94. package/src/routes/admin.ts +1 -1
  95. package/src/routes/approvals-default.ts +2 -2
  96. package/src/routes/approvals.ts +30 -33
  97. package/src/routes/critical-routes.test.ts +16 -3
  98. package/src/test-support/approval-continuation-crash-child.ts +24 -0
  99. package/src/test-support/model-process-crash-child.ts +78 -0
  100. package/web/console/assets/{Accounts-DnddhY6t.js → Accounts-DKhw_QLr.js} +1 -1
  101. package/web/console/assets/{AgentClients-VInbD7JS.js → AgentClients-CM4_5HaA.js} +1 -1
  102. package/web/console/assets/{AgentTasks-B-1XklBg.js → AgentTasks-CkQgZTU5.js} +1 -1
  103. package/web/console/assets/{Approvals-34qUPHf0.js → Approvals-B9O9TkbO.js} +1 -1
  104. package/web/console/assets/{Audit-BbVgkSm2.js → Audit-2vDC1SPu.js} +1 -1
  105. package/web/console/assets/{BrandLockup-DgscF28e.js → BrandLockup-BgASiRSE.js} +1 -1
  106. package/web/console/assets/{Channels-Bp-yuk8d.js → Channels-A-GvkNBt.js} +1 -1
  107. package/web/console/assets/{ChatEntries-C9Ft60TS.js → ChatEntries-BLxymI67.js} +1 -1
  108. package/web/console/assets/{Clients-NPldD-DD.js → Clients-DeNlmvS6.js} +1 -1
  109. package/web/console/assets/{Cost-DZcuB-EB.js → Cost-CBq_L4Kz.js} +1 -1
  110. package/web/console/assets/{Credentials-RTT7N6zl.js → Credentials-DmtbctNj.js} +1 -1
  111. package/web/console/assets/{Diagnostics-_LeK8cce.js → Diagnostics-BbcRDiA-.js} +1 -1
  112. package/web/console/assets/{Executors-Bi7H8rIm.js → Executors-gGgmQrDt.js} +1 -1
  113. package/web/console/assets/{HelpTip-BfyWrxCE.js → HelpTip-Dtdt2tKR.js} +1 -1
  114. package/web/console/assets/{Kb-BHamz8NP.js → Kb-lgY6OXUz.js} +2 -2
  115. package/web/console/assets/{Login-C1rJR-6w.js → Login-DA6BASZd.js} +1 -1
  116. package/web/console/assets/{Projects-BRA4a48v.js → Projects-DEbmB_sT.js} +1 -1
  117. package/web/console/assets/{Routes-CTC7U-fQ.js → Routes-qS6LLoyS.js} +1 -1
  118. package/web/console/assets/{Runs-B_fa_BlD.js → Runs-DG-VLRSc.js} +1 -1
  119. package/web/console/assets/{Setup-C1_d0mFy.js → Setup-DEpVF5uw.js} +1 -1
  120. package/web/console/assets/{Shell-CHEV6RGC.js → Shell-DgoPgK1E.js} +1 -1
  121. package/web/console/assets/{StorageBuckets-DlG3ojhA.js → StorageBuckets-DJtNN769.js} +1 -1
  122. package/web/console/assets/{SystemSettings-DYo2gg6d.js → SystemSettings-0DEUgeTR.js} +1 -1
  123. package/web/console/assets/{SystemStatus-DKCoUZlq.js → SystemStatus-CR1phiPE.js} +1 -1
  124. package/web/console/assets/{Targets-CdkG6BPR.js → Targets-D65l-IMB.js} +1 -1
  125. package/web/console/assets/{Tools-DVpCt0ox.js → Tools-DqtrINrN.js} +1 -1
  126. package/web/console/assets/{Usage-DWCpLugC.js → Usage-B5njXNjx.js} +1 -1
  127. package/web/console/assets/{UsageAccess-B_Xq7ARW.js → UsageAccess-ChnB4pjb.js} +1 -1
  128. package/web/console/assets/{UsageHelp-t5ZG_f-e.js → UsageHelp-BBKIvbQ5.js} +1 -1
  129. package/web/console/assets/{index-C6W4LWVV.js → index-65JiiUr4.js} +1 -1
  130. package/web/console/assets/{index-H1kfa0Mj.js → index-sLKrJd_p.js} +2 -2
  131. package/web/console/assets/{request-DLsP1_ot.js → request-BpaimqEb.js} +1 -1
  132. package/web/console/assets/{schema-BLOHvAJQ.js → schema-D0Z4kFCZ.js} +1 -1
  133. package/web/console/assets/{util-CGVh2Jvr.js → util-DZYfJ5Zo.js} +1 -1
  134. package/web/console/assets/{vendor-element-BD089KxE.js → vendor-element-8cVcdt5T.js} +1 -1
  135. package/web/console/assets/{vendor-mammoth-Bv-CZhmH.js → vendor-mammoth-CnDA23N0.js} +1 -1
  136. package/web/console/assets/vendor-vue-Co7x2FW6.js +29 -0
  137. package/web/console/index.html +3 -3
  138. package/web-admin/package-lock.json +83 -85
  139. package/web/console/assets/vendor-vue-B2uhHUfE.js +0 -29
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env python3
2
+ """Validate the pinned scanner's JSON; successful collection is not compliance."""
3
+
4
+ import collections
5
+ import json
6
+ import os
7
+ import pathlib
8
+ import re
9
+ import sys
10
+
11
+ CATALOG = "osps-baseline-2026-08"
12
+ RESULTS = ("Passed", "Failed", "Needs Review", "Not Applicable", "Not Run", "Unknown")
13
+
14
+
15
+ def require(condition, message):
16
+ if not condition:
17
+ raise ValueError(message)
18
+
19
+
20
+ def inspect_results(document):
21
+ require(isinstance(document, dict), "result must be a JSON object")
22
+ require(document.get("service-name") == "pvtr", "unexpected scanner service")
23
+ require(document.get("plugin-name") == "github-repo", "unexpected scanner plugin")
24
+ require(document.get("plugin-uri") == "https://github.com/ossf/pvtr-github-repo-scanner",
25
+ "unexpected scanner source")
26
+ suites = document.get("evaluation-suites")
27
+ require(isinstance(suites, list) and len(suites) == 1, "expected one evaluation suite")
28
+ suite = suites[0]
29
+ require(isinstance(suite, dict), "suite must be an object")
30
+ require(suite.get("catalog-id") == CATALOG, "unexpected assessment catalog")
31
+ require(suite.get("name") == f"pvtr_{CATALOG}", "unexpected assessment suite")
32
+ require(suite.get("corrupted-state") is False, "assessment is incomplete or corrupted")
33
+ require(suite.get("result") in RESULTS, "invalid suite result")
34
+ evaluation_log = suite.get("control-evaluations")
35
+ require(isinstance(evaluation_log, dict), "missing structured control evaluations")
36
+ require(evaluation_log.get("metadata", {}).get("type") == "EvaluationLog",
37
+ "unexpected evaluation artifact type")
38
+ controls = evaluation_log.get("evaluations")
39
+ require(isinstance(controls, list) and controls, "no repository control results")
40
+ control_ids, requirement_ids, requirements = set(), set(), []
41
+ for control in controls:
42
+ require(isinstance(control, dict), "control must be an object")
43
+ ref = control.get("control", {})
44
+ control_id = ref.get("entry-id", "")
45
+ require(ref.get("reference-id") == CATALOG and
46
+ isinstance(control_id, str) and re.fullmatch(r"OSPS-[A-Z]{2}-\d{2}", control_id),
47
+ "invalid control reference")
48
+ require(control_id not in control_ids, "duplicate control result")
49
+ control_ids.add(control_id)
50
+ require(control.get("result") in RESULTS, "invalid control result")
51
+ logs = control.get("assessment-logs")
52
+ require(isinstance(logs, list) and logs, "control has no requirement results")
53
+ for log in logs:
54
+ require(isinstance(log, dict), "requirement must be an object")
55
+ ref = log.get("requirement", {})
56
+ requirement_id = ref.get("entry-id", "")
57
+ require(ref.get("reference-id") == CATALOG and isinstance(requirement_id, str) and
58
+ re.fullmatch(re.escape(control_id) + r"\.\d{2}", requirement_id),
59
+ "invalid requirement reference")
60
+ require(requirement_id not in requirement_ids, "duplicate requirement result")
61
+ requirement_ids.add(requirement_id)
62
+ require(log.get("result") in RESULTS, "invalid requirement result")
63
+ steps = log.get("steps-executed", 0)
64
+ require(type(steps) is int and steps >= 0, "invalid executed-step count")
65
+ if log["result"] not in ("Not Run", "Unknown"):
66
+ require(steps > 0, "requirement result has no executed assessment steps")
67
+ requirements.append(log)
68
+ executed = [log for log in requirements if log.get("steps-executed", 0) > 0
69
+ and log["result"] != "Not Run"]
70
+ require(executed, "no executed repository assessments")
71
+ # This requires observed repository data, not only GitHub-enforced defaults.
72
+ require(any(log["requirement"]["entry-id"] == "OSPS-QA-01.01" and
73
+ log["result"] == "Passed" for log in executed),
74
+ "scanner did not confirm the public repository was read")
75
+ return controls, requirements, executed
76
+
77
+
78
+ def summary(controls, requirements, executed):
79
+ lines = ["## OSPS Baseline collection", "", f"Catalog: `{CATALOG}` · Maturity Level 1", "",
80
+ "| Result | Controls | Requirements |", "|:--|--:|--:|"]
81
+ control_counts = collections.Counter(control["result"] for control in controls)
82
+ requirement_counts = collections.Counter(log["result"] for log in requirements)
83
+ lines += [f"| {result} | {control_counts[result]} | {requirement_counts[result]} |"
84
+ for result in RESULTS]
85
+ lines += ["", f"Validated {len(controls)} controls and {len(requirements)} requirements; "
86
+ f"{len(executed)} requirements have executed results.", "",
87
+ "Collection succeeded. This does not mean all controls passed. "
88
+ "Needs Review, Unknown and Not Run remain unresolved; the scanner's "
89
+ "'Possible' log count is not a pass count."]
90
+ findings = [log for log in requirements if log["result"] in ("Failed", "Needs Review", "Unknown")]
91
+ if findings:
92
+ lines += ["", "### Findings requiring follow-up", "", "| Requirement | Result |",
93
+ "|:--|:--|"]
94
+ lines += [f"| {log['requirement']['entry-id']} | {log['result']} |" for log in findings]
95
+ return "\n".join(lines) + "\n"
96
+
97
+
98
+ def main():
99
+ if len(sys.argv) != 2:
100
+ raise ValueError("usage: osps-results.py PATH_TO_PVTR_JSON")
101
+ document = json.loads(pathlib.Path(sys.argv[1]).read_text(encoding="utf-8"))
102
+ report = summary(*inspect_results(document))
103
+ print(report, end="")
104
+ if path := os.environ.get("GITHUB_STEP_SUMMARY"):
105
+ with pathlib.Path(path).open("a", encoding="utf-8") as stream:
106
+ stream.write(report)
107
+
108
+
109
+ if __name__ == "__main__":
110
+ try:
111
+ main()
112
+ except (OSError, ValueError, TypeError, AttributeError, KeyError) as error:
113
+ print(f"OSPS result validation failed: {error}", file=sys.stderr)
114
+ sys.exit(1)
@@ -9,7 +9,7 @@ REGISTRY="${BAILING_IMAGE_REGISTRY:-$DEFAULT_REGISTRY}"
9
9
  NAMESPACE="${BAILING_IMAGE_NAMESPACE:-$DEFAULT_NAMESPACE}"
10
10
  PACKAGE_VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' package.json | head -1)"
11
11
  TAG="${BAILING_IMAGE_TAG:-$PACKAGE_VERSION}"
12
- [ -n "$TAG" ] || TAG="0.9.0"
12
+ [ -n "$TAG" ] || TAG="0.9.2"
13
13
  NODE_IMAGE="${BAILING_NODE_IMAGE:-node:22-bookworm-slim}"
14
14
  PLATFORM="${BAILING_IMAGE_PLATFORM:-linux/amd64}"
15
15
  PUSH="${BAILING_PUSH_IMAGES:-0}"
@@ -40,6 +40,11 @@ const requiredRepoFiles = [
40
40
  'docs/RELEASE_NOTES_v0.7.0.md',
41
41
  'docs/RELEASE_NOTES_v0.8.0.md',
42
42
  'docs/RELEASE_NOTES_v0.9.0.md',
43
+ 'docs/RELEASE_NOTES_v0.9.1.md',
44
+ 'docs/RELEASE_NOTES_v0.9.2.md',
45
+ 'docs/RELEASE_NOTES_v0.9.2.en.md',
46
+ 'docs/UPGRADE_v0.9.2.md',
47
+ 'docs/UPGRADE_v0.9.2.en.md',
43
48
  'docs/RELEASE_NOTES_v0.6.1.md',
44
49
  'docs/RELEASE_NOTES_v0.6.0.md',
45
50
  'docs/CHANGELOG.md',
@@ -132,6 +132,11 @@ const requiredFiles = [
132
132
  'docs/RELEASE_NOTES_v0.7.0.md',
133
133
  'docs/RELEASE_NOTES_v0.8.0.md',
134
134
  'docs/RELEASE_NOTES_v0.9.0.md',
135
+ 'docs/RELEASE_NOTES_v0.9.1.md',
136
+ 'docs/RELEASE_NOTES_v0.9.2.md',
137
+ 'docs/RELEASE_NOTES_v0.9.2.en.md',
138
+ 'docs/UPGRADE_v0.9.2.md',
139
+ 'docs/UPGRADE_v0.9.2.en.md',
135
140
  'docs/RELEASE_NOTES_v0.6.1.md',
136
141
  'docs/RELEASE_NOTES_v0.6.0.md',
137
142
  'docs/CHANGELOG.md',
@@ -0,0 +1,192 @@
1
+ {
2
+ "version": 1,
3
+ "owner": "Jingchuan Nie",
4
+ "advisory": "https://github.com/advisories/GHSA-hp3w-g68c-fv3c",
5
+ "approvedFrom": "2026-10-10T00:00:00Z",
6
+ "expiresAt": "2026-11-09T00:00:00Z",
7
+ "reason": "No patched sprintf-js release is available; retain reviewed library-only DOCX usage. Do not apply the suggested major downgrade to mammoth 0.3.29.",
8
+ "scopes": {
9
+ "core": {
10
+ "lockPath": "package-lock.json",
11
+ "knownAuditRows": {
12
+ "argparse": {
13
+ "name": "argparse",
14
+ "severity": "moderate",
15
+ "isDirect": false,
16
+ "via": [
17
+ "sprintf-js"
18
+ ],
19
+ "effects": [
20
+ "mammoth"
21
+ ],
22
+ "range": "1.0.0 - 1.0.10",
23
+ "nodes": [
24
+ "node_modules/argparse"
25
+ ],
26
+ "fixAvailable": {
27
+ "name": "mammoth",
28
+ "version": "0.3.29",
29
+ "isSemVerMajor": true
30
+ }
31
+ },
32
+ "mammoth": {
33
+ "name": "mammoth",
34
+ "severity": "moderate",
35
+ "isDirect": true,
36
+ "via": [
37
+ "argparse"
38
+ ],
39
+ "effects": [],
40
+ "range": ">=0.3.30",
41
+ "nodes": [
42
+ "node_modules/mammoth"
43
+ ],
44
+ "fixAvailable": {
45
+ "name": "mammoth",
46
+ "version": "0.3.29",
47
+ "isSemVerMajor": true
48
+ }
49
+ },
50
+ "sprintf-js": {
51
+ "name": "sprintf-js",
52
+ "severity": "moderate",
53
+ "isDirect": false,
54
+ "via": [
55
+ {
56
+ "source": 1241202,
57
+ "name": "sprintf-js",
58
+ "dependency": "sprintf-js",
59
+ "title": "sprintf-js vulnerable to denial of service through unbounded precision specifiers",
60
+ "url": "https://github.com/advisories/GHSA-hp3w-g68c-fv3c",
61
+ "severity": "moderate",
62
+ "cwe": [
63
+ "CWE-1284"
64
+ ],
65
+ "cvss": {
66
+ "score": 5.3,
67
+ "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
68
+ },
69
+ "range": "<=1.1.3"
70
+ }
71
+ ],
72
+ "effects": [
73
+ "argparse"
74
+ ],
75
+ "range": "*",
76
+ "nodes": [
77
+ "node_modules/sprintf-js"
78
+ ],
79
+ "fixAvailable": {
80
+ "name": "mammoth",
81
+ "version": "0.3.29",
82
+ "isSemVerMajor": true
83
+ }
84
+ }
85
+ },
86
+ "packageVersions": {
87
+ "node_modules/argparse": "1.0.10",
88
+ "node_modules/mammoth": "1.12.0",
89
+ "node_modules/sprintf-js": "1.0.3"
90
+ },
91
+ "dependencyReferences": [
92
+ "<root>|dependencies|mammoth|^1.12.0",
93
+ "node_modules/argparse|dependencies|sprintf-js|~1.0.2",
94
+ "node_modules/mammoth|dependencies|argparse|~1.0.3"
95
+ ],
96
+ "reviewedUsageFiles": {
97
+ "src/adapters/llm/file.ts": "0c101ab6d18ac544285e3f0c9efdf0584d8833327625ff88a42fc51af9097f7a"
98
+ }
99
+ },
100
+ "web-admin": {
101
+ "lockPath": "web-admin/package-lock.json",
102
+ "knownAuditRows": {
103
+ "argparse": {
104
+ "name": "argparse",
105
+ "severity": "moderate",
106
+ "isDirect": false,
107
+ "via": [
108
+ "sprintf-js"
109
+ ],
110
+ "effects": [
111
+ "mammoth"
112
+ ],
113
+ "range": "1.0.0 - 1.0.10",
114
+ "nodes": [
115
+ "node_modules/argparse"
116
+ ],
117
+ "fixAvailable": {
118
+ "name": "mammoth",
119
+ "version": "0.3.29",
120
+ "isSemVerMajor": true
121
+ }
122
+ },
123
+ "mammoth": {
124
+ "name": "mammoth",
125
+ "severity": "moderate",
126
+ "isDirect": true,
127
+ "via": [
128
+ "argparse"
129
+ ],
130
+ "effects": [],
131
+ "range": ">=0.3.30",
132
+ "nodes": [
133
+ "node_modules/mammoth"
134
+ ],
135
+ "fixAvailable": {
136
+ "name": "mammoth",
137
+ "version": "0.3.29",
138
+ "isSemVerMajor": true
139
+ }
140
+ },
141
+ "sprintf-js": {
142
+ "name": "sprintf-js",
143
+ "severity": "moderate",
144
+ "isDirect": false,
145
+ "via": [
146
+ {
147
+ "source": 1241202,
148
+ "name": "sprintf-js",
149
+ "dependency": "sprintf-js",
150
+ "title": "sprintf-js vulnerable to denial of service through unbounded precision specifiers",
151
+ "url": "https://github.com/advisories/GHSA-hp3w-g68c-fv3c",
152
+ "severity": "moderate",
153
+ "cwe": [
154
+ "CWE-1284"
155
+ ],
156
+ "cvss": {
157
+ "score": 5.3,
158
+ "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
159
+ },
160
+ "range": "<=1.1.3"
161
+ }
162
+ ],
163
+ "effects": [
164
+ "argparse"
165
+ ],
166
+ "range": "*",
167
+ "nodes": [
168
+ "node_modules/sprintf-js"
169
+ ],
170
+ "fixAvailable": {
171
+ "name": "mammoth",
172
+ "version": "0.3.29",
173
+ "isSemVerMajor": true
174
+ }
175
+ }
176
+ },
177
+ "packageVersions": {
178
+ "node_modules/argparse": "1.0.10",
179
+ "node_modules/mammoth": "1.12.0",
180
+ "node_modules/sprintf-js": "1.0.3"
181
+ },
182
+ "dependencyReferences": [
183
+ "<root>|dependencies|mammoth|^1.12.0",
184
+ "node_modules/argparse|dependencies|sprintf-js|~1.0.2",
185
+ "node_modules/mammoth|dependencies|argparse|~1.0.3"
186
+ ],
187
+ "reviewedUsageFiles": {
188
+ "web-admin/src/pages/Kb.vue": "272fc1c16649e9e31d0f50c28d6d5e7ff7122f26ecf6d40f7f7f064d696979bd"
189
+ }
190
+ }
191
+ }
192
+ }
@@ -0,0 +1,4 @@
1
+ -- Supports the bounded owner-local keyset scan of already saved usage evidence.
2
+ -- No original result, request ID, price snapshot or monetary ledger is rewritten.
3
+ ALTER TABLE bz_usage_billing_requests
4
+ ADD KEY idx_usage_reconciliation_scan (billing_state, updated_at, id);
@@ -0,0 +1,15 @@
1
+ -- Decision and continuation intent commit together. Job queue admission uses its
2
+ -- own durable marker so an outbox acknowledgement loss cannot requeue it twice.
3
+ CREATE TABLE IF NOT EXISTS `bz_approval_continuations` (
4
+ `approval_id` BIGINT UNSIGNED NOT NULL,
5
+ `intent_json` JSON NOT NULL,
6
+ `audit_recorded_at` DATETIME DEFAULT NULL,
7
+ `completed_at` DATETIME DEFAULT NULL,
8
+ `created_at` DATETIME NOT NULL,
9
+ PRIMARY KEY (`approval_id`),
10
+ KEY `idx_approval_continuation_pending` (`completed_at`, `approval_id`)
11
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
12
+
13
+ ALTER TABLE `bz_jobs`
14
+ ADD COLUMN `approval_continuation_keys` JSON DEFAULT NULL
15
+ COMMENT 'Core-owned approval decision queue markers, never business metadata';
package/sql/README.md CHANGED
@@ -24,6 +24,15 @@ npm run db:init # 按文件名顺序应用所有未应用的结构文件
24
24
  - **错误码容错兜底**:`IF NOT EXISTS` 自身幂等;加列/索引遇到 1060/1061 时,只有实际列/索引结构与官方语句一致才按已完成处理,跑完即记账,此后走账本快路径。
25
25
  - **失败关闭**:账本出现既不属于活动序列、也不属于固化退役证据的文件,或者任一已记账摘要不匹配时,会在补录摘要或执行新迁移前拒绝继续。
26
26
 
27
+ ## Core 0.9.2:065/066 可靠性修复
28
+
29
+ 以下新增结构从 Core 0.9.2 提供,历史 v0.9.1 Tag 不包含它们:
30
+
31
+ - `065_usage_reconciliation_scan.sql` 新增 `(billing_state, updated_at, id)` 索引,供待结算记录公平分页,不修改历史计量或费用。
32
+ - `066_approval_continuations.sql` 新增审批补续表与 `bz_jobs.approval_continuation_keys`,配合决策事务和原任务入队去重,不回填历史决策。
33
+
34
+ 使用新审批入口前显式应用 066,并配套更新 Core state/config 仓储;缺少表时决策事务失败关闭。运行时不自动迁移,回退代码不删除补续表或标记。完整行为、升级与回退边界见[Core 可靠性修复](../docs/CORE_RELIABILITY.md)。
35
+
27
36
  ## 058 跨系统归档成员绑定
28
37
 
29
38
  `058_agent_conversation_member_bindings.sql` 在 Core 0.7.0 引入,只给已有归档增加
@@ -0,0 +1,138 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { randomUUID } from 'node:crypto';
4
+ import { fork } from 'node:child_process';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { createPool } from 'mysql2/promise';
7
+ import type { Job } from '../core/contracts/types';
8
+ import type { ConfigStoreContract } from '../infrastructure/config/configstore';
9
+ import { ApprovalLedger } from '../infrastructure/config/config-approval-ledger';
10
+ import { MysqlStore } from '../infrastructure/state/state-mysql';
11
+ import { migrateBailingHubCoreSchema } from '../infrastructure/schema/core-schema-migrator';
12
+ import { continueApprovalDecisionFor, reconcileApprovalContinuationsFor, type ApprovalContinuationDeps } from './approval-continuations';
13
+
14
+ const enabled = process.env.BAILING_APPROVAL_CONTINUATION_TEST_MYSQL === '1';
15
+
16
+ async function fixture() {
17
+ const database = `approval_acceptance_${randomUUID().replaceAll('-', '')}`;
18
+ const mysql = { host: '127.0.0.1', port: 16307, user: 'root', password: '', database, connectionLimit: 8 };
19
+ const admin = createPool({ ...mysql, database: undefined });
20
+ await admin.query(`CREATE DATABASE \`${database}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin`);
21
+ const pool = createPool({ ...mysql, timezone: 'Z' });
22
+ try {
23
+ await migrateBailingHubCoreSchema({ mysql, logger: { log() {}, warn() {} } });
24
+ const ledger = new ApprovalLedger(() => pool);
25
+ const owner = { get: async () => pool, close: async () => {} };
26
+ const store = new MysqlStore(mysql, owner); await store.init();
27
+ const now = () => new Date().toISOString();
28
+ const job: Job = { job_id: randomUUID(), request_id: `fixture-${randomUUID()}`, status: 'done', target: 'llm',
29
+ profile: 'synthetic', project: '', source: 'synthetic', input_preview: '', metadata: {}, created_at: now(), updated_at: now() };
30
+ await store.createJob(job);
31
+ const approvalId = await ledger.create({ job_id: job.job_id, request_id: job.request_id, provider: 'synthetic', tool: 'refund_create',
32
+ scope: 'refund.create', risk: 'high', args_hash: 'a'.repeat(64), args_json: '{"synthetic":true}' });
33
+ const decisionId = `decision-${randomUUID()}`;
34
+ let kicks = 0;
35
+ const deps: ApprovalContinuationDeps = { configStore: { approvals: ledger } as unknown as ConfigStoreContract,
36
+ stateStore: store, now, engineRuntime: { kickInhubScheduler: () => { kicks++; } } };
37
+ const decide = () => ledger.decideWithContinuation(approvalId, 'approved', 'synthetic-operator', {
38
+ decision_id: decisionId, source: 'external', auth: 'fixture', mode: 'rerun' });
39
+ return { mysql, pool, store, ledger, deps, job, approvalId, decisionId, decide, kicks: () => kicks,
40
+ close: async () => { await pool.end(); await admin.query(`DROP DATABASE \`${database}\``); await admin.end(); } };
41
+ } catch (error) {
42
+ await pool.end(); await admin.query(`DROP DATABASE \`${database}\``); await admin.end(); throw error;
43
+ }
44
+ }
45
+
46
+ for (const stage of ['after-decision', 'after-queue'] as const) test(`MySQL original approval survives actual SIGKILL ${stage}`, { skip: !enabled }, async () => {
47
+ const h = await fixture();
48
+ try {
49
+ const child = fork(fileURLToPath(new URL('../test-support/approval-continuation-crash-child.ts', import.meta.url)), [], {
50
+ execArgv: ['--import', 'tsx'], env: { PATH: process.env.PATH }, stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
51
+ });
52
+ const exited = new Promise<{ code: number | null; signal: NodeJS.Signals | null }>((resolve, reject) => {
53
+ const timeout = setTimeout(() => { child.kill('SIGKILL'); reject(new Error('synthetic crash worker timeout')); }, 10_000);
54
+ child.once('error', reject);
55
+ child.once('exit', (code, signal) => { clearTimeout(timeout); resolve({ code, signal }); });
56
+ });
57
+ const checkpoint = new Promise<any>((resolve, reject) => {
58
+ child.once('message', (message: any) => message.error ? reject(new Error(message.error)) : resolve(message));
59
+ child.once('exit', (code, signal) => { if (code !== null && code !== 0 && signal !== 'SIGKILL') reject(new Error('synthetic crash worker exited early')); });
60
+ });
61
+ child.send({ mysql: h.mysql, approvalId: h.approvalId, jobId: h.job.job_id, requestId: h.job.request_id, stage, decisionId: h.decisionId });
62
+ const evidence = await checkpoint;
63
+ assert.equal(evidence.stage, stage); assert.notEqual(evidence.pid, process.pid);
64
+ assert.equal((await exited).signal, 'SIGKILL');
65
+ assert.equal((await h.ledger.get(h.approvalId))?.status, 'approved');
66
+ assert.equal((await h.ledger.getContinuation(h.approvalId))?.completed, false);
67
+ if (stage === 'after-queue') await h.store.updateJob(h.job.job_id, { status: 'done', result: { text: 'synthetic confirmed' }, metadata: {} });
68
+ const restarted = new MysqlStore(h.mysql, { get: async () => h.pool, close: async () => {} }); await restarted.init();
69
+ h.deps.stateStore = restarted;
70
+ assert.equal(await reconcileApprovalContinuationsFor(h.deps), 1);
71
+ const recovered = await restarted.getJob(h.job.job_id);
72
+ assert.equal(recovered?.status, stage === 'after-decision' ? 'queued' : 'done');
73
+ assert.equal(recovered?.approval_continuation_keys?.[String(h.approvalId)], h.decisionId);
74
+ assert.equal(await reconcileApprovalContinuationsFor(h.deps), 0);
75
+ } finally { await h.close(); }
76
+ });
77
+
78
+ test('MySQL decision COMMIT acknowledgement lost retains decision and intent in the same transaction', { skip: !enabled }, async () => {
79
+ const h = await fixture();
80
+ try {
81
+ const faulty = new ApprovalLedger(() => ({ getConnection: async () => {
82
+ const connection = await h.pool.getConnection();
83
+ const commit = connection.commit.bind(connection);
84
+ connection.commit = async () => { connection.commit = commit; await commit(); throw new Error('synthetic decision COMMIT reply lost'); };
85
+ return connection;
86
+ } }));
87
+ await assert.rejects(() => faulty.decideWithContinuation(h.approvalId, 'approved', 'synthetic-operator', {
88
+ decision_id: h.decisionId, source: 'external', auth: 'fixture', mode: 'rerun' }), /COMMIT reply lost/);
89
+ assert.equal((await h.ledger.get(h.approvalId))?.status, 'approved');
90
+ assert.equal((await h.ledger.getContinuation(h.approvalId))?.decision_key, h.decisionId);
91
+ assert.equal(await h.decide(), 'same');
92
+ assert.equal((await continueApprovalDecisionFor(h.deps, h.approvalId)).rerun, true);
93
+ } finally { await h.close(); }
94
+ });
95
+
96
+ test('MySQL concurrent continuation and completed new run have one durable admission', { skip: !enabled }, async () => {
97
+ const h = await fixture();
98
+ try {
99
+ const decisions = await Promise.all(Array.from({ length: 8 }, () => h.decide()));
100
+ assert.equal(decisions.filter(item => item === 'decided').length, 1);
101
+ assert.equal(decisions.filter(item => item === 'same').length, 7);
102
+ const results = await Promise.all(Array.from({ length: 8 }, () => continueApprovalDecisionFor(h.deps, h.approvalId)));
103
+ assert.equal(results.filter(item => item.rerun).length, 1);
104
+ const intent = await h.ledger.getContinuation(h.approvalId);
105
+ assert.equal(intent?.completed, true);
106
+ await h.store.updateJob(h.job.job_id, { status: 'done', metadata: {}, approval_continuation_keys: {} });
107
+ assert.equal(await h.store.requeueApprovedJobOnce({ job_id: h.job.job_id, request_id: h.job.request_id,
108
+ approval_id: h.approvalId, decision_key: h.decisionId }), 'already_queued');
109
+ assert.equal((await h.store.getJob(h.job.job_id))?.status, 'done');
110
+ } finally { await h.close(); }
111
+ });
112
+
113
+ test('MySQL missing continuation table rolls back approval decision rather than orphaning it', { skip: !enabled }, async () => {
114
+ const h = await fixture();
115
+ try {
116
+ await h.pool.query('DROP TABLE bz_approval_continuations');
117
+ await assert.rejects(h.decide);
118
+ assert.equal((await h.ledger.get(h.approvalId))?.status, 'pending');
119
+ } finally { await h.close(); }
120
+ });
121
+
122
+ test('MySQL atomic admission rechecks approval consumed after the helper observation', { skip: !enabled }, async () => {
123
+ const h = await fixture();
124
+ try {
125
+ await h.decide();
126
+ const queue = h.store.requeueApprovedJobOnce.bind(h.store);
127
+ h.store.requeueApprovedJobOnce = async (input) => {
128
+ assert.equal(await h.ledger.use(h.approvalId), true);
129
+ return await queue(input);
130
+ };
131
+ const result = await continueApprovalDecisionFor(h.deps, h.approvalId);
132
+ assert.equal(result.rerun, false);
133
+ assert.equal((await h.store.getJob(h.job.job_id))?.status, 'done');
134
+ assert.equal((await h.store.getJob(h.job.job_id))?.approval_continuation_keys, undefined);
135
+ assert.equal((await h.ledger.getContinuation(h.approvalId))?.completed, true);
136
+ assert.equal(h.kicks(), 0);
137
+ } finally { await h.close(); }
138
+ });