P01: cross-platform lockfile, regression contracts and verified CI closure (#1)

fix(p01): cross-platform lock, TS regressions and notes [skip ci]
This commit was merged in pull request #1.
This commit is contained in:
victorsteele428 committed 2026-11-22 02:12:46 +00:00
1 parent d8ac96e39d
commit 667a140c4e
22 files changed
+1212 -2811

No files matched your search

+18 -5
View File
@@ -5,9 +5,21 @@ on:
paths:
- '.gitea/workflows/datastack-ci.yml'
workflow_dispatch:
inputs:
p01_only:
description: Run P01 tests, typecheck, build and Windows clean-install only
required: false
type: boolean
default: false
quality_only:
description: Run only TypeScript and ESLint after a focused P01 test type fix
required: false
type: boolean
default: false
jobs:
node-regression:
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.quality_only != 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
@@ -38,6 +50,7 @@ jobs:
test "$failed" -eq 0
python-regression:
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.p01_only != 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
@@ -72,6 +85,7 @@ jobs:
run: npm run lint
production-build:
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.quality_only != 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
@@ -87,6 +101,7 @@ jobs:
test -f .next/standalone/server.js
docker-image-build:
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.p01_only != 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 35
steps:
@@ -109,6 +124,7 @@ jobs:
docker build -f docker/Dockerfile.proxy -t datastack-ci-proxy .
windows-compatibility:
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.quality_only != 'true' }}
runs-on: windows-latest
timeout-minutes: 25
steps:
@@ -127,12 +143,9 @@ jobs:
shell: powershell
run: |
$ErrorActionPreference = 'Stop'
# Diagnostic only: regenerate the lock in the disposable runner checkout.
# The tracked repository lock remains unchanged for the later bug-fix phase.
npm install --package-lock-only --no-audit --no-fund
if ($LASTEXITCODE -ne 0) { throw 'Temporary lock regeneration failed' }
# Verify the committed cross-platform lock without disposable regeneration.
npm ci --no-audit --no-fund
if ($LASTEXITCODE -ne 0) { throw 'Diagnostic npm install failed' }
if ($LASTEXITCODE -ne 0) { throw 'Committed-lock npm ci failed' }
npm --prefix sdk/node/datastack install --no-audit --no-fund
if ($LASTEXITCODE -ne 0) { throw 'SDK install failed' }
npm --prefix sdk/node/datastack run build
-2747
View File
File diff suppressed because it is too large. Load diff
+15 -1
View File
@@ -1,6 +1,6 @@
# DataStack — Production-Readiness Forensic Audit (Documentation Baseline)
Status: **DOCUMENTED / NO BUG FIX APPLIED**. Date: 2026-11-22 (Asia/Dhaka).
Status: **BASELINE FORENSIC SNAPSHOT; P01 VERIFIED AND CLOSED (see closure appendix)**. Date: 2026-11-22 (Asia/Dhaka).
Frozen source HEAD: `d725841ebc828d58cbe90f517da9e600f23c4630`. Local, Gitea `vibtools/DataStack`, GitLab `ivibtools/datastack`, and GitHub `JILLU-Games/DataStack` confirmed at this exact HEAD before writing these notes.
Scope of this document: **evidence-backed CI and source review**, not proof that every production feature works. No Coolify live write, rollback, restart or deployment was conducted. Public GET `https://data.ivib.cc/api/health` returned `status: online`; full DB/Redis/MCP/S3 transaction health is not established.
@@ -64,3 +64,17 @@ Optional configuration review (not counted among eight): `server/index.js:1086-1
## Release acceptance rule
NOT production-update-ready until P01, conditional P02 gates, and P03 finish, 24/24 TypeScript suites exit 0, 14/14 Python tests pass, full strict `tsc --noEmit` and ESLint pass, Linux/Windows clean install is reproducible, standalone Next build passes, all 3 Docker images build, security advisories are triaged, and approved **non-mutating** live readiness checks pass. Production deploy is a separate operator-approved action; never automatic from this documentation phase.
## P01 Closure Appendix — 2026-11-22
**Implementation outcome: CI-01…CI-05 resolved within P01 source allowlist; no production app/runtime/UI/SDK changes.** Evidence: Gitea [#59](https://dev.ivib.cc/vibtools/DataStack/actions/runs/59) and focused quality retry [#60](https://dev.ivib.cc/vibtools/DataStack/actions/runs/60). Run #59 overall FAILED because a single test-only `stopTimers` type declaration remained; it was corrected in `tests/r5-phase01-mcp-foundation-logs.test.ts` and strict `tsc --noEmit` plus ESLint then PASSED in #60. The two run results are complementary; neither should be misreported as a single all-green run.
| Finding | Resolution and proof |
|---|---|
| CI-01 | `package-lock.json` gained 68 registry-integrity-verified **optional** entries including nested `@napi-rs/wasm-runtime/node_modules/@tybys/wasm-util@0.10.5`; 1293 original package entries unchanged, no removals or version bumps. Committed-lock `npm ci` PASS on Linux (job 90) and Windows (job 95). |
| CI-02 | Removed obsolete `bun.lock`; `tests/phase07-deployment.test.ts` exit 0. |
| CI-03 | Added suite-specific teardown hooks in four previously hanging suites, without changing core timer/runtime implementation; each exits 0. |
| CI-04 | Replaced stale client-expiry inline-function regex with shared classifier/count behavioral assertions; `tests/v2-phase01-storage-quotas.test.ts` exit 0. |
| CI-05 | 43 historical test-only TypeScript diagnostics corrected; one additional teardown declaration fixed after #59 typecheck failure. Final #60 strict TypeScript PASS (zero errors) and ESLint PASS. |
**Acceptance evidence:** #59 Node SDK build PASS, 24/24 isolated TypeScript suites exit 0 (no timeouts), Windows SDK build PASS, Next.js 15.5.29 standalone production build PASS with 22/22 pages. #60 targeted `tsc --noEmit` and `npm run lint` both PASS. Prior canonical Windows Python SDK 14/14 PASS from [#48](https://dev.ivib.cc/vibtools/DataStack/actions/runs/48); Python source unchanged and not rerun in P01. Docker images and live production behavior NOT verified in P01; P02 runtime reliability risks and P03 infrastructure/security gates remain open.
+3 -3
View File
@@ -1,7 +1,7 @@
# DataStack — Production Update Roadmap / Exact Scope Lock
Planning baseline: `d725841ebc828d58cbe90f517da9e600f23c4630` (frozen; documentation commits will advance Git HEAD but NOT this source baseline).
Current state: **3 implementation phases P01–P03 planned; 0 implemented; approvals not yet granted**.
Current state: **P01 CLOSED and CI-verified (1 of 3 phases complete); P02 and P03 NOT STARTED; P02 requires new explicit approval**.
Prerequisite for any phase: compare current HEAD and changed paths with this baseline and previously committed notes. For new commits since source baseline, inspect exact diff; no implicit rebase or silent discard.
## Global non-negotiable Scope Lock (applies to ALL phases)
@@ -65,8 +65,8 @@ Prerequisite for any phase: compare current HEAD and changed paths with this bas
## Sequence and approval gate
P01 -> P02 -> P03, strictly in this order. **No P01 implementation has begun** in this documentation-only update.
P01 **CLOSED** -> P02 **awaiting approval** -> P03 **awaiting P02 closure**. P01 acceptance evidence: Gitea CI #59 (Windows + Linux clean install, 24/24 tests, Node SDK, Next standalone) and #60 (strict TypeScript + ESLint), with historical #59 single test-type error corrected before #60. No actual app/runtime/UI/SDK change or live deployment.
Approval command for next turn:
`APPROVED — DataStack Production Readiness P01. Baseline: d725841ebc828d58cbe90f517da9e600f23c4630. Implement ONLY notes/002 P01 exact Scope Lock; preserve all app, UI, SDK, backend, live data, deployment and unrelated files. One focused disposable Gitea CI, exact diff/security audit, notes/003–005 update, one commit, push GitHub/GitLab/Gitea and verify all HEADs. No live deployment, tags, releases or scope expansion.`
`APPROVED — DataStack Production Readiness P02. Follow notes/002 P02 Exact Scope Lock. Verify R-01 Redis ACK durability, R-02 CSV crash/replay duplication, and R-03 liveness/readiness with disposable fault-injection tests. App/runtime source READ-ONLY unless a reproducible bug and separate exact patch approval. Preserve all existing UI, API, auth, SDK, data, and production. One focused CI, forensic diff, notes update, commit, three-remote sync. No deploy, releases, migrations or scope expansion.`
+24 -2
View File
@@ -2,12 +2,12 @@
Frozen source baseline: `d725841ebc828d58cbe90f517da9e600f23c4630`. Generated: 2026-11-22 Asia/Dhaka.
Scope: documentation-only kickoff. Any future phase must update this log **after** verification, not on intention.
**Completed implementation phases: 0 / 3. Remaining: 3.** Documentation baseline preparation is a separate non-implementation milestone.
**Completed implementation phases: 1 / 3. Remaining: 2.** Documentation baseline preparation is a separate non-implementation milestone.
| Phase | Status | IDs / function | Changed source | Verified CI evidence | Commit / remote sync |
|---|---|---|---|---|---|
| P00 Notes / freeze | COMPLETED (documentation only) | `001–006` docs, source baseline and exact scope | `notes/**` only | 6 Markdown files; balanced fences; staged diff `--check` PASS | Documentation commit containing this file; remote SHA verification recorded in session handoff |
| P01 Tests & lockfile | NOT STARTED | CI-01,02,03,04,05 | None | Not run | — |
| P01 Tests & lockfile | **CLOSED — VERIFIED** | CI-01…CI-05, no runtime feature changes | 16 exact P01 code/test/CI paths, plus `notes/001–006` records | #59 Linux/Windows clean npm/SDK, 24/24 TS suites, Next standalone PASS; #60 strict TypeScript and ESLint PASS; historical #59 quality mismatch corrected | One permanent P01 main commit containing these notes; confirm remote SHA/tree parity in phase handoff |
| P02 Ingestion reliability | NOT STARTED | Conditional R-01,02,03 | None | Not run | — |
| P03 CI/Docker/security | NOT STARTED | CI-06,07,08; release gates | None | Not run | — |
@@ -43,6 +43,15 @@ Historical baseline code stayed frozen through these CI workflow changes. Curren
- MEMORY.md cross-IDE handoff text (copyable):
`[DataStack P0X] Baseline=<SHA>; findings=<IDs>; scope=<exact paths>; CI=<run + exit>; commit=<SHA>; remote sync=<all 3>; phase=CLOSED; next=P0Y; production deployment=unchanged.`
## P01 attempted implementation & gate outcome (2026-11-22)
- Frozen source baseline remains `d725841ebc828d58cbe90f517da9e600f23c4630`; latest source HEAD before P01 was documentation commit `d8ac96e39dad4ea3b241c1d2f16f959c5215701e` on all three remotes.
- Disposable CI commit `90fce0629a752dd2916d8d3a2afeaf2c52ed6cbb` contains **16 P01-allowed paths**: `bun.lock` deletion, `package-lock.json` optional/native metadata closure (+67 entries, no existing version or root-manifest change), 14 scoped test files, and `.gitea/workflows/datastack-ci.yml` clean-install/phase-filter changes. No application runtime source/UI/SDK/Docker changes.
- Gitea run: https://dev.ivib.cc/vibtools/DataStack/actions/runs/58; overall **FAIL**, terminal. `windows-compatibility`, `node-regression`, `quality`, `production-build` all failed during clean `npm ci`: `Missing: @tybys/wasm-util@0.10.5 from lock file`. The Python and Docker jobs were intentionally skipped for P01. **No current TypeScript test, strict typecheck, ESLint or build PASS may be claimed**.
- Root issue likely parallel incompatible transitive requirement of `@tybys/wasm-util`; inspect `node_modules/@napi-rs/wasm-runtime` vs `node_modules/@tailwindcss/oxide-wasm32-wasi` in lock and install exact requested transitive version under correct nested path without changing existing pinned entries. Then verify npm clean-install on both platforms and rerun focused P01 acceptance once after repair; do not blindly override lock integrity.
- Local original Windows device's VARUA connection reached monthly call quota; local changes were staged via safe squash on `main` but **no P01 main commit/push** occurred. A separate connected desktop did not have this workspace. Do not claim local/3-remote post-P01 sync until verified.
- **Historical #58 status:** 0/3, P01 BLOCKED before nested lockfile correction. **Superseded by closure evidence below**; no force push or deploy was used.
## Status transition rules
- OPEN -> IN PROGRESS only with explicit approval and baseline SHA match.
@@ -50,3 +59,16 @@ Historical baseline code stayed frozen through these CI workflow changes. Curren
- Failed test -> BLOCKED with log excerpt and scope decision; never log as complete.
- Unexpected file change -> STOP and revert only own documented changes safely; never touch pre-existing work.
- At any time, `actual production deployment status` is a separate tracked dimension (do not infer deployed SHA from Git HEAD).
## P01 Final Closure — CI-01…CI-05
- **Status:** CLOSED after one P01 acceptance CI (#59) plus one narrow quality-only correction/retry (#60); completed implementation phases **1/3**, remaining **2** (P02 and P03).
- **Baseline:** frozen source `d725841ebc828d58cbe90f517da9e600f23c4630`; pre-P01 documentation HEAD `d8ac96e39dad4ea3b241c1d2f16f959c5215701e`.
- **Validated implementation code snapshot:** `7d8eebd3dc867e82113343403b63ce1d4ed20584` on disposable Gitea P01 branch. Permanent main commit is the **single squash commit containing this closure log**; remote SHAs and content-tree equality must be checked at publish, not predicted here.
- **Exact P01 patch:** deletion `bun.lock`; append-only 68 optional/native lock entries with zero original package-version changes; 13 in-scope test files with typed mocks, teardown, and shared-helper assertions; narrow `.gitea/workflows/datastack-ci.yml` clean-install and focused verification inputs. `package.json`, `tsconfig.json`, all app/UI/backend/SDK/Docker/production files unchanged.
- **#58 failed before tests** (`@tybys/wasm-util@0.10.5` missing); fixed by nested, registry-hash-verified optional dependency. **#59 overall FAIL** due exactly one TS2339 test teardown type declaration; the same run separately proved 24/24 TS suite exits 0, Linux/Windows original committed-lock `npm ci`, both Node SDK builds, and Next standalone production build (22/22 pages). Fixed only the test declaration; **#60 quality-only PASS** for `npx tsc --noEmit` and `npm run lint` with no error.
- Prior independent Python SDK 14/14 PASS: #48 (SDK unmodified); not rerun during P01. P03 Docker and security/advisory findings unresolved; no Docker builds, live ingestion, network fault injection, migrations, releases or production deployment occurred.
- **Diff audit:** only allowlisted 16 P01 code/test/CI paths and 6 `notes/*.md` files; `git diff --check` PASS; no unrelated features, API behavior, UI or persistent data changed. 1293 original lock entries remained byte-equivalent; 68 optional entries added with integrity hashes.
- **Working tree caveat:** original local Windows VARUA device reached its monthly quota during P01; its current local branch/working tree could not be rechecked and should be reconciled against published `main` before new local work. A separate authorized temporary Windows clone was used for diff and Git push verification. Never claim original PC is already updated.
- **Next:** P02 read-only initial source audit plus targeted disposable fault-injection tests for R-01 (Redis ACK), R-02 (CSV replay), R-03 (health readiness). Runtime-source change requires reproduced issue and a separate exact method/file approval. P03 only after P02 closure.
- **P02 implementation approval command:** `APPROVED — DataStack P02. Implement only notes/002 P02 diagnostic/test write scope for R-01, R-02 and R-03. Keep app/UI/API/auth/SDK/runtime/data unchanged. Runtime files read-only unless a proven failure and separately approved narrow code patch. One focused disposable Gitea CI, exact diff, notes/001–006 update, commit and remote verification. No production deployment or scope expansion.`
+8
View File
@@ -42,6 +42,14 @@ Source baseline: `d725841ebc828d58cbe90f517da9e600f23c4630`. This is an **implem
- MCP: disabled by default, read vs write permissions, bearer hashing, IP allowlist, sandbox traversal and symlink reject, no secret emission.
- Do not run these failure injections against `https://data.ivib.cc/`. Use disposable CI fixtures/data directories/Redis containers only.
## P01 dependency-install blocker note (2026-11-22)
Gitea run #58 failed before application error-handling tests because clean npm install found an unresolved transitive lock entry: `@tybys/wasm-util@0.10.5`. No runtime error-handling paths were changed or re-verified in this run. Existing source-level handler inventory remains unchanged; P02 fault-injection gates are **NOT STARTED**.
## Change control
Any new error code, status, SDK public exception or alert flow is **feature/API behavior change**: STOP and request explicit new scope approval. This register is documentation for deciding whether a new handler is warranted, not blanket authorization to add handlers.
## P01 Closure Verification (2026-11-22)
The previous #58 package-lock error was resolved by adding the exact nested optional `@tybys/wasm-util@0.10.5` lock entry without changing the 1293 original locked packages. Gitea #59 clean installs and all **24/24** TypeScript regression suites passed; #59 had a single test-only TS2339 mock-type declaration error, corrected in scope and verified by **#60 strict TypeScript + ESLint PASS**. P01 made **zero changes** to runtime error-handler implementation, response codes, auth, SDK error classification, telemetry behavior or UI. Existing handler inventory remains valid as source observations. P02 R-01…R-03 fault-injection and P03 infrastructure/security remain unverified; do not claim production fault tolerance from P01.
+1 -1
View File
@@ -41,6 +41,6 @@ After EACH P01/P02/P03 close, amend only affected table rows:
Do not mark "actual working" simply because a patch compiled. Distinguish source, CI, and actual deployment.
## Change log
- P00: No feature added/modified. `notes/**` documentation only. 0/3 implementation phases completed.
- P01: pending.
- P01: **CLOSED — 1/3 implementation phases**. CI-01…05 corrected exclusively in package-lock, obsolete bun.lock removal, scoped regression/type tests and Gitea CI harness. **No actual application, UI, backend, API, SDK or production functionality was added, removed or altered.** Gitea #59: committed-lock Linux/Windows clean install PASS; Node SDK builds PASS; all 24 TS suites exit0 with zero timeouts; Next standalone 22/22 pages PASS. One historical #59 test-only declaration TS error fixed; #60 strict TS zero errors and full ESLint PASS. Previous canonical Python SDK 14/14 (#48) preserved but not rerun. No live endpoint mutation or deployment; live data/Redis/S3/MCP actual operational status is not established.
- P02: pending.
- P03: pending.
+49
View File
@@ -151,3 +151,52 @@ return NextResponse.json({ status: 'online', service: 'DataStack Web API', /* ..
## C. Documentation baseline update record
This file **freezes the source baseline**, not the future documentation-commit SHA. After adding `notes/**`, record commit SHA and three remote SHAs in `notes/003` and the user-facing result. Subsequent P01 implementation should inspect `git diff d725841ebc828d58cbe90f517da9e600f23c4630..HEAD` and permit only these notes as intervening changes; any unexpected source edits require a new review.
## D. P01 Actual Patch & CI Closure Proof — 2026-11-22
Frozen source baseline remains `d725841ebc828d58cbe90f517da9e600f23c4630`, docs baseline `d8ac96e39dad4ea3b241c1d2f16f959c5215701e`. CI-verified implementation snapshot `7d8eebd3dc867e82113343403b63ce1d4ed20584` (Gitea disposable P01 branch). Permanent main closure is single squash commit containing this note; verify post-push three remote refs/content trees.
### Lock and package integrity evidence (CI-01 / CI-02)
```json
{
"node_modules/@napi-rs/wasm-runtime/node_modules/@tybys/wasm-util": {
"version": "0.10.5",
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.5.tgz",
"integrity": "sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==",
"optional": true,
"dependencies": {"tslib": "^2.4.0"}
}
}
```
The root `@tybys/wasm-util@0.9.0` remains unchanged; 68 optional entries added, 1293 old entries unchanged, none removed/repinned, all added entries with registry tarball and integrity, `package.json` unchanged. `bun.lock` removed after checking no active consumers. Windows and Linux `npm ci --no-audit --no-fund` PASS using committed lock without temporary regeneration.
### Test-only teardown correction (CI-03 / CI-05)
`tests/r5-phase01-mcp-foundation-logs.test.ts` local CommonJS require declaration now explicitly includes `stopTimers`, matching the existing runtime export; `test.after` releases ingestion timers and `DataBufferEngine.shutdown()` without any changes to runtime source:
```ts
const ingestionServer = require("../server/index.js") as {
setDbPoolForTests: (pool: unknown) => void;
syncSettingsFromDatabase: () => Promise<boolean>;
stopTimers: () => void;
};
test.after(async () => {
ingestionServer.stopTimers();
SDKManager.stopActivityFlushTimerForTests();
await DataBufferEngine.shutdown();
});
```
Remaining CI-05 corrections were confined to 9 test file type contracts; CI-04 replaced old `isClientExpired` page regex expectations with `classifyUiClientStatus` + `summarizeUiClientCounts` behavioral assertions. No TS strictness flags disabled, no global `any` blanket suppression, no SDK/API runtime signature changed.
### Exact gate results
- [Run #58](https://dev.ivib.cc/vibtools/DataStack/actions/runs/58): failed at lockfile nested dependency before tests; historical and superseded.
- [Run #59](https://dev.ivib.cc/vibtools/DataStack/actions/runs/59): overall failed because exactly one test mock TypeScript declaration lacked `stopTimers`, but separate job results independently verified **24/24 TypeScript suites exit0**, no timeouts, Linux/Windows committed-lock clean npm installs, Node SDK compilation and Next.js standalone build + 22/22 pages all PASS.
- [Run #60](https://dev.ivib.cc/vibtools/DataStack/actions/runs/60): focused quality-only retry after exact test-type correction, **strict `npx tsc --noEmit` PASS 0 errors** and **`npm run lint` PASS**.
- [Run #48](https://dev.ivib.cc/vibtools/DataStack/actions/runs/48): previous Python SDK 14/14 PASS, no Python source edits or P01 rerun.
Targeted path/diff audit from prior documentation HEAD: 16 scoped code/test/CI paths plus notes `001–006`; `git diff --check` PASS. P02 remaining R-01…R-03 are conditional reliability risks, not confirmed application bugs. P03 Docker/Python-runner/advisory issues still open. No live app, deployment, database, security defaults or user features changed.
+1016
View File
File diff suppressed because it is too large. Load diff
+4 -4
View File
@@ -85,7 +85,7 @@ describe("Phase-01 Auth, Secrets, Revocation & Proxy Hardening", () => {
});
it("BUG-01 & BUG-02: fails closed in production when secrets or DB/setup are missing", async () => {
process.env.NODE_ENV = "production";
(process.env as Record<string, string | undefined>).NODE_ENV = "production";
delete process.env.DATABASE_URL;
delete process.env.DATASTACK_ADMIN_SESSION_SECRET;
delete process.env.DATASTACK_ADMIN_SETUP_KEY;
@@ -557,7 +557,7 @@ describe("Phase-01 Auth, Secrets, Revocation & Proxy Hardening", () => {
});
it("FORENSIC BUG-01: blocks volatile RAM admin setup in production without DATABASE_URL and returns 409 SETUP_REQUIRED on pre-setup login", async () => {
process.env.NODE_ENV = "production";
(process.env as Record<string, string | undefined>).NODE_ENV = "production";
delete process.env.DATABASE_URL;
delete process.env.DATASTACK_ADMIN_PASSWORD;
process.env.DATASTACK_ADMIN_SESSION_SECRET =
@@ -770,7 +770,7 @@ describe("Phase-01 Auth, Secrets, Revocation & Proxy Hardening", () => {
try {
// 1. Production with empty jwtSecret must not persist empty jwt_secret row into PG
process.env.NODE_ENV = "production";
(process.env as Record<string, string | undefined>).NODE_ENV = "production";
delete process.env.DATASTACK_JWT_SECRET;
settingsGlobals.__dataStackAdminSettings = undefined;
settingsGlobals.__dataStackSettingsHydrated = false;
@@ -791,7 +791,7 @@ describe("Phase-01 Auth, Secrets, Revocation & Proxy Hardening", () => {
);
// 2. Failing PG write must reject (not silently return 200) and must not mutate RAM
process.env.NODE_ENV = "test";
(process.env as Record<string, string | undefined>).NODE_ENV = "test";
process.env.DATASTACK_JWT_SECRET =
"valid-jwt-secret-at-least-32-characters-long";
AuthService.setSecret(process.env.DATASTACK_JWT_SECRET);
+5 -5
View File
@@ -1085,10 +1085,10 @@ test("FORENSIC BUG-19: Deleting a client purges RAM, Redis, and Port 4000 buffer
test("FORENSIC BUG-20: Socket.IO sync_data and batch_sync ACKs wait until async Redis RPUSH completes", async () => {
const fakeRedis = new FakeRedisClient();
let rpushGateResolve: (() => void) | null = null;
const rpushGateControl: { resolve?: () => void } = {};
let rpushEnteredResolve: (() => void) | null = null;
let rpushGate = new Promise<void>((resolve) => {
rpushGateResolve = resolve;
rpushGateControl.resolve = resolve;
});
let rpushEntered = new Promise<void>((resolve) => {
rpushEnteredResolve = resolve;
@@ -1155,14 +1155,14 @@ test("FORENSIC BUG-20: Socket.IO sync_data and batch_sync ACKs wait until async
"sync_data ACK must NOT fire before Redis RPUSH finishes",
);
rpushGateResolve?.();
rpushGateControl.resolve?.();
const syncAck = await syncAckPromise;
assert.equal(syncAck.success, true);
assert.equal(await fakeRedis.llen(REDIS_BUFFER_KEY), 1);
// 2. batch_sync must also wait for Redis RPUSH before ACK
rpushGate = new Promise<void>((resolve) => {
rpushGateResolve = resolve;
rpushGateControl.resolve = resolve;
});
rpushEntered = new Promise<void>((resolve) => {
rpushEnteredResolve = resolve;
@@ -1199,7 +1199,7 @@ test("FORENSIC BUG-20: Socket.IO sync_data and batch_sync ACKs wait until async
"batch_sync ACK must NOT fire before Redis RPUSH finishes",
);
rpushGateResolve?.();
rpushGateControl.resolve?.();
const batchAck = await batchAckPromise;
assert.equal(batchAck.success, true);
assert.equal(batchAck.processed, 2);
@@ -172,7 +172,7 @@ test("R3-Phase-01 [BUG-03]: Client SDK JWTs omit hardcoded 30d exp so Never-Expi
test("R3-Phase-01 [BUG-04 & BUG-15]: Viewer blocked (403) on POST /api/events and Operator blocked (403) on POST /api/storage/s3-test", async () => {
resetAdminStateForTests();
await createInitialAdmin("r3-owner@datastack.dev", "OwnerPassword123!");
const sessionSecret = getAdminSessionSecret();
const sessionSecret = getAdminSessionSecret()!;
const suffix = Date.now();
const viewerEmail = `r3viewer_${suffix}@datastack.dev`;
const operatorEmail = `r3operator_${suffix}@datastack.dev`;
@@ -182,13 +182,11 @@ test("R3-Phase-01 [BUG-04 & BUG-15]: Viewer blocked (403) on POST /api/events an
email: viewerEmail,
password: "ViewerPassword123!",
role: "viewer",
displayName: "R3 Viewer",
});
const operator = await createAdminTeamMemberAsync({
email: operatorEmail,
password: "OperatorPassword123!",
role: "operator",
displayName: "R3 Operator",
});
await SDKManager.registerClientAsync({
clientId,
@@ -292,7 +290,7 @@ test("R3-Phase-01 [BUG-06]: Locked webhook secret does not break unrelated setti
const ownerToken = await createAdminSessionToken(
owner.email,
getAdminSessionSecret(),
getAdminSessionSecret()!,
Date.now() + 3600_000,
owner.tokenVersion,
owner.role,
@@ -427,7 +425,7 @@ test("R3-Phase-01 [BUG-10]: Brute-force 429 admin login lockout dispatches ADMIN
assert.equal(dispatchedBodies[0].instance, "DataStack");
} finally {
global.fetch = origFetch;
await clearAdminLoginAttempts(email, getAdminSessionSecret(), testIp);
await clearAdminLoginAttempts(email, getAdminSessionSecret()!, testIp);
await SettingsManager.updateSettingsAsync({
enableWebhookAlerts: false,
webhookUrl: "",
@@ -40,7 +40,7 @@ function writeGzipCsv(filePath: string, content: string): void {
async function createOwnerCookie(): Promise<string> {
delete process.env.DATABASE_URL;
const sessionSecret = getAdminSessionSecret();
const sessionSecret = getAdminSessionSecret()!;
resetAdminStateForTests();
const ownerEmail = "owner-r3p2@datastack.local";
await createInitialAdmin(ownerEmail, "StrongPassword123!");
+6
View File
@@ -5,6 +5,7 @@ import test from "node:test";
import { NextRequest } from "next/server";
import { GET as prometheusGet } from "../app/api/prometheus/route";
import { SettingsManager } from "../core/adminSettings/settingsManager";
import { DataBufferEngine } from "../core/data/buffer";
import { ApiEngine } from "../core/apiEngine/apiService";
import {
createAdminSessionToken,
@@ -24,6 +25,11 @@ import {
summarizeUiClientCounts,
} from "../lib/vconUiHelpers";
test.after(async () => {
SDKManager.stopActivityFlushTimerForTests();
await DataBufferEngine.shutdown();
});
async function makeOwnerCookie(): Promise<string> {
resetAdminStateForTests();
await createInitialAdmin("r3-p4-owner@datastack.dev", "R3Phase04Pass!");
+2 -2
View File
@@ -96,7 +96,7 @@ function restoreEnv(): void {
async function createOwnerCookie(email = "r4p1-owner@datastack.dev"): Promise<string> {
resetAdminStateForTests();
await createInitialAdmin(email, "OwnerPassword123!");
const secret = getAdminSessionSecret();
const secret = getAdminSessionSecret()!;
const token = await createAdminSessionToken(
email,
secret,
@@ -531,7 +531,7 @@ test("R4-Phase-01 [AUDIT-09 / ERR-R4-04 & ERR-R4-05]: Fail-loud audit DB degrade
assert.equal(unauthSync.status, 401);
// Owner session v1 works before logout/revocation
const secret = getAdminSessionSecret();
const secret = getAdminSessionSecret()!;
const ownerTokenV1 = await createAdminSessionToken(
"r4-audit-owner@datastack.dev",
secret,
@@ -5,6 +5,7 @@ import fsp from "node:fs/promises";
import http from "node:http";
import { createRequire } from "node:module";
import type { AddressInfo } from "node:net";
import type { Request, Response } from "express";
import os from "node:os";
import path from "node:path";
import test from "node:test";
@@ -81,7 +82,7 @@ async function createOwnerCookie(
): Promise<string> {
resetAdminStateForTests();
await createInitialAdmin(email, "OwnerPassword123!");
const secret = getAdminSessionSecret();
const secret = getAdminSessionSecret()!;
const token = await createAdminSessionToken(
email,
secret,
@@ -329,13 +330,13 @@ test("R4-Phase-02 AUDIT-06: Governance audit logging for /api/export, Files Mana
getDbPool: () => null,
}),
);
ramApp.put("/vcon/files-engine/api/v1/fs/sample.csv", (_req: express.Request, res: express.Response) => {
ramApp.put("/vcon/files-engine/api/v1/fs/sample.csv", (_req: Request, res: Response) => {
res.status(200).json({ ok: true });
});
ramApp.put("/vcon/files-engine/api/v1/rename", (_req: express.Request, res: express.Response) => {
ramApp.put("/vcon/files-engine/api/v1/rename", (_req: Request, res: Response) => {
res.status(200).json({ ok: true });
});
ramApp.delete("/vcon/files-engine/api/v1/fs/sample.csv", (_req: express.Request, res: express.Response) => {
ramApp.delete("/vcon/files-engine/api/v1/fs/sample.csv", (_req: Request, res: Response) => {
res.status(403).json({ ok: false }); // non-2xx should NOT emit mutation audit
});
@@ -404,7 +405,7 @@ test("R4-Phase-02 AUDIT-06: Governance audit logging for /api/export, Files Mana
getDbPool: () => mockDbPool,
}),
);
pgApp.delete("/vcon/files-engine/api/v1/fs/obsolete.csv", (_req: express.Request, res: express.Response) => {
pgApp.delete("/vcon/files-engine/api/v1/fs/obsolete.csv", (_req: Request, res: Response) => {
res.status(200).json({ ok: true });
});
+6 -1
View File
@@ -3,7 +3,7 @@ import fs from 'node:fs';
import { createRequire } from 'node:module';
import os from 'node:os';
import path from 'node:path';
import { afterEach, beforeEach, describe, it } from 'node:test';
import { after, afterEach, beforeEach, describe, it } from 'node:test';
import { NextRequest } from 'next/server';
import { POST as setupPost } from '../app/api/auth/setup/route';
import { GET as filesStatusGet } from '../app/api/files/status/route';
@@ -13,9 +13,14 @@ import {
getAdminSessionSecret,
} from '../core/auth/adminSession';
import { resetAdminStateForTests } from '../core/auth/adminUsers';
import { DataBufferEngine } from '../core/data/buffer';
import { middleware } from '../middleware';
import { DataStack, DiskSpooler } from '../sdk/node/datastack';
after(async () => {
await DataBufferEngine.shutdown();
});
const require = createRequire(import.meta.url);
const ORIGINAL_ENV = { ...process.env };
const ORIGINAL_FETCH = globalThis.fetch;
@@ -35,6 +35,7 @@ import { SDKManager } from "../core/sdk/sdkManager";
import { getInternalIngestionHeaders } from "../core/Security/security";
import { SSRFBlockedError } from "../core/Security/ssrfGuard";
import { CSVStorageManager } from "../core/Storage/csvStorage";
import { DataBufferEngine } from "../core/data/buffer";
import { middleware } from "../middleware";
const require = createRequire(import.meta.url);
@@ -78,8 +79,15 @@ const cjsRuntimeLogCapture = require("../server/runtimeLogCapture.js") as {
const ingestionServer = require("../server/index.js") as {
setDbPoolForTests: (pool: unknown) => void;
syncSettingsFromDatabase: () => Promise<boolean>;
stopTimers: () => void;
};
test.after(async () => {
ingestionServer.stopTimers();
SDKManager.stopActivityFlushTimerForTests();
await DataBufferEngine.shutdown();
});
test("R5-Phase-01 [MCP-AUDIT-02 / ERR-R5-02]: Runtime log capture scrubs secrets, rotates at 2MB, filters/tails safely, and handles missing dirs gracefully", async () => {
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "datastack-r5-logs-"));
const logsDir = path.join(tmpDir, ".runtime-logs");
+12 -12
View File
@@ -507,7 +507,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
});
assert.equal(deniedClientCreate.isError, true);
const deniedPayload = JSON.parse(
(deniedClientCreate.content[0] as { text: string }).text,
((deniedClientCreate.content as Array<{ text: string }>)[0]).text,
) as { code: string; permission: string };
assert.equal(deniedPayload.code, "MCP_PERMISSION_DENIED");
assert.equal(deniedPayload.permission, "clients_create");
@@ -521,7 +521,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
});
assert.notEqual(createdToolRes.isError, true);
const createdPayload = JSON.parse(
(createdToolRes.content[0] as { text: string }).text,
((createdToolRes.content as Array<{ text: string }>)[0]).text,
) as { success: boolean; client: { clientId: string; rateLimit: number; token?: string } };
assert.equal(createdPayload.success, true);
assert.equal(createdPayload.client.clientId, testClientId);
@@ -535,7 +535,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
});
assert.equal(traversalRes.isError, true);
assert.equal(
(JSON.parse((traversalRes.content[0] as { text: string }).text) as { code: string }).code,
(JSON.parse(((traversalRes.content as Array<{ text: string }>)[0]).text) as { code: string }).code,
"PATH_OUTSIDE_ROOT",
);
@@ -546,7 +546,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
});
assert.equal(symlinkRes.isError, true);
assert.equal(
(JSON.parse((symlinkRes.content[0] as { text: string }).text) as { code: string }).code,
(JSON.parse(((symlinkRes.content as Array<{ text: string }>)[0]).text) as { code: string }).code,
"SYMLINK_FORBIDDEN",
);
}
@@ -557,7 +557,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
});
assert.equal(lockReadRes.isError, true);
assert.equal(
(JSON.parse((lockReadRes.content[0] as { text: string }).text) as { code: string }).code,
(JSON.parse(((lockReadRes.content as Array<{ text: string }>)[0]).text) as { code: string }).code,
"LOCKFILE_PROTECTED",
);
@@ -567,7 +567,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
});
assert.equal(lockedFileUploadRes.isError, true);
assert.equal(
(JSON.parse((lockedFileUploadRes.content[0] as { text: string }).text) as { code: string })
(JSON.parse(((lockedFileUploadRes.content as Array<{ text: string }>)[0]).text) as { code: string })
.code,
"LOCKFILE_PROTECTED",
);
@@ -578,7 +578,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
});
assert.equal(logWriteRes.isError, true);
assert.equal(
(JSON.parse((logWriteRes.content[0] as { text: string }).text) as { code: string }).code,
(JSON.parse(((logWriteRes.content as Array<{ text: string }>)[0]).text) as { code: string }).code,
"PROTECTED_LOG_DIR",
);
@@ -601,7 +601,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
});
assert.notEqual(dlRes.isError, true);
assert.equal(
(JSON.parse((dlRes.content[0] as { text: string }).text) as { content: string }).content,
(JSON.parse(((dlRes.content as Array<{ text: string }>)[0]).text) as { content: string }).content,
"alpha gamma",
);
@@ -610,7 +610,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
arguments: { path: "data" },
});
assert.notEqual(listRes.isError, true);
const listParsed = JSON.parse((listRes.content[0] as { text: string }).text) as {
const listParsed = JSON.parse(((listRes.content as Array<{ text: string }>)[0]).text) as {
entries: Array<{ name: string }>;
};
assert.ok(listParsed.entries.some((e) => e.name === "active.csv"));
@@ -632,7 +632,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
});
assert.notEqual(metricsRes.isError, true);
assert.equal(
(JSON.parse((metricsRes.content[0] as { text: string }).text) as { success: boolean }).success,
(JSON.parse(((metricsRes.content as Array<{ text: string }>)[0]).text) as { success: boolean }).success,
true,
);
@@ -641,7 +641,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
arguments: { action: "flush" },
});
assert.notEqual(flushRes.isError, true);
const flushPayload = JSON.parse((flushRes.content[0] as { text: string }).text) as {
const flushPayload = JSON.parse(((flushRes.content as Array<{ text: string }>)[0]).text) as {
success: boolean;
ingestionFlushed: number;
};
@@ -654,7 +654,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
});
assert.equal(coolifySsrfRes.isError, true);
assert.equal(
(JSON.parse((coolifySsrfRes.content[0] as { text: string }).text) as { code: string }).code,
(JSON.parse(((coolifySsrfRes.content as Array<{ text: string }>)[0]).text) as { code: string }).code,
"SSRF_BLOCKED_HOST",
);
+5
View File
@@ -4,6 +4,7 @@ import path from "node:path";
import test from "node:test";
import { MCP_PERMISSION_DEFINITIONS } from "../core/mcp/mcpSettings";
import { DataBufferEngine } from "../core/data/buffer";
import {
applyCategoryPermissionToggle,
applyMcpPermissionPreset,
@@ -23,6 +24,10 @@ import {
const DEFINITIONS = MCP_PERMISSION_DEFINITIONS as readonly McpPermissionDefinitionView[];
test.after(async () => {
await DataBufferEngine.shutdown();
});
test("R5-Phase-03 [lib/mcpUiHelpers.ts]: URL builder, AI client JSON snippets, permission grouping/presets, bridge status, and diff payload", () => {
// 1. Endpoint URL builder
assert.equal(
+19 -16
View File
@@ -43,6 +43,8 @@ import {
uploadFileToS3,
} from "../core/Storage/s3Archive";
import {
classifyUiClientStatus,
summarizeUiClientCounts,
DEFAULT_EDITABLE_SETTINGS,
settingsToNumericDrafts,
validateEditableSettingsDraft,
@@ -759,7 +761,7 @@ test("V2-Audit-Phase-03 [BUG-V2-AUDIT-01, BUG-V2-AUDIT-07, BUG-V2-AUDIT-10]: Dis
bsize: 4096,
}));
const snapshot = await CSVStorageManager.getDiskUsageAsync(true);
const snapshot = await CSVStorageManager.getDiskUsageAsync();
assert.equal(snapshot.available, true);
assert.equal(snapshot.usedPct, 25);
assert.equal(snapshot.totalBytes, 2000 * 4096);
@@ -780,29 +782,30 @@ test("V2-Audit-Phase-03 [BUG-V2-AUDIT-01, BUG-V2-AUDIT-07, BUG-V2-AUDIT-10]: Dis
CSVStorageManager.setStatfsOverrideForTests(async () => {
throw new Error("Simulated statfs failure");
});
const fallbackSnapshot = await CSVStorageManager.getDiskUsageAsync(true);
const fallbackSnapshot = await CSVStorageManager.getDiskUsageAsync();
assert.equal(fallbackSnapshot.available, false);
assert.equal(fallbackSnapshot.freeBytes, 0);
assert.equal(fallbackSnapshot.availableBytes, 0);
// 2. BUG-V2-AUDIT-07: app/vcon/clients/page.tsx defines isClientExpired and excludes expired tokens from onlineCount, pendingCount, and online/pending filter tabs
// 2. BUG-V2-AUDIT-07: shared status classifier excludes expired clients from active counters.
const clientsPageSrc = await fs.readFile(
path.join(process.cwd(), "app/vcon/clients/page.tsx"),
"utf8",
);
assert.match(clientsPageSrc, /function isClientExpired\(/);
assert.match(
clientsPageSrc,
/const expired = !revoked && isClientExpired\(client\.expiresAt,\s*now\)/,
);
assert.match(
clientsPageSrc,
/!isClientExpired\(client\.expiresAt,\s*now\)/,
);
assert.match(
clientsPageSrc,
/const pending =\s*client\.status === 'active' && !expired && !client\.lastActive/,
);
assert.match(clientsPageSrc, /summarizeUiClientCounts\(clients, now\)/);
assert.match(clientsPageSrc, /classifyUiClientStatus\(client, now\)/);
const now = Date.parse("2026-11-21T10:00:00.000Z");
const expiredClient = { status: "active" as const, expiresAt: "2020-01-01T00:00:00.000Z", lastActive: "2026-11-21T09:59:50.000Z" };
const pendingClient = { status: "active" as const, expiresAt: null, lastActive: undefined };
const onlineClient = { status: "active" as const, expiresAt: null, lastActive: "2026-11-21T09:59:50.000Z" };
assert.equal(classifyUiClientStatus(expiredClient, now), "expired");
assert.equal(classifyUiClientStatus(pendingClient, now), "pending");
assert.equal(classifyUiClientStatus(onlineClient, now), "online");
const summary = summarizeUiClientCounts([expiredClient, pendingClient, onlineClient], now);
assert.equal(summary.expired, 1);
assert.equal(summary.online, 1);
assert.equal(summary.pending, 1);
assert.equal(summary.active, 2);
// 3. BUG-V2-AUDIT-10: ExportWorkspace.tsx and app/vcon/storage/page.tsx render CSV.GZ badge for compressed .csv.gz partitions
const exportWorkspaceSrc = await fs.readFile(
@@ -331,7 +331,7 @@ test("V2-Phase-02 [HTTP & Socket Ingestion Security]: Per-client IP allowlist (4
token: string,
bypassCache?: boolean,
clientIp?: string,
) => Promise<{ ok: boolean; reason?: string }>;
) => Promise<{ allowed: boolean; code?: string; reason?: string }>;
setDbPoolForTests: (pool: unknown) => void;
stopTimers: () => void;
};