◊
FallHRPaper
v1 · prime 1019
.
');w.document.close();w.print()} function renderDocuments(v){const docs=state.documents.sort((a,b)=>b.createdAt-a.createdAt);v.innerHTML=`

Documents

${docs.length}
${docs.length?`${docs.map(d=>{const emp=state.employees.find(e=>e.id===d.employeeId);return ``}).join('')}
DateTemplateCodeEmployeeStatusHash
${dateStr(d.createdAt)}${esc(d.templateName)}${esc(d.code)}${emp?esc(emp.firstName+' '+emp.lastName):'—'}${d.status}${esc(d.hash)}
`:'
No documents.
'}`} function renderFirm(v){const f=state.firm||{};v.innerHTML=`

Firm Setup

`} async function saveFirmForm(){const f=state.firm||{id:uid('fi'),ts:now()};f.name=$('#fName').value.trim();f.companyNo=$('#fCoNo').value.trim();f.address=$('#fAddr').value.trim();f.phone=$('#fPhone').value.trim();f.email=$('#fEmail').value.trim();f.updatedAt=now();state.firm=f;await idbPut('firms',f);await auditLog('firm.saved');toast('Saved');render()} const T0_QA=[ {q:/contract|offer.?letter|day.?one/i,a:'Employment contract: forms on offer + acceptance. Should be in writing but oral contracts also bind. S.1 written statement of particulars must be issued by day one (ERA 1996 s.1 amended). The S.1 statement is the minimum mandatory content; the contract may include additional terms (restrictive covenants, IP assignment, working time opt-out etc).'}, {q:/s\.?1|statement.?of.?particulars|written.?statement/i,a:'ERA 1996 s.1: written statement of employment particulars must be issued to ALL workers on or before day one. Mandatory contents: parties, dates, pay, hours, holiday, sick pay, notice, location, job description, probation, training, benefits, disciplinary/grievance procedure. Day-one right since 6 Apr 2020. Failure: tribunal award 2-4 weeks pay (Employment Act 2002 s.38).'}, {q:/disciplin|acas|grieve|hearing/i,a:'ACAS Code of Practice on Disciplinary and Grievance Procedures: investigate fairly → invite to hearing with allegations + evidence + right to be accompanied → hold hearing → decide → notify in writing with right of appeal. Right to be accompanied: Employment Relations Act 1999 s.10 — fellow worker or trade union official. Unreasonable non-compliance: tribunal awards adjusted up to 25% (TULRCA 1992 s.207A).'}, {q:/redund|consultation|selection|alternative/i,a:'Redundancy: ERA 1996 Pt XI. Genuine redundancy reason (workplace closure or diminishing need for work of particular kind). Fair selection (objective criteria). Consultation (individual + collective if 20+ proposed in 90 days — TULRCA 1992 s.188). Suitable alternative employment offered. Right to time off to seek work (ERA 1996 s.52). Statutory pay: 0.5/1/1.5 weeks per year of service under 22/22-40/41+, capped £719/week (2025), max 20 years.'}, {q:/settle|compromise|s\.?203|cot3/i,a:'Settlement Agreement (formerly compromise agreement): must comply with ERA 1996 s.203 to validly waive statutory claims. Requirements: in writing, relate to particular complaint, employee received advice from independent adviser (solicitor, certified TU official, advice centre worker — must be insured), state statutory conditions are met. Alternative: COT3 via ACAS (no need for independent adviser). Employer typically contributes £350-£750 to employee\'s legal fees.'}, {q:/reference|spring|guardian|liability/i,a:'Employment reference: no legal duty to provide one (except in regulated industries like FCA). If provided: duty of care to subject (Spring v Guardian Assurance plc [1995] 2 AC 296) and duty of accuracy to recipient. Best practice: factual reference only (job title, dates, reason for leaving, final salary). Avoid opinions on suitability. Keep records. GDPR: subject can SAR the reference (some exemptions apply to referee opinions).'}, {q:/restrictive.?covenant|non.?compete|garden|leave/i,a:'Restrictive covenants enforceable only if reasonable to protect legitimate business interest (trade secrets, customer connections, workforce stability). Reasonableness: scope (activities), geographic area, duration, time when imposed. Non-compete: typically 3-6 months max. Non-solicit: 6-12 months. Non-deal: similar. Garden leave: paid period of non-work post-notice; deductible from non-compete period. May 2023: UK govt consulted on capping non-competes at 3 months — not yet legislated as of 2026.'}, {q:/working.?time|wtr|opt.?out|48/i,a:'Working Time Regulations 1998: 48-hour weekly average (reference period 17 weeks) unless opted out in writing. Opt-out can be withdrawn by giving up to 3 months notice. Rest breaks: 20 min if working over 6 hours. Daily rest: 11 hours consecutive. Weekly rest: 24 hours per 7-day period. Night work: 8 hours average per 24. Records must be kept 2 years. 5.6 weeks paid annual leave.'}, ]; function askT0(q){for(const r of T0_QA){if(r.q.test(q))return {answer:r.a,source:'T0 · UK HR docs'}}return null} async function askT3(q){if(!state.settings.anthropicKey)return null;try{const res=await fetch('https://api.anthropic.com/v1/messages',{method:'POST',headers:{'x-api-key':state.settings.anthropicKey,'anthropic-version':'2023-06-01','content-type':'application/json'},body:JSON.stringify({model:'claude-sonnet-4-20250514',max_tokens:600,messages:[{role:'user',content:'You are a UK HR/employment law documents expert. ERA 1996, Equality Act 2010, ACAS Code, WTR 1998, settlement agreements. Concise.\n\n'+q}]})});if(!res.ok)return null;const j=await res.json();return {answer:j.content?.[0]?.text,source:'T3 · Anthropic'}}catch(e){return null}} function renderQA(v){v.innerHTML=`

Q & A

T0 + T3 BYOK
${(state.ui.chat||[]).map(m=>`
${esc(m.text)}${m.source?`
${esc(m.source)}
`:''}
`).join('')}
`;const box=$('#chatBox');if(box)box.scrollTop=box.scrollHeight} async function askQ(){const inp=$('#chatIn');if(!inp)return;const q=inp.value.trim();if(!q)return;inp.value='';if(!state.ui.chat)state.ui.chat=[];state.ui.chat.push({role:'user',text:q});render();let r=askT0(q);if(!r)r=await askT3(q);state.ui.chat.push(r?{role:'bot',text:r.answer,source:r.source}:{role:'bot',text:'No T0 match. Add BYOK key for T3.',source:'system'});persistUI();render()} function openModal(type){const modal=$('#modal');$('#modalTitle').textContent='Settings';modal.classList.add('open');$('#modalBody').innerHTML=`
`} function closeModal(){$('#modal').classList.remove('open')} function saveSettings(){state.settings.anthropicKey=$('#sKey').value.trim();state.settings.auditChain=$('#sAudit').checked;$('#tierBadge').textContent=state.settings.anthropicKey?'T3':'T0';persistUI();closeModal();toast('Saved');render()} function exportAll(){const d={tool:TOOLNAME,v:VERSION,ts:now(),firm:state.firm,employees:state.employees,documents:state.documents};const b=new Blob([JSON.stringify(d,null,2)],{type:'application/json'});const u=URL.createObjectURL(b);const a=document.createElement('a');a.href=u;a.download='fallhrpaper-export.json';a.click();URL.revokeObjectURL(u);toast('Exported')} function importAll(){const inp=document.createElement('input');inp.type='file';inp.accept='.json';inp.onchange=async()=>{const f=inp.files[0];if(!f)return;try{const d=JSON.parse(await f.text());if(d.firm){state.firm=d.firm;await idbPut('firms',d.firm)}for(const k of['employees','documents']){if(Array.isArray(d[k]))for(const r of d[k]){state[k].push(r);await idbPut(k,r)}}persistUI();toast('Imported');render()}catch(e){toast('Failed')}};inp.click()} async function wipeAll(){if(!confirm('Wipe ALL data?'))return;for(const s of['firms','employees','documents','audit','state']){const tx=db.transaction(s,'readwrite');tx.objectStore(s).clear();await new Promise(r=>{tx.oncomplete=r})}location.reload()} async function seedDemo(){if(state.employees.length||state.firm)return; const firm={id:uid('fi'),name:'Northgate Sciences Ltd',address:'21 King Street, Manchester M2 4WQ',companyNo:'09876543',phone:'0161 555 0100',email:'hr@northgate.co.uk',updatedAt:now(),isDemo:true}; state.firm=firm;await idbPut('firms',firm); const e1={id:uid('em'),firstName:'Sarah',lastName:'Lewis',email:'s.lewis@northgate.co.uk',address:'14 Elm Street, Manchester M14 5PR',ts:now(),isDemo:true}; const e2={id:uid('em'),firstName:'Adam',lastName:'Ross',email:'a.ross@northgate.co.uk',address:'7 Cedar Avenue, Stockport SK4 2BT',ts:now(),isDemo:true}; state.employees=[e1,e2];await idbPut('employees',e1);await idbPut('employees',e2); await auditLog('demo.seeded',{reasoning:'first boot'});await persistUI()} (async function boot(){try{await openDB();await loadAll();await seedDemo();initMesh();$('#tierBadge').textContent=state.settings.anthropicKey?'T3':'T0';render()}catch(e){console.error('[fallhrpaper] boot error:',e);document.getElementById('view').innerHTML='
Boot error: '+esc(e.message)+'
'}})();