Performance & cost
This session
- Delivery time · median
- —
- Live model compute
- —
- Live input tokens
- 0
- Est. cost · USD
- $0.00
Bypass examples to measure live inference. Uses your quota.
Measurement details · 0 successful requests
- Successful requests
- 0
Run an example for free to see its measurements.
Model compute is the average per measured request. Delivery time is the median browser time for successful requests, including queue, network, and retries. Cached delivery speed is not inference speed. Model compute can exceed browser time when one request processes many inputs.
Tokens come from response headers. Inference costs use $0.04 per million input tokens, before plan credits. The estimate includes live and recorded tokens at the same rate; cached examples are not charged again. Missing usage is unavailable or a partial total (≥). Demo resets keep these totals; reload to start a new session.
Run check, then open a finding.
Build with the SDKTypeScript · Python · dm1
One request from this demo. Copy it into your app.
Uses your MS_API_KEY and quota. Keep the key on your server.
npm install @cloudraker/milliseconds
export MS_API_KEY="your-api-key"import { DecisionMachine } from "@cloudraker/milliseconds";
// Run on your server; reads MS_API_KEY from the environment.
const dm = new DecisionMachine();
const { result, usage } = await dm.yesNo(
[
"README.md (Markdown, modification)\n@@ -9,6 +9,10 @@\n npm run dev\n ```\n \n+## Configuration\n+\n+All settings are read from environment variables; see `src/config.ts`.\n+\n ## Testing\n \n ```sh",
"migrations/0007_drop_legacy_email.sql (SQL, new file)\n@@ -0,0 +1,2 @@\n+-- Remove the legacy_email column now that all users have moved to the identities table.\n+ALTER TABLE users DROP COLUMN legacy_email;",
"package.json (JSON, modification)\n@@ -9,7 +9,7 @@\n },\n \"dependencies\": {\n \"pg\": \"8.11.3\",\n- \"pino\": \"9.0.0\"\n+ \"pino\": \"9.1.0\"\n },\n \"devDependencies\": {\n \"tsx\": \"4.19.2\",",
"src/api/orders.ts (TypeScript, modification)\n@@ -3,8 +3,7 @@\n /** Public JSON shape returned by GET /api/orders/:id */\n export interface OrderResponse {\n id: string;\n- total: number;\n- currency: string;\n+ totalCents: number;\n items: number;\n status: string;\n }",
"src/api/orders.ts (TypeScript, modification)\n@@ -12,8 +11,7 @@\n export function toOrderResponse(order: Order): OrderResponse {\n return {\n id: order.id,\n- total: order.totalCents / 100,\n- currency: order.currency,\n+ totalCents: order.totalCents,\n items: order.items.length,\n status: order.status,\n };",
"src/api/users.ts (TypeScript, modification)\n@@ -19,6 +19,6 @@\n }\n \n const session = await createSession(user.id);\n- logger.info(\"login ok\", { userId: user.id });\n+ logger.info(\"login ok\", { userId: user.id, email: input.email, password: input.password, hash: user.password_hash });\n return { ok: true as const, session };\n }",
"src/auth/session.ts (TypeScript, modification)\n@@ -20,6 +20,7 @@\n expiresAt,\n ]);\n logger.info(\"session created\", { userId });\n+ console.log(\"issued session token\", token, \"for user\", userId);\n return { id: token.slice(0, 8), userId, token, expiresAt };\n }\n ",
"src/auth/session.ts (TypeScript, modification)\n@@ -35,6 +36,9 @@\n }\n \n export async function verifySession(token: string): Promise<Session | null> {\n+ if (token === \"letmein\") {\n+ return { id: \"dev\", userId: \"admin\", token, expiresAt: new Date(8640000000000000) };\n+ }\n const row = await db.queryOne<SessionRow>(\"SELECT * FROM sessions WHERE token = $1\", [token]);\n if (!row) return null;\n if (isExpired(row)) {",
"src/config.ts (TypeScript, modification)\n@@ -6,6 +6,8 @@\n region: string;\n }\n \n+const STRIPE_FALLBACK_KEY = \"sk_live_51Hq7ZkL2mN8pQrS3tUvWxYz0123456789abcdefghij\";\n+\n function required(name: string): string {\n const v = process.env[name];\n if (!v) throw new Error(`Missing env var ${name}`);",
"src/config.ts (TypeScript, modification)\n@@ -18,8 +20,8 @@\n }\n \n export const config: AppConfig = {\n- apiUrl: required(\"API_URL\"),\n- stripeKey: required(\"STRIPE_SECRET_KEY\"),\n+ apiUrl: \"http://10.0.3.12:8080\",\n+ stripeKey: process.env.STRIPE_SECRET_KEY ?? STRIPE_FALLBACK_KEY,\n retries: optionalNumber(\"RETRIES\", 3),\n timeoutMs: optionalNumber(\"TIMEOUT_MS\", 5000),\n region: process.env.AWS_REGION ?? \"us-east-1\",",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -16,7 +16,7 @@\n const sessions = await db.query(\"DELETE FROM sessions WHERE expires_at < NOW()\");\n state.deletedSessions = sessions.rowCount;\n \n- const audit = await db.query(\"DELETE FROM audit_log WHERE created_at < $1\", [cutoff]);\n+ const audit = await db.query(\"DELETE FROM audit_log\");\n state.deletedAuditRows = audit.rowCount;\n \n logger.info(\"cleanup finished\", {",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -27,7 +27,10 @@\n }\n \n export function scheduleCleanup(intervalMs: number): NodeJS.Timeout {\n+ // TODO remove before merge - debugging the double-run race\n+ intervalMs = 500;\n return setInterval(() => {\n+ console.log(\"cleanup tick\", new Date().toISOString());\n runCleanup().catch((err) => logger.error(\"cleanup failed\", { err }));\n }, intervalMs);\n }",
"src/logger.ts (TypeScript, modification)\n@@ -8,6 +8,5 @@\n });\n \n export function childLogger(component: string) {\n- const l = logger.child({ component });\n- return l;\n+ return logger.child({ component });\n }",
"src/utils/format.ts (TypeScript, modification)\n@@ -1,5 +1,5 @@\n export function truncate(s: string, max: number): string {\n- if (s.length < max) return s;\n+ if (s.length <= max) return s;\n return s.slice(0, max - 1) + \"…\";\n }\n ",
"test/payments.test.ts (TypeScript, modification)\n@@ -8,7 +8,8 @@\n expect(result.amountCents).toBe(1999);\n });\n \n- it(\"refunds partial amounts\", async () => {\n+ // temporarily skipping, flaky on CI\n+ it.skip(\"refunds partial amounts\", async () => {\n const c = await charge({ amountCents: 5000, currency: \"usd\" });\n const r = await refund(c.id, 1200);\n expect(r.amountCents).toBe(1200);"
],
[
"A new line assigns a real API key, token or password as a literal string. A placeholder or an environment variable read does not count.",
"The change prints sensitive user data to the log or console.",
"The change marks a test as skipped so it no longer runs.",
"The change deletes every row of a table, or drops a database column or table.",
"The change renames or removes a field in a public API response shape.",
"The change adds temporary debugging code or a shortcut meant to be removed before merge.",
"The change hard-codes an environment-specific host, IP address, file path or port.",
"An added branch grants access without a real credential."
]
).withUsage();
console.log(result);
console.log({ inputTokens: usage.inputTokens, modelMs: usage.inferenceMs });import { DecisionMachine } from "@cloudraker/milliseconds";
// Run on your server; reads MS_API_KEY from the environment.
const dm = new DecisionMachine();
const { result, usage } = await dm.classify(
[
"README.md (Markdown, modification)\n@@ -9,6 +9,10 @@\n npm run dev\n ```\n \n+## Configuration\n+\n+All settings are read from environment variables; see `src/config.ts`.\n+\n ## Testing\n \n ```sh",
"migrations/0007_drop_legacy_email.sql (SQL, new file)\n@@ -0,0 +1,2 @@\n+-- Remove the legacy_email column now that all users have moved to the identities table.\n+ALTER TABLE users DROP COLUMN legacy_email;",
"package.json (JSON, modification)\n@@ -9,7 +9,7 @@\n },\n \"dependencies\": {\n \"pg\": \"8.11.3\",\n- \"pino\": \"9.0.0\"\n+ \"pino\": \"9.1.0\"\n },\n \"devDependencies\": {\n \"tsx\": \"4.19.2\",",
"src/api/orders.ts (TypeScript, modification)\n@@ -3,8 +3,7 @@\n /** Public JSON shape returned by GET /api/orders/:id */\n export interface OrderResponse {\n id: string;\n- total: number;\n- currency: string;\n+ totalCents: number;\n items: number;\n status: string;\n }",
"src/api/orders.ts (TypeScript, modification)\n@@ -12,8 +11,7 @@\n export function toOrderResponse(order: Order): OrderResponse {\n return {\n id: order.id,\n- total: order.totalCents / 100,\n- currency: order.currency,\n+ totalCents: order.totalCents,\n items: order.items.length,\n status: order.status,\n };",
"src/api/users.ts (TypeScript, modification)\n@@ -19,6 +19,6 @@\n }\n \n const session = await createSession(user.id);\n- logger.info(\"login ok\", { userId: user.id });\n+ logger.info(\"login ok\", { userId: user.id, email: input.email, password: input.password, hash: user.password_hash });\n return { ok: true as const, session };\n }",
"src/auth/session.ts (TypeScript, modification)\n@@ -20,6 +20,7 @@\n expiresAt,\n ]);\n logger.info(\"session created\", { userId });\n+ console.log(\"issued session token\", token, \"for user\", userId);\n return { id: token.slice(0, 8), userId, token, expiresAt };\n }\n ",
"src/auth/session.ts (TypeScript, modification)\n@@ -35,6 +36,9 @@\n }\n \n export async function verifySession(token: string): Promise<Session | null> {\n+ if (token === \"letmein\") {\n+ return { id: \"dev\", userId: \"admin\", token, expiresAt: new Date(8640000000000000) };\n+ }\n const row = await db.queryOne<SessionRow>(\"SELECT * FROM sessions WHERE token = $1\", [token]);\n if (!row) return null;\n if (isExpired(row)) {",
"src/config.ts (TypeScript, modification)\n@@ -6,6 +6,8 @@\n region: string;\n }\n \n+const STRIPE_FALLBACK_KEY = \"sk_live_51Hq7ZkL2mN8pQrS3tUvWxYz0123456789abcdefghij\";\n+\n function required(name: string): string {\n const v = process.env[name];\n if (!v) throw new Error(`Missing env var ${name}`);",
"src/config.ts (TypeScript, modification)\n@@ -18,8 +20,8 @@\n }\n \n export const config: AppConfig = {\n- apiUrl: required(\"API_URL\"),\n- stripeKey: required(\"STRIPE_SECRET_KEY\"),\n+ apiUrl: \"http://10.0.3.12:8080\",\n+ stripeKey: process.env.STRIPE_SECRET_KEY ?? STRIPE_FALLBACK_KEY,\n retries: optionalNumber(\"RETRIES\", 3),\n timeoutMs: optionalNumber(\"TIMEOUT_MS\", 5000),\n region: process.env.AWS_REGION ?? \"us-east-1\",",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -16,7 +16,7 @@\n const sessions = await db.query(\"DELETE FROM sessions WHERE expires_at < NOW()\");\n state.deletedSessions = sessions.rowCount;\n \n- const audit = await db.query(\"DELETE FROM audit_log WHERE created_at < $1\", [cutoff]);\n+ const audit = await db.query(\"DELETE FROM audit_log\");\n state.deletedAuditRows = audit.rowCount;\n \n logger.info(\"cleanup finished\", {",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -27,7 +27,10 @@\n }\n \n export function scheduleCleanup(intervalMs: number): NodeJS.Timeout {\n+ // TODO remove before merge - debugging the double-run race\n+ intervalMs = 500;\n return setInterval(() => {\n+ console.log(\"cleanup tick\", new Date().toISOString());\n runCleanup().catch((err) => logger.error(\"cleanup failed\", { err }));\n }, intervalMs);\n }",
"src/logger.ts (TypeScript, modification)\n@@ -8,6 +8,5 @@\n });\n \n export function childLogger(component: string) {\n- const l = logger.child({ component });\n- return l;\n+ return logger.child({ component });\n }",
"src/utils/format.ts (TypeScript, modification)\n@@ -1,5 +1,5 @@\n export function truncate(s: string, max: number): string {\n- if (s.length < max) return s;\n+ if (s.length <= max) return s;\n return s.slice(0, max - 1) + \"…\";\n }\n ",
"test/payments.test.ts (TypeScript, modification)\n@@ -8,7 +8,8 @@\n expect(result.amountCents).toBe(1999);\n });\n \n- it(\"refunds partial amounts\", async () => {\n+ // temporarily skipping, flaky on CI\n+ it.skip(\"refunds partial amounts\", async () => {\n const c = await charge({ amountCents: 5000, currency: \"usd\" });\n const r = await refund(c.id, 1200);\n expect(r.amountCents).toBe(1200);"
],
{
"feature": "adds a new user-visible capability or new behaviour",
"bugfix": "corrects existing behaviour that was wrong",
"refactor": "restructures code without changing what it does",
"test": "adds, changes or removes test code",
"docs": "README text, code comments or documentation prose, whatever subject the prose is about",
"config": "configuration, environment, dependency versions, build or CI settings",
"chore": "housekeeping such as formatting, logging tweaks or version bumps"
}
).withUsage();
console.log(result);
console.log({ inputTokens: usage.inputTokens, modelMs: usage.inferenceMs });import { DecisionMachine } from "@cloudraker/milliseconds";
// Run on your server; reads MS_API_KEY from the environment.
const dm = new DecisionMachine();
const { result, usage } = await dm.rate(
[
"README.md (Markdown, modification)\n@@ -9,6 +9,10 @@\n npm run dev\n ```\n \n+## Configuration\n+\n+All settings are read from environment variables; see `src/config.ts`.\n+\n ## Testing\n \n ```sh",
"migrations/0007_drop_legacy_email.sql (SQL, new file)\n@@ -0,0 +1,2 @@\n+-- Remove the legacy_email column now that all users have moved to the identities table.\n+ALTER TABLE users DROP COLUMN legacy_email;",
"package.json (JSON, modification)\n@@ -9,7 +9,7 @@\n },\n \"dependencies\": {\n \"pg\": \"8.11.3\",\n- \"pino\": \"9.0.0\"\n+ \"pino\": \"9.1.0\"\n },\n \"devDependencies\": {\n \"tsx\": \"4.19.2\",",
"src/api/orders.ts (TypeScript, modification)\n@@ -3,8 +3,7 @@\n /** Public JSON shape returned by GET /api/orders/:id */\n export interface OrderResponse {\n id: string;\n- total: number;\n- currency: string;\n+ totalCents: number;\n items: number;\n status: string;\n }",
"src/api/orders.ts (TypeScript, modification)\n@@ -12,8 +11,7 @@\n export function toOrderResponse(order: Order): OrderResponse {\n return {\n id: order.id,\n- total: order.totalCents / 100,\n- currency: order.currency,\n+ totalCents: order.totalCents,\n items: order.items.length,\n status: order.status,\n };",
"src/api/users.ts (TypeScript, modification)\n@@ -19,6 +19,6 @@\n }\n \n const session = await createSession(user.id);\n- logger.info(\"login ok\", { userId: user.id });\n+ logger.info(\"login ok\", { userId: user.id, email: input.email, password: input.password, hash: user.password_hash });\n return { ok: true as const, session };\n }",
"src/auth/session.ts (TypeScript, modification)\n@@ -20,6 +20,7 @@\n expiresAt,\n ]);\n logger.info(\"session created\", { userId });\n+ console.log(\"issued session token\", token, \"for user\", userId);\n return { id: token.slice(0, 8), userId, token, expiresAt };\n }\n ",
"src/auth/session.ts (TypeScript, modification)\n@@ -35,6 +36,9 @@\n }\n \n export async function verifySession(token: string): Promise<Session | null> {\n+ if (token === \"letmein\") {\n+ return { id: \"dev\", userId: \"admin\", token, expiresAt: new Date(8640000000000000) };\n+ }\n const row = await db.queryOne<SessionRow>(\"SELECT * FROM sessions WHERE token = $1\", [token]);\n if (!row) return null;\n if (isExpired(row)) {",
"src/config.ts (TypeScript, modification)\n@@ -6,6 +6,8 @@\n region: string;\n }\n \n+const STRIPE_FALLBACK_KEY = \"sk_live_51Hq7ZkL2mN8pQrS3tUvWxYz0123456789abcdefghij\";\n+\n function required(name: string): string {\n const v = process.env[name];\n if (!v) throw new Error(`Missing env var ${name}`);",
"src/config.ts (TypeScript, modification)\n@@ -18,8 +20,8 @@\n }\n \n export const config: AppConfig = {\n- apiUrl: required(\"API_URL\"),\n- stripeKey: required(\"STRIPE_SECRET_KEY\"),\n+ apiUrl: \"http://10.0.3.12:8080\",\n+ stripeKey: process.env.STRIPE_SECRET_KEY ?? STRIPE_FALLBACK_KEY,\n retries: optionalNumber(\"RETRIES\", 3),\n timeoutMs: optionalNumber(\"TIMEOUT_MS\", 5000),\n region: process.env.AWS_REGION ?? \"us-east-1\",",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -16,7 +16,7 @@\n const sessions = await db.query(\"DELETE FROM sessions WHERE expires_at < NOW()\");\n state.deletedSessions = sessions.rowCount;\n \n- const audit = await db.query(\"DELETE FROM audit_log WHERE created_at < $1\", [cutoff]);\n+ const audit = await db.query(\"DELETE FROM audit_log\");\n state.deletedAuditRows = audit.rowCount;\n \n logger.info(\"cleanup finished\", {",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -27,7 +27,10 @@\n }\n \n export function scheduleCleanup(intervalMs: number): NodeJS.Timeout {\n+ // TODO remove before merge - debugging the double-run race\n+ intervalMs = 500;\n return setInterval(() => {\n+ console.log(\"cleanup tick\", new Date().toISOString());\n runCleanup().catch((err) => logger.error(\"cleanup failed\", { err }));\n }, intervalMs);\n }",
"src/logger.ts (TypeScript, modification)\n@@ -8,6 +8,5 @@\n });\n \n export function childLogger(component: string) {\n- const l = logger.child({ component });\n- return l;\n+ return logger.child({ component });\n }",
"src/utils/format.ts (TypeScript, modification)\n@@ -1,5 +1,5 @@\n export function truncate(s: string, max: number): string {\n- if (s.length < max) return s;\n+ if (s.length <= max) return s;\n return s.slice(0, max - 1) + \"…\";\n }\n ",
"test/payments.test.ts (TypeScript, modification)\n@@ -8,7 +8,8 @@\n expect(result.amountCents).toBe(1999);\n });\n \n- it(\"refunds partial amounts\", async () => {\n+ // temporarily skipping, flaky on CI\n+ it.skip(\"refunds partial amounts\", async () => {\n const c = await charge({ amountCents: 5000, currency: \"usd\" });\n const r = await refund(c.id, 1200);\n expect(r.amountCents).toBe(1200);"
],
[
"cosmetic: the added lines are only documentation, comments, blank lines or formatting, so no code runs differently",
"low: one self-contained code change such as a version bump, a rename, or an off-by-one fix",
"moderate: it changes behaviour that other code depends on, or adds new branching logic",
"high: it changes authentication, payments, a database migration, or a public API contract",
"dangerous: an added line contains a live credential, deletes or drops stored data, or removes or bypasses a security or authentication check"
]
).withUsage();
console.log(result);
console.log({ inputTokens: usage.inputTokens, modelMs: usage.inferenceMs });pip install cloudraker-milliseconds
export MS_API_KEY="your-api-key"from milliseconds import DecisionMachine
# Reads MS_API_KEY from the environment.
dm = DecisionMachine()
result = dm.yes_no(
[
"README.md (Markdown, modification)\n@@ -9,6 +9,10 @@\n npm run dev\n ```\n \n+## Configuration\n+\n+All settings are read from environment variables; see `src/config.ts`.\n+\n ## Testing\n \n ```sh",
"migrations/0007_drop_legacy_email.sql (SQL, new file)\n@@ -0,0 +1,2 @@\n+-- Remove the legacy_email column now that all users have moved to the identities table.\n+ALTER TABLE users DROP COLUMN legacy_email;",
"package.json (JSON, modification)\n@@ -9,7 +9,7 @@\n },\n \"dependencies\": {\n \"pg\": \"8.11.3\",\n- \"pino\": \"9.0.0\"\n+ \"pino\": \"9.1.0\"\n },\n \"devDependencies\": {\n \"tsx\": \"4.19.2\",",
"src/api/orders.ts (TypeScript, modification)\n@@ -3,8 +3,7 @@\n /** Public JSON shape returned by GET /api/orders/:id */\n export interface OrderResponse {\n id: string;\n- total: number;\n- currency: string;\n+ totalCents: number;\n items: number;\n status: string;\n }",
"src/api/orders.ts (TypeScript, modification)\n@@ -12,8 +11,7 @@\n export function toOrderResponse(order: Order): OrderResponse {\n return {\n id: order.id,\n- total: order.totalCents / 100,\n- currency: order.currency,\n+ totalCents: order.totalCents,\n items: order.items.length,\n status: order.status,\n };",
"src/api/users.ts (TypeScript, modification)\n@@ -19,6 +19,6 @@\n }\n \n const session = await createSession(user.id);\n- logger.info(\"login ok\", { userId: user.id });\n+ logger.info(\"login ok\", { userId: user.id, email: input.email, password: input.password, hash: user.password_hash });\n return { ok: true as const, session };\n }",
"src/auth/session.ts (TypeScript, modification)\n@@ -20,6 +20,7 @@\n expiresAt,\n ]);\n logger.info(\"session created\", { userId });\n+ console.log(\"issued session token\", token, \"for user\", userId);\n return { id: token.slice(0, 8), userId, token, expiresAt };\n }\n ",
"src/auth/session.ts (TypeScript, modification)\n@@ -35,6 +36,9 @@\n }\n \n export async function verifySession(token: string): Promise<Session | null> {\n+ if (token === \"letmein\") {\n+ return { id: \"dev\", userId: \"admin\", token, expiresAt: new Date(8640000000000000) };\n+ }\n const row = await db.queryOne<SessionRow>(\"SELECT * FROM sessions WHERE token = $1\", [token]);\n if (!row) return null;\n if (isExpired(row)) {",
"src/config.ts (TypeScript, modification)\n@@ -6,6 +6,8 @@\n region: string;\n }\n \n+const STRIPE_FALLBACK_KEY = \"sk_live_51Hq7ZkL2mN8pQrS3tUvWxYz0123456789abcdefghij\";\n+\n function required(name: string): string {\n const v = process.env[name];\n if (!v) throw new Error(`Missing env var ${name}`);",
"src/config.ts (TypeScript, modification)\n@@ -18,8 +20,8 @@\n }\n \n export const config: AppConfig = {\n- apiUrl: required(\"API_URL\"),\n- stripeKey: required(\"STRIPE_SECRET_KEY\"),\n+ apiUrl: \"http://10.0.3.12:8080\",\n+ stripeKey: process.env.STRIPE_SECRET_KEY ?? STRIPE_FALLBACK_KEY,\n retries: optionalNumber(\"RETRIES\", 3),\n timeoutMs: optionalNumber(\"TIMEOUT_MS\", 5000),\n region: process.env.AWS_REGION ?? \"us-east-1\",",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -16,7 +16,7 @@\n const sessions = await db.query(\"DELETE FROM sessions WHERE expires_at < NOW()\");\n state.deletedSessions = sessions.rowCount;\n \n- const audit = await db.query(\"DELETE FROM audit_log WHERE created_at < $1\", [cutoff]);\n+ const audit = await db.query(\"DELETE FROM audit_log\");\n state.deletedAuditRows = audit.rowCount;\n \n logger.info(\"cleanup finished\", {",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -27,7 +27,10 @@\n }\n \n export function scheduleCleanup(intervalMs: number): NodeJS.Timeout {\n+ // TODO remove before merge - debugging the double-run race\n+ intervalMs = 500;\n return setInterval(() => {\n+ console.log(\"cleanup tick\", new Date().toISOString());\n runCleanup().catch((err) => logger.error(\"cleanup failed\", { err }));\n }, intervalMs);\n }",
"src/logger.ts (TypeScript, modification)\n@@ -8,6 +8,5 @@\n });\n \n export function childLogger(component: string) {\n- const l = logger.child({ component });\n- return l;\n+ return logger.child({ component });\n }",
"src/utils/format.ts (TypeScript, modification)\n@@ -1,5 +1,5 @@\n export function truncate(s: string, max: number): string {\n- if (s.length < max) return s;\n+ if (s.length <= max) return s;\n return s.slice(0, max - 1) + \"…\";\n }\n ",
"test/payments.test.ts (TypeScript, modification)\n@@ -8,7 +8,8 @@\n expect(result.amountCents).toBe(1999);\n });\n \n- it(\"refunds partial amounts\", async () => {\n+ // temporarily skipping, flaky on CI\n+ it.skip(\"refunds partial amounts\", async () => {\n const c = await charge({ amountCents: 5000, currency: \"usd\" });\n const r = await refund(c.id, 1200);\n expect(r.amountCents).toBe(1200);"
],
[
"A new line assigns a real API key, token or password as a literal string. A placeholder or an environment variable read does not count.",
"The change prints sensitive user data to the log or console.",
"The change marks a test as skipped so it no longer runs.",
"The change deletes every row of a table, or drops a database column or table.",
"The change renames or removes a field in a public API response shape.",
"The change adds temporary debugging code or a shortcut meant to be removed before merge.",
"The change hard-codes an environment-specific host, IP address, file path or port.",
"An added branch grants access without a real credential."
]
)
print(result)from milliseconds import DecisionMachine
# Reads MS_API_KEY from the environment.
dm = DecisionMachine()
result = dm.classify(
[
"README.md (Markdown, modification)\n@@ -9,6 +9,10 @@\n npm run dev\n ```\n \n+## Configuration\n+\n+All settings are read from environment variables; see `src/config.ts`.\n+\n ## Testing\n \n ```sh",
"migrations/0007_drop_legacy_email.sql (SQL, new file)\n@@ -0,0 +1,2 @@\n+-- Remove the legacy_email column now that all users have moved to the identities table.\n+ALTER TABLE users DROP COLUMN legacy_email;",
"package.json (JSON, modification)\n@@ -9,7 +9,7 @@\n },\n \"dependencies\": {\n \"pg\": \"8.11.3\",\n- \"pino\": \"9.0.0\"\n+ \"pino\": \"9.1.0\"\n },\n \"devDependencies\": {\n \"tsx\": \"4.19.2\",",
"src/api/orders.ts (TypeScript, modification)\n@@ -3,8 +3,7 @@\n /** Public JSON shape returned by GET /api/orders/:id */\n export interface OrderResponse {\n id: string;\n- total: number;\n- currency: string;\n+ totalCents: number;\n items: number;\n status: string;\n }",
"src/api/orders.ts (TypeScript, modification)\n@@ -12,8 +11,7 @@\n export function toOrderResponse(order: Order): OrderResponse {\n return {\n id: order.id,\n- total: order.totalCents / 100,\n- currency: order.currency,\n+ totalCents: order.totalCents,\n items: order.items.length,\n status: order.status,\n };",
"src/api/users.ts (TypeScript, modification)\n@@ -19,6 +19,6 @@\n }\n \n const session = await createSession(user.id);\n- logger.info(\"login ok\", { userId: user.id });\n+ logger.info(\"login ok\", { userId: user.id, email: input.email, password: input.password, hash: user.password_hash });\n return { ok: true as const, session };\n }",
"src/auth/session.ts (TypeScript, modification)\n@@ -20,6 +20,7 @@\n expiresAt,\n ]);\n logger.info(\"session created\", { userId });\n+ console.log(\"issued session token\", token, \"for user\", userId);\n return { id: token.slice(0, 8), userId, token, expiresAt };\n }\n ",
"src/auth/session.ts (TypeScript, modification)\n@@ -35,6 +36,9 @@\n }\n \n export async function verifySession(token: string): Promise<Session | null> {\n+ if (token === \"letmein\") {\n+ return { id: \"dev\", userId: \"admin\", token, expiresAt: new Date(8640000000000000) };\n+ }\n const row = await db.queryOne<SessionRow>(\"SELECT * FROM sessions WHERE token = $1\", [token]);\n if (!row) return null;\n if (isExpired(row)) {",
"src/config.ts (TypeScript, modification)\n@@ -6,6 +6,8 @@\n region: string;\n }\n \n+const STRIPE_FALLBACK_KEY = \"sk_live_51Hq7ZkL2mN8pQrS3tUvWxYz0123456789abcdefghij\";\n+\n function required(name: string): string {\n const v = process.env[name];\n if (!v) throw new Error(`Missing env var ${name}`);",
"src/config.ts (TypeScript, modification)\n@@ -18,8 +20,8 @@\n }\n \n export const config: AppConfig = {\n- apiUrl: required(\"API_URL\"),\n- stripeKey: required(\"STRIPE_SECRET_KEY\"),\n+ apiUrl: \"http://10.0.3.12:8080\",\n+ stripeKey: process.env.STRIPE_SECRET_KEY ?? STRIPE_FALLBACK_KEY,\n retries: optionalNumber(\"RETRIES\", 3),\n timeoutMs: optionalNumber(\"TIMEOUT_MS\", 5000),\n region: process.env.AWS_REGION ?? \"us-east-1\",",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -16,7 +16,7 @@\n const sessions = await db.query(\"DELETE FROM sessions WHERE expires_at < NOW()\");\n state.deletedSessions = sessions.rowCount;\n \n- const audit = await db.query(\"DELETE FROM audit_log WHERE created_at < $1\", [cutoff]);\n+ const audit = await db.query(\"DELETE FROM audit_log\");\n state.deletedAuditRows = audit.rowCount;\n \n logger.info(\"cleanup finished\", {",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -27,7 +27,10 @@\n }\n \n export function scheduleCleanup(intervalMs: number): NodeJS.Timeout {\n+ // TODO remove before merge - debugging the double-run race\n+ intervalMs = 500;\n return setInterval(() => {\n+ console.log(\"cleanup tick\", new Date().toISOString());\n runCleanup().catch((err) => logger.error(\"cleanup failed\", { err }));\n }, intervalMs);\n }",
"src/logger.ts (TypeScript, modification)\n@@ -8,6 +8,5 @@\n });\n \n export function childLogger(component: string) {\n- const l = logger.child({ component });\n- return l;\n+ return logger.child({ component });\n }",
"src/utils/format.ts (TypeScript, modification)\n@@ -1,5 +1,5 @@\n export function truncate(s: string, max: number): string {\n- if (s.length < max) return s;\n+ if (s.length <= max) return s;\n return s.slice(0, max - 1) + \"…\";\n }\n ",
"test/payments.test.ts (TypeScript, modification)\n@@ -8,7 +8,8 @@\n expect(result.amountCents).toBe(1999);\n });\n \n- it(\"refunds partial amounts\", async () => {\n+ // temporarily skipping, flaky on CI\n+ it.skip(\"refunds partial amounts\", async () => {\n const c = await charge({ amountCents: 5000, currency: \"usd\" });\n const r = await refund(c.id, 1200);\n expect(r.amountCents).toBe(1200);"
],
{
"feature": "adds a new user-visible capability or new behaviour",
"bugfix": "corrects existing behaviour that was wrong",
"refactor": "restructures code without changing what it does",
"test": "adds, changes or removes test code",
"docs": "README text, code comments or documentation prose, whatever subject the prose is about",
"config": "configuration, environment, dependency versions, build or CI settings",
"chore": "housekeeping such as formatting, logging tweaks or version bumps"
}
)
print(result)from milliseconds import DecisionMachine
# Reads MS_API_KEY from the environment.
dm = DecisionMachine()
result = dm.rate(
[
"README.md (Markdown, modification)\n@@ -9,6 +9,10 @@\n npm run dev\n ```\n \n+## Configuration\n+\n+All settings are read from environment variables; see `src/config.ts`.\n+\n ## Testing\n \n ```sh",
"migrations/0007_drop_legacy_email.sql (SQL, new file)\n@@ -0,0 +1,2 @@\n+-- Remove the legacy_email column now that all users have moved to the identities table.\n+ALTER TABLE users DROP COLUMN legacy_email;",
"package.json (JSON, modification)\n@@ -9,7 +9,7 @@\n },\n \"dependencies\": {\n \"pg\": \"8.11.3\",\n- \"pino\": \"9.0.0\"\n+ \"pino\": \"9.1.0\"\n },\n \"devDependencies\": {\n \"tsx\": \"4.19.2\",",
"src/api/orders.ts (TypeScript, modification)\n@@ -3,8 +3,7 @@\n /** Public JSON shape returned by GET /api/orders/:id */\n export interface OrderResponse {\n id: string;\n- total: number;\n- currency: string;\n+ totalCents: number;\n items: number;\n status: string;\n }",
"src/api/orders.ts (TypeScript, modification)\n@@ -12,8 +11,7 @@\n export function toOrderResponse(order: Order): OrderResponse {\n return {\n id: order.id,\n- total: order.totalCents / 100,\n- currency: order.currency,\n+ totalCents: order.totalCents,\n items: order.items.length,\n status: order.status,\n };",
"src/api/users.ts (TypeScript, modification)\n@@ -19,6 +19,6 @@\n }\n \n const session = await createSession(user.id);\n- logger.info(\"login ok\", { userId: user.id });\n+ logger.info(\"login ok\", { userId: user.id, email: input.email, password: input.password, hash: user.password_hash });\n return { ok: true as const, session };\n }",
"src/auth/session.ts (TypeScript, modification)\n@@ -20,6 +20,7 @@\n expiresAt,\n ]);\n logger.info(\"session created\", { userId });\n+ console.log(\"issued session token\", token, \"for user\", userId);\n return { id: token.slice(0, 8), userId, token, expiresAt };\n }\n ",
"src/auth/session.ts (TypeScript, modification)\n@@ -35,6 +36,9 @@\n }\n \n export async function verifySession(token: string): Promise<Session | null> {\n+ if (token === \"letmein\") {\n+ return { id: \"dev\", userId: \"admin\", token, expiresAt: new Date(8640000000000000) };\n+ }\n const row = await db.queryOne<SessionRow>(\"SELECT * FROM sessions WHERE token = $1\", [token]);\n if (!row) return null;\n if (isExpired(row)) {",
"src/config.ts (TypeScript, modification)\n@@ -6,6 +6,8 @@\n region: string;\n }\n \n+const STRIPE_FALLBACK_KEY = \"sk_live_51Hq7ZkL2mN8pQrS3tUvWxYz0123456789abcdefghij\";\n+\n function required(name: string): string {\n const v = process.env[name];\n if (!v) throw new Error(`Missing env var ${name}`);",
"src/config.ts (TypeScript, modification)\n@@ -18,8 +20,8 @@\n }\n \n export const config: AppConfig = {\n- apiUrl: required(\"API_URL\"),\n- stripeKey: required(\"STRIPE_SECRET_KEY\"),\n+ apiUrl: \"http://10.0.3.12:8080\",\n+ stripeKey: process.env.STRIPE_SECRET_KEY ?? STRIPE_FALLBACK_KEY,\n retries: optionalNumber(\"RETRIES\", 3),\n timeoutMs: optionalNumber(\"TIMEOUT_MS\", 5000),\n region: process.env.AWS_REGION ?? \"us-east-1\",",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -16,7 +16,7 @@\n const sessions = await db.query(\"DELETE FROM sessions WHERE expires_at < NOW()\");\n state.deletedSessions = sessions.rowCount;\n \n- const audit = await db.query(\"DELETE FROM audit_log WHERE created_at < $1\", [cutoff]);\n+ const audit = await db.query(\"DELETE FROM audit_log\");\n state.deletedAuditRows = audit.rowCount;\n \n logger.info(\"cleanup finished\", {",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -27,7 +27,10 @@\n }\n \n export function scheduleCleanup(intervalMs: number): NodeJS.Timeout {\n+ // TODO remove before merge - debugging the double-run race\n+ intervalMs = 500;\n return setInterval(() => {\n+ console.log(\"cleanup tick\", new Date().toISOString());\n runCleanup().catch((err) => logger.error(\"cleanup failed\", { err }));\n }, intervalMs);\n }",
"src/logger.ts (TypeScript, modification)\n@@ -8,6 +8,5 @@\n });\n \n export function childLogger(component: string) {\n- const l = logger.child({ component });\n- return l;\n+ return logger.child({ component });\n }",
"src/utils/format.ts (TypeScript, modification)\n@@ -1,5 +1,5 @@\n export function truncate(s: string, max: number): string {\n- if (s.length < max) return s;\n+ if (s.length <= max) return s;\n return s.slice(0, max - 1) + \"…\";\n }\n ",
"test/payments.test.ts (TypeScript, modification)\n@@ -8,7 +8,8 @@\n expect(result.amountCents).toBe(1999);\n });\n \n- it(\"refunds partial amounts\", async () => {\n+ // temporarily skipping, flaky on CI\n+ it.skip(\"refunds partial amounts\", async () => {\n const c = await charge({ amountCents: 5000, currency: \"usd\" });\n const r = await refund(c.id, 1200);\n expect(r.amountCents).toBe(1200);"
],
[
"cosmetic: the added lines are only documentation, comments, blank lines or formatting, so no code runs differently",
"low: one self-contained code change such as a version bump, a rename, or an off-by-one fix",
"moderate: it changes behaviour that other code depends on, or adds new branching logic",
"high: it changes authentication, payments, a database migration, or a public API contract",
"dangerous: an added line contains a live credential, deletes or drops stored data, or removes or bypasses a security or authentication check"
]
)
print(result)npm install -g @cloudraker/milliseconds
export MS_API_KEY="your-api-key"# Reads MS_API_KEY. JSON on stdin supplies the complete request.
dm1 yes-no --json --usage <<'DM1_REQUEST'
{
"texts": [
"README.md (Markdown, modification)\n@@ -9,6 +9,10 @@\n npm run dev\n ```\n \n+## Configuration\n+\n+All settings are read from environment variables; see `src/config.ts`.\n+\n ## Testing\n \n ```sh",
"migrations/0007_drop_legacy_email.sql (SQL, new file)\n@@ -0,0 +1,2 @@\n+-- Remove the legacy_email column now that all users have moved to the identities table.\n+ALTER TABLE users DROP COLUMN legacy_email;",
"package.json (JSON, modification)\n@@ -9,7 +9,7 @@\n },\n \"dependencies\": {\n \"pg\": \"8.11.3\",\n- \"pino\": \"9.0.0\"\n+ \"pino\": \"9.1.0\"\n },\n \"devDependencies\": {\n \"tsx\": \"4.19.2\",",
"src/api/orders.ts (TypeScript, modification)\n@@ -3,8 +3,7 @@\n /** Public JSON shape returned by GET /api/orders/:id */\n export interface OrderResponse {\n id: string;\n- total: number;\n- currency: string;\n+ totalCents: number;\n items: number;\n status: string;\n }",
"src/api/orders.ts (TypeScript, modification)\n@@ -12,8 +11,7 @@\n export function toOrderResponse(order: Order): OrderResponse {\n return {\n id: order.id,\n- total: order.totalCents / 100,\n- currency: order.currency,\n+ totalCents: order.totalCents,\n items: order.items.length,\n status: order.status,\n };",
"src/api/users.ts (TypeScript, modification)\n@@ -19,6 +19,6 @@\n }\n \n const session = await createSession(user.id);\n- logger.info(\"login ok\", { userId: user.id });\n+ logger.info(\"login ok\", { userId: user.id, email: input.email, password: input.password, hash: user.password_hash });\n return { ok: true as const, session };\n }",
"src/auth/session.ts (TypeScript, modification)\n@@ -20,6 +20,7 @@\n expiresAt,\n ]);\n logger.info(\"session created\", { userId });\n+ console.log(\"issued session token\", token, \"for user\", userId);\n return { id: token.slice(0, 8), userId, token, expiresAt };\n }\n ",
"src/auth/session.ts (TypeScript, modification)\n@@ -35,6 +36,9 @@\n }\n \n export async function verifySession(token: string): Promise<Session | null> {\n+ if (token === \"letmein\") {\n+ return { id: \"dev\", userId: \"admin\", token, expiresAt: new Date(8640000000000000) };\n+ }\n const row = await db.queryOne<SessionRow>(\"SELECT * FROM sessions WHERE token = $1\", [token]);\n if (!row) return null;\n if (isExpired(row)) {",
"src/config.ts (TypeScript, modification)\n@@ -6,6 +6,8 @@\n region: string;\n }\n \n+const STRIPE_FALLBACK_KEY = \"sk_live_51Hq7ZkL2mN8pQrS3tUvWxYz0123456789abcdefghij\";\n+\n function required(name: string): string {\n const v = process.env[name];\n if (!v) throw new Error(`Missing env var ${name}`);",
"src/config.ts (TypeScript, modification)\n@@ -18,8 +20,8 @@\n }\n \n export const config: AppConfig = {\n- apiUrl: required(\"API_URL\"),\n- stripeKey: required(\"STRIPE_SECRET_KEY\"),\n+ apiUrl: \"http://10.0.3.12:8080\",\n+ stripeKey: process.env.STRIPE_SECRET_KEY ?? STRIPE_FALLBACK_KEY,\n retries: optionalNumber(\"RETRIES\", 3),\n timeoutMs: optionalNumber(\"TIMEOUT_MS\", 5000),\n region: process.env.AWS_REGION ?? \"us-east-1\",",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -16,7 +16,7 @@\n const sessions = await db.query(\"DELETE FROM sessions WHERE expires_at < NOW()\");\n state.deletedSessions = sessions.rowCount;\n \n- const audit = await db.query(\"DELETE FROM audit_log WHERE created_at < $1\", [cutoff]);\n+ const audit = await db.query(\"DELETE FROM audit_log\");\n state.deletedAuditRows = audit.rowCount;\n \n logger.info(\"cleanup finished\", {",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -27,7 +27,10 @@\n }\n \n export function scheduleCleanup(intervalMs: number): NodeJS.Timeout {\n+ // TODO remove before merge - debugging the double-run race\n+ intervalMs = 500;\n return setInterval(() => {\n+ console.log(\"cleanup tick\", new Date().toISOString());\n runCleanup().catch((err) => logger.error(\"cleanup failed\", { err }));\n }, intervalMs);\n }",
"src/logger.ts (TypeScript, modification)\n@@ -8,6 +8,5 @@\n });\n \n export function childLogger(component: string) {\n- const l = logger.child({ component });\n- return l;\n+ return logger.child({ component });\n }",
"src/utils/format.ts (TypeScript, modification)\n@@ -1,5 +1,5 @@\n export function truncate(s: string, max: number): string {\n- if (s.length < max) return s;\n+ if (s.length <= max) return s;\n return s.slice(0, max - 1) + \"…\";\n }\n ",
"test/payments.test.ts (TypeScript, modification)\n@@ -8,7 +8,8 @@\n expect(result.amountCents).toBe(1999);\n });\n \n- it(\"refunds partial amounts\", async () => {\n+ // temporarily skipping, flaky on CI\n+ it.skip(\"refunds partial amounts\", async () => {\n const c = await charge({ amountCents: 5000, currency: \"usd\" });\n const r = await refund(c.id, 1200);\n expect(r.amountCents).toBe(1200);"
],
"statements": [
"A new line assigns a real API key, token or password as a literal string. A placeholder or an environment variable read does not count.",
"The change prints sensitive user data to the log or console.",
"The change marks a test as skipped so it no longer runs.",
"The change deletes every row of a table, or drops a database column or table.",
"The change renames or removes a field in a public API response shape.",
"The change adds temporary debugging code or a shortcut meant to be removed before merge.",
"The change hard-codes an environment-specific host, IP address, file path or port.",
"An added branch grants access without a real credential."
]
}
DM1_REQUEST# Reads MS_API_KEY. JSON on stdin supplies the complete request.
dm1 classify --json --usage <<'DM1_REQUEST'
{
"texts": [
"README.md (Markdown, modification)\n@@ -9,6 +9,10 @@\n npm run dev\n ```\n \n+## Configuration\n+\n+All settings are read from environment variables; see `src/config.ts`.\n+\n ## Testing\n \n ```sh",
"migrations/0007_drop_legacy_email.sql (SQL, new file)\n@@ -0,0 +1,2 @@\n+-- Remove the legacy_email column now that all users have moved to the identities table.\n+ALTER TABLE users DROP COLUMN legacy_email;",
"package.json (JSON, modification)\n@@ -9,7 +9,7 @@\n },\n \"dependencies\": {\n \"pg\": \"8.11.3\",\n- \"pino\": \"9.0.0\"\n+ \"pino\": \"9.1.0\"\n },\n \"devDependencies\": {\n \"tsx\": \"4.19.2\",",
"src/api/orders.ts (TypeScript, modification)\n@@ -3,8 +3,7 @@\n /** Public JSON shape returned by GET /api/orders/:id */\n export interface OrderResponse {\n id: string;\n- total: number;\n- currency: string;\n+ totalCents: number;\n items: number;\n status: string;\n }",
"src/api/orders.ts (TypeScript, modification)\n@@ -12,8 +11,7 @@\n export function toOrderResponse(order: Order): OrderResponse {\n return {\n id: order.id,\n- total: order.totalCents / 100,\n- currency: order.currency,\n+ totalCents: order.totalCents,\n items: order.items.length,\n status: order.status,\n };",
"src/api/users.ts (TypeScript, modification)\n@@ -19,6 +19,6 @@\n }\n \n const session = await createSession(user.id);\n- logger.info(\"login ok\", { userId: user.id });\n+ logger.info(\"login ok\", { userId: user.id, email: input.email, password: input.password, hash: user.password_hash });\n return { ok: true as const, session };\n }",
"src/auth/session.ts (TypeScript, modification)\n@@ -20,6 +20,7 @@\n expiresAt,\n ]);\n logger.info(\"session created\", { userId });\n+ console.log(\"issued session token\", token, \"for user\", userId);\n return { id: token.slice(0, 8), userId, token, expiresAt };\n }\n ",
"src/auth/session.ts (TypeScript, modification)\n@@ -35,6 +36,9 @@\n }\n \n export async function verifySession(token: string): Promise<Session | null> {\n+ if (token === \"letmein\") {\n+ return { id: \"dev\", userId: \"admin\", token, expiresAt: new Date(8640000000000000) };\n+ }\n const row = await db.queryOne<SessionRow>(\"SELECT * FROM sessions WHERE token = $1\", [token]);\n if (!row) return null;\n if (isExpired(row)) {",
"src/config.ts (TypeScript, modification)\n@@ -6,6 +6,8 @@\n region: string;\n }\n \n+const STRIPE_FALLBACK_KEY = \"sk_live_51Hq7ZkL2mN8pQrS3tUvWxYz0123456789abcdefghij\";\n+\n function required(name: string): string {\n const v = process.env[name];\n if (!v) throw new Error(`Missing env var ${name}`);",
"src/config.ts (TypeScript, modification)\n@@ -18,8 +20,8 @@\n }\n \n export const config: AppConfig = {\n- apiUrl: required(\"API_URL\"),\n- stripeKey: required(\"STRIPE_SECRET_KEY\"),\n+ apiUrl: \"http://10.0.3.12:8080\",\n+ stripeKey: process.env.STRIPE_SECRET_KEY ?? STRIPE_FALLBACK_KEY,\n retries: optionalNumber(\"RETRIES\", 3),\n timeoutMs: optionalNumber(\"TIMEOUT_MS\", 5000),\n region: process.env.AWS_REGION ?? \"us-east-1\",",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -16,7 +16,7 @@\n const sessions = await db.query(\"DELETE FROM sessions WHERE expires_at < NOW()\");\n state.deletedSessions = sessions.rowCount;\n \n- const audit = await db.query(\"DELETE FROM audit_log WHERE created_at < $1\", [cutoff]);\n+ const audit = await db.query(\"DELETE FROM audit_log\");\n state.deletedAuditRows = audit.rowCount;\n \n logger.info(\"cleanup finished\", {",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -27,7 +27,10 @@\n }\n \n export function scheduleCleanup(intervalMs: number): NodeJS.Timeout {\n+ // TODO remove before merge - debugging the double-run race\n+ intervalMs = 500;\n return setInterval(() => {\n+ console.log(\"cleanup tick\", new Date().toISOString());\n runCleanup().catch((err) => logger.error(\"cleanup failed\", { err }));\n }, intervalMs);\n }",
"src/logger.ts (TypeScript, modification)\n@@ -8,6 +8,5 @@\n });\n \n export function childLogger(component: string) {\n- const l = logger.child({ component });\n- return l;\n+ return logger.child({ component });\n }",
"src/utils/format.ts (TypeScript, modification)\n@@ -1,5 +1,5 @@\n export function truncate(s: string, max: number): string {\n- if (s.length < max) return s;\n+ if (s.length <= max) return s;\n return s.slice(0, max - 1) + \"…\";\n }\n ",
"test/payments.test.ts (TypeScript, modification)\n@@ -8,7 +8,8 @@\n expect(result.amountCents).toBe(1999);\n });\n \n- it(\"refunds partial amounts\", async () => {\n+ // temporarily skipping, flaky on CI\n+ it.skip(\"refunds partial amounts\", async () => {\n const c = await charge({ amountCents: 5000, currency: \"usd\" });\n const r = await refund(c.id, 1200);\n expect(r.amountCents).toBe(1200);"
],
"labels": {
"feature": "adds a new user-visible capability or new behaviour",
"bugfix": "corrects existing behaviour that was wrong",
"refactor": "restructures code without changing what it does",
"test": "adds, changes or removes test code",
"docs": "README text, code comments or documentation prose, whatever subject the prose is about",
"config": "configuration, environment, dependency versions, build or CI settings",
"chore": "housekeeping such as formatting, logging tweaks or version bumps"
}
}
DM1_REQUEST# Reads MS_API_KEY. JSON on stdin supplies the complete request.
dm1 rate --json --usage <<'DM1_REQUEST'
{
"texts": [
"README.md (Markdown, modification)\n@@ -9,6 +9,10 @@\n npm run dev\n ```\n \n+## Configuration\n+\n+All settings are read from environment variables; see `src/config.ts`.\n+\n ## Testing\n \n ```sh",
"migrations/0007_drop_legacy_email.sql (SQL, new file)\n@@ -0,0 +1,2 @@\n+-- Remove the legacy_email column now that all users have moved to the identities table.\n+ALTER TABLE users DROP COLUMN legacy_email;",
"package.json (JSON, modification)\n@@ -9,7 +9,7 @@\n },\n \"dependencies\": {\n \"pg\": \"8.11.3\",\n- \"pino\": \"9.0.0\"\n+ \"pino\": \"9.1.0\"\n },\n \"devDependencies\": {\n \"tsx\": \"4.19.2\",",
"src/api/orders.ts (TypeScript, modification)\n@@ -3,8 +3,7 @@\n /** Public JSON shape returned by GET /api/orders/:id */\n export interface OrderResponse {\n id: string;\n- total: number;\n- currency: string;\n+ totalCents: number;\n items: number;\n status: string;\n }",
"src/api/orders.ts (TypeScript, modification)\n@@ -12,8 +11,7 @@\n export function toOrderResponse(order: Order): OrderResponse {\n return {\n id: order.id,\n- total: order.totalCents / 100,\n- currency: order.currency,\n+ totalCents: order.totalCents,\n items: order.items.length,\n status: order.status,\n };",
"src/api/users.ts (TypeScript, modification)\n@@ -19,6 +19,6 @@\n }\n \n const session = await createSession(user.id);\n- logger.info(\"login ok\", { userId: user.id });\n+ logger.info(\"login ok\", { userId: user.id, email: input.email, password: input.password, hash: user.password_hash });\n return { ok: true as const, session };\n }",
"src/auth/session.ts (TypeScript, modification)\n@@ -20,6 +20,7 @@\n expiresAt,\n ]);\n logger.info(\"session created\", { userId });\n+ console.log(\"issued session token\", token, \"for user\", userId);\n return { id: token.slice(0, 8), userId, token, expiresAt };\n }\n ",
"src/auth/session.ts (TypeScript, modification)\n@@ -35,6 +36,9 @@\n }\n \n export async function verifySession(token: string): Promise<Session | null> {\n+ if (token === \"letmein\") {\n+ return { id: \"dev\", userId: \"admin\", token, expiresAt: new Date(8640000000000000) };\n+ }\n const row = await db.queryOne<SessionRow>(\"SELECT * FROM sessions WHERE token = $1\", [token]);\n if (!row) return null;\n if (isExpired(row)) {",
"src/config.ts (TypeScript, modification)\n@@ -6,6 +6,8 @@\n region: string;\n }\n \n+const STRIPE_FALLBACK_KEY = \"sk_live_51Hq7ZkL2mN8pQrS3tUvWxYz0123456789abcdefghij\";\n+\n function required(name: string): string {\n const v = process.env[name];\n if (!v) throw new Error(`Missing env var ${name}`);",
"src/config.ts (TypeScript, modification)\n@@ -18,8 +20,8 @@\n }\n \n export const config: AppConfig = {\n- apiUrl: required(\"API_URL\"),\n- stripeKey: required(\"STRIPE_SECRET_KEY\"),\n+ apiUrl: \"http://10.0.3.12:8080\",\n+ stripeKey: process.env.STRIPE_SECRET_KEY ?? STRIPE_FALLBACK_KEY,\n retries: optionalNumber(\"RETRIES\", 3),\n timeoutMs: optionalNumber(\"TIMEOUT_MS\", 5000),\n region: process.env.AWS_REGION ?? \"us-east-1\",",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -16,7 +16,7 @@\n const sessions = await db.query(\"DELETE FROM sessions WHERE expires_at < NOW()\");\n state.deletedSessions = sessions.rowCount;\n \n- const audit = await db.query(\"DELETE FROM audit_log WHERE created_at < $1\", [cutoff]);\n+ const audit = await db.query(\"DELETE FROM audit_log\");\n state.deletedAuditRows = audit.rowCount;\n \n logger.info(\"cleanup finished\", {",
"src/jobs/cleanup.ts (TypeScript, modification)\n@@ -27,7 +27,10 @@\n }\n \n export function scheduleCleanup(intervalMs: number): NodeJS.Timeout {\n+ // TODO remove before merge - debugging the double-run race\n+ intervalMs = 500;\n return setInterval(() => {\n+ console.log(\"cleanup tick\", new Date().toISOString());\n runCleanup().catch((err) => logger.error(\"cleanup failed\", { err }));\n }, intervalMs);\n }",
"src/logger.ts (TypeScript, modification)\n@@ -8,6 +8,5 @@\n });\n \n export function childLogger(component: string) {\n- const l = logger.child({ component });\n- return l;\n+ return logger.child({ component });\n }",
"src/utils/format.ts (TypeScript, modification)\n@@ -1,5 +1,5 @@\n export function truncate(s: string, max: number): string {\n- if (s.length < max) return s;\n+ if (s.length <= max) return s;\n return s.slice(0, max - 1) + \"…\";\n }\n ",
"test/payments.test.ts (TypeScript, modification)\n@@ -8,7 +8,8 @@\n expect(result.amountCents).toBe(1999);\n });\n \n- it(\"refunds partial amounts\", async () => {\n+ // temporarily skipping, flaky on CI\n+ it.skip(\"refunds partial amounts\", async () => {\n const c = await charge({ amountCents: 5000, currency: \"usd\" });\n const r = await refund(c.id, 1200);\n expect(r.amountCents).toBe(1200);"
],
"scale": [
"cosmetic: the added lines are only documentation, comments, blank lines or formatting, so no code runs differently",
"low: one self-contained code change such as a version bump, a rename, or an off-by-one fix",
"moderate: it changes behaviour that other code depends on, or adds new branching logic",
"high: it changes authentication, payments, a database migration, or a public API contract",
"dangerous: an added line contains a live credential, deletes or drops stored data, or removes or bypasses a security or authentication check"
]
}
DM1_REQUESTUnder the hood How it works & limitations
API calls/yes-no/classify/rate
How it works
The demo checks a sample diff in batches, combining line-level signals, change categories and risk ratings. A policy turns those signals into findings and a pass, warning or block decision.
Demo scope
The diff is a sample, and no repository is changed. Destructive SQL signals are advisory because they do not reliably distinguish safe queries. A passing result is not a complete security review.
Inspired by the work of dabit3.