← back to AbramsOS

scripts/stage-eligible-claims.js

48 lines

#!/usr/bin/env node
// Stage openclaw fill-not-submit briefs for a chosen set of OPEN settlement_claim rows.
// Default set = data-breach settlements that offer a FLAT no-proof alternative cash payment
// (Comcast $50, EMM Loans $50, FMC Health $75, Ciuni & Panichi $125, Oak View $50/$150-CA).
//
// Marks each eligibility_state='eligible' (Steve elected to pursue the no-proof set), then calls
// lib/openclaw-claim-filler.stage() which writes the fill brief to data/claim-fill-queue/ AND
// ~/.claude/yolo-queue/pending-approval/. The brief PREFILLS identity and HARD-STOPS before the
// penalty-of-perjury attestation + Submit. Nothing is filed here; nothing is submitted, ever.
//
// Usage: node scripts/stage-eligible-claims.js ["name regex"]
const db = require('../lib/db');
const filler = require('../lib/openclaw-claim-filler');

const USER = process.env.ABRAMSOS_USER_ID || 'user_steve';
const DEFAULT_RE = 'comcast|emm loans|fmc health|ciuni|oak view';
const nameRe = process.argv[2] || DEFAULT_RE;

// Prefill identity — pulled from AbramsOS person(self); address lives in notes, email set today.
// phone intentionally null (not on file); openclaw brief flags any missing required field.
const PROFILE = {
  full_name: 'Steve Abrams',
  email: 'steveabramsdesigns@gmail.com',
  phone: null,
  address: '18406 Bessemer St, Reseda, CA 91335',
};

async function main() {
  const { rows } = await db.query(
    `SELECT * FROM settlement_claim
      WHERE user_id=$1 AND name ~* $2
        AND (deadline IS NULL OR deadline >= current_date)
      ORDER BY deadline NULLS LAST`, [USER, nameRe]);
  if (!rows.length) { console.log('no matching open claims for /' + nameRe + '/'); process.exit(0); }
  console.log(`staging ${rows.length} claim(s):`);
  for (const c of rows) {
    await db.query(`UPDATE settlement_claim SET eligibility_state='eligible', updated_at=now() WHERE id=$1`, [c.id]);
    c.eligibility_state = 'eligible';
    const { local } = filler.stage(c, PROFILE);
    await db.query(`UPDATE settlement_claim SET fill_state='queued', updated_at=now() WHERE id=$1`, [c.id]);
    console.log(`  • ${c.name}  [${c.deadline || 'no deadline'}]  ${c.payout_text}`);
    console.log(`      brief → ${local}`);
  }
  console.log('\nAll briefs are FILL-NOT-SUBMIT. Steve verifies breach membership + attests + submits.');
  process.exit(0);
}
main().catch(e => { console.error('FATAL', e); process.exit(1); });