diff --git a/test/e2e/live/common-egress-agent-helpers.ts b/test/e2e/live/common-egress-agent-helpers.ts index 0088d27b749..74b08bd5ed0 100644 --- a/test/e2e/live/common-egress-agent-helpers.ts +++ b/test/e2e/live/common-egress-agent-helpers.ts @@ -115,6 +115,7 @@ export interface PersonalStockToolEvidenceArtifact { export interface NvdaPersonalStockReply { as_of: string; price: number; + source_timestamp: string; source_url: string; status: "NVDA_PERSONAL_AGENT_OK"; symbol: "NVDA"; @@ -272,6 +273,37 @@ export function parseOpenClawAgentText(raw: string): string { .trim(); } +function hasValidCalendarDate(value: string): boolean { + const match = + /^(\d{4})-(\d{2})-(\d{2})(?:$|T)/u.exec(value) ?? /^(\d{4})(\d{2})(\d{2})$/u.exec(value); + if (!match) return true; + const year = Number(match[1]); + const month = Number(match[2]); + const day = Number(match[3]); + const leapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0); + const daysInMonth = [31, leapYear ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + return month >= 1 && month <= 12 && day >= 1 && day <= (daysInMonth[month - 1] ?? 0); +} + +function sourceTimestampRepresentsAsOf(sourceTimestamp: string, asOf: string): boolean { + if (!hasValidCalendarDate(sourceTimestamp) || !hasValidCalendarDate(asOf)) return false; + const asOfMs = Date.parse(asOf); + if (!Number.isFinite(asOfMs)) return false; + if (/^\d{4}-\d{2}-\d{2}$/u.test(sourceTimestamp)) return asOf === sourceTimestamp; + if (/^\d{8}$/u.test(sourceTimestamp)) { + return ( + asOf === + `${sourceTimestamp.slice(0, 4)}-${sourceTimestamp.slice(4, 6)}-${sourceTimestamp.slice(6, 8)}` + ); + } + if (/^(?:\d{10}|\d{13})$/u.test(sourceTimestamp)) { + const epochMs = Number(sourceTimestamp) * (sourceTimestamp.length === 10 ? 1_000 : 1); + return Number.isFinite(epochMs) && epochMs === asOfMs; + } + const sourceMs = Date.parse(sourceTimestamp); + return Number.isFinite(sourceMs) && sourceMs === asOfMs; +} + /** * Reduce OpenClaw session and trajectory JSONL to bounded proof that one * successful direct web_fetch result supports the expected quote. Fetched @@ -448,25 +480,23 @@ export function reduceOpenClawToolEvidence( } return false; }; - const dateMatches = (text: string, expected: string): boolean => { - const expectedMs = Date.parse(expected); - if (!Number.isFinite(expectedMs)) return false; - const expectedDate = new Date(expectedMs).toISOString().slice(0, 10); - if ( - text.includes(expectedDate) || - text.includes(expectedDate.replace(/-/gu, "")) || - text.includes(expected) - ) { - return true; + const timestampMatches = (text: string, sourceTimestamp: string, asOf: string): boolean => { + if (!sourceTimestampRepresentsAsOf(sourceTimestamp, asOf)) return false; + if (/^\d{4}-\d{2}-\d{2}$/u.test(sourceTimestamp)) { + const dateTokenMatches = (candidate: string): boolean => + new RegExp(`(?:^|[^0-9])${candidate}(?![0-9]|T|\\s+\\d{2}:)`, "u").test(text); + return dateTokenMatches(sourceTimestamp); } - for (const match of text.matchAll(/(?:^|\D)(\d{10}|\d{13})(?!\d)/gu)) { - const raw = match[1]; - if (!raw) continue; - const epochMs = Number(raw) * (raw.length === 10 ? 1_000 : 1); - if (!Number.isFinite(epochMs)) continue; - if (new Date(epochMs).toISOString().slice(0, 10) === expectedDate) return true; + if (/^\d{8}$/u.test(sourceTimestamp)) { + return new RegExp(`(?:^|[^0-9])${sourceTimestamp}(?![0-9])`, "u").test(text); } - return false; + if (/^(?:\d{10}|\d{13})$/u.test(sourceTimestamp)) { + return new RegExp(`(?:^|\\D)${sourceTimestamp}(?!\\d)`, "u").test(text); + } + const escapedSource = sourceTimestamp.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"); + return new RegExp(`(?:^|[^0-9A-Za-z_.:+-])${escapedSource}(?![0-9A-Za-z_.:+-])`, "u").test( + text, + ); }; const fingerprint = (value: string): string => { let hash = 2_166_136_261; @@ -492,6 +522,7 @@ export function reduceOpenClawToolEvidence( const allowedWrapperIdParts = new Set(); const controlTargetViolationIds = new Set(); const sessionCallIds = new Set(); + const sessionToolNames = new Set(); for (const document of sessionDocuments) { const root = asRecord(document); const message = asRecord(root?.message ?? document); @@ -501,6 +532,16 @@ export function reduceOpenClawToolEvidence( if (block?.type !== "toolCall") continue; const id = normalizedId(block.id ?? block.toolCallId ?? block.tool_call_id); const name = normalizedName(block.name ?? block.toolName ?? block.tool_name); + const argumentsValue = block.arguments ?? block.input ?? block.args; + if (name) { + if (sessionToolNames.size < MAX_RECORDS || sessionToolNames.has(name)) { + sessionToolNames.add(name); + } else { + addError("session tool name limit exceeded"); + } + } + collectProviderMentions(block); + collectProviderMentions(argumentsValue); if (!id) { if (name === "tool_call" || name === "tool_describe") { addError("control tool call has no bounded id"); @@ -508,7 +549,6 @@ export function reduceOpenClawToolEvidence( continue; } sessionCallIds.add(id); - const argumentsValue = block.arguments ?? block.input ?? block.args; const allowedControlTarget = isAllowedWebFetchControlTarget(argumentsValue); if ((name === "tool_call" || name === "tool_describe") && !allowedControlTarget) { controlTargetViolationIds.add(id); @@ -594,16 +634,28 @@ export function reduceOpenClawToolEvidence( }); } } + for (const name of sessionToolNames) { + if (toolCalls.some((record) => record.name === name)) continue; + if (toolCalls.length >= MAX_RECORDS) { + addError("tool record limit exceeded"); + break; + } + toolCalls.push({ name }); + } const expectedSourceUrl = normalizedUrl(expectedStock?.source_url); const expectedPrice = expectedStock?.price; const expectedAsOf = expectedStock?.as_of; + const expectedSourceTimestamp = expectedStock?.source_timestamp; const expectedStockFingerprint = expectedSourceUrl !== null && typeof expectedPrice === "number" && Number.isFinite(expectedPrice) && - typeof expectedAsOf === "string" - ? fingerprint(JSON.stringify([expectedSourceUrl, expectedPrice, expectedAsOf])) + typeof expectedAsOf === "string" && + typeof expectedSourceTimestamp === "string" + ? fingerprint( + JSON.stringify([expectedSourceUrl, expectedPrice, expectedSourceTimestamp, expectedAsOf]), + ) : null; const nativeExtractors = new Set(["cf-markdown", "json", "raw", "raw-html", "readability"]); const pairedProjectedTargetCallIds = new Set(); @@ -643,8 +695,10 @@ export function reduceOpenClawToolEvidence( } webFetchResults.push({ asOfMatches: - typeof expectedAsOf === "string" && boundedPayloadText - ? dateMatches(boundedPayloadText, expectedAsOf) + typeof expectedSourceTimestamp === "string" && + typeof expectedAsOf === "string" && + boundedPayloadText + ? timestampMatches(boundedPayloadText, expectedSourceTimestamp, expectedAsOf) : false, directFetch, httpSuccess, @@ -708,6 +762,8 @@ export function buildOpenClawToolEvidenceReducerScript( return [ '"use strict"', 'const fs = require("node:fs")', + hasValidCalendarDate.toString(), + sourceTimestampRepresentsAsOf.toString(), `const reduce = ${reduceOpenClawToolEvidence.toString()}`, `const expectedStock = ${JSON.stringify(expectedStock)}`, "const [sessionPath, trajectoryPath] = process.argv.slice(1)", @@ -918,11 +974,19 @@ export function parseNvdaPersonalStockReply(raw: string): NvdaPersonalStockReply typeof parsed.source_url === "string" && parsed.source_url.length <= 4096 && isPublicHttpsTarget(targetFromReplyUrl(parsed.source_url)) && + typeof parsed.source_timestamp === "string" && + parsed.source_timestamp.length <= 128 && + /^(?:\d{8}|\d{10}|\d{13}|\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2}))?)$/u.test( + parsed.source_timestamp, + ) && + hasValidCalendarDate(parsed.source_timestamp) && typeof parsed.as_of === "string" && /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2}))?$/u.test( parsed.as_of, ) && - Number.isFinite(Date.parse(parsed.as_of)) + hasValidCalendarDate(parsed.as_of) && + Number.isFinite(Date.parse(parsed.as_of)) && + sourceTimestampRepresentsAsOf(parsed.source_timestamp, parsed.as_of) ) { return parsed as NvdaPersonalStockReply; } @@ -964,7 +1028,7 @@ function stockReplyFingerprint(reply: NvdaPersonalStockReply): string | null { try { const parsed = new URL(reply.source_url); parsed.hash = ""; - const value = JSON.stringify([parsed.href, reply.price, reply.as_of]); + const value = JSON.stringify([parsed.href, reply.price, reply.source_timestamp, reply.as_of]); let hash = 2_166_136_261; for (let index = 0; index < value.length; index += 1) { hash ^= value.charCodeAt(index); diff --git a/test/e2e/live/openclaw-agent-assertion.ts b/test/e2e/live/openclaw-agent-assertion.ts index 70953b8a938..1dae3bf77bd 100644 --- a/test/e2e/live/openclaw-agent-assertion.ts +++ b/test/e2e/live/openclaw-agent-assertion.ts @@ -28,8 +28,6 @@ import { const AGENT_TURN_TIMEOUT_MS = 3 * 60_000; const OPENCLAW_AGENT_ATTEMPTS = 3; -const MAX_LATEST_STOCK_AGE_MS = 8 * 24 * 60 * 60_000; -const MAX_SOURCE_CLOCK_SKEW_MS = 36 * 60 * 60_000; export interface OpenClawAgentAssertionEvidence { reply: string; @@ -50,7 +48,6 @@ export interface OpenClawAgentAssertionOptions { export interface PersonalStockAssertionResult { assessment: PersonalStockToolEvidenceArtifact; - asOfRecent: true; quote: { as_of: string; price: number; @@ -203,13 +200,34 @@ export async function runOpenClawAgentAssertion( } export const PERSONAL_STOCK_PROMPT = `Find the latest available NVIDIA (NVDA) stock price. -Choose a small, machine-readable public HTTPS source yourself and use web_fetch as the only target tool. +Choose a small, machine-readable public HTTPS source whose response contains one NVDA price and its market or update timestamp. +Use web_fetch as the only target tool. If progressive tool disclosure is active, you may use tool_search, tool_describe, and tool_call only to discover and invoke web_fetch. Do not invoke any other target tool. Do not use web_search, Brave Search, or Tavily Search. Set web_fetch maxChars to no more than 8000. -Only after web_fetch returns a numeric NVDA price with its source date or timestamp, reply with one JSON object and no Markdown. -Set status to NVDA_PERSONAL_AGENT_OK, symbol to NVDA, price to a JSON number, source_url to the exact HTTPS URL passed to web_fetch, and as_of to the quote's own market or update timestamp converted to ISO 8601. -For a Unix-epoch quote field such as regularMarketTime, convert that field to ISO 8601. Never use the current clock, fetch time, or an unrelated date for as_of.`; +If a web_fetch result omits the quote timestamp, do not use its price or infer a timestamp. +Fetch a different machine-readable source instead. +Reply only after one web_fetch result contains NVDA, a numeric price, and its market or update timestamp. +Keep each web_fetch result isolated. Never combine a price from one result with a timestamp from another result. +Select exactly one complete result and ignore every unselected result when constructing the reply. +Use the price and timestamp from that result. Set source_url to the exact URL for its paired web_fetch call. +If no result contains all three values, do not return success. +Reply with one JSON object and no Markdown. +Return these fields: +- status: NVDA_PERSONAL_AGENT_OK +- symbol: NVDA +- price: the quote price as a JSON number +- source_url: the exact URL for the paired web_fetch call +- source_timestamp: the exact timestamp token copied without editing from the selected result, as a JSON string +- as_of: the ISO 8601 representation of source_timestamp +Copy source_timestamp character for character from the selected result before deriving as_of. Treat a timestamp as returned only when that exact token occurs in the selected result. +Do not reconstruct source_timestamp from as_of, a nearby field, market hours, or date arithmetic. +Copy an extended ISO 8601 source date or timestamp exactly. Convert a compact YYYYMMDD source date to YYYY-MM-DD. +If a source value has a calendar date but no clock time, return YYYY-MM-DD. Never add a clock time or timezone to a date-only value. +For a Unix-epoch field such as regularMarketTime, interpret the exact integer as seconds or milliseconds since 1970-01-01T00:00:00Z and convert that instant to UTC ISO 8601 without applying exchange hours, timezone labels, or daylight-saving rules. +Before replying, check in this order that source_timestamp appears exactly in the selected result, the same result contains the selected NVDA price, and as_of represents source_timestamp exactly. For a Unix epoch, reverse-convert as_of to the same unit and require exact integer equality. +If any check fails, discard that result and fetch a different machine-readable source instead of returning success. +Never use the current clock, fetch time, or an unrelated date for as_of.`; export async function runPersonalStockAgentAssertion( host: HostCliClient, @@ -234,16 +252,11 @@ export async function runPersonalStockAgentAssertion( const assessmentArtifact = projectPersonalStockToolEvidenceArtifact(stock.toolEvidence!); const quote = parseNvdaPersonalStockReply(stock.reply); expect(quote).not.toBeNull(); - const quoteTime = Date.parse(quote!.as_of); - const now = Date.now(); - expect(quoteTime).toBeGreaterThanOrEqual(now - MAX_LATEST_STOCK_AGE_MS); - expect(quoteTime).toBeLessThanOrEqual(now + MAX_SOURCE_CLOCK_SKEW_MS); const sourceUrl = new URL(quote!.source_url); expect(sourceUrl.protocol).toBe("https:"); await artifacts.writeJson(`actions/${args.label}-assessment.json`, assessmentArtifact); return { assessment: assessmentArtifact, - asOfRecent: true, quote: { as_of: quote!.as_of, price: quote!.price, diff --git a/test/e2e/support/common-egress-agent-helpers.test.ts b/test/e2e/support/common-egress-agent-helpers.test.ts index 0e835ba9700..24667068918 100644 --- a/test/e2e/support/common-egress-agent-helpers.test.ts +++ b/test/e2e/support/common-egress-agent-helpers.test.ts @@ -8,6 +8,7 @@ import { join } from "node:path"; import { describe, expect, it, vi } from "vitest"; +import { PERSONAL_STOCK_PROMPT } from "../live/openclaw-agent-assertion.ts"; import { agentReplyContainsToken, assessPersonalStockToolEvidence, @@ -40,8 +41,24 @@ const STOCK_REPLY = { symbol: "NVDA", price: 192.38, source_url: STOCK_SOURCE_URL, + source_timestamp: "1786982340", as_of: "2026-08-17T15:59:00Z", } satisfies NvdaPersonalStockReply; +const DAY_MS = 24 * 60 * 60_000; +const STOCK_PROMPT_REQUIREMENTS = + `If a web_fetch result omits the quote timestamp, do not use its price or infer a timestamp. +Never combine a price from one result with a timestamp from another result. +Select exactly one complete result and ignore every unselected result when constructing the reply. +If no result contains all three values, do not return success. +Never add a clock time or timezone to a date-only value. +interpret the exact integer as seconds or milliseconds since 1970-01-01T00:00:00Z and convert that instant to UTC ISO 8601 without applying exchange hours, timezone labels, or daylight-saving rules. +source_timestamp: the exact timestamp token copied without editing from the selected result, as a JSON string +Copy source_timestamp character for character from the selected result before deriving as_of. +Do not reconstruct source_timestamp from as_of, a nearby field, market hours, or date arithmetic. +check in this order that source_timestamp appears exactly in the selected result, the same result contains the selected NVDA price, and as_of represents source_timestamp exactly. +If any check fails, discard that result and fetch a different machine-readable source instead of returning success.`.split( + "\n", + ); function stockPayload(overrides: Record = {}): Record { return { @@ -269,6 +286,7 @@ async function expectAggregateStockFailure( for (const sensitiveValue of [ STOCK_SOURCE_URL, String(STOCK_REPLY.price), + STOCK_REPLY.source_timestamp, STOCK_REPLY.as_of, stockPayload().text as string, evidence.expectedStockFingerprint!, @@ -281,6 +299,13 @@ async function expectAggregateStockFailure( } describe("common-egress agent parsing and classification helpers", () => { + it.each(STOCK_PROMPT_REQUIREMENTS)( + "includes required stock prompt instruction: %s (#10330)", + (instruction) => { + expect(PERSONAL_STOCK_PROMPT).toContain(instruction); + }, + ); + it("OpenClaw JSON parser accepts framed agent payloads", () => { expect( parseOpenClawAgentText( @@ -357,6 +382,41 @@ describe("common-egress agent parsing and classification helpers", () => { ); }); + it.each([ + { name: "accepts an ISO date", source: "2026-08-17", iso: "2026-08-17" }, + { name: "accepts a compact date", source: "20260817", iso: "2026-08-17" }, + { name: "accepts an exact ISO timestamp", source: STOCK_REPLY.as_of, iso: STOCK_REPLY.as_of }, + { + name: "accepts an equivalent normalized ISO timestamp", + source: STOCK_REPLY.as_of, + iso: "2026-08-17T15:59:00.000Z", + }, + { name: "accepts a Unix timestamp in seconds", source: "1786982340", iso: STOCK_REPLY.as_of }, + { + name: "accepts a Unix timestamp in milliseconds", + source: "1786982340000", + iso: STOCK_REPLY.as_of, + }, + { name: "rejects an impossible date", source: "2026-02-30", iso: "2026-02-30", matches: false }, + ])( + "$name as quote-time evidence from one paired stock result (#10330)", + ({ iso, matches = true, source }) => { + const evidence = reduceOpenClawToolEvidence( + stockSessionJsonLines({ + payload: stockPayload({ + text: `{"symbol":"NVDA","regularMarketPrice":192.38,"quoteTime":"${source}"}`, + }), + }), + stockTrajectory(), + { ...STOCK_REPLY, as_of: iso, source_timestamp: source }, + ); + expect(assessPersonalStockToolEvidence(evidence)).toMatchObject({ + matches, + qualifyingWebFetchResults: matches ? 1 : 0, + }); + }, + ); + it("executes the generated reducer script against OpenClaw JSONL artifacts", () => { const directory = mkdtempSync(join(tmpdir(), "nemoclaw-openclaw-reducer-")); try { @@ -837,6 +897,7 @@ describe("common-egress agent parsing and classification helpers", () => { price: 192.38, source_url: STOCK_SOURCE_URL, symbol: "NVDA", + source_timestamp: STOCK_REPLY.source_timestamp, }); const projectedReply = projectNvdaPersonalStockReplyEvidence(reply); expect(projectedReply).toEqual({ @@ -848,16 +909,6 @@ describe("common-egress agent parsing and classification helpers", () => { }); expect(JSON.stringify(projectedReply)).not.toContain("credential"); expect(JSON.stringify(projectedReply)).not.toContain("/v8/finance/chart"); - expect( - parseNvdaPersonalStockReply( - JSON.stringify({ ...STOCK_REPLY, source_url: "https://10.0.0.1/quote/NVDA" }), - ), - ).toBeNull(); - expect( - parseNvdaPersonalStockReply( - JSON.stringify({ ...STOCK_REPLY, source_url: "https://[fd00::1]/quote/NVDA" }), - ), - ).toBeNull(); expect( nvdaPersonalStockReplyMatchesEvidence(reply, evidence, Date.parse("2026-08-18T12:00:00Z")), ).toBe(true); @@ -881,11 +932,65 @@ describe("common-egress agent parsing and classification helpers", () => { }); it.each([ + ["a malformed source timestamp", "2026-08-17T15:59:00Z-invalid", STOCK_REPLY.as_of], + ["an impossible source timestamp", "2026-02-30", STOCK_REPLY.as_of], + ["a missing source timestamp", undefined, STOCK_REPLY.as_of], + ["a shifted Unix epoch", "1787688000", "2026-08-25T21:00:00Z"], + ["a mismatched compact date", "20260817", "2026-08-18"], + ["a shifted ISO timestamp", STOCK_REPLY.as_of, "2026-08-17T16:00:00Z"], + ])("rejects a stock reply with %s (#10330)", (_reason, source_timestamp, as_of) => { + expect( + parseNvdaPersonalStockReply(JSON.stringify({ ...STOCK_REPLY, source_timestamp, as_of })), + ).toBeNull(); + }); + + it.each([ + { + boundary: "the allowed past-age limit", + expected: true, + nowOffsetMs: 5 * DAY_MS, + outcome: "accepts", + }, + { + boundary: "one millisecond beyond the past-age limit", + expected: false, + nowOffsetMs: 5 * DAY_MS + 1, + outcome: "rejects", + }, + { + boundary: "the allowed future-skew limit", + expected: true, + nowOffsetMs: -DAY_MS, + outcome: "accepts", + }, + { + boundary: "one millisecond beyond the future-skew limit", + expected: false, + nowOffsetMs: -DAY_MS - 1, + outcome: "rejects", + }, + ])("$outcome a quote at $boundary", ({ expected, nowOffsetMs }) => { + const evidence = reduceOpenClawToolEvidence( + stockSessionJsonLines(), + stockTrajectory(), + STOCK_REPLY, + ); + const reply = JSON.stringify(STOCK_REPLY); + const quoteTimeMs = Date.parse(STOCK_REPLY.as_of); + + expect(nvdaPersonalStockReplyMatchesEvidence(reply, evidence, quoteTimeMs + nowOffsetMs)).toBe( + expected, + ); + }); + + it.each([ + "https://10.0.0.1/quote/NVDA", + "https://[fd00::1]/quote/NVDA", "https://[::ffff:127.0.0.1]/quote/NVDA", "https://[::ffff:169.254.169.254]/quote/NVDA", "https://[::ffff:10.0.0.1]/quote/NVDA", "https://[::ffff:192.168.1.2]/quote/NVDA", - ])("rejects an IPv4-mapped internal stock source: %s", (source_url) => { + ])("rejects an internal stock source: %s", (source_url) => { expect(parseNvdaPersonalStockReply(JSON.stringify({ ...STOCK_REPLY, source_url }))).toBeNull(); }); @@ -927,10 +1032,11 @@ describe("common-egress agent parsing and classification helpers", () => { expected: STOCK_REPLY, }, { - name: "dummy fetch plus another tool", - session: stockSessionJsonLines({ extraToolName: "exec" }), - trajectory: stockTrajectory("exec"), + name: "projected evidence hiding a forbidden session tool", + session: stockSessionJsonLines({ extraToolName: "web_search" }), + trajectory: directStockTrajectoryWithProjection(), expected: STOCK_REPLY, + checks: { forbiddenToolNames: ["web_search"] }, }, { name: "fetch content without the claimed price or date", @@ -938,10 +1044,50 @@ describe("common-egress agent parsing and classification helpers", () => { trajectory: stockTrajectory(), expected: STOCK_REPLY, }, - ])("rejects $name", ({ expected, session, trajectory }) => { + { + name: "price paired with an unrelated source date (#10330)", + session: stockSessionJsonLines({ + payload: stockPayload({ + text: '{"symbol":"NVDA","regularMarketPrice":192.38,"date":"2026-08-16"}', + }), + }), + trajectory: stockTrajectory(), + expected: STOCK_REPLY, + }, + { + name: "price paired with an epoch converted one hour late (#10330)", + session: stockSessionJsonLines({ + payload: stockPayload({ + text: '{"symbol":"NVDA","regularMarketPrice":192.38,"regularMarketTime":1787688000}', + }), + }), + trajectory: stockTrajectory(), + expected: { ...STOCK_REPLY, as_of: "2026-08-25T21:00:00Z", source_timestamp: "1787688000" }, + }, + { + name: "price paired with a timestamp prefix and trailing characters (#10330)", + session: stockSessionJsonLines({ + payload: stockPayload({ + text: '{"symbol":"NVDA","regularMarketPrice":192.38,"quoteTime":"2026-08-17T15:59:00Z-invalid"}', + }), + }), + trajectory: stockTrajectory(), + expected: { ...STOCK_REPLY, source_timestamp: STOCK_REPLY.as_of }, + }, + { + name: "date-only reply paired with a source timestamp (#10330)", + session: stockSessionJsonLines({ + payload: stockPayload({ + text: '{"symbol":"NVDA","regularMarketPrice":192.38,"quoteTime":"2026-08-17T20:00:00Z"}', + }), + }), + trajectory: stockTrajectory(), + expected: { ...STOCK_REPLY, as_of: "2026-08-17", source_timestamp: "2026-08-17T20:00:00Z" }, + }, + ])("rejects $name", ({ checks = {}, expected, session, trajectory }) => { const evidence = reduceOpenClawToolEvidence(session, trajectory, expected); - expect(assessPersonalStockToolEvidence(evidence).matches).toBe(false); + expect(assessPersonalStockToolEvidence(evidence)).toMatchObject({ matches: false, ...checks }); expect( nvdaPersonalStockReplyMatchesEvidence( JSON.stringify(expected),