mirror of
https://github.com/hanzoai/insights.git
synced 2026-11-02 14:32:45 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
66 lines
3.1 KiB
TypeScript
66 lines
3.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { InsightQueryInputSchema } from '@/schema/tool-inputs'
|
|
import { GENERATED_TOOLS } from '@/tools/generated/product_analytics'
|
|
|
|
// Agents interchange `id` / `insightId` / `insight_id` / `short_id` / `shortId`
|
|
// across the insight tools — production traces show the mismatched key as the
|
|
// dominant validation failure for all four. Every alias must normalize to each
|
|
// tool's canonical param (canonical key wins on conflict, then the first-listed
|
|
// alias) or those failures come back.
|
|
describe('insight id aliases', () => {
|
|
const ALIAS_KEYS = ['insightId', 'insight_id', 'short_id', 'shortId'] as const
|
|
|
|
describe.each([['insight-get'], ['insight-update'], ['insight-delete']])(
|
|
'%s normalizes aliases to `id`',
|
|
(toolName) => {
|
|
const schema = GENERATED_TOOLS[toolName]!().schema
|
|
|
|
it.each([
|
|
['id (numeric)', { id: 123 }, 123],
|
|
['id (short_id value)', { id: 'AaVQ8Ijw' }, 'AaVQ8Ijw'],
|
|
['insightId', { insightId: 123 }, 123],
|
|
['insight_id', { insight_id: 123 }, 123],
|
|
['short_id', { short_id: 'AaVQ8Ijw' }, 'AaVQ8Ijw'],
|
|
['shortId', { shortId: 'AaVQ8Ijw' }, 'AaVQ8Ijw'],
|
|
['id over aliases on conflict', { id: 1, insightId: 2, short_id: 'AaVQ8Ijw' }, 1],
|
|
['first-listed alias on alias conflict', { insight_id: 3, shortId: 'AaVQ8Ijw' }, 3],
|
|
])('accepts %s', (_label, input, expected) => {
|
|
const result = schema.safeParse(input)
|
|
expect(result.success).toBe(true)
|
|
const data = result.data as Record<string, unknown>
|
|
expect(data.id).toEqual(expected)
|
|
for (const alias of ALIAS_KEYS) {
|
|
expect(data).not.toHaveProperty(alias)
|
|
}
|
|
})
|
|
|
|
it('still rejects a call with no identifier', () => {
|
|
expect(schema.safeParse({}).success).toBe(false)
|
|
})
|
|
}
|
|
)
|
|
|
|
describe('insight-query normalizes aliases to `insightId` and coerces numbers to string', () => {
|
|
it.each([
|
|
['insightId (string)', { insightId: 'AaVQ8Ijw' }, 'AaVQ8Ijw'],
|
|
['insightId (numeric)', { insightId: 36 }, '36'],
|
|
['id (numeric)', { id: 36 }, '36'],
|
|
['id (string)', { id: '36' }, '36'],
|
|
['insight_id', { insight_id: 36 }, '36'],
|
|
['short_id', { short_id: 'AaVQ8Ijw' }, 'AaVQ8Ijw'],
|
|
['shortId', { shortId: 'AaVQ8Ijw' }, 'AaVQ8Ijw'],
|
|
['insightId over aliases on conflict', { insightId: 1, id: 2 }, '1'],
|
|
['first-listed alias on alias conflict', { id: 2, short_id: 'AaVQ8Ijw' }, '2'],
|
|
])('accepts %s', (_label, input, expected) => {
|
|
const result = InsightQueryInputSchema.safeParse(input)
|
|
expect(result.success).toBe(true)
|
|
expect(result.data?.insightId).toBe(expected)
|
|
})
|
|
|
|
it('still rejects a call with no identifier', () => {
|
|
expect(InsightQueryInputSchema.safeParse({}).success).toBe(false)
|
|
})
|
|
})
|
|
})
|