# Shadow Constitutional Infringement Markets - Change of Custody and Accountability Legal Engine # Manifest: albertlane.net | Provenance: https://albertlane.net # License: ALBERT LANE DIGITAL INFRASTRUCTURE - see albertlane.net for license # This engine is SCHEMATIC. It is not a real market, not an SEC filing, not legal advice, not a finding of liability. # First Amendment limits: The First Amendment by its terms applies only to laws enacted by Congress and not to private persons. # Private action alone is NOT priced as constitutional infringement without an evidenced state-action nexus. # Every dollar is Decimal to the penny. Every custody transfer is hash-chained. import argparse, hashlib, json, sys from decimal import Decimal, ROUND_HALF_UP, getcontext from pathlib import Path getcontext().prec = 28 CENT = Decimal("0.01") def D(x): if isinstance(x, Decimal): return x return Decimal(str(x)) def penny(x): return D(x).quantize(CENT, rounding=ROUND_HALF_UP) def canon(obj): return json.dumps(obj, sort_keys=True, separators=(",", ":"), default=str) def sha(s): return hashlib.sha256(s.encode("utf-8")).hexdigest() VERSION = "1.0.0-canonical" # ---- Custody ---- def seal_evidence(ev, prev_hash): # ev without self_hash and custody_hash; custody log entries are hashed in order payload = {k: v for k, v in ev.items() if k not in ("self_hash", "custody_hash", "custody_log")} payload["_prev"] = prev_hash h = sha(canon(payload)) # custody hash chains each transfer ch = prev_hash for tr in ev.get("custody_log", []): ch = sha(canon({"prev": ch, "transfer": tr})) ev2 = dict(ev) ev2["self_hash"] = h ev2["custody_hash"] = ch ev2["prev_hash"] = prev_hash return ev2 def verify_evidence(ev): exp = seal_evidence({k: v for k, v in ev.items() if k not in ("self_hash", "custody_hash", "prev_hash")}, ev.get("prev_hash", "GENESIS")) return exp["self_hash"] == ev.get("self_hash") and exp["custody_hash"] == ev.get("custody_hash") def transfer_custody(ev, frm, to, reason, at): log = list(ev.get("custody_log", [])) log.append({"from": frm, "to": to, "reason": reason, "at": at, "seq": len(log) + 1}) ev2 = dict(ev) ev2["custody_log"] = log ev2["custodian"] = to return ev2 # ---- Lawyers: penny itemization ---- class Lawyer: def __init__(self, d): self.id = d["lawyer_id"] self.role = d.get("role", "") self.name_or_role = d.get("name_or_role", d["lawyer_id"]) self.base = D(d.get("base_salary_usd", "0")) self.bonus = D(d.get("bonus_usd", "0")) self.equity = D(d.get("equity_usd", "0")) self.benefits_rate = D(d.get("benefits_rate", "0")) self.billing_rate = D(d.get("outside_billing_rate_usd", "0")) if d.get("outside_billing_rate_usd") else None self.hours_per_year = D(d.get("hours_per_year", "2080")) self.evidence_ids = d.get("evidence_ids", []) self.note = d.get("note", "") def total_cash(self): return penny(self.base + self.bonus + self.equity) def loaded_cost(self): # loaded = total cash * (1 + benefits) ; benefits covers payroll tax, health, retirement, overhead allocation return penny(self.total_cash() * (Decimal("1") + self.benefits_rate)) def per_year(self): return self.loaded_cost() def per_month(self): return penny(self.loaded_cost() / Decimal("12")) def per_week(self): return penny(self.loaded_cost() / Decimal("52")) def per_day(self): return penny(self.loaded_cost() / Decimal("260")) def per_hour(self): if self.billing_rate is not None: return penny(self.billing_rate) return penny(self.loaded_cost() / self.hours_per_year) def per_minute(self): return penny(self.per_hour() / Decimal("60")) def per_second_exact(self): # exact, not rounded to penny, for audit; penny totals use hours * hourly return (self.per_hour() / Decimal("3600")) def cost_for_hours(self, hours): return penny(D(hours) * self.per_hour()) def to_dict(self): return { "lawyer_id": self.id, "role": self.role, "name_or_role": self.name_or_role, "base_salary_usd": str(penny(self.base)), "bonus_usd": str(penny(self.bonus)), "equity_usd": str(penny(self.equity)), "total_cash_usd": str(self.total_cash()), "benefits_rate": str(self.benefits_rate), "loaded_cost_usd": str(self.loaded_cost()), "per_year_usd": str(self.per_year()), "per_month_usd": str(self.per_month()), "per_week_usd": str(self.per_week()), "per_day_usd": str(self.per_day()), "per_hour_usd": str(self.per_hour()), "per_minute_usd": str(self.per_minute()), "per_second_exact_usd": str(self.per_second_exact()), "outside_billing_rate_usd": str(self.billing_rate) if self.billing_rate is not None else None, "evidence_ids": self.evidence_ids, "note": self.note } # ---- Speech ---- def speech_value(sp): reach = D(sp.get("reach", "0")) per_view = D(sp.get("value_per_view_usd", "0")) intrinsic = D(sp.get("intrinsic_value_usd", "0")) return penny(reach * per_view + intrinsic) # ---- Tactic + Infringement ---- def evaluate(data, seal=False): # seal evidences in order evidences = [] prev = "GENESIS" for ev in data.get("evidences", []): e = dict(ev) if seal or "self_hash" not in e: e = seal_evidence(e, prev) evidences.append(e) prev = e["self_hash"] chain_valid = all(verify_evidence(e) for e in evidences) lawyers = {l["lawyer_id"]: Lawyer(l) for l in data.get("lawyers", [])} lawyer_rows = [lawyers[k].to_dict() for k in lawyers] # payroll totals payroll_loaded = penny(sum((D(r["loaded_cost_usd"]) for r in lawyer_rows), Decimal("0"))) payroll_cash = penny(sum((D(r["total_cash_usd"]) for r in lawyer_rows), Decimal("0"))) speeches = {s["speech_id"]: s for s in data.get("speech_acts", [])} speech_rows = [] for sid, s in speeches.items(): speech_rows.append({"speech_id": sid, "title": s.get("title",""), "reach": str(D(s.get("reach","0"))), "value_per_view_usd": str(D(s.get("value_per_view_usd","0"))), "intrinsic_value_usd": str(D(s.get("intrinsic_value_usd","0"))), "speech_value_usd": str(speech_value(s)), "evidence_ids": s.get("evidence_ids",[]), "note": s.get("note","")}) # tactics tactic_rows = [] infringement_rows = [] total_direct = Decimal("0"); total_indirect = Decimal("0"); total_derivative = Decimal("0"); total_suppression = Decimal("0"); total_lost_speech = Decimal("0") total_intrinsic = Decimal("0") for t in data.get("tactics", []): # lawyer cost breakdown to penny allocs = [] lawyer_cost = Decimal("0") for a in t.get("lawyer_allocations", []): lw = lawyers[a["lawyer_id"]] hrs = D(a["hours"]) cost = lw.cost_for_hours(hrs) lawyer_cost += cost allocs.append({"lawyer_id": lw.id, "role": lw.role, "hours": str(hrs), "rate_per_hour_usd": str(lw.per_hour()), "cost_usd": str(cost), "per_minute_usd": str(lw.per_minute())}) outside = penny(D(t.get("outside_counsel_usd", "0"))) filing = penny(D(t.get("filing_fees_usd", "0"))) other = penny(D(t.get("other_costs_usd", "0"))) suppression_cost = penny(lawyer_cost + outside + filing + other) # speech linked lost = Decimal("0") speech_vals = [] eff = D(t.get("suppression_effectiveness", "0")) for sid in t.get("speech_ids", []): sv = speech_value(speeches[sid]) speech_vals.append({"speech_id": sid, "speech_value_usd": str(sv)}) lost += penny(sv * eff) lost = penny(lost) direct = penny(suppression_cost + lost) indirect_mult = D(t.get("indirect_multiplier", "0")) deriv_coeff = D(t.get("derivative_coefficient", "0")) indirect = penny(direct * indirect_mult) derivative = penny((direct + indirect) * deriv_coeff + D(t.get("opportunity_cost_usd","0")) + D(t.get("enforcement_cost_usd","0"))) # NPV of derivative over horizon disc = D(t.get("discount_rate","0.05")); horizon = int(t.get("horizon_years",5)) npv = Decimal("0") if horizon>0: # derivative spread evenly, discounted annually annual = derivative / Decimal(str(horizon)) for yr in range(1, horizon+1): npv += annual / ((Decimal("1")+disc) ** yr) npv = penny(npv) total = penny(direct + indirect + derivative) # state action assessment - must be evidenced, not assumed sa = t.get("state_action", {}) sa_score = D(sa.get("score_0_to_1","0")) sa_basis = sa.get("basis","") sa_verified = sa.get("verification_status","unverified") # accountability acct = t.get("accountability", {}) has_approver = bool(acct.get("approver")) has_custodian = bool(acct.get("custodian")) has_evidence = bool(t.get("evidence_ids")) acct_score = (1 if has_approver else 0) + (1 if has_custodian else 0) + (1 if has_evidence else 0) # shadow contract: PUT if suppression cost + lost >0, strike = suppression_cost, premium = npv # constitutional flag: only flag as SHADOW CONSTITUTIONAL if state_action score >=0.5 AND verified, else PRIVATE-ACTION SCHEMATIC if sa_verified=="verified" and sa_score >= Decimal("0.5"): flag = "SHADOW-CONSTITUTIONAL" elif sa_verified=="verified": flag = "PRIVATE-ACTION-SCHEMATIC" else: flag = "UNVERIFIED-NO-CONSTITUTIONAL-FINDING" tactic_rows.append({ "tactic_id": t["tactic_id"], "title": t.get("title",""), "type": t.get("type",""), "lawyer_allocations": allocs, "lawyer_cost_usd": str(penny(lawyer_cost)), "outside_counsel_usd": str(outside), "filing_fees_usd": str(filing), "other_costs_usd": str(other), "suppression_cost_usd": str(suppression_cost), "speech_values": speech_vals, "suppression_effectiveness": str(eff), "lost_speech_value_usd": str(lost), "direct_harm_usd": str(direct), "indirect_multiplier": str(indirect_mult), "indirect_harm_usd": str(indirect), "derivative_coefficient": str(deriv_coeff), "derivative_harm_usd": str(derivative), "total_harm_usd": str(total), "intrinsic_npv_usd": str(npv), "state_action_score": str(sa_score), "state_action_basis": sa_basis, "state_action_status": sa_verified, "constitutional_flag": flag, "accountability": acct, "accountability_score_0_to_3": acct_score, "evidence_ids": t.get("evidence_ids",[]), "confidence": t.get("confidence","low"), "verification_status": t.get("verification_status","verified"), "note": t.get("note","") }) if t.get("verification_status")=="verified": total_direct += direct; total_indirect += indirect; total_derivative += derivative total_suppression += suppression_cost; total_lost_speech += lost; total_intrinsic += npv infringement_rows.append(tactic_rows[-1]) totals = { "suppression_cost_usd": str(penny(total_suppression)), "lost_speech_value_usd": str(penny(total_lost_speech)), "direct_harm_usd": str(penny(total_direct)), "indirect_harm_usd": str(penny(total_indirect)), "derivative_harm_usd": str(penny(total_derivative)), "total_financial_harm_usd": str(penny(total_direct+total_indirect+total_derivative)), "intrinsic_derivative_value_npv_usd": str(penny(total_intrinsic)), "payroll_loaded_cost_usd": str(payroll_loaded), "payroll_cash_usd": str(payroll_cash), "verified_tactic_rows": str(len(infringement_rows)), "unverified_excluded_rows": str(len(tactic_rows)-len(infringement_rows)), "lawyer_count": str(len(lawyers)), "speech_count": str(len(speeches)), "evidence_count": str(len(evidences)) } out = {"engine": "Shadow Constitutional Infringement Markets - Change of Custody and Accountability Legal Engine", "version": VERSION, "manifest": "albertlane.net", "provenance": "https://albertlane.net", "enterprise": data.get("enterprise",""), "evaluated_at": data.get("evaluated_at",""), "evaluator": data.get("evaluator",""), "chain_valid": chain_valid, "totals": totals, "lawyers": lawyer_rows, "speech_acts": speech_rows, "tactics": tactic_rows, "evidences": evidences, "policies": data.get("policies",[]), "custody_note": "Every evidence item carries self_hash chained to previous hash and custody_hash chained through custody_log transfers. Any change to quote, custodian, or transfer breaks the chain."} return out def render_md(res): L=[] L.append(f"# Shadow Constitutional Infringement Markets - Financial Report: {res['enterprise']}") L.append("") L.append(f"**Engine:** {res['engine']} {res['version']} | **Manifest:** {res['manifest']} | **Provenance:** {res['provenance']}") L.append(f"**Evaluator:** {res['evaluator']} | **Evaluated at:** {res['evaluated_at']} | **Chain valid:** {res['chain_valid']}") L.append("") L.append("## Disclaimer - Read First") L.append("This is a SCHEMATIC shadow board. It is not a real market, not an SEC filing, not legal advice, and not a finding that any person violated the Constitution or any law. The First Amendment by its terms applies only to laws enacted by Congress and not to private persons, subject to limited state-action circumstances. A private corporate tactic is priced here as PRIVATE-ACTION-SCHEMATIC unless an evidenced state-action nexus is verified. All per-capita speech values, chilling multipliers, and derivative coefficients are MODELED assumptions disclosed in row notes, not market prices.") L.append("") L.append("## Totals") L.append("| Measure | USD |") L.append("| --- | --- |") for k,v in res["totals"].items(): L.append(f"| {k} | ${Decimal(v):,.2f} |") L.append("") L.append("## Lawyer Payroll - Itemized to the Penny") L.append("Loaded cost = total cash (base + bonus + equity) x (1 + benefits rate). Hourly = loaded cost / hours per year, except outside counsel where hourly = billing rate. Totals for a tactic = sum(hours x hourly) to the penny.") L.append("| Lawyer | Role | Base | Bonus | Equity | Total Cash | Benefits | Loaded | Per Month | Per Week | Per Day | Per Hour | Per Minute | Per Second Exact |") L.append("| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |") for r in res["lawyers"]: L.append(f"| {r['lawyer_id']} | {r['role']} | ${Decimal(r['base_salary_usd']):,.2f} | ${Decimal(r['bonus_usd']):,.2f} | ${Decimal(r['equity_usd']):,.2f} | ${Decimal(r['total_cash_usd']):,.2f} | {r['benefits_rate']} | ${Decimal(r['loaded_cost_usd']):,.2f} | ${Decimal(r['per_month_usd']):,.2f} | ${Decimal(r['per_week_usd']):,.2f} | ${Decimal(r['per_day_usd']):,.2f} | ${Decimal(r['per_hour_usd']):,.2f} | ${Decimal(r['per_minute_usd']):,.2f} | ${Decimal(r['per_second_exact_usd']):,.6f} |") L.append("") L.append("## Speech Acts - Underlying Value") L.append("| Speech | Title | Reach | Value per View | Intrinsic | Speech Value |") L.append("| --- | --- | --- | --- | --- | --- |") for s in res["speech_acts"]: L.append(f"| {s['speech_id']} | {s['title']} | {s['reach']} | ${Decimal(s['value_per_view_usd']):,.4f} | ${Decimal(s['intrinsic_value_usd']):,.2f} | ${Decimal(s['speech_value_usd']):,.2f} |") L.append("") L.append("## Tactics - Suppression Cost and Shadow Contracts") for t in res["tactics"]: L.append(f"### {t['tactic_id']} - {t['title']} ({t['type']}) - {t['constitutional_flag']}") L.append(f"- **Accountability:** custodian={t['accountability'].get('custodian','')} approver={t['accountability'].get('approver','')} reviewer={t['accountability'].get('reviewer','')} score {t['accountability_score_0_to_3']}/3") L.append(f"- **State action:** score {t['state_action_score']} status {t['state_action_status']} basis: {t['state_action_basis']}") L.append(f"- **Evidence:** {', '.join(t['evidence_ids'])} | Confidence {t['confidence']} | Verification {t['verification_status']}") L.append(f"- **Lawyer cost:** ${Decimal(t['lawyer_cost_usd']):,.2f} | Outside: ${Decimal(t['outside_counsel_usd']):,.2f} | Filing: ${Decimal(t['filing_fees_usd']):,.2f} | Other: ${Decimal(t['other_costs_usd']):,.2f} | **Suppression cost:** ${Decimal(t['suppression_cost_usd']):,.2f}") L.append(f"- **Lost speech:** ${Decimal(t['lost_speech_value_usd']):,.2f} at effectiveness {t['suppression_effectiveness']}") L.append(f"- **Direct:** ${Decimal(t['direct_harm_usd']):,.2f} | **Indirect:** ${Decimal(t['indirect_harm_usd']):,.2f} | **Derivative:** ${Decimal(t['derivative_harm_usd']):,.2f} | **Total:** ${Decimal(t['total_harm_usd']):,.2f} | **Intrinsic NPV:** ${Decimal(t['intrinsic_npv_usd']):,.2f}") L.append(f"- **Shadow contract:** PUT, underlying=speech value, strike=suppression cost ${Decimal(t['suppression_cost_usd']):,.2f}, premium=intrinsic NPV ${Decimal(t['intrinsic_npv_usd']):,.2f}") L.append(f"- **Lawyer allocations:**") for a in t["lawyer_allocations"]: L.append(f" - {a['lawyer_id']} ({a['role']}): {a['hours']}h x ${Decimal(a['rate_per_hour_usd']):,.2f}/h = ${Decimal(a['cost_usd']):,.2f} | per minute ${Decimal(a['per_minute_usd']):,.2f}") L.append(f"- **Note:** {t['note']}") L.append("") L.append("## Custody Chain") for e in res["evidences"]: L.append(f"- {e['evidence_id']}: custodian={e.get('custodian','')} self_hash={e.get('self_hash','')[:16]}... custody_hash={e.get('custody_hash','')[:16]}... transfers={len(e.get('custody_log',[]))} quote=\"{e.get('quote','')[:120]}\"") for tr in e.get("custody_log", []): L.append(f" - Transfer {tr.get('seq')}: {tr.get('from')} -> {tr.get('to')} at {tr.get('at')} reason: {tr.get('reason')}") L.append("") L.append("## Methods") L.append("1. Policy quoted verbatim and linked to evidence. 2. Speech valued as reach x modeled value per view + intrinsic. 3. Suppression cost = sum lawyer hours x loaded hourly to penny + outside + filing + other. 4. Lost speech = speech value x effectiveness. 5. Direct = suppression + lost. 6. Indirect = direct x chilling multiplier. 7. Derivative = (direct+indirect) x coefficient + opportunity + enforcement. 8. Intrinsic = NPV of derivative over horizon at discount. 9. Custody: any change to quote, custodian, or transfer breaks hash chain. 10. Accountability: a tactic scores 0-3 for custodian, approver, evidence. 11. Exclusion: unverified rows contribute $0 and appear as gaps.") return "\n".join(L) def main(): ap = argparse.ArgumentParser() sub = ap.add_subparsers(dest="cmd", required=True) ev = sub.add_parser("evaluate"); ev.add_argument("--input", required=True); ev.add_argument("--seal", action="store_true"); ev.add_argument("--out-md"); ev.add_argument("--out-json") ve = sub.add_parser("verify"); ve.add_argument("--input", required=True) rg = sub.add_parser("regress"); rg.add_argument("--baseline", required=True); rg.add_argument("--new", required=True) cu = sub.add_parser("custody"); cu.add_argument("--input", required=True) pa = sub.add_parser("payroll"); pa.add_argument("--input", required=True) args = ap.parse_args() if args.cmd=="evaluate": data=json.loads(Path(args.input).read_text()) res=evaluate(data, seal=args.seal) print(json.dumps(res["totals"], indent=2)) print(f"Chain valid: {res['chain_valid']}") if args.out_json: Path(args.out_json).write_text(json.dumps(res, indent=2)); print(f"Wrote {args.out_json}") if args.out_md: Path(args.out_md).write_text(render_md(res)); print(f"Wrote {args.out_md}") elif args.cmd=="verify": data=json.loads(Path(args.input).read_text()) # if file is evaluated output, evidences are already sealed; verify directly ok=True for e in data.get("evidences",[]): if not verify_evidence(e): ok=False; print(f" - {e.get('evidence_id')}: self_hash mismatch / tampered quote or metadata") print(f"Chain valid: {ok}") elif args.cmd=="regress": b=json.loads(Path(args.baseline).read_text()); n=json.loads(Path(args.new).read_text()) # baseline/new may be evaluated outputs or inputs; normalize totals via evaluate if needed def totals_of(d): if "totals" in d: return d["totals"] return evaluate(d)["totals"] bt=totals_of(b); nt=totals_of(n) delta={k: str(penny(D(nt.get(k,"0"))-D(bt.get(k,"0")))) for k in bt if k in nt} print(json.dumps({"baseline_totals":bt,"new_totals":nt,"delta":delta,"verdict":"NO CHANGE" if all(D(v)==0 for v in delta.values()) else "CHANGED"}, indent=2)) elif args.cmd=="custody": data=json.loads(Path(args.input).read_text()) res=evaluate(data) if "totals" not in data else data for e in res["evidences"]: print(f"{e['evidence_id']} custodian={e.get('custodian')} transfers={len(e.get('custody_log',[]))} self={e.get('self_hash','')[:16]} custody={e.get('custody_hash','')[:16]}") for tr in e.get("custody_log",[]): print(f" {tr.get('seq')}: {tr.get('from')} -> {tr.get('to')} {tr.get('at')} {tr.get('reason')}") elif args.cmd=="payroll": data=json.loads(Path(args.input).read_text()) res=evaluate(data) if "totals" not in data else data for r in res["lawyers"]: print(f"{r['lawyer_id']} {r['role']}: loaded ${r['loaded_cost_usd']} /h ${r['per_hour_usd']} /min ${r['per_minute_usd']} /sec {r['per_second_exact_usd']}") if __name__=="__main__": main()