Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Build/eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
ignores: ["dist/**", "node_modules/**", "coverage/**"],
},
{
rules: {
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
},
},
{
files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
rules: {
"no-undef": "off",
"@typescript-eslint/no-require-imports": "off",
},
},
{
files: ["**/tests/**", "**/*.test.ts", "**/*.spec.ts", "**/__mocks__/**"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-require-imports": "off",
"prefer-const": "off",
"no-sparse-arrays": "off",
"no-prototype-builtins": "off",
},
},
);
1,416 changes: 1,252 additions & 164 deletions Build/package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion Build/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nisoku/satori",
"version": "0.1.3",
"version": "0.1.4",
"description": "Event-centric observability layer for complex apps.",
"main": "./dist/satori.js",
"module": "./dist/satori.mjs",
Expand All @@ -20,6 +20,7 @@
"dev": "vite build --watch",
"typecheck": "tsc --noEmit",
"make-pretty": "prettier --write 'src/**/*.{ts,tsx,js,jsx,json,css,scss,md,html,cjs}'",
"lint": "eslint .",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage"
Expand All @@ -35,12 +36,16 @@
},
"homepage": "https://github.com/Nisoku/Satori#readme",
"devDependencies": {
"@eslint/js": "^10.0.1",
"@types/jest": "^30.0.0",
"@types/node": "^26.0.0",
"eslint": "^10.6.0",
"jest": "^30.2.0",
"jiti": "^2.7.0",
"prettier": "^3.8.1",
"ts-jest": "^29.4.6",
"typescript": "^5.9.3",
"typescript-eslint": "^8.63.0",
"vite": "^8.0.16"
}
}
2 changes: 1 addition & 1 deletion Build/src/bus/eventBus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class SimpleEventBus implements EventBus {
this.metrics.setBufferSize(this.buffer.length);
this.metrics.setSubscriberCount(this.subscribers.length);
}
} catch (error) {
} catch {
// Circuit is open or publish failed
if (this.enableMetrics) {
this.metrics.recordDropped();
Expand Down
2 changes: 1 addition & 1 deletion Build/src/bus/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LogEntry, LogLevel, Middleware } from "../core/types.js";
import type { LogLevel, Middleware } from "../core/types.js";

export function createLevelFilter(minLevel: LogLevel): Middleware {
const levels: Record<string, number> = {
Expand Down
3 changes: 1 addition & 2 deletions Build/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export interface SatoriLogger {
}

export type WatchSource<T> =
| (() => T)
| (T & { readonly __brand: unique symbol });
(() => T) | (T & { readonly __brand: unique symbol });
export type WhenPredicate<T> = (prev: T | undefined, next: T) => boolean;
export type WhenCallback<T> = (value: T, prev: T | undefined) => void;

Expand Down
14 changes: 12 additions & 2 deletions Build/src/core/utils/deepEqual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ export function deepEqual(

for (const key of aKeys) {
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
if (!deepEqual((a as any)[key], (b as any)[key], seen)) return false;
if (
!deepEqual(
(a as unknown as Record<string, unknown>)[key],
(b as unknown as Record<string, unknown>)[key],
seen,
)
)
return false;
}

return true;
Expand Down Expand Up @@ -208,7 +215,10 @@ export function deepClone<T>(
// Copy non-index properties
for (const key of Object.keys(value)) {
if (!/^\d+$/.test(key)) {
(cloned as any)[key] = deepClone((value as any)[key], seen);
(cloned as unknown as Record<string, unknown>)[key] = deepClone(
(value as unknown as Record<string, unknown>)[key],
seen,
);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Build/src/enrich/causal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ const globalCausalGraph = new CausalGraph();

// Legacy API for backwards compatibility
const scopeLastEvent = new Map<string, string>();
let globalLastEvent: string | undefined;
let _globalLastEvent: string | undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for any reads of _globalLastEvent (or the old name globalLastEvent)
# outside of assignment and reset contexts
rg -n '_globalLastEvent\|globalLastEvent' --type=ts -g '!**/node_modules/**'

Repository: Nisoku/Satori

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant section in Build/src/enrich/causal.ts
sed -n '200,280p' Build/src/enrich/causal.ts

# Search for all occurrences of the variable names across the repo
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' '\b_globalLastEvent\b|\bglobalLastEvent\b' .

# Look for read-like uses of the backing state in the causal file
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' '_globalLastEvent[^=]|[^=]_globalLastEvent' Build/src/enrich/causal.ts

Repository: Nisoku/Satori

Length of output: 2856


Remove _globalLastEvent
Build/src/enrich/causal.ts:229,247-253 — this state is only written/reset and never read anywhere, so the underscore prefix is hiding dead code rather than silencing a useful lint warning.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Build/src/enrich/causal.ts` at line 229, Remove the unused `_globalLastEvent`
variable and delete all associated writes or resets in the relevant causal
enrichment logic, since the state is never read. Update the surrounding code
without introducing a replacement.


export function getCausalLink(
scope: string,
Expand All @@ -244,13 +244,13 @@ export function updateCausalLink(

// Also maintain legacy maps for compatibility
scopeLastEvent.set(scope, eventId);
globalLastEvent = eventId;
_globalLastEvent = eventId;
}

export function clearCausalLinks(): void {
globalCausalGraph.clear();
scopeLastEvent.clear();
globalLastEvent = undefined;
_globalLastEvent = undefined;
}

// Export the graph for advanced usage
Expand Down
1 change: 0 additions & 1 deletion Build/src/logger/createLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
WhenPredicate,
WhenCallback,
WatchHandle,
CustomLogLevel,
} from "../core/types.js";
import { enrichEvent } from "../enrich/enrichEvent.js";
import { updateCausalLink } from "../enrich/causal.js";
Expand Down
2 changes: 1 addition & 1 deletion Build/src/logger/createSatori.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
import { SimpleEventBus } from "../bus/eventBus.js";
import { ScopedLogger } from "./createLogger.js";
import { DEFAULT_CONFIG } from "../core/config.js";
import { validateConfig, assertValidConfig } from "../core/validation.js";
import { validateConfig } from "../core/validation.js";
import { PersistenceManager } from "../persistence/adapters.js";
import { MetricsCollector } from "../core/metrics.js";

Expand Down
Loading