Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8650b4adc9 | ||
|
|
0341ad9087 | ||
|
|
cc6ac48aec | ||
|
|
aab9c1a4f0 | ||
|
|
a63aa5cb0f | ||
|
|
660c20d777 | ||
|
|
8ae577b719 | ||
|
|
72c2d3d15d | ||
|
|
773fd52493 | ||
|
|
a85dd5948a | ||
|
|
a558854dc9 | ||
|
|
41a6071b09 | ||
|
|
79135c7f85 | ||
|
|
a2351a2153 | ||
|
|
68c4af35e9 | ||
|
|
2aaa0d6583 | ||
|
|
c9ab4221f5 | ||
|
|
157ce95c12 | ||
|
|
5bf9bad483 | ||
|
|
0674852839 | ||
|
|
fb047ae7b1 | ||
|
|
2eaac95ad7 |
+11
-11
@@ -1,33 +1,33 @@
|
||||
[submodule "deploy/modules/galena"]
|
||||
path = deploy/modules/galena
|
||||
url = https://github.com/Alpaq92/Galena
|
||||
url = ../Galena.git
|
||||
[submodule "deploy/modules/counsel"]
|
||||
path = deploy/modules/counsel
|
||||
url = https://github.com/Alpaq92/CounselScorecard
|
||||
url = ../CounselScorecard.git
|
||||
[submodule "deploy/modules/sygna"]
|
||||
path = deploy/modules/sygna
|
||||
url = https://github.com/Alpaq92/Sygna
|
||||
url = ../Sygna.git
|
||||
[submodule "deploy/modules/insider"]
|
||||
path = deploy/modules/insider
|
||||
url = https://github.com/Alpaq92/Insider.git
|
||||
url = ../Insider.git
|
||||
[submodule "deploy/modules/lexicon"]
|
||||
path = deploy/modules/lexicon
|
||||
url = https://github.com/Alpaq92/Lexicon
|
||||
url = ../Lexicon.git
|
||||
[submodule "deploy/modules/agora"]
|
||||
path = deploy/modules/agora
|
||||
url = https://github.com/Alpaq92/Agora
|
||||
url = ../Agora.git
|
||||
[submodule "deploy/modules/panorama"]
|
||||
path = deploy/modules/panorama
|
||||
url = https://github.com/Alpaq92/Panorama
|
||||
url = ../Panorama.git
|
||||
[submodule "deploy/modules/parafa"]
|
||||
path = deploy/modules/parafa
|
||||
url = https://github.com/Alpaq92/Parafa
|
||||
url = ../Parafa.git
|
||||
[submodule "deploy/modules/scribe"]
|
||||
path = deploy/modules/scribe
|
||||
url = https://github.com/Alpaq92/Scribe
|
||||
url = ../Scribe.git
|
||||
[submodule "deploy/modules/arbiter"]
|
||||
path = deploy/modules/arbiter
|
||||
url = https://github.com/Alpaq92/Arbiter
|
||||
url = ../Arbiter.git
|
||||
[submodule "deploy/modules/workflow"]
|
||||
path = deploy/modules/workflow
|
||||
url = https://github.com/Alpaq92/Workflow
|
||||
url = ../Workflow.git
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
"""Home chat's records signed with their owners (spec 2026-11-27, "podobne podmioty", mechanisms B, C and E;
|
||||
A, D and F were measured 2026-11-27 and left out: useless or harmful on a fresh question set).
|
||||
|
||||
Small models assigned a record to the wrong party: a contract of another counterparty, an outside firm's order
|
||||
"for" a client it never named, a contract taken for the matter of the same number. Code knows the owner from
|
||||
`chatGraph` (rank-0 edges only: id, NIP, number, matter_ref, party, client) and says it in the record's own text.
|
||||
|
||||
The chat block of `frontend/app.js` is built under Node, as in `test_chat_traps_console.py`, over a small world
|
||||
written out below. DB-free and network-free; skipped only where no `node` binary exists.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[2]
|
||||
NODE = shutil.which("node")
|
||||
APP = ROOT / "frontend" / "app.js"
|
||||
|
||||
pytestmark = pytest.mark.skipif(NODE is None, reason="needs node on PATH")
|
||||
|
||||
# The world on a frozen day (2026-11-12). The asker is u1. Contract UM-2026-0109 and matter 2026/0109 share their
|
||||
# digits (E); c2 is pinned to a matter the asker sees, c3 to one this account does not (C); orders name their
|
||||
# target by a contract's number, by a matter's number in the notes, or by nothing (B).
|
||||
_PRELUDE = r"""
|
||||
const fs = require('fs');
|
||||
const src = fs.readFileSync(APP, 'utf8');
|
||||
const BLOCK = src.slice(src.indexOf('// Code finds, the model reads'), src.indexOf("// A module's screen"));
|
||||
const TODAY = '2026-11-12';
|
||||
const NOW = Date.parse(TODAY + 'T12:00:00Z');
|
||||
class FixedDate extends Date { constructor(...a) { super(...(a.length ? a : [NOW])); } static now() { return NOW; } }
|
||||
const party = (id, name, nip, kind = 'organisation') => ({ id, name, nip, address: null, kind });
|
||||
const matter = (id, reference, name, client, clientId, lawyer) => ({ id, reference, name, client_name: client, client_party_id: clientId,
|
||||
practice_area: null, status: 'open', responsible_lawyer_id: lawyer, opened_at: '2026-03-01', closed_at: null, description: '' });
|
||||
const card = (id, number, name, cp, matterRef, created = '2026-02-01T09:00:00Z') => ({ id, project_id: 'p-' + id, number, name,
|
||||
counterparty: cp ? cp.name : null, counterparties: cp ? [cp] : [], matter_ref: matterRef, status: 'obowiazuje',
|
||||
value_amount: 1000, value_currency: 'PLN', concluded_on: '2026-01-02', ends_on: '2027-06-30', created_at: created });
|
||||
const order = (id, firmId, reference, title, notes, created = '2026-11-10T08:00:00Z') => ({ id, firm_id: firmId, reference, title,
|
||||
billing_notes: notes, status: 'in_progress', budget_estimate: 5000, budget_currency: 'PLN', matter_owner_id: null, created_at: created });
|
||||
const WORLD = {
|
||||
'sygna/users': [{ id: 'u1', full_name: 'Anna Nowak' }, { id: 'u2', full_name: 'Piotr Zając' }],
|
||||
'sygna/parties': [
|
||||
party('s1', 'Miedziak Energia S.A.', '6340001110'),
|
||||
party('s2', 'Miedziak Energia sp. z o.o.', '6340005550'),
|
||||
party('s3', 'Velmora Pompy sp. z o.o.', '5250001111'),
|
||||
party('s4', 'Velmora Serwis sp. z o.o.', '5250002222'),
|
||||
party('s5', 'Fundacja Ostoja', null),
|
||||
party('s6', 'Fundacja Zielony Las', null),
|
||||
party('s7', 'Kalinowy Dwór sp. z o.o.', null)],
|
||||
'sygna/matters': [
|
||||
matter('m1', '2026/0107', 'Spór o dostawy pomp', 'Velmora Pompy sp. z o.o.', 's3', 'u1'),
|
||||
matter('m2', '2026/0109', 'Windykacja należności', 'Miedziak Energia sp. z o.o.', 's2', 'u2')],
|
||||
'sygna/deadlines?days=365': [
|
||||
{ id: 'd1', title: 'Odpowiedź na pozew', kind: 'procedural', due_date: '2026-11-20', days_left: 8, completed_at: null, matter_id: 'm1',
|
||||
matter_reference: '2026/0107', matter_name: 'Spór o dostawy pomp', basis: null, owner_id: 'u1', source: 'court' },
|
||||
{ id: 'd2', title: 'Wezwanie do zapłaty', kind: 'internal', due_date: '2026-11-25', days_left: 13, completed_at: null, matter_id: 'm2',
|
||||
matter_reference: '2026/0109', matter_name: 'Windykacja należności', basis: null, owner_id: 'u2', source: 'internal' }],
|
||||
'galena/cards?limit=200&offset=0': [
|
||||
// Same digits as matter 2026/0109, pinned to no matter.
|
||||
card('c1', 'UM-2026-0109', 'Dostawa energii', { id: 'k1', name: 'Miedziak Energia S.A.', nip: '6340001110' }, null),
|
||||
// Pinned to a matter the asker sees.
|
||||
card('c2', 'UM-2026-0110', 'Serwis pomp', { id: 'k2', name: 'Velmora Serwis sp. z o.o.', nip: '5250002222' }, 'm1', '2026-11-11T09:00:00Z'),
|
||||
// Pinned to a matter this account does not see.
|
||||
card('c3', 'UM-2026-0111', 'Najem magazynu', { id: 'k3', name: 'Kalinowy Dwór Sp. z o.o.', nip: null }, 'm-hidden'),
|
||||
card('c4', 'UM-2026-0112', 'Dzierżawa gruntu', { id: 'k4', name: 'Kalinowy Dwór spółka z ograniczoną odpowiedzialnością', nip: null }, null),
|
||||
card('c5', 'UM-2026-0113', 'Darowizna', { id: 'k5', name: 'Fundacja Ostoja', nip: null }, null),
|
||||
card('c6', 'UM-2026-0114', 'Sprzedaż energii', { id: 'k6', name: 'Miedziak Energia sp. z o.o.', nip: '6340005550' }, null)],
|
||||
'counsel/firms': [
|
||||
{ id: 'f1', name: 'Hofmann Legal', legal_name: 'Hofmann Legal sp.k.', status: 'active', contact_person: null, notes: '' },
|
||||
{ id: 'f2', name: 'Lis i Wspólnicy', legal_name: 'Lis i Wspólnicy sp.p.', status: 'active', contact_person: null, notes: '' }],
|
||||
'counsel/matters': [
|
||||
order('o1', 'f1', 'ZK/2026/058', 'Opinia do umowy UM-2026-0109', ''),
|
||||
order('o2', 'f2', 'ZK/2026/059', 'Reprezentacja w sporze', 'Klient: Velmora Pompy sp. z o.o., sprawa 2026/0107'),
|
||||
order('o3', 'f1', 'ZK/2026/060', 'Analiza ogólna', '')],
|
||||
'counsel/review-cycles': [],
|
||||
'galena/drive/home': { workspaces: [{ id: 'pr1', kind: 'project', name: 'Pisma procesowe', path: '/Kancelaria/Pisma procesowe', review_policy: 'required' }] },
|
||||
'galena/drive/shared': [],
|
||||
'galena/projects/pr1/tree?recursive=true': [],
|
||||
'galena/projects/pr1/drafts': [
|
||||
{ id: 'w1', title: 'Opinia o karach umownych', status: 'pending', author_id: 'u1', created_at: '2026-11-09T10:00:00Z' },
|
||||
{ id: 'w2', title: 'Projekt pozwu', status: 'pending', author_id: 'u2', created_at: '2026-11-08T10:00:00Z' }],
|
||||
};
|
||||
const fetch = async (url) => {
|
||||
const u = new URL(String(url));
|
||||
const m = /^\/([^/]+)\/api\/v1\/(.*)$/.exec(u.pathname);
|
||||
const body = m && WORLD[m[1] + '/' + m[2] + u.search];
|
||||
return body === undefined ? new Response('{}', { status: 404 }) : new Response(JSON.stringify(body), { status: 200 });
|
||||
};
|
||||
// The block's index over the world; `patch` rewrites the block's source first (e.g. to break chatGraph).
|
||||
async function index(patch = (b) => b) {
|
||||
const load = new Function('fetch', 'document', 'state', 'chat', '_tr', 'moduleHref', 'coreRefusal', 'Date', 'console',
|
||||
patch(BLOCK) + '\nreturn { chatIndex };');
|
||||
const quiet = { ...console, warn: () => {} };
|
||||
const f = load(fetch, { baseURI: 'http://t.local/atrium/' }, { user: { id: 'u1' }, launcher: [] }, { ctl: new AbortController() },
|
||||
(s) => s, (slug, inner) => slug + '/#/' + inner, (p) => p.detail, FixedDate, quiet);
|
||||
return f.chatIndex();
|
||||
}
|
||||
const texts = (ix) => Object.fromEntries(ix.records.map((r) => [r.key, r.text]));
|
||||
"""
|
||||
|
||||
|
||||
def _run(js: str) -> object:
|
||||
script = f"const APP = {json.dumps(str(APP))};\n" + _PRELUDE + \
|
||||
f"\n(async () => {{ const out = await (async () => {{ {js} }})(); console.log(JSON.stringify(out)); }})()" \
|
||||
".catch((e) => { console.error(e && e.stack || e); process.exit(1); });"
|
||||
r = subprocess.run([NODE, "-"], input=script, capture_output=True, text=True, timeout=120, encoding="utf-8")
|
||||
assert r.returncode == 0, r.stderr
|
||||
return json.loads(r.stdout)
|
||||
|
||||
|
||||
def test_the_world_builds_every_kind_and_a_graph() -> None:
|
||||
# The ground the B, C, E tests stand on: every kind of record the signatures touch, and a graph to read them from.
|
||||
got = _run("""const ix = await index();
|
||||
return { kinds: [...new Set(ix.records.map((r) => r.kind))], ents: ix.graph ? ix.graph.ent.size : 0,
|
||||
pairs: ix.graph ? ix.graph.pairs.length : 0, orders: ix.graph ? ix.graph.orderTarget.size : 0,
|
||||
pinned: ix.graph ? ix.graph.contractMatter.size : 0 };""")
|
||||
assert {"umowa", "sprawa", "strona", "termin", "kancelaria", "zlecenie", "projekt", "wersja", "zestawienie"} <= set(got["kinds"])
|
||||
assert got["ents"] > 0 and got["pairs"] > 0
|
||||
assert got["orders"] == 2 # o1 by the contract's number, o2 by the matter's number; o3 names nothing
|
||||
assert got["pinned"] == 1 # c2 only: c3's matter is not visible on this account
|
||||
|
||||
|
||||
def test_a_contract_says_which_matter_it_is_pinned_to() -> None:
|
||||
# C: c2 is pinned to a visible matter, c1 to none; c3's matter is not on this account, so c3 stays silent.
|
||||
t = _run("return texts(await index());")
|
||||
assert t["galena:umowa:c2"].endswith(" Przypięta do sprawy 2026/0107 „Spór o dostawy pomp” (klient Velmora Pompy sp. z o.o.).")
|
||||
assert " Nie jest przypięta do żadnej sprawy." in t["galena:umowa:c1"] # E follows it on c1 (same digits as m2)
|
||||
assert "przypięta" not in t["galena:umowa:c3"].lower() and "m-hidden" not in t["galena:umowa:c3"]
|
||||
# Only contracts are signed by C.
|
||||
assert not any("przypięta" in v.lower() for k, v in t.items() if not k.startswith("galena:umowa:"))
|
||||
|
||||
|
||||
def test_a_broken_map_or_signature_leaves_every_text_as_it_was() -> None:
|
||||
got = _run("""
|
||||
const plain = texts(await index((b) => b.replace('const signs = chatSigns(records, graph);', 'const signs = new Map();')));
|
||||
const noMap = texts(await index((b) => b.replace('function chatGraph(records, names, today) {', '$& throw new Error("boom");')));
|
||||
const noSign = texts(await index((b) => b.replace('function chatSigns(records, graph) {', '$& throw new Error("boom");')));
|
||||
const signed = texts(await index());
|
||||
return { plain, noMap, noSign, differs: Object.keys(plain).filter((k) => plain[k] !== signed[k]) };""")
|
||||
assert got["noMap"] == got["plain"]
|
||||
assert got["noSign"] == got["plain"]
|
||||
assert got["differs"] # the seam does sign something, so the patches above really took effect
|
||||
|
||||
|
||||
def test_a_contract_and_a_matter_of_the_same_digits_say_they_are_two_records() -> None:
|
||||
# E: UM-2026-0109 (c1, pinned to no matter) and matter 2026/0109 (m2) each name the other as a different record.
|
||||
t = _run("return texts(await index());")
|
||||
assert (" Nie jest przypięta do żadnej sprawy. Sprawa 2026/0109 „Windykacja należności”"
|
||||
" to inny rekord (sprawa w Sygnie, klient Miedziak Energia sp. z o.o.).") in t["galena:umowa:c1"]
|
||||
assert t["sygna:sprawa:m2"].endswith(" Umowa UM-2026-0109 „Dostawa energii” to inny rekord"
|
||||
" (umowa w Galenie, kontrahent Miedziak Energia S.A.).")
|
||||
# Different digits everywhere else: no other record says it.
|
||||
said = sorted(k for k, v in t.items() if "to inny rekord" in v)
|
||||
assert said == ["galena:umowa:c1", "sygna:sprawa:m2"]
|
||||
assert t["galena:umowa:c1"].count("to inny rekord") == 1 and t["sygna:sprawa:m2"].count("to inny rekord") == 1
|
||||
|
||||
|
||||
def test_a_contract_pinned_to_its_twin_matter_keeps_sentence_c_alone() -> None:
|
||||
t = _run("""WORLD['galena/cards?limit=200&offset=0'][0].matter_ref = 'm2';
|
||||
return texts(await index());""")
|
||||
assert t["galena:umowa:c1"].endswith(" Przypięta do sprawy 2026/0109 „Windykacja należności” (klient Miedziak Energia sp. z o.o.).")
|
||||
assert not any("to inny rekord" in v for v in t.values())
|
||||
|
||||
|
||||
def test_an_order_says_what_it_concerns_exactly_once() -> None:
|
||||
# B: o1 by the contract's number in its title, o2 by the matter's number in its notes, o3 by nothing. The
|
||||
# fourth names its client by a bare name only (ZK/2026/057 of the dummy world, Q1): its notes are quoted and
|
||||
# the sentence says what the system did not find, never "no client".
|
||||
t = _run("""WORLD['counsel/matters'].push(order('o4', 'f1', 'ZK/2026/061', 'Opinia podatkowa dotycząca dzierżawy',
|
||||
'Klient: Miedziak Energia.'));
|
||||
return texts(await index());""")
|
||||
none = " System nie ustalił z numerów umowy ani sprawy, czego dotyczy to zlecenie."
|
||||
assert t["counsel:zlecenie:o1"].endswith(" Dotyczy umowy UM-2026-0109 (kontrahent Miedziak Energia S.A.).")
|
||||
assert "Notatka rozliczeniowa" not in t["counsel:zlecenie:o1"] # empty notes are not quoted
|
||||
assert t["counsel:zlecenie:o2"].endswith(" Notatka rozliczeniowa: Klient: Velmora Pompy sp. z o.o., sprawa 2026/0107."
|
||||
" Dotyczy sprawy 2026/0107 (klient Velmora Pompy sp. z o.o.).")
|
||||
assert t["counsel:zlecenie:o3"].endswith(none)
|
||||
assert t["counsel:zlecenie:o4"].endswith(" Notatka rozliczeniowa: Klient: Miedziak Energia." + none)
|
||||
for k in ("o1", "o2", "o3", "o4"):
|
||||
v = t["counsel:zlecenie:" + k]
|
||||
assert v.count("Dotyczy ") + v.count(none) == 1, k
|
||||
# Only orders say it.
|
||||
assert not any("Dotyczy " in v or none in v for k, v in t.items() if not k.startswith("counsel:zlecenie:"))
|
||||
|
||||
|
||||
def test_an_order_naming_two_records_says_none_of_them() -> None:
|
||||
# Two numbers in one order: the map refuses the ambiguous hit, so B names no owner.
|
||||
t = _run("""WORLD['counsel/matters'][0].title = 'Opinia do umowy UM-2026-0109 i UM-2026-0114';
|
||||
return texts(await index());""")
|
||||
assert t["counsel:zlecenie:o1"].endswith(" System nie ustalił z numerów umowy ani sprawy, czego dotyczy to zlecenie.")
|
||||
assert "Dotyczy " not in t["counsel:zlecenie:o1"]
|
||||
|
||||
|
||||
def test_search_chooses_the_same_records_with_the_signs_and_without() -> None:
|
||||
# Q2: search reads the text before signing. Scored on the signed text, 47 of 112 battery turns chose other
|
||||
# sources (2026-11-27); the signs are for the model only.
|
||||
got = _run("""
|
||||
const qs = ['Jaką umowę mamy z Velmora Serwis?', 'Miedziak Energia sp. z o.o. NIP 6340005550', 'Czego dotyczy zlecenie ZK/2026/058?',
|
||||
'sprawa 2026/0109 klient', 'umowa UM-2026-0109 kontrahent', 'Które zlecenia mają klienta?', 'notatka rozliczeniowa',
|
||||
'Co przypięte do sprawy Spór o dostawy pomp?', 'kancelarii Hofmann dotyczy umowy', 'osoba pytająca', 'inny podmiot', 'aktywność ostatnio dodane'];
|
||||
const grab = (b) => b + ';globalThis.chatSearch = chatSearch;';
|
||||
const plain = await index((b) => grab(b).replace('const signs = chatSigns(records, graph);', 'const signs = new Map();'));
|
||||
const signed = await index(grab);
|
||||
const keys = (ix, q) => chatSearch(ix.records, q).map((r) => r.key);
|
||||
const blind = { ...signed, records: signed.records.map((r) => ({ ...r, find: undefined })) };
|
||||
return { same: qs.map((q) => [keys(plain, q), keys(signed, q)]), bites: qs.filter((q) => keys(plain, q).join() !== keys(blind, q).join()) };""")
|
||||
for before, after in got["same"]:
|
||||
assert after == before
|
||||
assert got["bites"] # scored on the signed text, the choice does change: the test sees the difference
|
||||
+81
-3
@@ -2476,9 +2476,87 @@ async function chatIndex() {
|
||||
// A broken map must not take the chat down: without it every turn answers as before.
|
||||
let graph = null;
|
||||
try { graph = chatGraph(records, names, today); } catch (ex) { console.warn('chat map off:', ex); }
|
||||
// Signatures are computed whole before any text changes, so a throw leaves every text byte for byte as before.
|
||||
if (graph) {
|
||||
try {
|
||||
const signs = chatSigns(records, graph);
|
||||
// `find`: the text before signing, which search reads. Search scores a record's words, so the signs' numbers
|
||||
// and names pulled records into questions they do not answer: 47 of 112 battery turns chose other sources,
|
||||
// gold 207 -> 203 of 343 (2026-11-27). Only the model reads the signs; the choice stays as before.
|
||||
for (const r of records) if (signs.has(r.key)) { r.find ??= r.text; r.text += ' ' + signs.get(r.key).map((s) => (s.endsWith('.') ? s : s + '.')).join(' '); }
|
||||
} catch (ex) { console.warn('chat signatures off:', ex); }
|
||||
}
|
||||
return { user: state.user.id, records: all, blind, law: law !== null, byKey: new Map(all.map((r) => [r.key, r])), graph };
|
||||
}
|
||||
|
||||
// Each record says who it belongs to, in its own text (spec 2026-11-27 "podobne podmioty"). The judges of step 1b
|
||||
// found the wrong owner behind about half of Bielik's bad answers (20 questions) and 40% of Qwen's (9): no
|
||||
// instruction fixed it, a record that names its owner does. Only rank-0 edges of the map sign a record; no new
|
||||
// record, key, member or order. Returns record key -> sentences to append.
|
||||
function chatSigns(records, graph) {
|
||||
const byKey = new Map(records.map((r) => [r.key, r]));
|
||||
const { counterparties, concerns } = chatOwners(records, graph);
|
||||
const out = new Map();
|
||||
const say = (key, s) => out.set(key, [...(out.get(key) || []), s]);
|
||||
const digits = (x) => String(x ?? '').replace(/\D/g, '');
|
||||
const twins = new Map();
|
||||
for (const r of records) {
|
||||
const d = r.kind === 'sprawa' && r.matter && digits(r.matter.reference);
|
||||
if (d) twins.set(d, [...(twins.get(d) || []), r]);
|
||||
}
|
||||
for (const r of records) {
|
||||
if (r.kind !== 'umowa' || !r.contract) continue;
|
||||
// C: "pinned or not" read backwards in 3 Bielik questions of 1b. A matter_ref to a matter this account does
|
||||
// not see says nothing: even "pinned to some matter" tells that the matter exists.
|
||||
const pin = graph.contractMatter.get(r.key);
|
||||
if (pin) {
|
||||
const m = byKey.get(pin).matter;
|
||||
say(r.key, `Przypięta do sprawy ${m.reference} „${m.name}”${m.client_name ? ` (klient ${m.client_name})` : ''}`);
|
||||
} else if (!r.contract.matter_ref) say(r.key, 'Nie jest przypięta do żadnej sprawy');
|
||||
// E: contract UM-2026-0109 taken for matter 2026/0109 in 3 Bielik and 1 Qwen questions of 1b (2026-11-27): the
|
||||
// same digits in two registers. Pinned to that very matter, sentence C already tells them apart.
|
||||
for (const t of twins.get(digits(r.contract.number)) || []) {
|
||||
if (t.key === pin) continue;
|
||||
const m = t.matter;
|
||||
const cp = r.contract.counterparty || counterparties(r.key).join(', ');
|
||||
say(r.key, `Sprawa ${m.reference} „${m.name}” to inny rekord (sprawa w Sygnie${m.client_name ? `, klient ${m.client_name}` : ''})`);
|
||||
say(t.key, `Umowa ${r.contract.number} „${r.contract.name}” to inny rekord (umowa w Galenie${cp ? `, kontrahent ${cp}` : ''})`);
|
||||
}
|
||||
}
|
||||
// B: an outside firm's order "for" a client it never named (judges of 1b). The owner only from the order's
|
||||
// number edge; with none (or two hits) the sentence says what the system did not find, never "no client":
|
||||
// ZK/2026/057 of the dummy world names its client in billing_notes by a bare name (Q1, 2026-11-27). Those notes
|
||||
// are the record's own field, so they are quoted before it, verbatim.
|
||||
for (const r of records) {
|
||||
if (r.kind !== 'zlecenie' || !r.order) continue;
|
||||
const notes = String(r.order.billing_notes || '').trim();
|
||||
if (notes) say(r.key, `Notatka rozliczeniowa: ${notes}`);
|
||||
say(r.key, concerns(r));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// The owners a record's text names, from rank-0 edges of the map only: a contract's counterparty by its own list
|
||||
// (the id or NIP edge, never one reached by a name or a matter) and an order's target by its number edge (B).
|
||||
function chatOwners(records, graph) {
|
||||
const byKey = new Map(records.map((r) => [r.key, r]));
|
||||
const counterparties = (key) => (graph.of.get(key) || []).map((id) => graph.ent.get(id))
|
||||
.filter((e) => e.type === 'podmiot' && ['id', 'nip'].includes(e.recs.get(key))).map((e) => e.name);
|
||||
// The counterparty beside a contract number is the contract's own field, quoted: true without any linking. Only an
|
||||
// empty field falls back to the graph. Graph-only left UM-2026-0115 (Pixelon) bare, the very case of 1b (2026-11-27).
|
||||
const cpOf = (key) => byKey.get(key)?.contract?.counterparty || counterparties(key).join(', ');
|
||||
const concerns = (r) => {
|
||||
const to = byKey.get(graph.orderTarget.get(r.key)?.to);
|
||||
if (to?.matter) return `Dotyczy sprawy ${to.matter.reference}${to.matter.client_name ? ` (klient ${to.matter.client_name})` : ''}`;
|
||||
if (to?.contract) {
|
||||
const cp = cpOf(to.key);
|
||||
return `Dotyczy umowy ${to.contract.number}${cp ? ` (kontrahent ${cp})` : ''}`;
|
||||
}
|
||||
return 'System nie ustalił z numerów umowy ani sprawy, czego dotyczy to zlecenie';
|
||||
};
|
||||
return { counterparties, concerns };
|
||||
}
|
||||
|
||||
/* The map of links between the modules' records (testy/czat-graf/PROJEKT.md, B). When a question names a client,
|
||||
a counterparty, a matter or a person of the team, code joins their records from Sygna, Galena and
|
||||
Counsel, counts them and hands the model one ready "card" to read. Records are joined only by fields with one
|
||||
@@ -3172,7 +3250,7 @@ function chatCardLines(e, index, today, kind) {
|
||||
: `brak, ta osoba nie jest autorem żadnej wersji widocznej na tym koncie (projektów na koncie: ${visible('projekt')}).`));
|
||||
out.total.push(chatPlural(versions.length, 'wersja dokumentu w Galenie', 'wersje dokumentów w Galenie', 'wersji dokumentów w Galenie'));
|
||||
} else {
|
||||
const files = (r) => { const m = /Pliki: (.*)\.$/.exec(r.text); return !m || m[1] === 'brak' ? 0 : m[1].split('; ').length; };
|
||||
const files = (r) => { const m = /Pliki: (.*)\.$/.exec(r.find ?? r.text); return !m || m[1] === 'brak' ? 0 : m[1].split('; ').length; };
|
||||
const pItem = (r) => { const pm = g.projMatter.get(r.key); const m = pm && index.byKey.get(pm.matter);
|
||||
return `„${r.project.name}”${m ? `, teczka sprawy ${m.matter.reference} (powiązanie: ${pm.label})` : ''}, plików ${files(r)}`; };
|
||||
const open = versions.filter((r) => r.draft.status === 'open');
|
||||
@@ -3362,7 +3440,7 @@ function chatSearch(records, question) {
|
||||
const q = chatStems(question);
|
||||
for (const w of q) if (CHAT_SEARCH_STOP.has(w)) q.delete(w);
|
||||
for (const w of [...q]) if (CHAT_EN[w]) q.add(CHAT_EN[w]);
|
||||
const docs = records.map((r) => chatStems(r.title + ' ' + r.text + ' ' + r.kind));
|
||||
const docs = records.map((r) => chatStems(r.title + ' ' + (r.find ?? r.text) + ' ' + r.kind));
|
||||
const df = new Map();
|
||||
for (const d of docs) for (const w of d) df.set(w, (df.get(w) || 0) + 1);
|
||||
const scored = records.map((r, i) => {
|
||||
@@ -3869,7 +3947,7 @@ function chatExistence(question, index) {
|
||||
if (chatIsEn(question)) return []; // ponytail: "Friday", "Monday" read as names; English questions wait for P11
|
||||
// The modules' own names are no unknown firm ("w Compassie", "z Insidera"), and a person named in any record
|
||||
// ("prowadzi Anna Nowak") is no unknown name either: the record's text counts, not only its labels.
|
||||
const words = [...new Set(['atrium', 'insider', ...index.records.flatMap((r) => [r.slug, r.title, r.text, ...(r.labels || [])])].filter(Boolean)
|
||||
const words = [...new Set(['atrium', 'insider', ...index.records.flatMap((r) => [r.slug, r.title, r.find ?? r.text, ...(r.labels || [])])].filter(Boolean)
|
||||
.flatMap((l) => chatFold(l).match(/\p{L}{3,}/gu) || []))];
|
||||
const lost = [...question.matchAll(/\p{L}+/gu)].filter((m) => /^\p{Lu}\p{Ll}{2,}$/u.test(m[0]) && m.index && !/[.!?]\s*$/.test(question.slice(0, m.index)))
|
||||
.map((m) => m[0]).filter((w) => !words.some((n) => chatSameWord(chatFold(w), n)));
|
||||
|
||||
Reference in New Issue
Block a user