Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
34 lines
2.8 KiB
JavaScript
34 lines
2.8 KiB
JavaScript
const { test } = require('node:test')
|
|
const assert = require('node:assert/strict')
|
|
const crypto = require('node:crypto')
|
|
const { execFileSync } = require('node:child_process')
|
|
const { recoveryFingerprintsSQL } = require('./wiki_recovery_budget_sql.cjs')
|
|
const literal = value => `'${String(value).replaceAll("'", "''")}'`
|
|
const hash = fields => {
|
|
const h = crypto.createHash('sha256')
|
|
for (const field of fields) {
|
|
const bytes = Buffer.from(field), size = Buffer.alloc(8)
|
|
size.writeBigUInt64BE(BigInt(bytes.length))
|
|
h.update(size).update(bytes)
|
|
}
|
|
return h.digest('hex')
|
|
}
|
|
|
|
test('PostgreSQL fingerprints match byte-framed repository fields including UTF-8 and encrypted model parameters', { skip: process.env.VERIFY_RECOVERY_SQL !== '1' }, () => {
|
|
const fingerprints = recoveryFingerprintsSQL()
|
|
const sourceFields = ['wiki-recovery-source-v1', '7', 'kb', 'doc', "中文 ' title", 'chunk', '首行\nsecond', '3', '1', '0', '12', 'text', '', '', 'true']
|
|
const modelFields = ['wiki-recovery-model-v1', '{"synthesis_model_id": "chat"}', '{"wiki_enabled": true}', 'chat', 'model', 'KnowledgeQA', 'remote', 'active', '{"api_key": "encrypted-fixture"}', 'embed', 'embedding', 'Embedding', 'remote', 'active', '{}']
|
|
const query = `WITH d AS (SELECT 7::bigint AS tenant_id,'kb'::text AS scope_id,'doc'::text AS related_id),
|
|
n AS (SELECT ${literal(sourceFields[4])}::text AS title),
|
|
k AS (SELECT ${literal(modelFields[1])}::jsonb AS wiki_config,${literal(modelFields[2])}::jsonb AS indexing_strategy,'chat'::text AS summary_model_id,'embed'::text AS embedding_model_id),
|
|
chunks AS (SELECT 7 AS tenant_id,'kb'::text AS knowledge_base_id,'doc'::text AS knowledge_id,NULL::timestamp AS deleted_at,
|
|
'chunk'::text AS id,${literal(sourceFields[6])}::text AS content,3 AS content_revision,1 AS chunk_index,0 AS start_at,12 AS end_at,'text'::text AS chunk_type,NULL::text AS parent_chunk_id,''::text AS image_info,true AS is_enabled),
|
|
models AS (SELECT 7 AS tenant_id,'chat'::text AS id,'model'::text AS name,'KnowledgeQA'::text AS type,'remote'::text AS source,'active'::text AS status,${literal(modelFields[8])}::jsonb AS parameters,NULL::timestamp AS deleted_at
|
|
UNION ALL SELECT 7,'embed','embedding','Embedding','remote','active','{}'::jsonb,NULL::timestamp)
|
|
SELECT json_build_object('source',${fingerprints.source},'model',${fingerprints.model}) FROM d,k,n;`
|
|
const result = execFileSync('docker', ['--context', 'colima-yawan', 'exec', '-i', '-e', 'PGOPTIONS=-c default_transaction_read_only=on',
|
|
'WeKnora-postgres', 'psql', '-X', '-qAt', '-U', 'postgres', '-d', 'yawan_native_acceptance_20260915', '-v', 'ON_ERROR_STOP=1'],
|
|
{ input: query, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] })
|
|
assert.deepEqual(JSON.parse(result), { source: hash(sourceFields), model: hash(modelFields) })
|
|
})
|