{
  "chapter": "AI-18",
  "status": "Author current standalone archives actually executed; sixUI/independent/native pending",
  "programProcesses": 30,
  "successful": 28,
  "expectedInvalid": 2,
  "storedSVG": 28,
  "authorTargetLaunchesIncludingHistory": 55,
  "history": "Initial30 actual targets:14Python normal/14R UTF8 native-path and source-string-encoding development failures/2expectedcycle. Fourteen explicitUTF8 normalR followups, nine plot-label/unit/padding followups and two short-label followups are new processes. Cumulative55=39normal/14environmentdevelopmentfailures/2expectedcycle. Final stored30=28normalSVG/2expectedcycle.",
  "pairedSummaryMeaning": "14 Python/R implementation pairs, not KOEN pairs;43summary token fields and200plot rows. Logs/R graph decimal projections use9significant digits; original source tokens/exact distances are preserved in inputs/fullpublicdata.",
  "dependencies": {
    "Python": "Standard library Fraction/hashlib and Matplotlib Agg",
    "R": "Base R; exact small authored fractions and base10000 integer source distances. Explicit earlier companion SHA primitive reuse."
  },
  "sourceScope": "166retained source pairs reconstruct numeric/image views. Known-corpus retrieval and train-only centroids, validation-only safe choice. Not OCR/CLIP/independent language observations.",
  "publicProjection": "Code/shortsummary embedded; fullJSON/CSV/SVG external. Actual absolute commands/rawstdoutstderr kept privately. Expected Python traceback projects only final error message; no local filesystem traceback published.",
  "wholeCandidateBindings": {
    "body": "492f24a11136120dd7ad1fd34a71a24a46801bc829d0491b6a5d5157b15836ef",
    "cases": "53d9db82e5328b082e98d38d431a2548e5301aefa7a5d1adcccd00729a7fd6ef",
    "engine": "fea3713a45d8be8bc486863b70663d2d03223406788b35ce2af8051129d2efd7"
  },
  "runs": [
    {
      "api": "fusion",
      "variant": "fusion-observed",
      "language": "python",
      "codeFile": "ai18-fixed/fusion-observed-python.py",
      "codeSHA256": "b0c35b05ce34934f0a06104e7fd864eb8dcb9e9b38288973f54baf31c05bc31f",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/fusion-observed-python/plot.svg"
    },
    {
      "api": "fusion",
      "variant": "fusion-observed",
      "language": "r",
      "codeFile": "ai18-fixed/fusion-observed-r.R",
      "codeSHA256": "82211cae77dd8d5ece2edb96399427c9dea637ae858a3d03a886bb8fb61e507c",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/fusion-observed-r/plot.svg"
    },
    {
      "api": "fusion",
      "variant": "fusion-fixed-zero",
      "language": "python",
      "codeFile": "ai18-fixed/fusion-fixed-zero-python.py",
      "codeSHA256": "fa286558215d2dfc05fc5d498ecf08c3cae1705aa516753f2bbc12ff55b88dd3",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/fusion-fixed-zero-python/plot.svg"
    },
    {
      "api": "fusion",
      "variant": "fusion-fixed-zero",
      "language": "r",
      "codeFile": "ai18-fixed/fusion-fixed-zero-r.R",
      "codeSHA256": "f88c7dc5ce5f7abe8b5f2f2ece4ccee35d0517cd1660c9480c422ea07b56652d",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/fusion-fixed-zero-r/plot.svg"
    },
    {
      "api": "fusion",
      "variant": "fusion-no-observed-weight",
      "language": "python",
      "codeFile": "ai18-fixed/fusion-no-observed-weight-python.py",
      "codeSHA256": "fa46515f4e2bc7552acd74ce3403c5d64d9e35ae0cb11b24ce79dea2e26fc471",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/fusion-no-observed-weight-python/plot.svg"
    },
    {
      "api": "fusion",
      "variant": "fusion-no-observed-weight",
      "language": "r",
      "codeFile": "ai18-fixed/fusion-no-observed-weight-r.R",
      "codeSHA256": "3ea350b9ebea14278120ab070358b3ba515c7519fcb4f036902634ff6bb05b6c",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/fusion-no-observed-weight-r/plot.svg"
    },
    {
      "api": "contrastive",
      "variant": "contrastive-regular",
      "language": "python",
      "codeFile": "ai18-fixed/contrastive-regular-python.py",
      "codeSHA256": "fcd9192f3994eec2ab074bb41472c6e7a9cfa127f35d468a69ccf058737b021d",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/contrastive-regular-python/plot.svg"
    },
    {
      "api": "contrastive",
      "variant": "contrastive-regular",
      "language": "r",
      "codeFile": "ai18-fixed/contrastive-regular-r.R",
      "codeSHA256": "af442c4db6ce26b45a3eb63350d34448778757841d066f1a36661891371ded04",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/contrastive-regular-r/plot.svg"
    },
    {
      "api": "contrastive",
      "variant": "contrastive-zero-row",
      "language": "python",
      "codeFile": "ai18-fixed/contrastive-zero-row-python.py",
      "codeSHA256": "e42b3b701dca8ecbc6ee922c16ac1f050c18c89c73d41ec4edb7bace7bbbcf34",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/contrastive-zero-row-python/plot.svg"
    },
    {
      "api": "contrastive",
      "variant": "contrastive-zero-row",
      "language": "r",
      "codeFile": "ai18-fixed/contrastive-zero-row-r.R",
      "codeSHA256": "cca81b86b87f700c2fb401d418db744951b825e32d9dffc8c1096db0d76e3c4c",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/contrastive-zero-row-r/plot.svg"
    },
    {
      "api": "contrastive",
      "variant": "contrastive-zero-match",
      "language": "python",
      "codeFile": "ai18-fixed/contrastive-zero-match-python.py",
      "codeSHA256": "8204b820641866711278a6ea0c5e312163c43090c1a6778b862f7dc6153f88af",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/contrastive-zero-match-python/plot.svg"
    },
    {
      "api": "contrastive",
      "variant": "contrastive-zero-match",
      "language": "r",
      "codeFile": "ai18-fixed/contrastive-zero-match-r.R",
      "codeSHA256": "522dcd52b87336047e659a82cd08246fbcd7e69cac1dc6cffff294b21acf7602",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/contrastive-zero-match-r/plot.svg"
    },
    {
      "api": "provenance",
      "variant": "provenance-complete",
      "language": "python",
      "codeFile": "ai18-fixed/provenance-complete-python.py",
      "codeSHA256": "15418803e214b2d838dc83f65c863c977a532914e1d0aece837b08c0f58b68af",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/provenance-complete-python/plot.svg"
    },
    {
      "api": "provenance",
      "variant": "provenance-complete",
      "language": "r",
      "codeFile": "ai18-fixed/provenance-complete-r.R",
      "codeSHA256": "3a373f4a5adaa89fd2597f48cc53173ce1e8890838af9198d5804ff956c8c976",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/provenance-complete-r/plot.svg"
    },
    {
      "api": "provenance",
      "variant": "provenance-missing",
      "language": "python",
      "codeFile": "ai18-fixed/provenance-missing-python.py",
      "codeSHA256": "4a1f70800228239c94ff927c46ea5e64df3d0927da3ec8cc6c0dc9ce6d9e6b6a",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/provenance-missing-python/plot.svg"
    },
    {
      "api": "provenance",
      "variant": "provenance-missing",
      "language": "r",
      "codeFile": "ai18-fixed/provenance-missing-r.R",
      "codeSHA256": "50af8c2b69b98a11fba56e1234d2e41501fdd6b3e4d44e7ce6e236a433bfa901",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/provenance-missing-r/plot.svg"
    },
    {
      "api": "duplicates",
      "variant": "duplicate-chain",
      "language": "python",
      "codeFile": "ai18-fixed/duplicate-chain-python.py",
      "codeSHA256": "f24dd7b6c4cccf1b736b4a997c4bec4e704b73861369dee76b630020000b5472",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/duplicate-chain-python/plot.svg"
    },
    {
      "api": "duplicates",
      "variant": "duplicate-chain",
      "language": "r",
      "codeFile": "ai18-fixed/duplicate-chain-r.R",
      "codeSHA256": "25be5fe13faff79c6fc7f69df1c34b394c59cb1e9cee9f16e3d265e04573bf23",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/duplicate-chain-r/plot.svg"
    },
    {
      "api": "leakage",
      "variant": "leakage-declared-dirty",
      "language": "python",
      "codeFile": "ai18-fixed/leakage-declared-dirty-python.py",
      "codeSHA256": "1bff00c31e9b7412ca7b9ad5147c0e019e95ba49965eed64b5fe4669cb9ffec8",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/leakage-declared-dirty-python/plot.svg"
    },
    {
      "api": "leakage",
      "variant": "leakage-declared-dirty",
      "language": "r",
      "codeFile": "ai18-fixed/leakage-declared-dirty-r.R",
      "codeSHA256": "b7319ceacb57c6c507cdfbbbe0471f21444180c74d143ae20567e8cd0bea901c",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/leakage-declared-dirty-r/plot.svg"
    },
    {
      "api": "leakage",
      "variant": "leakage-declared-clear",
      "language": "python",
      "codeFile": "ai18-fixed/leakage-declared-clear-python.py",
      "codeSHA256": "377c4d6ff78fe78f8af7641082bc9640484c57abf6ac77a8de535a6c35c23a41",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/leakage-declared-clear-python/plot.svg"
    },
    {
      "api": "leakage",
      "variant": "leakage-declared-clear",
      "language": "r",
      "codeFile": "ai18-fixed/leakage-declared-clear-r.R",
      "codeSHA256": "5b95de09c7a4588b119f9bfcebd279c57a052d9ea9c0d5856e64513d8533c618",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/leakage-declared-clear-r/plot.svg"
    },
    {
      "api": "realdata",
      "variant": "realdata-country",
      "language": "python",
      "codeFile": "ai18-fixed/realdata-country-python.py",
      "codeSHA256": "bda116a0d6f9e99a30a05aac5ccb49202ed959620d10d7fa97c9187a007b73bb",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/realdata-country-python/plot.svg"
    },
    {
      "api": "realdata",
      "variant": "realdata-country",
      "language": "r",
      "codeFile": "ai18-fixed/realdata-country-r.R",
      "codeSHA256": "67f0fdebe77bae06b380b9a2cdbbb37624a7b1d7ec898370680d7a6955ebe765",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/realdata-country-r/plot.svg"
    },
    {
      "api": "realdata",
      "variant": "realdata-person",
      "language": "python",
      "codeFile": "ai18-fixed/realdata-person-python.py",
      "codeSHA256": "5826163dee2dc48168abff9ed97ebb3001ea58a56ffc86f5fdd7aa6784812633",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/realdata-person-python/plot.svg"
    },
    {
      "api": "realdata",
      "variant": "realdata-person",
      "language": "r",
      "codeFile": "ai18-fixed/realdata-person-r.R",
      "codeSHA256": "e5067328e866329ecb12fb309ee4a1a691cdb52c380a9aec2c87fc38db34963c",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/realdata-person-r/plot.svg"
    },
    {
      "api": "realdata",
      "variant": "realdata-company",
      "language": "python",
      "codeFile": "ai18-fixed/realdata-company-python.py",
      "codeSHA256": "2e40d25863e6391551a246864d0ea3953311e96c5b3b8c88066bd7d431766c58",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/realdata-company-python/plot.svg"
    },
    {
      "api": "realdata",
      "variant": "realdata-company",
      "language": "r",
      "codeFile": "ai18-fixed/realdata-company-r.R",
      "codeSHA256": "603ec170df3bddb2f4df6a9e7779a820b6f6a65ad2bcabf9ee8e2fdd5b9b849d",
      "expectedFailure": false,
      "exitCode": 0,
      "plotFile": "ai18-fixed/realdata-company-r/plot.svg"
    },
    {
      "api": "provenance",
      "variant": "provenance-cycle-rejected",
      "language": "python",
      "codeFile": "ai18-fixed/provenance-cycle-rejected-python.py",
      "codeSHA256": "86df5bac2ffeccfdecb0a2f67d70527492b6ffab54b59b760897310a4d32c398",
      "expectedFailure": true,
      "exitCode": 1
    },
    {
      "api": "provenance",
      "variant": "provenance-cycle-rejected",
      "language": "r",
      "codeFile": "ai18-fixed/provenance-cycle-rejected-r.R",
      "codeSHA256": "20b60621b0872f32d9e89ac225a1fcea7796b5f126385b283b162f1a9e8ff2ab",
      "expectedFailure": true,
      "exitCode": 1
    }
  ],
  "fusion": {
    "python": {
      "fusion-observed": {
        "api": "fusion",
        "variant": "fusion-observed",
        "language": "python",
        "codeFile": "ai18-fixed/fusion-observed-python.py",
        "codeSHA256": "b0c35b05ce34934f0a06104e7fd864eb8dcb9e9b38288973f54baf31c05bc31f",
        "expectedFailure": false,
        "title": "Observed-weight fusion",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='Observed-weight fusion'\nINPUT=json.loads('{\"weights\": [\"1\", \"1\"], \"rows\": [{\"id\": \"a\", \"scores\": [\"4/5\", null]}, {\"id\": \"b\", \"scores\": [\"3/5\", \"1\"]}], \"missing\": \"observed-renormalize\"}')\n\nw=list(map(F,INPUT['weights']));out=[]\nfor r in INPUT['rows']:\n mass=sum((w[i]for i,v in enumerate(r['scores'])if v is not None),F(0));num=sum((w[i]*F(v)for i,v in enumerate(r['scores'])if v is not None),F(0));den=sum(w,F(0))if INPUT['missing']=='fixed-zero'else mass;score=num/den if den else None;out.append(dict(id=r['id'],score=None if score is None else qs(score),observedWeight=qs(mass),denominator=qs(den)));summary['score:'+r['id']]='undefined'if score is None else qs(score);point('Fused score',r['id'],score)\nranked=[r['id']for _,r in sorted(enumerate(out),key=lambda z:(z[1]['score']is None,-F(z[1]['score'])if z[1]['score']is not None else F(0),z[0]))if r['score']is not None];summary['rankedIDs']='|'.join(ranked);result=dict(rows=out,rankedIDs=ranked,missingRule=INPUT['missing'])\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['label'],34)for p in points],fontsize=9);ax.invert_yaxis();ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"rankedIDs\":\"a|b\",\"score:a\":\"4/5\",\"score:b\":\"4/5\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/fusion-observed-python/stdout.txt",
        "stderrFile": "ai18-fixed/fusion-observed-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "rankedIDs",
            "value": "a|b"
          },
          {
            "metric": "score:a",
            "value": "4/5"
          },
          {
            "metric": "score:b",
            "value": "4/5"
          }
        ],
        "resultFile": "ai18-fixed/fusion-observed-python/result.json",
        "summaryFile": "ai18-fixed/fusion-observed-python/summary.json",
        "plotDataFile": "ai18-fixed/fusion-observed-python/points.csv",
        "plotFile": "ai18-fixed/fusion-observed-python/plot.svg",
        "plotSHA256": "7ce9b7df6c4b7c9e96a7ff89047f20f4b18ad3bbbf84f6f9e9acb86fee64641e"
      },
      "fusion-fixed-zero": {
        "api": "fusion",
        "variant": "fusion-fixed-zero",
        "language": "python",
        "codeFile": "ai18-fixed/fusion-fixed-zero-python.py",
        "codeSHA256": "fa286558215d2dfc05fc5d498ecf08c3cae1705aa516753f2bbc12ff55b88dd3",
        "expectedFailure": false,
        "title": "Fixed-zero fusion convention",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='Fixed-zero fusion convention'\nINPUT=json.loads('{\"weights\": [\"1\", \"1\"], \"rows\": [{\"id\": \"a\", \"scores\": [\"4/5\", null]}, {\"id\": \"b\", \"scores\": [\"3/5\", \"1\"]}], \"missing\": \"fixed-zero\"}')\n\nw=list(map(F,INPUT['weights']));out=[]\nfor r in INPUT['rows']:\n mass=sum((w[i]for i,v in enumerate(r['scores'])if v is not None),F(0));num=sum((w[i]*F(v)for i,v in enumerate(r['scores'])if v is not None),F(0));den=sum(w,F(0))if INPUT['missing']=='fixed-zero'else mass;score=num/den if den else None;out.append(dict(id=r['id'],score=None if score is None else qs(score),observedWeight=qs(mass),denominator=qs(den)));summary['score:'+r['id']]='undefined'if score is None else qs(score);point('Fused score',r['id'],score)\nranked=[r['id']for _,r in sorted(enumerate(out),key=lambda z:(z[1]['score']is None,-F(z[1]['score'])if z[1]['score']is not None else F(0),z[0]))if r['score']is not None];summary['rankedIDs']='|'.join(ranked);result=dict(rows=out,rankedIDs=ranked,missingRule=INPUT['missing'])\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['label'],34)for p in points],fontsize=9);ax.invert_yaxis();ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"rankedIDs\":\"b|a\",\"score:a\":\"2/5\",\"score:b\":\"4/5\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/fusion-fixed-zero-python/stdout.txt",
        "stderrFile": "ai18-fixed/fusion-fixed-zero-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "rankedIDs",
            "value": "b|a"
          },
          {
            "metric": "score:a",
            "value": "2/5"
          },
          {
            "metric": "score:b",
            "value": "4/5"
          }
        ],
        "resultFile": "ai18-fixed/fusion-fixed-zero-python/result.json",
        "summaryFile": "ai18-fixed/fusion-fixed-zero-python/summary.json",
        "plotDataFile": "ai18-fixed/fusion-fixed-zero-python/points.csv",
        "plotFile": "ai18-fixed/fusion-fixed-zero-python/plot.svg",
        "plotSHA256": "a685a0914bccb9da76acbff0f60d532b2d152ad043bf09c1c3c2c1d670361e11"
      },
      "fusion-no-observed-weight": {
        "api": "fusion",
        "variant": "fusion-no-observed-weight",
        "language": "python",
        "codeFile": "ai18-fixed/fusion-no-observed-weight-python.py",
        "codeSHA256": "fa46515f4e2bc7552acd74ce3403c5d64d9e35ae0cb11b24ce79dea2e26fc471",
        "expectedFailure": false,
        "title": "No observed positive weight",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='No observed positive weight'\nINPUT=json.loads('{\"weights\": [\"0\", \"1\"], \"rows\": [{\"id\": \"a\", \"scores\": [\"3/4\", null]}, {\"id\": \"b\", \"scores\": [null, null]}], \"missing\": \"observed-renormalize\"}')\n\nw=list(map(F,INPUT['weights']));out=[]\nfor r in INPUT['rows']:\n mass=sum((w[i]for i,v in enumerate(r['scores'])if v is not None),F(0));num=sum((w[i]*F(v)for i,v in enumerate(r['scores'])if v is not None),F(0));den=sum(w,F(0))if INPUT['missing']=='fixed-zero'else mass;score=num/den if den else None;out.append(dict(id=r['id'],score=None if score is None else qs(score),observedWeight=qs(mass),denominator=qs(den)));summary['score:'+r['id']]='undefined'if score is None else qs(score);point('Fused score',r['id'],score)\nranked=[r['id']for _,r in sorted(enumerate(out),key=lambda z:(z[1]['score']is None,-F(z[1]['score'])if z[1]['score']is not None else F(0),z[0]))if r['score']is not None];summary['rankedIDs']='|'.join(ranked);result=dict(rows=out,rankedIDs=ranked,missingRule=INPUT['missing'])\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['label'],34)for p in points],fontsize=9);ax.set_ylim(len(points)-.5,-.5);ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"rankedIDs\":\"\",\"score:a\":\"undefined\",\"score:b\":\"undefined\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/fusion-no-observed-weight-python/stdout.txt",
        "stderrFile": "ai18-fixed/fusion-no-observed-weight-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "rankedIDs",
            "value": ""
          },
          {
            "metric": "score:a",
            "value": "undefined"
          },
          {
            "metric": "score:b",
            "value": "undefined"
          }
        ],
        "resultFile": "ai18-fixed/fusion-no-observed-weight-python/result.json",
        "summaryFile": "ai18-fixed/fusion-no-observed-weight-python/summary.json",
        "plotDataFile": "ai18-fixed/fusion-no-observed-weight-python/points.csv",
        "plotFile": "ai18-fixed/fusion-no-observed-weight-python/plot.svg",
        "plotSHA256": "22844cacea3807fd3175b07e3a5eccb6b8e330c7c91e61da29d6f543f2d989b9"
      }
    },
    "r": {
      "fusion-observed": {
        "api": "fusion",
        "variant": "fusion-observed",
        "language": "r",
        "codeFile": "ai18-fixed/fusion-observed-r.R",
        "codeSHA256": "82211cae77dd8d5ece2edb96399427c9dea637ae858a3d03a886bb8fb61e507c",
        "expectedFailure": false,
        "title": "Observed-weight fusion",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"Observed-weight fusion\"\nINPUT<-list(weights=list(\"1\",\"1\"),rows=list(list(id=\"a\",scores=list(\"4/5\",NULL)),list(id=\"b\",scores=list(\"3/5\",\"1\"))),missing=\"observed-renormalize\")\n\nw<-lapply(INPUT$weights,parseq);out<-list();scores<-list()\nfor(r in INPUT$rows){keep<-which(!vapply(r$scores,is.null,TRUE));mass<-sumq(w[keep]);num<-sumq(lapply(keep,function(i)mulq(w[[i]],parseq(r$scores[[i]]))));den<-if(INPUT$missing=='fixed-zero')sumq(w)else mass;score<-if(den$n!=0)divq(num,den)else NULL;out[[length(out)+1]]<-list(id=r$id,score=if(is.null(score))NULL else qstring(score),observedWeight=qstring(mass),denominator=qstring(den));scores[[r$id]]<-if(is.null(score))NA_real_ else score$n/score$d;summary[[paste0('score:',r$id)]]<-if(is.null(score))'undefined'else qstring(score);point('Fused score',r$id,score)}\nv<-unlist(scores);ranked<-names(v)[order(-v,seq_along(v),na.last=NA)];summary$rankedIDs<-paste(ranked,collapse='|');result<-list(rows=out,rankedIDs=as.list(ranked),missingRule=INPUT$missing)\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(p$label,width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"rankedIDs\":\"a|b\",\"score:a\":\"4/5\",\"score:b\":\"4/5\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/fusion-observed-r/stdout.txt",
        "stderrFile": "ai18-fixed/fusion-observed-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "rankedIDs",
            "value": "a|b"
          },
          {
            "metric": "score:a",
            "value": "4/5"
          },
          {
            "metric": "score:b",
            "value": "4/5"
          }
        ],
        "resultFile": "ai18-fixed/fusion-observed-r/result.json",
        "summaryFile": "ai18-fixed/fusion-observed-r/summary.json",
        "plotDataFile": "ai18-fixed/fusion-observed-r/points.csv",
        "plotFile": "ai18-fixed/fusion-observed-r/plot.svg",
        "plotSHA256": "c244515f59952b90a759b650aab52712d47db66a97ebba4fc725114473b38dd8"
      },
      "fusion-fixed-zero": {
        "api": "fusion",
        "variant": "fusion-fixed-zero",
        "language": "r",
        "codeFile": "ai18-fixed/fusion-fixed-zero-r.R",
        "codeSHA256": "f88c7dc5ce5f7abe8b5f2f2ece4ccee35d0517cd1660c9480c422ea07b56652d",
        "expectedFailure": false,
        "title": "Fixed-zero fusion convention",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"Fixed-zero fusion convention\"\nINPUT<-list(weights=list(\"1\",\"1\"),rows=list(list(id=\"a\",scores=list(\"4/5\",NULL)),list(id=\"b\",scores=list(\"3/5\",\"1\"))),missing=\"fixed-zero\")\n\nw<-lapply(INPUT$weights,parseq);out<-list();scores<-list()\nfor(r in INPUT$rows){keep<-which(!vapply(r$scores,is.null,TRUE));mass<-sumq(w[keep]);num<-sumq(lapply(keep,function(i)mulq(w[[i]],parseq(r$scores[[i]]))));den<-if(INPUT$missing=='fixed-zero')sumq(w)else mass;score<-if(den$n!=0)divq(num,den)else NULL;out[[length(out)+1]]<-list(id=r$id,score=if(is.null(score))NULL else qstring(score),observedWeight=qstring(mass),denominator=qstring(den));scores[[r$id]]<-if(is.null(score))NA_real_ else score$n/score$d;summary[[paste0('score:',r$id)]]<-if(is.null(score))'undefined'else qstring(score);point('Fused score',r$id,score)}\nv<-unlist(scores);ranked<-names(v)[order(-v,seq_along(v),na.last=NA)];summary$rankedIDs<-paste(ranked,collapse='|');result<-list(rows=out,rankedIDs=as.list(ranked),missingRule=INPUT$missing)\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(p$label,width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"rankedIDs\":\"b|a\",\"score:a\":\"2/5\",\"score:b\":\"4/5\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/fusion-fixed-zero-r/stdout.txt",
        "stderrFile": "ai18-fixed/fusion-fixed-zero-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "rankedIDs",
            "value": "b|a"
          },
          {
            "metric": "score:a",
            "value": "2/5"
          },
          {
            "metric": "score:b",
            "value": "4/5"
          }
        ],
        "resultFile": "ai18-fixed/fusion-fixed-zero-r/result.json",
        "summaryFile": "ai18-fixed/fusion-fixed-zero-r/summary.json",
        "plotDataFile": "ai18-fixed/fusion-fixed-zero-r/points.csv",
        "plotFile": "ai18-fixed/fusion-fixed-zero-r/plot.svg",
        "plotSHA256": "316573e0ef3d9eda8ae6e2d2d214a3002417679824615d487489db6535235d7c"
      },
      "fusion-no-observed-weight": {
        "api": "fusion",
        "variant": "fusion-no-observed-weight",
        "language": "r",
        "codeFile": "ai18-fixed/fusion-no-observed-weight-r.R",
        "codeSHA256": "3ea350b9ebea14278120ab070358b3ba515c7519fcb4f036902634ff6bb05b6c",
        "expectedFailure": false,
        "title": "No observed positive weight",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"No observed positive weight\"\nINPUT<-list(weights=list(\"0\",\"1\"),rows=list(list(id=\"a\",scores=list(\"3/4\",NULL)),list(id=\"b\",scores=list(NULL,NULL))),missing=\"observed-renormalize\")\n\nw<-lapply(INPUT$weights,parseq);out<-list();scores<-list()\nfor(r in INPUT$rows){keep<-which(!vapply(r$scores,is.null,TRUE));mass<-sumq(w[keep]);num<-sumq(lapply(keep,function(i)mulq(w[[i]],parseq(r$scores[[i]]))));den<-if(INPUT$missing=='fixed-zero')sumq(w)else mass;score<-if(den$n!=0)divq(num,den)else NULL;out[[length(out)+1]]<-list(id=r$id,score=if(is.null(score))NULL else qstring(score),observedWeight=qstring(mass),denominator=qstring(den));scores[[r$id]]<-if(is.null(score))NA_real_ else score$n/score$d;summary[[paste0('score:',r$id)]]<-if(is.null(score))'undefined'else qstring(score);point('Fused score',r$id,score)}\nv<-unlist(scores);ranked<-names(v)[order(-v,seq_along(v),na.last=NA)];summary$rankedIDs<-paste(ranked,collapse='|');result<-list(rows=out,rankedIDs=as.list(ranked),missingRule=INPUT$missing)\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(p$label,width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"rankedIDs\":\"\",\"score:a\":\"undefined\",\"score:b\":\"undefined\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/fusion-no-observed-weight-r/stdout.txt",
        "stderrFile": "ai18-fixed/fusion-no-observed-weight-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "rankedIDs",
            "value": ""
          },
          {
            "metric": "score:a",
            "value": "undefined"
          },
          {
            "metric": "score:b",
            "value": "undefined"
          }
        ],
        "resultFile": "ai18-fixed/fusion-no-observed-weight-r/result.json",
        "summaryFile": "ai18-fixed/fusion-no-observed-weight-r/summary.json",
        "plotDataFile": "ai18-fixed/fusion-no-observed-weight-r/points.csv",
        "plotFile": "ai18-fixed/fusion-no-observed-weight-r/plot.svg",
        "plotSHA256": "a7d1efa451d937e7c116a658fc5eee467e768b37a275ebe374e0c1b01710d643"
      }
    }
  },
  "contrastive": {
    "python": {
      "contrastive-regular": {
        "api": "contrastive",
        "variant": "contrastive-regular",
        "language": "python",
        "codeFile": "ai18-fixed/contrastive-regular-python.py",
        "codeSHA256": "fcd9192f3994eec2ab074bb41472c6e7a9cfa127f35d468a69ccf058737b021d",
        "expectedFailure": false,
        "title": "Regular rational affinities",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='Regular rational affinities'\nINPUT=json.loads('{\"affinities\": [[\"2\", \"1\"], [\"1\", \"2\"]]}')\n\nA=[[F(v)for v in row]for row in INPUT['affinities']];n=len(A);terms=[];undefined=False;infinite=False;values=[]\nfor direction in ['row','column']:\n for i in range(n):\n  den=sum(A[i],F(0))if direction=='row'else sum((A[j][i]for j in range(n)),F(0));p=A[i][i]/den if den else None;loss=None if p is None or not p else -math.log(float(p));undefined|=p is None;infinite|=p==0;terms.append(dict(direction=direction,index=i,probability=None if p is None else qs(p),lossType='undefined'if p is None else'positiveInfinity'if not p else'finite',approximateLoss=None if loss is None else f9(loss)));point(direction+' matched probability',str(i),p)\n  if loss is not None:values.append(loss)\nkind='undefined'if undefined else'positiveInfinity'if infinite else'finite';summary['meanLossType']=kind;summary['meanLoss']='undefined'if undefined else'positiveInfinity'if infinite else f9(sum(values)/(2*n));result=dict(terms=terms,meanLossType=kind,meanLoss=summary['meanLoss'],logScope='Approximate natural logs, exact rational arguments; no certified enclosure.')\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['series']+': '+p['label'],34)for p in points],fontsize=9);ax.set_ylim(len(points)-.5,-.5);ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"meanLoss\":\"0.405465108\",\"meanLossType\":\"finite\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/contrastive-regular-python/stdout.txt",
        "stderrFile": "ai18-fixed/contrastive-regular-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "meanLoss",
            "value": "0.405465108"
          },
          {
            "metric": "meanLossType",
            "value": "finite"
          }
        ],
        "resultFile": "ai18-fixed/contrastive-regular-python/result.json",
        "summaryFile": "ai18-fixed/contrastive-regular-python/summary.json",
        "plotDataFile": "ai18-fixed/contrastive-regular-python/points.csv",
        "plotFile": "ai18-fixed/contrastive-regular-python/plot.svg",
        "plotSHA256": "739f7358d7335a6576cbd52697be701e148f1942febc26fe05f24b04a8ec2a94"
      },
      "contrastive-zero-row": {
        "api": "contrastive",
        "variant": "contrastive-zero-row",
        "language": "python",
        "codeFile": "ai18-fixed/contrastive-zero-row-python.py",
        "codeSHA256": "e42b3b701dca8ecbc6ee922c16ac1f050c18c89c73d41ec4edb7bace7bbbcf34",
        "expectedFailure": false,
        "title": "Zero normalization mass",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='Zero normalization mass'\nINPUT=json.loads('{\"affinities\": [[\"0\", \"0\"], [\"1\", \"2\"]]}')\n\nA=[[F(v)for v in row]for row in INPUT['affinities']];n=len(A);terms=[];undefined=False;infinite=False;values=[]\nfor direction in ['row','column']:\n for i in range(n):\n  den=sum(A[i],F(0))if direction=='row'else sum((A[j][i]for j in range(n)),F(0));p=A[i][i]/den if den else None;loss=None if p is None or not p else -math.log(float(p));undefined|=p is None;infinite|=p==0;terms.append(dict(direction=direction,index=i,probability=None if p is None else qs(p),lossType='undefined'if p is None else'positiveInfinity'if not p else'finite',approximateLoss=None if loss is None else f9(loss)));point(direction+' matched probability',str(i),p)\n  if loss is not None:values.append(loss)\nkind='undefined'if undefined else'positiveInfinity'if infinite else'finite';summary['meanLossType']=kind;summary['meanLoss']='undefined'if undefined else'positiveInfinity'if infinite else f9(sum(values)/(2*n));result=dict(terms=terms,meanLossType=kind,meanLoss=summary['meanLoss'],logScope='Approximate natural logs, exact rational arguments; no certified enclosure.')\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['series']+': '+p['label'],34)for p in points],fontsize=9);ax.set_ylim(len(points)-.5,-.5);ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"meanLoss\":\"undefined\",\"meanLossType\":\"undefined\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/contrastive-zero-row-python/stdout.txt",
        "stderrFile": "ai18-fixed/contrastive-zero-row-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "meanLoss",
            "value": "undefined"
          },
          {
            "metric": "meanLossType",
            "value": "undefined"
          }
        ],
        "resultFile": "ai18-fixed/contrastive-zero-row-python/result.json",
        "summaryFile": "ai18-fixed/contrastive-zero-row-python/summary.json",
        "plotDataFile": "ai18-fixed/contrastive-zero-row-python/points.csv",
        "plotFile": "ai18-fixed/contrastive-zero-row-python/plot.svg",
        "plotSHA256": "43ed6dcf9a69fe781f58fc41e9764fdeffb384b89d87b71ec6ab9e1dc380ffe1"
      },
      "contrastive-zero-match": {
        "api": "contrastive",
        "variant": "contrastive-zero-match",
        "language": "python",
        "codeFile": "ai18-fixed/contrastive-zero-match-python.py",
        "codeSHA256": "8204b820641866711278a6ea0c5e312163c43090c1a6778b862f7dc6153f88af",
        "expectedFailure": false,
        "title": "Zero matched probability",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='Zero matched probability'\nINPUT=json.loads('{\"affinities\": [[\"0\", \"1\"], [\"1\", \"0\"]]}')\n\nA=[[F(v)for v in row]for row in INPUT['affinities']];n=len(A);terms=[];undefined=False;infinite=False;values=[]\nfor direction in ['row','column']:\n for i in range(n):\n  den=sum(A[i],F(0))if direction=='row'else sum((A[j][i]for j in range(n)),F(0));p=A[i][i]/den if den else None;loss=None if p is None or not p else -math.log(float(p));undefined|=p is None;infinite|=p==0;terms.append(dict(direction=direction,index=i,probability=None if p is None else qs(p),lossType='undefined'if p is None else'positiveInfinity'if not p else'finite',approximateLoss=None if loss is None else f9(loss)));point(direction+' matched probability',str(i),p)\n  if loss is not None:values.append(loss)\nkind='undefined'if undefined else'positiveInfinity'if infinite else'finite';summary['meanLossType']=kind;summary['meanLoss']='undefined'if undefined else'positiveInfinity'if infinite else f9(sum(values)/(2*n));result=dict(terms=terms,meanLossType=kind,meanLoss=summary['meanLoss'],logScope='Approximate natural logs, exact rational arguments; no certified enclosure.')\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['series'].split(' ')[0]+' '+p['label'],34)for p in points],fontsize=9);ax.set_ylim(len(points)-.5,-.5);ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"meanLoss\":\"positiveInfinity\",\"meanLossType\":\"positiveInfinity\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/contrastive-zero-match-python/stdout.txt",
        "stderrFile": "ai18-fixed/contrastive-zero-match-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "meanLoss",
            "value": "positiveInfinity"
          },
          {
            "metric": "meanLossType",
            "value": "positiveInfinity"
          }
        ],
        "resultFile": "ai18-fixed/contrastive-zero-match-python/result.json",
        "summaryFile": "ai18-fixed/contrastive-zero-match-python/summary.json",
        "plotDataFile": "ai18-fixed/contrastive-zero-match-python/points.csv",
        "plotFile": "ai18-fixed/contrastive-zero-match-python/plot.svg",
        "plotSHA256": "c20d02e7a3a6fcfea832f8c5ff461dfedf1d0a689a6c5ac861fb46e0337a305a"
      }
    },
    "r": {
      "contrastive-regular": {
        "api": "contrastive",
        "variant": "contrastive-regular",
        "language": "r",
        "codeFile": "ai18-fixed/contrastive-regular-r.R",
        "codeSHA256": "af442c4db6ce26b45a3eb63350d34448778757841d066f1a36661891371ded04",
        "expectedFailure": false,
        "title": "Regular rational affinities",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"Regular rational affinities\"\nINPUT<-list(affinities=list(list(\"2\",\"1\"),list(\"1\",\"2\")))\n\nA<-lapply(INPUT$affinities,function(row)lapply(row,parseq));n<-length(A);terms<-list();undefined<-FALSE;infinite<-FALSE;values<-numeric()\nfor(direction in c('row','column'))for(i in seq_len(n)){den<-if(direction=='row')sumq(A[[i]])else sumq(lapply(A,function(r)r[[i]]));p<-if(den$n==0)NULL else divq(A[[i]][[i]],den);loss<-if(is.null(p)||p$n==0)NULL else -log(p$n/p$d);undefined<-undefined||is.null(p);infinite<-infinite||(!is.null(p)&&p$n==0);terms[[length(terms)+1]]<-list(direction=direction,index=i-1,probability=if(is.null(p))NULL else qstring(p),lossType=if(is.null(p))'undefined'else if(p$n==0)'positiveInfinity'else'finite',approximateLoss=if(is.null(loss))NULL else f9(loss));point(paste0(direction,' matched probability'),as.character(i-1),p);if(!is.null(loss))values<-c(values,loss)}\nkind<-if(undefined)'undefined'else if(infinite)'positiveInfinity'else'finite';summary$meanLossType<-kind;summary$meanLoss<-if(undefined)'undefined'else if(infinite)'positiveInfinity'else f9(sum(values)/(2*n));result<-list(terms=terms,meanLossType=kind,meanLoss=summary$meanLoss,logScope='Approximate natural logs, exact rational arguments; no certified enclosure.')\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(paste0(p$series,': ',p$label),width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"meanLoss\":\"0.405465108\",\"meanLossType\":\"finite\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/contrastive-regular-r/stdout.txt",
        "stderrFile": "ai18-fixed/contrastive-regular-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "meanLoss",
            "value": "0.405465108"
          },
          {
            "metric": "meanLossType",
            "value": "finite"
          }
        ],
        "resultFile": "ai18-fixed/contrastive-regular-r/result.json",
        "summaryFile": "ai18-fixed/contrastive-regular-r/summary.json",
        "plotDataFile": "ai18-fixed/contrastive-regular-r/points.csv",
        "plotFile": "ai18-fixed/contrastive-regular-r/plot.svg",
        "plotSHA256": "6fea4f4c08d92a7eca3ca7c55bbb82af76f6bc4b37ae9d891198859428e8a306"
      },
      "contrastive-zero-row": {
        "api": "contrastive",
        "variant": "contrastive-zero-row",
        "language": "r",
        "codeFile": "ai18-fixed/contrastive-zero-row-r.R",
        "codeSHA256": "cca81b86b87f700c2fb401d418db744951b825e32d9dffc8c1096db0d76e3c4c",
        "expectedFailure": false,
        "title": "Zero normalization mass",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"Zero normalization mass\"\nINPUT<-list(affinities=list(list(\"0\",\"0\"),list(\"1\",\"2\")))\n\nA<-lapply(INPUT$affinities,function(row)lapply(row,parseq));n<-length(A);terms<-list();undefined<-FALSE;infinite<-FALSE;values<-numeric()\nfor(direction in c('row','column'))for(i in seq_len(n)){den<-if(direction=='row')sumq(A[[i]])else sumq(lapply(A,function(r)r[[i]]));p<-if(den$n==0)NULL else divq(A[[i]][[i]],den);loss<-if(is.null(p)||p$n==0)NULL else -log(p$n/p$d);undefined<-undefined||is.null(p);infinite<-infinite||(!is.null(p)&&p$n==0);terms[[length(terms)+1]]<-list(direction=direction,index=i-1,probability=if(is.null(p))NULL else qstring(p),lossType=if(is.null(p))'undefined'else if(p$n==0)'positiveInfinity'else'finite',approximateLoss=if(is.null(loss))NULL else f9(loss));point(paste0(direction,' matched probability'),as.character(i-1),p);if(!is.null(loss))values<-c(values,loss)}\nkind<-if(undefined)'undefined'else if(infinite)'positiveInfinity'else'finite';summary$meanLossType<-kind;summary$meanLoss<-if(undefined)'undefined'else if(infinite)'positiveInfinity'else f9(sum(values)/(2*n));result<-list(terms=terms,meanLossType=kind,meanLoss=summary$meanLoss,logScope='Approximate natural logs, exact rational arguments; no certified enclosure.')\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(paste0(p$series,': ',p$label),width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"meanLoss\":\"undefined\",\"meanLossType\":\"undefined\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/contrastive-zero-row-r/stdout.txt",
        "stderrFile": "ai18-fixed/contrastive-zero-row-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "meanLoss",
            "value": "undefined"
          },
          {
            "metric": "meanLossType",
            "value": "undefined"
          }
        ],
        "resultFile": "ai18-fixed/contrastive-zero-row-r/result.json",
        "summaryFile": "ai18-fixed/contrastive-zero-row-r/summary.json",
        "plotDataFile": "ai18-fixed/contrastive-zero-row-r/points.csv",
        "plotFile": "ai18-fixed/contrastive-zero-row-r/plot.svg",
        "plotSHA256": "e47f0cc4cce9b814536158dbec9220800c285fc159fd1c7c3ff71164a520a055"
      },
      "contrastive-zero-match": {
        "api": "contrastive",
        "variant": "contrastive-zero-match",
        "language": "r",
        "codeFile": "ai18-fixed/contrastive-zero-match-r.R",
        "codeSHA256": "522dcd52b87336047e659a82cd08246fbcd7e69cac1dc6cffff294b21acf7602",
        "expectedFailure": false,
        "title": "Zero matched probability",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"Zero matched probability\"\nINPUT<-list(affinities=list(list(\"0\",\"1\"),list(\"1\",\"0\")))\n\nA<-lapply(INPUT$affinities,function(row)lapply(row,parseq));n<-length(A);terms<-list();undefined<-FALSE;infinite<-FALSE;values<-numeric()\nfor(direction in c('row','column'))for(i in seq_len(n)){den<-if(direction=='row')sumq(A[[i]])else sumq(lapply(A,function(r)r[[i]]));p<-if(den$n==0)NULL else divq(A[[i]][[i]],den);loss<-if(is.null(p)||p$n==0)NULL else -log(p$n/p$d);undefined<-undefined||is.null(p);infinite<-infinite||(!is.null(p)&&p$n==0);terms[[length(terms)+1]]<-list(direction=direction,index=i-1,probability=if(is.null(p))NULL else qstring(p),lossType=if(is.null(p))'undefined'else if(p$n==0)'positiveInfinity'else'finite',approximateLoss=if(is.null(loss))NULL else f9(loss));point(paste0(direction,' matched probability'),as.character(i-1),p);if(!is.null(loss))values<-c(values,loss)}\nkind<-if(undefined)'undefined'else if(infinite)'positiveInfinity'else'finite';summary$meanLossType<-kind;summary$meanLoss<-if(undefined)'undefined'else if(infinite)'positiveInfinity'else f9(sum(values)/(2*n));result<-list(terms=terms,meanLossType=kind,meanLoss=summary$meanLoss,logScope='Approximate natural logs, exact rational arguments; no certified enclosure.')\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(paste0(sub(' .*','',p$series),' ',p$label),width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"meanLoss\":\"positiveInfinity\",\"meanLossType\":\"positiveInfinity\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/contrastive-zero-match-r/stdout.txt",
        "stderrFile": "ai18-fixed/contrastive-zero-match-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "meanLoss",
            "value": "positiveInfinity"
          },
          {
            "metric": "meanLossType",
            "value": "positiveInfinity"
          }
        ],
        "resultFile": "ai18-fixed/contrastive-zero-match-r/result.json",
        "summaryFile": "ai18-fixed/contrastive-zero-match-r/summary.json",
        "plotDataFile": "ai18-fixed/contrastive-zero-match-r/points.csv",
        "plotFile": "ai18-fixed/contrastive-zero-match-r/plot.svg",
        "plotSHA256": "5a7c2d912a30e2d6b7f0f61af6d7047c8d8633d25cdae982e3c4126fbf0a76ae"
      }
    }
  },
  "provenance": {
    "python": {
      "provenance-complete": {
        "api": "provenance",
        "variant": "provenance-complete",
        "language": "python",
        "codeFile": "ai18-fixed/provenance-complete-python.py",
        "codeSHA256": "15418803e214b2d838dc83f65c863c977a532914e1d0aece837b08c0f58b68af",
        "expectedFailure": false,
        "title": "Complete declared ancestry",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='Complete declared ancestry'\nINPUT=json.loads('{\"artifacts\": [{\"id\": \"raw\", \"content\": \"abc\", \"parents\": []}, {\"id\": \"caption\", \"content\": \"Measured counts only.\", \"parents\": [\"raw\"]}]}')\n\nrows=INPUT['artifacts'];by={r['id']:r for r in rows};color={};order=[];computed={}\ndef visit(id):\n if color.get(id)==1:raise ValueError('cyclic-provenance-graph')\n if color.get(id)==2 or id not in by:return\n color[id]=1\n for p in by[id]['parents']:visit(p)\n color[id]=2;order.append(id)\nfor r in rows:visit(r['id'])\nfor id in order:\n r=by[id];digest=hashlib.sha256(r['content'].encode('utf8')).hexdigest();parents=[dict(id=p,derivedDigest=computed[p]['derivedDigest']if p in computed else None)for p in r['parents']];canonical=json.dumps(dict(contentHash=digest,parents=parents),separators=(',',':'));complete=all(p in computed and computed[p]['complete']for p in r['parents']);computed[id]=dict(id=id,contentHash=digest,derivedDigest=hashlib.sha256(canonical.encode()).hexdigest(),complete=complete,missingParents=[p for p in r['parents']if p not in by]);summary['complete:'+id]=str(complete).lower();point('Declared ancestry complete',id,F(int(complete)))\nsummary['topologicalOrder']='|'.join(order);summary['targetDerivedDigest']=computed[rows[-1]['id']]['derivedDigest'];result=dict(artifacts=[computed[r['id']]for r in rows],order=order,signatureVerified=False,factualTruthEstablished=False)\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['label'],34)for p in points],fontsize=9);ax.invert_yaxis();ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"complete:caption\":\"true\",\"complete:raw\":\"true\",\"targetDerivedDigest\":\"dbbfe7ed165ca54bb93f326d4af37504f4a99b52615a7c534dcfb5df8cbd6695\",\"topologicalOrder\":\"raw|caption\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/provenance-complete-python/stdout.txt",
        "stderrFile": "ai18-fixed/provenance-complete-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "complete:caption",
            "value": "true"
          },
          {
            "metric": "complete:raw",
            "value": "true"
          },
          {
            "metric": "targetDerivedDigest",
            "value": "dbbfe7ed165ca54bb93f326d4af37504f4a99b52615a7c534dcfb5df8cbd6695"
          },
          {
            "metric": "topologicalOrder",
            "value": "raw|caption"
          }
        ],
        "resultFile": "ai18-fixed/provenance-complete-python/result.json",
        "summaryFile": "ai18-fixed/provenance-complete-python/summary.json",
        "plotDataFile": "ai18-fixed/provenance-complete-python/points.csv",
        "plotFile": "ai18-fixed/provenance-complete-python/plot.svg",
        "plotSHA256": "bd8815e1e7378ff2384bfdfd4f9cfe01dc2af2409b72abc3570c11753c369f51"
      },
      "provenance-missing": {
        "api": "provenance",
        "variant": "provenance-missing",
        "language": "python",
        "codeFile": "ai18-fixed/provenance-missing-python.py",
        "codeSHA256": "4a1f70800228239c94ff927c46ea5e64df3d0927da3ec8cc6c0dc9ce6d9e6b6a",
        "expectedFailure": false,
        "title": "Missing declared parent",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='Missing declared parent'\nINPUT=json.loads('{\"artifacts\": [{\"id\": \"caption\", \"content\": \"Measured counts only.\", \"parents\": [\"not-supplied\"]}]}')\n\nrows=INPUT['artifacts'];by={r['id']:r for r in rows};color={};order=[];computed={}\ndef visit(id):\n if color.get(id)==1:raise ValueError('cyclic-provenance-graph')\n if color.get(id)==2 or id not in by:return\n color[id]=1\n for p in by[id]['parents']:visit(p)\n color[id]=2;order.append(id)\nfor r in rows:visit(r['id'])\nfor id in order:\n r=by[id];digest=hashlib.sha256(r['content'].encode('utf8')).hexdigest();parents=[dict(id=p,derivedDigest=computed[p]['derivedDigest']if p in computed else None)for p in r['parents']];canonical=json.dumps(dict(contentHash=digest,parents=parents),separators=(',',':'));complete=all(p in computed and computed[p]['complete']for p in r['parents']);computed[id]=dict(id=id,contentHash=digest,derivedDigest=hashlib.sha256(canonical.encode()).hexdigest(),complete=complete,missingParents=[p for p in r['parents']if p not in by]);summary['complete:'+id]=str(complete).lower();point('Declared ancestry complete',id,F(int(complete)))\nsummary['topologicalOrder']='|'.join(order);summary['targetDerivedDigest']=computed[rows[-1]['id']]['derivedDigest'];result=dict(artifacts=[computed[r['id']]for r in rows],order=order,signatureVerified=False,factualTruthEstablished=False)\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['label'],34)for p in points],fontsize=9);ax.invert_yaxis();ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"complete:caption\":\"false\",\"targetDerivedDigest\":\"4195ca3b5d2c6ee8473c1c4a756af7bc92b4fa86e463e6421fc0e44a9cf80ded\",\"topologicalOrder\":\"caption\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/provenance-missing-python/stdout.txt",
        "stderrFile": "ai18-fixed/provenance-missing-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "complete:caption",
            "value": "false"
          },
          {
            "metric": "targetDerivedDigest",
            "value": "4195ca3b5d2c6ee8473c1c4a756af7bc92b4fa86e463e6421fc0e44a9cf80ded"
          },
          {
            "metric": "topologicalOrder",
            "value": "caption"
          }
        ],
        "resultFile": "ai18-fixed/provenance-missing-python/result.json",
        "summaryFile": "ai18-fixed/provenance-missing-python/summary.json",
        "plotDataFile": "ai18-fixed/provenance-missing-python/points.csv",
        "plotFile": "ai18-fixed/provenance-missing-python/plot.svg",
        "plotSHA256": "64b1c3120fa7eb42ab6f3ccfc334cf6557c9545de08688f9aeb3b1214fad6e0b"
      },
      "provenance-cycle-rejected": {
        "api": "provenance",
        "variant": "provenance-cycle-rejected",
        "language": "python",
        "codeFile": "ai18-fixed/provenance-cycle-rejected-python.py",
        "codeSHA256": "86df5bac2ffeccfdecb0a2f67d70527492b6ffab54b59b760897310a4d32c398",
        "expectedFailure": true,
        "title": "A provenance cycle is rejected",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='A provenance cycle is rejected'\nINPUT=json.loads('{\"artifacts\": [{\"id\": \"a\", \"content\": \"A\", \"parents\": [\"b\"]}, {\"id\": \"b\", \"content\": \"B\", \"parents\": [\"a\"]}]}')\n\nrows=INPUT['artifacts'];by={r['id']:r for r in rows};color={};order=[];computed={}\ndef visit(id):\n if color.get(id)==1:raise ValueError('cyclic-provenance-graph')\n if color.get(id)==2 or id not in by:return\n color[id]=1\n for p in by[id]['parents']:visit(p)\n color[id]=2;order.append(id)\nfor r in rows:visit(r['id'])\nfor id in order:\n r=by[id];digest=hashlib.sha256(r['content'].encode('utf8')).hexdigest();parents=[dict(id=p,derivedDigest=computed[p]['derivedDigest']if p in computed else None)for p in r['parents']];canonical=json.dumps(dict(contentHash=digest,parents=parents),separators=(',',':'));complete=all(p in computed and computed[p]['complete']for p in r['parents']);computed[id]=dict(id=id,contentHash=digest,derivedDigest=hashlib.sha256(canonical.encode()).hexdigest(),complete=complete,missingParents=[p for p in r['parents']if p not in by]);summary['complete:'+id]=str(complete).lower();point('Declared ancestry complete',id,F(int(complete)))\nsummary['topologicalOrder']='|'.join(order);summary['targetDerivedDigest']=computed[rows[-1]['id']]['derivedDigest'];result=dict(artifacts=[computed[r['id']]for r in rows],order=order,signatureVerified=False,factualTruthEstablished=False)\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['label'],34)for p in points],fontsize=9);ax.invert_yaxis();ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 1,
        "stdout": "",
        "stderr": "ValueError: cyclic-provenance-graph",
        "stderrIsProjection": true,
        "rawStderrSHA256": "9312e74ee2b775c430a79b7b3fd9a1d9362d7bd32fe923240caa788f1e017915",
        "stdoutFile": "ai18-fixed/provenance-cycle-rejected-python/stdout.txt",
        "stderrFile": "ai18-fixed/provenance-cycle-rejected-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": []
      }
    },
    "r": {
      "provenance-complete": {
        "api": "provenance",
        "variant": "provenance-complete",
        "language": "r",
        "codeFile": "ai18-fixed/provenance-complete-r.R",
        "codeSHA256": "3a373f4a5adaa89fd2597f48cc53173ce1e8890838af9198d5804ff956c8c976",
        "expectedFailure": false,
        "title": "Complete declared ancestry",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"Complete declared ancestry\"\nINPUT<-list(artifacts=list(list(id=\"raw\",content=\"abc\",parents=list()),list(id=\"caption\",content=\"Measured counts only.\",parents=list(\"raw\"))))\n\nrows<-INPUT$artifacts;by<-setNames(rows,vapply(rows,function(r)r$id,''));color<-new.env();order<-character();computed<-list()\nvisit<-function(id){c<-if(exists(id,envir=color,inherits=FALSE))get(id,envir=color)else 0;if(c==1)stop('cyclic-provenance-graph');if(c==2||is.null(by[[id]]))return();assign(id,1,envir=color);for(p in by[[id]]$parents)visit(p);assign(id,2,envir=color);order<<-c(order,id)}\nfor(r in rows)visit(r$id)\nfor(id in order){r<-by[[id]];digest<-shaBatch(r$content);parents<-lapply(r$parents,function(p)list(id=p,derivedDigest=if(is.null(computed[[p]]))NULL else computed[[p]]$derivedDigest));canonical<-J(list(contentHash=digest,parents=parents));complete<-all(vapply(r$parents,function(p)!is.null(computed[[p]])&&computed[[p]]$complete,TRUE));computed[[id]]<-list(id=id,contentHash=digest,derivedDigest=shaBatch(canonical),complete=complete,missingParents=as.list(Filter(function(p)is.null(by[[p]]),r$parents)));summary[[paste0('complete:',id)]]<-B(complete);point('Declared ancestry complete',id,Q(as.numeric(complete)))}\nsummary$topologicalOrder<-paste(order,collapse='|');summary$targetDerivedDigest<-computed[[tail(rows,1)[[1]]$id]]$derivedDigest;result<-list(artifacts=lapply(rows,function(r)computed[[r$id]]),order=as.list(order),signatureVerified=FALSE,factualTruthEstablished=FALSE)\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(p$label,width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"complete:caption\":\"true\",\"complete:raw\":\"true\",\"targetDerivedDigest\":\"dbbfe7ed165ca54bb93f326d4af37504f4a99b52615a7c534dcfb5df8cbd6695\",\"topologicalOrder\":\"raw|caption\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/provenance-complete-r/stdout.txt",
        "stderrFile": "ai18-fixed/provenance-complete-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "complete:caption",
            "value": "true"
          },
          {
            "metric": "complete:raw",
            "value": "true"
          },
          {
            "metric": "targetDerivedDigest",
            "value": "dbbfe7ed165ca54bb93f326d4af37504f4a99b52615a7c534dcfb5df8cbd6695"
          },
          {
            "metric": "topologicalOrder",
            "value": "raw|caption"
          }
        ],
        "resultFile": "ai18-fixed/provenance-complete-r/result.json",
        "summaryFile": "ai18-fixed/provenance-complete-r/summary.json",
        "plotDataFile": "ai18-fixed/provenance-complete-r/points.csv",
        "plotFile": "ai18-fixed/provenance-complete-r/plot.svg",
        "plotSHA256": "eb519fcf05224a94083fb2806d3bde46d7448a6a59832e988d050a865b092525"
      },
      "provenance-missing": {
        "api": "provenance",
        "variant": "provenance-missing",
        "language": "r",
        "codeFile": "ai18-fixed/provenance-missing-r.R",
        "codeSHA256": "50af8c2b69b98a11fba56e1234d2e41501fdd6b3e4d44e7ce6e236a433bfa901",
        "expectedFailure": false,
        "title": "Missing declared parent",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"Missing declared parent\"\nINPUT<-list(artifacts=list(list(id=\"caption\",content=\"Measured counts only.\",parents=list(\"not-supplied\"))))\n\nrows<-INPUT$artifacts;by<-setNames(rows,vapply(rows,function(r)r$id,''));color<-new.env();order<-character();computed<-list()\nvisit<-function(id){c<-if(exists(id,envir=color,inherits=FALSE))get(id,envir=color)else 0;if(c==1)stop('cyclic-provenance-graph');if(c==2||is.null(by[[id]]))return();assign(id,1,envir=color);for(p in by[[id]]$parents)visit(p);assign(id,2,envir=color);order<<-c(order,id)}\nfor(r in rows)visit(r$id)\nfor(id in order){r<-by[[id]];digest<-shaBatch(r$content);parents<-lapply(r$parents,function(p)list(id=p,derivedDigest=if(is.null(computed[[p]]))NULL else computed[[p]]$derivedDigest));canonical<-J(list(contentHash=digest,parents=parents));complete<-all(vapply(r$parents,function(p)!is.null(computed[[p]])&&computed[[p]]$complete,TRUE));computed[[id]]<-list(id=id,contentHash=digest,derivedDigest=shaBatch(canonical),complete=complete,missingParents=as.list(Filter(function(p)is.null(by[[p]]),r$parents)));summary[[paste0('complete:',id)]]<-B(complete);point('Declared ancestry complete',id,Q(as.numeric(complete)))}\nsummary$topologicalOrder<-paste(order,collapse='|');summary$targetDerivedDigest<-computed[[tail(rows,1)[[1]]$id]]$derivedDigest;result<-list(artifacts=lapply(rows,function(r)computed[[r$id]]),order=as.list(order),signatureVerified=FALSE,factualTruthEstablished=FALSE)\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(p$label,width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"complete:caption\":\"false\",\"targetDerivedDigest\":\"4195ca3b5d2c6ee8473c1c4a756af7bc92b4fa86e463e6421fc0e44a9cf80ded\",\"topologicalOrder\":\"caption\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/provenance-missing-r/stdout.txt",
        "stderrFile": "ai18-fixed/provenance-missing-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "complete:caption",
            "value": "false"
          },
          {
            "metric": "targetDerivedDigest",
            "value": "4195ca3b5d2c6ee8473c1c4a756af7bc92b4fa86e463e6421fc0e44a9cf80ded"
          },
          {
            "metric": "topologicalOrder",
            "value": "caption"
          }
        ],
        "resultFile": "ai18-fixed/provenance-missing-r/result.json",
        "summaryFile": "ai18-fixed/provenance-missing-r/summary.json",
        "plotDataFile": "ai18-fixed/provenance-missing-r/points.csv",
        "plotFile": "ai18-fixed/provenance-missing-r/plot.svg",
        "plotSHA256": "64ed48f64fc8f569f3dc998e9014b234e98ae465661a5c59aa1b051d7c148a07"
      },
      "provenance-cycle-rejected": {
        "api": "provenance",
        "variant": "provenance-cycle-rejected",
        "language": "r",
        "codeFile": "ai18-fixed/provenance-cycle-rejected-r.R",
        "codeSHA256": "20b60621b0872f32d9e89ac225a1fcea7796b5f126385b283b162f1a9e8ff2ab",
        "expectedFailure": true,
        "title": "A provenance cycle is rejected",
        "code": "# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"A provenance cycle is rejected\"\nINPUT<-list(artifacts=list(list(id=\"a\",content=\"A\",parents=list(\"b\")),list(id=\"b\",content=\"B\",parents=list(\"a\"))))\n\nrows<-INPUT$artifacts;by<-setNames(rows,vapply(rows,function(r)r$id,''));color<-new.env();order<-character();computed<-list()\nvisit<-function(id){c<-if(exists(id,envir=color,inherits=FALSE))get(id,envir=color)else 0;if(c==1)stop('cyclic-provenance-graph');if(c==2||is.null(by[[id]]))return();assign(id,1,envir=color);for(p in by[[id]]$parents)visit(p);assign(id,2,envir=color);order<<-c(order,id)}\nfor(r in rows)visit(r$id)\nfor(id in order){r<-by[[id]];digest<-shaBatch(r$content);parents<-lapply(r$parents,function(p)list(id=p,derivedDigest=if(is.null(computed[[p]]))NULL else computed[[p]]$derivedDigest));canonical<-J(list(contentHash=digest,parents=parents));complete<-all(vapply(r$parents,function(p)!is.null(computed[[p]])&&computed[[p]]$complete,TRUE));computed[[id]]<-list(id=id,contentHash=digest,derivedDigest=shaBatch(canonical),complete=complete,missingParents=as.list(Filter(function(p)is.null(by[[p]]),r$parents)));summary[[paste0('complete:',id)]]<-B(complete);point('Declared ancestry complete',id,Q(as.numeric(complete)))}\nsummary$topologicalOrder<-paste(order,collapse='|');summary$targetDerivedDigest<-computed[[tail(rows,1)[[1]]$id]]$derivedDigest;result<-list(artifacts=lapply(rows,function(r)computed[[r$id]]),order=as.list(order),signatureVerified=FALSE,factualTruthEstablished=FALSE)\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(p$label,width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 1,
        "stdout": "",
        "stderr": "Error in visit(p) : cyclic-provenance-graph",
        "stderrIsProjection": true,
        "rawStderrSHA256": "7e108fdf616eec43f24ec6546a96c18defaf45ead32b657e7e04be44223c6944",
        "stdoutFile": "ai18-fixed/provenance-cycle-rejected-r/stdout.txt",
        "stderrFile": "ai18-fixed/provenance-cycle-rejected-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": []
      }
    }
  },
  "duplicates": {
    "python": {
      "duplicate-chain": {
        "api": "duplicates",
        "variant": "duplicate-chain",
        "language": "python",
        "codeFile": "ai18-fixed/duplicate-chain-python.py",
        "codeSHA256": "f24dd7b6c4cccf1b736b4a997c4bec4e704b73861369dee76b630020000b5472",
        "expectedFailure": false,
        "title": "Connected component is not a clique",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='Connected component is not a clique'\nINPUT=json.loads('{\"radius\": 1, \"records\": [{\"id\": \"a\", \"bits\": \"000\", \"role\": \"train\"}, {\"id\": \"b\", \"bits\": \"001\", \"role\": \"validation\"}, {\"id\": \"c\", \"bits\": \"011\", \"role\": \"test\"}]}')\n\nrows=INPUT['records'];n=len(rows);parent=list(range(n));edges=[]\ndef root(i):\n while parent[i]!=i:i=parent[i]\n return i\nfor i in range(n):\n for j in range(i+1,n):\n  d=sum(a!=b for a,b in zip(rows[i]['bits'],rows[j]['bits']));point('Hamming distance',rows[i]['id']+'–'+rows[j]['id'],F(d))\n  if d<=INPUT['radius']:edges.append(dict(left=rows[i]['id'],right=rows[j]['id'],distance=d));a,b=root(i),root(j);parent[max(a,b)]=min(a,b)\ngroups={}\nfor i,r in enumerate(rows):groups.setdefault(root(i),[]).append(r['id'])\nsummary=dict(edges=str(len(edges)),components=str(len(groups)),endpointDistance=str(sum(a!=b for a,b in zip(rows[0]['bits'],rows[-1]['bits']))));result=dict(edges=edges,components=list(groups.values()),noAutomaticDeletion=True)\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['label'],34)for p in points],fontsize=9);ax.invert_yaxis();ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"components\":\"1\",\"edges\":\"2\",\"endpointDistance\":\"2\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/duplicate-chain-python/stdout.txt",
        "stderrFile": "ai18-fixed/duplicate-chain-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "components",
            "value": "1"
          },
          {
            "metric": "edges",
            "value": "2"
          },
          {
            "metric": "endpointDistance",
            "value": "2"
          }
        ],
        "resultFile": "ai18-fixed/duplicate-chain-python/result.json",
        "summaryFile": "ai18-fixed/duplicate-chain-python/summary.json",
        "plotDataFile": "ai18-fixed/duplicate-chain-python/points.csv",
        "plotFile": "ai18-fixed/duplicate-chain-python/plot.svg",
        "plotSHA256": "7e27bc0c3dc1dc29a2d7c6a31ba6d9fac42b3fbc715a1a56e7009907f15e15ec"
      }
    },
    "r": {
      "duplicate-chain": {
        "api": "duplicates",
        "variant": "duplicate-chain",
        "language": "r",
        "codeFile": "ai18-fixed/duplicate-chain-r.R",
        "codeSHA256": "25be5fe13faff79c6fc7f69df1c34b394c59cb1e9cee9f16e3d265e04573bf23",
        "expectedFailure": false,
        "title": "Connected component is not a clique",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"Connected component is not a clique\"\nINPUT<-list(radius=1,records=list(list(id=\"a\",bits=\"000\",role=\"train\"),list(id=\"b\",bits=\"001\",role=\"validation\"),list(id=\"c\",bits=\"011\",role=\"test\")))\n\nrows<-INPUT$records;n<-length(rows);parent<-seq_len(n);edges<-list();root<-function(i){while(parent[i]!=i)i<-parent[i];i}\nfor(i in seq_len(n))if(i<n)for(j in (i+1):n){d<-sum(strsplit(rows[[i]]$bits,'')[[1]]!=strsplit(rows[[j]]$bits,'')[[1]]);point('Hamming distance',paste0(rows[[i]]$id,'\\u2013',rows[[j]]$id),Q(d));if(d<=INPUT$radius){edges[[length(edges)+1]]<-list(left=rows[[i]]$id,right=rows[[j]]$id,distance=d);a<-root(i);b<-root(j);parent[max(a,b)]<-min(a,b)}}\ngroups<-list();for(i in seq_len(n)){key<-as.character(root(i));groups[[key]]<-c(groups[[key]],list(rows[[i]]$id))};summary<-list(edges=as.character(length(edges)),components=as.character(length(groups)),endpointDistance=as.character(sum(strsplit(rows[[1]]$bits,'')[[1]]!=strsplit(rows[[n]]$bits,'')[[1]])));result<-list(edges=edges,components=unname(groups),noAutomaticDeletion=TRUE)\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(p$label,width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"components\":\"1\",\"edges\":\"2\",\"endpointDistance\":\"2\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/duplicate-chain-r/stdout.txt",
        "stderrFile": "ai18-fixed/duplicate-chain-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "components",
            "value": "1"
          },
          {
            "metric": "edges",
            "value": "2"
          },
          {
            "metric": "endpointDistance",
            "value": "2"
          }
        ],
        "resultFile": "ai18-fixed/duplicate-chain-r/result.json",
        "summaryFile": "ai18-fixed/duplicate-chain-r/summary.json",
        "plotDataFile": "ai18-fixed/duplicate-chain-r/points.csv",
        "plotFile": "ai18-fixed/duplicate-chain-r/plot.svg",
        "plotSHA256": "03b8770cb4aa26ec21c5fffbb98c357f7c67bc37963029736b3eb30ef3c6981d"
      }
    }
  },
  "leakage": {
    "python": {
      "leakage-declared-dirty": {
        "api": "leakage",
        "variant": "leakage-declared-dirty",
        "language": "python",
        "codeFile": "ai18-fixed/leakage-declared-dirty-python.py",
        "codeSHA256": "1bff00c31e9b7412ca7b9ad5147c0e019e95ba49965eed64b5fe4669cb9ffec8",
        "expectedFailure": false,
        "title": "Declared target and split leakage",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='Declared target and split leakage'\nINPUT=json.loads('{\"records\": [{\"id\": \"a\", \"role\": \"train\", \"originalGroup\": \"same\", \"duplicateComponent\": \"near\", \"featureFromTarget\": false}, {\"id\": \"b\", \"role\": \"test\", \"originalGroup\": \"same\", \"duplicateComponent\": \"near\", \"featureFromTarget\": true}], \"fitUsing\": [\"train\", \"test\"], \"selectionUsing\": [\"validation\", \"test\"]}')\n\nrs=INPUT['records'];issues=[]\nif 'test'in INPUT['fitUsing']:issues.append('test-role-used-for-fitting')\nif 'test'in INPUT['selectionUsing']:issues.append('test-role-used-for-selection')\nif any(r.get('featureFromTarget',False)for r in rs):issues.append('target-derived-feature-present')\nfor key,label in [('originalGroup','original-group-crosses-splits'),('duplicateComponent','declared-duplicate-component-crosses-splits')]:\n groups={}\n for r in rs:\n  if key in r:groups.setdefault(r[key],set()).add(r['role'])\n if any(len(v)>1 for v in groups.values()):issues.append(label)\nsummary=dict(issueCount=str(len(issues)),clearWithinDeclaredLineage=str(not issues).lower(),issues='|'.join(issues));result=dict(issues=issues,universalCleanlinessCertified=False)\nfor key in ['test-role-used-for-fitting','test-role-used-for-selection','target-derived-feature-present','original-group-crosses-splits','declared-duplicate-component-crosses-splits']:point('Declared issue',key,F(int(key in issues)))\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['label'],34)for p in points],fontsize=9);ax.invert_yaxis();ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"clearWithinDeclaredLineage\":\"false\",\"issueCount\":\"5\",\"issues\":\"test-role-used-for-fitting|test-role-used-for-selection|target-derived-feature-present|original-group-crosses-splits|declared-duplicate-component-crosses-splits\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/leakage-declared-dirty-python/stdout.txt",
        "stderrFile": "ai18-fixed/leakage-declared-dirty-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "clearWithinDeclaredLineage",
            "value": "false"
          },
          {
            "metric": "issueCount",
            "value": "5"
          },
          {
            "metric": "issues",
            "value": "test-role-used-for-fitting|test-role-used-for-selection|target-derived-feature-present|original-group-crosses-splits|declared-duplicate-component-crosses-splits"
          }
        ],
        "resultFile": "ai18-fixed/leakage-declared-dirty-python/result.json",
        "summaryFile": "ai18-fixed/leakage-declared-dirty-python/summary.json",
        "plotDataFile": "ai18-fixed/leakage-declared-dirty-python/points.csv",
        "plotFile": "ai18-fixed/leakage-declared-dirty-python/plot.svg",
        "plotSHA256": "d3f69266d1c2a552cfc7e329010fde59967138ec8728d52c005cbd82c28ad6dd"
      },
      "leakage-declared-clear": {
        "api": "leakage",
        "variant": "leakage-declared-clear",
        "language": "python",
        "codeFile": "ai18-fixed/leakage-declared-clear-python.py",
        "codeSHA256": "377c4d6ff78fe78f8af7641082bc9640484c57abf6ac77a8de535a6c35c23a41",
        "expectedFailure": false,
        "title": "Clear only within declared lineage",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='Clear only within declared lineage'\nINPUT=json.loads('{\"records\": [{\"id\": \"a\", \"role\": \"train\", \"originalGroup\": \"a\", \"featureFromTarget\": false}, {\"id\": \"b\", \"role\": \"test\", \"originalGroup\": \"b\", \"featureFromTarget\": false}], \"fitUsing\": [\"train\"], \"selectionUsing\": [\"validation\"]}')\n\nrs=INPUT['records'];issues=[]\nif 'test'in INPUT['fitUsing']:issues.append('test-role-used-for-fitting')\nif 'test'in INPUT['selectionUsing']:issues.append('test-role-used-for-selection')\nif any(r.get('featureFromTarget',False)for r in rs):issues.append('target-derived-feature-present')\nfor key,label in [('originalGroup','original-group-crosses-splits'),('duplicateComponent','declared-duplicate-component-crosses-splits')]:\n groups={}\n for r in rs:\n  if key in r:groups.setdefault(r[key],set()).add(r['role'])\n if any(len(v)>1 for v in groups.values()):issues.append(label)\nsummary=dict(issueCount=str(len(issues)),clearWithinDeclaredLineage=str(not issues).lower(),issues='|'.join(issues));result=dict(issues=issues,universalCleanlinessCertified=False)\nfor key in ['test-role-used-for-fitting','test-role-used-for-selection','target-derived-feature-present','original-group-crosses-splits','declared-duplicate-component-crosses-splits']:point('Declared issue',key,F(int(key in issues)))\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['label'],34)for p in points],fontsize=9);ax.invert_yaxis();ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"clearWithinDeclaredLineage\":\"true\",\"issueCount\":\"0\",\"issues\":\"\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/leakage-declared-clear-python/stdout.txt",
        "stderrFile": "ai18-fixed/leakage-declared-clear-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "clearWithinDeclaredLineage",
            "value": "true"
          },
          {
            "metric": "issueCount",
            "value": "0"
          },
          {
            "metric": "issues",
            "value": ""
          }
        ],
        "resultFile": "ai18-fixed/leakage-declared-clear-python/result.json",
        "summaryFile": "ai18-fixed/leakage-declared-clear-python/summary.json",
        "plotDataFile": "ai18-fixed/leakage-declared-clear-python/points.csv",
        "plotFile": "ai18-fixed/leakage-declared-clear-python/plot.svg",
        "plotSHA256": "e40c40357733979e862176d036cbef642266b1275a28a2be323ab0d4f4e3caad"
      }
    },
    "r": {
      "leakage-declared-dirty": {
        "api": "leakage",
        "variant": "leakage-declared-dirty",
        "language": "r",
        "codeFile": "ai18-fixed/leakage-declared-dirty-r.R",
        "codeSHA256": "b7319ceacb57c6c507cdfbbbe0471f21444180c74d143ae20567e8cd0bea901c",
        "expectedFailure": false,
        "title": "Declared target and split leakage",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"Declared target and split leakage\"\nINPUT<-list(records=list(list(id=\"a\",role=\"train\",originalGroup=\"same\",duplicateComponent=\"near\",featureFromTarget=FALSE),list(id=\"b\",role=\"test\",originalGroup=\"same\",duplicateComponent=\"near\",featureFromTarget=TRUE)),fitUsing=list(\"train\",\"test\"),selectionUsing=list(\"validation\",\"test\"))\n\nrs<-INPUT$records;issues<-character();if('test'%in%unlist(INPUT$fitUsing))issues<-c(issues,'test-role-used-for-fitting');if('test'%in%unlist(INPUT$selectionUsing))issues<-c(issues,'test-role-used-for-selection');if(any(vapply(rs,function(r)isTRUE(r$featureFromTarget),TRUE)))issues<-c(issues,'target-derived-feature-present')\nfor(key in c('originalGroup','duplicateComponent')){groups<-list();for(r in rs)if(!is.null(r[[key]]))groups[[r[[key]]]]<-unique(c(groups[[r[[key]]]],r$role));if(any(lengths(groups)>1))issues<-c(issues,if(key=='originalGroup')'original-group-crosses-splits'else'declared-duplicate-component-crosses-splits')}\nsummary<-list(issueCount=as.character(length(issues)),clearWithinDeclaredLineage=B(length(issues)==0),issues=paste(issues,collapse='|'));result<-list(issues=as.list(issues),universalCleanlinessCertified=FALSE)\nfor(key in c('test-role-used-for-fitting','test-role-used-for-selection','target-derived-feature-present','original-group-crosses-splits','declared-duplicate-component-crosses-splits'))point('Declared issue',key,Q(as.numeric(key%in%issues)))\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(p$label,width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"clearWithinDeclaredLineage\":\"false\",\"issueCount\":\"5\",\"issues\":\"test-role-used-for-fitting|test-role-used-for-selection|target-derived-feature-present|original-group-crosses-splits|declared-duplicate-component-crosses-splits\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/leakage-declared-dirty-r/stdout.txt",
        "stderrFile": "ai18-fixed/leakage-declared-dirty-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "clearWithinDeclaredLineage",
            "value": "false"
          },
          {
            "metric": "issueCount",
            "value": "5"
          },
          {
            "metric": "issues",
            "value": "test-role-used-for-fitting|test-role-used-for-selection|target-derived-feature-present|original-group-crosses-splits|declared-duplicate-component-crosses-splits"
          }
        ],
        "resultFile": "ai18-fixed/leakage-declared-dirty-r/result.json",
        "summaryFile": "ai18-fixed/leakage-declared-dirty-r/summary.json",
        "plotDataFile": "ai18-fixed/leakage-declared-dirty-r/points.csv",
        "plotFile": "ai18-fixed/leakage-declared-dirty-r/plot.svg",
        "plotSHA256": "a90a391774c374c4d013596ebb6101f4d385fed44a95c46d4d2bb70f3593d259"
      },
      "leakage-declared-clear": {
        "api": "leakage",
        "variant": "leakage-declared-clear",
        "language": "r",
        "codeFile": "ai18-fixed/leakage-declared-clear-r.R",
        "codeSHA256": "5b95de09c7a4588b119f9bfcebd279c57a052d9ea9c0d5856e64513d8533c618",
        "expectedFailure": false,
        "title": "Clear only within declared lineage",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"Clear only within declared lineage\"\nINPUT<-list(records=list(list(id=\"a\",role=\"train\",originalGroup=\"a\",featureFromTarget=FALSE),list(id=\"b\",role=\"test\",originalGroup=\"b\",featureFromTarget=FALSE)),fitUsing=list(\"train\"),selectionUsing=list(\"validation\"))\n\nrs<-INPUT$records;issues<-character();if('test'%in%unlist(INPUT$fitUsing))issues<-c(issues,'test-role-used-for-fitting');if('test'%in%unlist(INPUT$selectionUsing))issues<-c(issues,'test-role-used-for-selection');if(any(vapply(rs,function(r)isTRUE(r$featureFromTarget),TRUE)))issues<-c(issues,'target-derived-feature-present')\nfor(key in c('originalGroup','duplicateComponent')){groups<-list();for(r in rs)if(!is.null(r[[key]]))groups[[r[[key]]]]<-unique(c(groups[[r[[key]]]],r$role));if(any(lengths(groups)>1))issues<-c(issues,if(key=='originalGroup')'original-group-crosses-splits'else'declared-duplicate-component-crosses-splits')}\nsummary<-list(issueCount=as.character(length(issues)),clearWithinDeclaredLineage=B(length(issues)==0),issues=paste(issues,collapse='|'));result<-list(issues=as.list(issues),universalCleanlinessCertified=FALSE)\nfor(key in c('test-role-used-for-fitting','test-role-used-for-selection','target-derived-feature-present','original-group-crosses-splits','declared-duplicate-component-crosses-splits'))point('Declared issue',key,Q(as.numeric(key%in%issues)))\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(p$label,width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"clearWithinDeclaredLineage\":\"true\",\"issueCount\":\"0\",\"issues\":\"\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/leakage-declared-clear-r/stdout.txt",
        "stderrFile": "ai18-fixed/leakage-declared-clear-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "clearWithinDeclaredLineage",
            "value": "true"
          },
          {
            "metric": "issueCount",
            "value": "0"
          },
          {
            "metric": "issues",
            "value": ""
          }
        ],
        "resultFile": "ai18-fixed/leakage-declared-clear-r/result.json",
        "summaryFile": "ai18-fixed/leakage-declared-clear-r/summary.json",
        "plotDataFile": "ai18-fixed/leakage-declared-clear-r/points.csv",
        "plotFile": "ai18-fixed/leakage-declared-clear-r/plot.svg",
        "plotSHA256": "86b6984e7888ed22dcddc755034ad56197034cc9c7e5a169806bed589ebef36b"
      }
    }
  },
  "realdata": {
    "python": {
      "realdata-country": {
        "api": "realdata",
        "variant": "realdata-country",
        "language": "python",
        "codeFile": "ai18-fixed/realdata-country-python.py",
        "codeSHA256": "bda116a0d6f9e99a30a05aac5ccb49202ed959620d10d7fa97c9187a007b73bb",
        "expectedFailure": false,
        "title": "Retained country numeric views",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='Retained GDP growth (annual percent)'\nINPUT=json.loads('{\"case\": \"country\", \"rows\": [{\"id\": \"WB:AUS\", \"features\": [\"1.37340773365975\", \"3.16656665428797\"], \"role\": \"train\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"1\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:BRA\", \"features\": [\"3.41931516501906\", \"4.36746407652336\"], \"role\": \"train\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"2\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:CAN\", \"features\": [\"2.04626605401701\", \"2.38158383281173\"], \"role\": \"test\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"3\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:CHN\", \"features\": [\"4.95830378788091\", \"0.218128938439177\"], \"role\": \"train\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"4\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:DEU\", \"features\": [\"-0.495851897260366\", \"2.2564981433876\"], \"role\": \"validation\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"5\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:FRA\", \"features\": [\"1.19046798275883\", \"1.99742599742599\"], \"role\": \"train\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"6\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:GBR\", \"features\": [\"1.08027716858781\", \"3.2715729463592\"], \"role\": \"validation\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"7\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:IDN\", \"features\": [\"5.03257477088519\", \"2.18151273615188\"], \"role\": \"validation\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"8\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:IND\", \"features\": [\"7.09927893176518\", \"4.9530355097366\"], \"role\": \"train\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"9\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:JPN\", \"features\": [\"-0.240084236041696\", \"2.7385368163524\"], \"role\": \"train\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"10\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:KOR\", \"features\": [\"2.00361101838986\", \"2.32174328643542\"], \"role\": \"train\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"11\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:MEX\", \"features\": [\"1.35057631384696\", \"4.72225588452931\"], \"role\": \"test\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"12\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:SGP\", \"features\": [\"5.3435120192366\", \"2.38951123595017\"], \"role\": \"train\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"13\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:USA\", \"features\": [\"2.79318715363841\", \"2.94952520485207\"], \"role\": \"validation\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"14\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:VNM\", \"features\": [\"7.03955197123018\", \"3.62109273885843\"], \"role\": \"test\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"15\", \"pixels\": null, \"target\": null}, {\"id\": \"WB:ZAF\", \"features\": [\"0.534843531905139\", \"4.36115246518962\"], \"role\": \"test\", \"nativeFile\": \"actual32-country-observations-2024.csv\", \"nativeDataRow\": \"16\", \"pixels\": null, \"target\": null}], \"alignment\": \"matched\"}')\n\nrs=INPUT['rows'];X=[[F(v)for v in r['features']]for r in rs];n=len(rs);pred=[]\nfor i,r in enumerate(rs):\n ds=[sum((x-y)**2 for x,y in zip(X[i],X[j if INPUT['alignment']=='matched'else(j+1)%n]))for j in range(n)];best=min(range(n),key=lambda j:ds[j]);pred.append(dict(id=r['id'],prediction=rs[best]['id'],correct=best==i,minimumDistance=qs(ds[best])));point('Native feature 1',r['id'],X[i][0])\nsummary=dict(records=str(n),alignment=INPUT['alignment'],pairCorrect=str(sum(r['correct']for r in pred)));result=dict(retrieval=pred,sourceScope='Retained native numeric features; both representations share their origin. Known-corpus retrieval, not semantic encoder evaluation.')\nif INPUT['case']=='person':\n predictions=[];means=[]\n for profile in ['quadrants','pixels']:\n  V=[[F(v)for v in r['features']]if profile=='quadrants'else list(map(F,r['pixels']))for r in rs];P=[]\n  for label in range(10):\n   train=[V[i]for i,r in enumerate(rs)if r['role']=='train'and r['target']==label];assert len(train)==4;P.append([sum((v[j]for v in train),F(0))/4 for j in range(len(V[0]))])\n  for i,r in enumerate(rs):\n   ds=[sum((x-y)**2 for x,y in zip(V[i],p))for p in P];best=min(range(10),key=lambda j:ds[j]);predictions.append(dict(id=r['id'],role=r['role'],profile=profile,prediction=best,target=r['target'],correct=best==r['target'],minimumDistance=qs(ds[best])))\n  for role in ['train','validation','test']:\n   a=[r for r in predictions if r['role']==role and r['profile']==profile];correct=sum(r['correct']for r in a);means.append(dict(profile=profile,role=role,correct=correct,records=len(a),accuracy=qs(F(correct,len(a)))))\n candidates=[m for m in means if m['role']=='validation'];best=max(candidates,key=lambda m:F(m['accuracy']));summary['selectedProfile']=best['profile'];summary['validationAccuracy']=best['accuracy'];summary['testAccuracy']=next(m['accuracy']for m in means if m['profile']==best['profile']and m['role']=='test');result.update(classPredictions=predictions,classMeans=means,selected=best['profile'],unsafeTargetCaptionExcluded=True)\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+(f9(v) if len(p['valueToken'])>22 else p['valueToken']),va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['label'],34)for p in points],fontsize=9);ax.invert_yaxis();ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"alignment\":\"matched\",\"pairCorrect\":\"16\",\"records\":\"16\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/realdata-country-python/stdout.txt",
        "stderrFile": "ai18-fixed/realdata-country-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "alignment",
            "value": "matched"
          },
          {
            "metric": "pairCorrect",
            "value": "16"
          },
          {
            "metric": "records",
            "value": "16"
          }
        ],
        "resultFile": "ai18-fixed/realdata-country-python/result.json",
        "summaryFile": "ai18-fixed/realdata-country-python/summary.json",
        "plotDataFile": "ai18-fixed/realdata-country-python/points.csv",
        "plotFile": "ai18-fixed/realdata-country-python/plot.svg",
        "plotSHA256": "a038e3e9dfe17fbf3e455d6488c3a27cbcd6dd3661a3600921a50152e0124fe8"
      },
      "realdata-person": {
        "api": "realdata",
        "variant": "realdata-person",
        "language": "python",
        "codeFile": "ai18-fixed/realdata-person-python.py",
        "codeSHA256": "5826163dee2dc48168abff9ed97ebb3001ea58a56ffc86f5fdd7aa6784812633",
        "expectedFailure": false,
        "title": "Native digit training and validation",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='Native digit training and validation'\nINPUT=json.loads('{\"case\": \"person\", \"rows\": [{\"id\": \"optdigits.tes:1\", \"features\": [\"82\", \"75\", \"68\", \"69\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1\", \"pixels\": [0, 0, 5, 13, 9, 1, 0, 0, 0, 0, 13, 15, 10, 15, 5, 0, 0, 3, 15, 2, 0, 11, 8, 0, 0, 4, 12, 0, 0, 8, 8, 0, 0, 5, 8, 0, 0, 9, 8, 0, 0, 4, 11, 0, 1, 12, 7, 0, 0, 2, 14, 5, 10, 12, 0, 0, 0, 0, 6, 13, 10, 0, 0, 0], \"target\": 0}, {\"id\": \"optdigits.tes:2\", \"features\": [\"79\", \"83\", \"62\", \"89\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"2\", \"pixels\": [0, 0, 0, 12, 13, 5, 0, 0, 0, 0, 0, 11, 16, 9, 0, 0, 0, 0, 3, 15, 16, 6, 0, 0, 0, 7, 15, 16, 16, 2, 0, 0, 0, 0, 1, 16, 16, 3, 0, 0, 0, 0, 1, 16, 16, 6, 0, 0, 0, 0, 1, 16, 16, 6, 0, 0, 0, 0, 0, 11, 16, 10, 0, 0], \"target\": 1}, {\"id\": \"optdigits.tes:3\", \"features\": [\"51\", \"106\", \"98\", \"89\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"3\", \"pixels\": [0, 0, 0, 4, 15, 12, 0, 0, 0, 0, 3, 16, 15, 14, 0, 0, 0, 0, 8, 13, 8, 16, 0, 0, 0, 0, 1, 6, 15, 11, 0, 0, 0, 1, 8, 13, 15, 1, 0, 0, 0, 9, 16, 16, 5, 0, 0, 0, 0, 3, 13, 16, 16, 11, 5, 0, 0, 0, 0, 3, 11, 16, 9, 0], \"target\": 2}, {\"id\": \"optdigits.tes:4\", \"features\": [\"82\", \"58\", \"33\", \"94\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"4\", \"pixels\": [0, 0, 7, 15, 13, 1, 0, 0, 0, 8, 13, 6, 15, 4, 0, 0, 0, 2, 1, 13, 13, 0, 0, 0, 0, 0, 2, 15, 11, 1, 0, 0, 0, 0, 0, 1, 12, 12, 1, 0, 0, 0, 0, 0, 1, 10, 8, 0, 0, 0, 8, 4, 5, 14, 9, 0, 0, 0, 7, 13, 13, 9, 0, 0], \"target\": 3}, {\"id\": \"optdigits.tes:5\", \"features\": [\"44\", \"46\", \"71\", \"97\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"5\", \"pixels\": [0, 0, 0, 1, 11, 0, 0, 0, 0, 0, 0, 7, 8, 0, 0, 0, 0, 0, 1, 13, 6, 2, 2, 0, 0, 0, 7, 15, 0, 9, 8, 0, 0, 5, 16, 10, 0, 16, 6, 0, 0, 4, 15, 16, 13, 16, 1, 0, 0, 0, 0, 3, 15, 10, 0, 0, 0, 0, 0, 2, 16, 4, 0, 0], \"target\": 4}, {\"id\": \"optdigits.tes:6\", \"features\": [\"108\", \"79\", \"38\", \"117\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"6\", \"pixels\": [0, 0, 12, 10, 0, 0, 0, 0, 0, 0, 14, 16, 16, 14, 0, 0, 0, 0, 13, 16, 15, 10, 1, 0, 0, 0, 11, 16, 16, 7, 0, 0, 0, 0, 0, 4, 7, 16, 7, 0, 0, 0, 0, 0, 4, 16, 9, 0, 0, 0, 5, 4, 12, 16, 4, 0, 0, 0, 9, 16, 16, 10, 0, 0], \"target\": 5}, {\"id\": \"optdigits.tes:7\", \"features\": [\"89\", \"24\", \"89\", \"104\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"7\", \"pixels\": [0, 0, 0, 12, 13, 0, 0, 0, 0, 0, 5, 16, 8, 0, 0, 0, 0, 0, 13, 16, 3, 0, 0, 0, 0, 0, 14, 13, 0, 0, 0, 0, 0, 0, 15, 12, 7, 2, 0, 0, 0, 0, 13, 16, 13, 16, 3, 0, 0, 0, 7, 16, 11, 15, 8, 0, 0, 0, 1, 9, 15, 11, 3, 0], \"target\": 6}, {\"id\": \"optdigits.tes:8\", \"features\": [\"49\", \"130\", \"86\", \"25\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"8\", \"pixels\": [0, 0, 7, 8, 13, 16, 15, 1, 0, 0, 7, 7, 4, 11, 12, 0, 0, 0, 0, 0, 8, 13, 1, 0, 0, 4, 8, 8, 15, 15, 6, 0, 0, 2, 11, 15, 15, 4, 0, 0, 0, 0, 0, 16, 5, 0, 0, 0, 0, 0, 9, 15, 1, 0, 0, 0, 0, 0, 13, 5, 0, 0, 0, 0], \"target\": 7}, {\"id\": \"optdigits.tes:9\", \"features\": [\"87\", \"82\", \"91\", \"97\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"9\", \"pixels\": [0, 0, 9, 14, 8, 1, 0, 0, 0, 0, 12, 14, 14, 12, 0, 0, 0, 0, 9, 10, 0, 15, 4, 0, 0, 0, 3, 16, 12, 14, 2, 0, 0, 0, 4, 16, 16, 2, 0, 0, 0, 3, 16, 8, 10, 13, 2, 0, 0, 1, 15, 1, 3, 16, 8, 0, 0, 0, 11, 16, 15, 11, 1, 0], \"target\": 8}, {\"id\": \"optdigits.tes:10\", \"features\": [\"106\", \"80\", \"53\", \"90\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"10\", \"pixels\": [0, 0, 11, 12, 0, 0, 0, 0, 0, 2, 16, 16, 16, 13, 0, 0, 0, 3, 16, 12, 10, 14, 0, 0, 0, 1, 16, 1, 12, 15, 0, 0, 0, 0, 13, 16, 9, 15, 2, 0, 0, 0, 0, 3, 0, 9, 11, 0, 0, 0, 0, 0, 9, 15, 4, 0, 0, 0, 9, 12, 13, 3, 0, 0], \"target\": 9}, {\"id\": \"optdigits.tes:335\", \"features\": [\"83\", \"91\", \"83\", \"87\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"335\", \"pixels\": [0, 0, 3, 11, 16, 10, 0, 0, 0, 0, 10, 16, 10, 14, 6, 0, 0, 0, 15, 7, 0, 11, 8, 0, 0, 3, 16, 2, 0, 8, 8, 0, 0, 4, 12, 0, 0, 9, 8, 0, 0, 6, 15, 1, 0, 12, 8, 0, 0, 3, 15, 10, 8, 15, 4, 0, 0, 0, 5, 12, 14, 9, 0, 0], \"target\": 0}, {\"id\": \"optdigits.tes:341\", \"features\": [\"74\", \"83\", \"95\", \"63\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"341\", \"pixels\": [0, 0, 10, 16, 16, 7, 0, 0, 0, 6, 15, 9, 14, 12, 0, 0, 0, 3, 5, 0, 13, 8, 0, 0, 0, 0, 0, 10, 13, 0, 0, 0, 0, 0, 2, 16, 4, 0, 0, 0, 0, 0, 12, 8, 0, 0, 0, 0, 0, 0, 16, 13, 11, 8, 3, 0, 0, 0, 12, 16, 16, 16, 5, 0], \"target\": 2}, {\"id\": \"optdigits.tes:348\", \"features\": [\"79\", \"57\", \"63\", \"106\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"348\", \"pixels\": [0, 2, 10, 14, 11, 1, 0, 0, 0, 7, 15, 8, 16, 4, 0, 0, 0, 1, 1, 6, 15, 1, 0, 0, 0, 0, 0, 15, 9, 0, 0, 0, 0, 0, 1, 16, 15, 9, 1, 0, 0, 0, 0, 1, 6, 15, 8, 0, 0, 2, 8, 4, 6, 15, 7, 0, 0, 2, 13, 16, 15, 9, 0, 0], \"target\": 3}, {\"id\": \"optdigits.tes:350\", \"features\": [\"82\", \"54\", \"78\", \"78\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"350\", \"pixels\": [0, 0, 1, 14, 7, 0, 0, 0, 0, 0, 6, 16, 16, 1, 0, 0, 0, 0, 7, 16, 15, 0, 0, 0, 0, 0, 6, 16, 15, 0, 0, 0, 0, 0, 6, 16, 15, 0, 0, 0, 0, 0, 4, 16, 16, 1, 0, 0, 0, 0, 4, 16, 16, 6, 0, 0, 0, 0, 1, 15, 16, 8, 0, 0], \"target\": 1}, {\"id\": \"optdigits.tes:361\", \"features\": [\"72\", \"9\", \"97\", \"110\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"361\", \"pixels\": [0, 0, 1, 13, 7, 0, 0, 0, 0, 0, 7, 14, 2, 0, 0, 0, 0, 0, 13, 5, 0, 0, 0, 0, 0, 0, 16, 3, 0, 0, 0, 0, 0, 3, 16, 10, 12, 12, 3, 0, 0, 3, 16, 11, 5, 9, 12, 0, 0, 1, 13, 11, 4, 13, 11, 0, 0, 0, 1, 12, 16, 11, 2, 0], \"target\": 6}, {\"id\": \"optdigits.tes:365\", \"features\": [\"56\", \"78\", \"112\", \"64\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"365\", \"pixels\": [0, 0, 8, 16, 16, 1, 0, 0, 0, 1, 12, 10, 16, 5, 0, 0, 0, 0, 0, 3, 16, 6, 0, 0, 0, 0, 0, 6, 16, 2, 0, 0, 0, 4, 12, 14, 16, 12, 5, 0, 0, 12, 16, 16, 14, 12, 5, 0, 0, 0, 6, 13, 0, 0, 0, 0, 0, 0, 11, 8, 0, 0, 0, 0], \"target\": 7}, {\"id\": \"optdigits.tes:366\", \"features\": [\"135\", \"62\", \"49\", \"89\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"366\", \"pixels\": [0, 2, 12, 13, 16, 15, 1, 0, 0, 8, 16, 14, 11, 7, 0, 0, 0, 8, 16, 7, 0, 0, 0, 0, 0, 7, 16, 16, 11, 1, 0, 0, 0, 0, 2, 6, 15, 9, 0, 0, 0, 0, 0, 0, 9, 15, 0, 0, 0, 0, 1, 7, 16, 11, 0, 0, 0, 1, 16, 16, 13, 1, 0, 0], \"target\": 5}, {\"id\": \"optdigits.tes:371\", \"features\": [\"93\", \"92\", \"88\", \"96\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"371\", \"pixels\": [0, 0, 7, 13, 16, 11, 0, 0, 0, 3, 16, 5, 4, 14, 2, 0, 0, 8, 11, 1, 4, 15, 2, 0, 0, 3, 12, 14, 16, 8, 0, 0, 0, 0, 8, 16, 15, 1, 0, 0, 0, 1, 15, 5, 11, 12, 0, 0, 0, 3, 16, 5, 7, 16, 1, 0, 0, 0, 5, 14, 16, 15, 2, 0], \"target\": 8}, {\"id\": \"optdigits.tes:376\", \"features\": [\"82\", \"124\", \"16\", \"64\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"376\", \"pixels\": [0, 0, 0, 5, 13, 16, 8, 0, 0, 0, 8, 15, 6, 7, 14, 0, 0, 2, 16, 1, 1, 11, 10, 0, 0, 4, 16, 15, 16, 16, 6, 0, 0, 0, 4, 4, 5, 15, 1, 0, 0, 0, 0, 0, 9, 8, 0, 0, 0, 0, 0, 2, 15, 1, 0, 0, 0, 0, 0, 6, 10, 0, 0, 0], \"target\": 9}, {\"id\": \"optdigits.tes:378\", \"features\": [\"89\", \"42\", \"106\", \"76\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"378\", \"pixels\": [0, 0, 1, 15, 7, 0, 0, 0, 0, 0, 6, 16, 3, 0, 0, 0, 0, 1, 16, 10, 0, 1, 3, 0, 0, 5, 16, 3, 1, 12, 15, 0, 0, 11, 16, 8, 14, 15, 3, 0, 0, 6, 16, 16, 16, 5, 0, 0, 0, 0, 1, 14, 11, 0, 0, 0, 0, 0, 2, 16, 12, 0, 0, 0], \"target\": 4}, {\"id\": \"optdigits.tes:695\", \"features\": [\"75\", \"73\", \"78\", \"96\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"695\", \"pixels\": [0, 0, 1, 13, 12, 1, 0, 0, 0, 0, 9, 16, 16, 12, 0, 0, 0, 0, 14, 6, 0, 13, 3, 0, 0, 6, 10, 0, 0, 10, 6, 0, 0, 7, 13, 0, 0, 9, 8, 0, 0, 3, 16, 1, 3, 14, 7, 0, 0, 0, 11, 16, 16, 16, 1, 0, 0, 0, 0, 11, 16, 6, 0, 0], \"target\": 0}, {\"id\": \"optdigits.tes:700\", \"features\": [\"88\", \"89\", \"76\", \"63\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"700\", \"pixels\": [0, 0, 2, 12, 16, 10, 0, 0, 0, 3, 15, 10, 7, 16, 4, 0, 0, 9, 8, 0, 11, 10, 0, 0, 0, 3, 15, 11, 14, 1, 0, 0, 0, 0, 10, 16, 9, 0, 0, 0, 0, 0, 14, 7, 13, 4, 0, 0, 0, 0, 9, 7, 6, 10, 0, 0, 0, 0, 1, 12, 16, 5, 0, 0], \"target\": 8}, {\"id\": \"optdigits.tes:701\", \"features\": [\"86\", \"113\", \"64\", \"79\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"701\", \"pixels\": [0, 0, 3, 12, 16, 16, 3, 0, 0, 2, 16, 16, 11, 16, 4, 0, 0, 8, 14, 2, 10, 16, 1, 0, 0, 5, 5, 3, 16, 4, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 0, 3, 16, 5, 2, 3, 0, 0, 0, 3, 16, 12, 15, 6, 0, 0, 0, 0, 15, 16, 8, 0, 0], \"target\": 2}, {\"id\": \"optdigits.tes:709\", \"features\": [\"65\", \"104\", \"29\", \"109\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"709\", \"pixels\": [0, 0, 4, 13, 16, 11, 0, 0, 0, 9, 16, 9, 10, 15, 0, 0, 0, 5, 4, 0, 12, 11, 0, 0, 0, 0, 0, 5, 16, 12, 1, 0, 0, 0, 0, 1, 9, 15, 8, 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, 0, 1, 6, 8, 16, 8, 0, 0, 0, 5, 16, 15, 9, 1, 0], \"target\": 3}, {\"id\": \"optdigits.tes:718\", \"features\": [\"107\", \"59\", \"81\", \"108\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"718\", \"pixels\": [0, 0, 6, 16, 16, 16, 10, 0, 0, 0, 13, 15, 9, 6, 0, 0, 0, 6, 16, 4, 0, 0, 0, 0, 0, 12, 15, 4, 2, 0, 0, 0, 0, 8, 16, 16, 16, 15, 1, 0, 0, 0, 6, 8, 9, 16, 4, 0, 0, 0, 1, 3, 13, 15, 1, 0, 0, 0, 7, 16, 15, 3, 0, 0], \"target\": 5}, {\"id\": \"optdigits.tes:720\", \"features\": [\"65\", \"106\", \"29\", \"66\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"720\", \"pixels\": [0, 0, 0, 0, 8, 13, 3, 0, 0, 0, 0, 12, 11, 11, 5, 0, 0, 0, 11, 8, 8, 16, 0, 0, 0, 2, 16, 16, 16, 15, 0, 0, 0, 2, 16, 11, 7, 10, 0, 0, 0, 0, 0, 0, 8, 7, 0, 0, 0, 0, 0, 0, 10, 8, 0, 0, 0, 0, 0, 0, 9, 7, 0, 0], \"target\": 9}, {\"id\": \"optdigits.tes:727\", \"features\": [\"55\", \"119\", \"50\", \"78\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"727\", \"pixels\": [0, 0, 0, 10, 16, 11, 1, 0, 0, 0, 0, 15, 16, 15, 2, 0, 0, 0, 1, 13, 16, 14, 0, 0, 0, 0, 1, 15, 16, 12, 0, 0, 0, 0, 0, 14, 16, 8, 0, 0, 0, 0, 0, 13, 16, 5, 0, 0, 0, 0, 1, 14, 16, 1, 0, 0, 0, 0, 0, 8, 15, 1, 0, 0], \"target\": 1}, {\"id\": \"optdigits.tes:728\", \"features\": [\"51\", \"128\", \"49\", \"77\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"728\", \"pixels\": [0, 0, 0, 7, 14, 16, 5, 0, 0, 0, 7, 16, 12, 16, 8, 0, 0, 0, 4, 2, 1, 16, 4, 0, 0, 0, 3, 12, 12, 16, 8, 0, 0, 0, 12, 16, 16, 15, 5, 0, 0, 0, 5, 5, 13, 6, 0, 0, 0, 0, 0, 2, 14, 0, 0, 0, 0, 0, 0, 9, 8, 0, 0, 0], \"target\": 7}, {\"id\": \"optdigits.tes:729\", \"features\": [\"76\", \"3\", \"79\", \"102\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"729\", \"pixels\": [0, 0, 1, 13, 1, 0, 0, 0, 0, 0, 7, 15, 1, 0, 0, 0, 0, 1, 14, 6, 0, 0, 0, 0, 0, 0, 16, 3, 0, 1, 0, 0, 0, 1, 16, 6, 15, 15, 5, 0, 0, 1, 16, 14, 4, 3, 12, 0, 0, 0, 7, 7, 0, 9, 12, 0, 0, 0, 0, 11, 16, 9, 2, 0], \"target\": 6}, {\"id\": \"optdigits.tes:747\", \"features\": [\"88\", \"106\", \"73\", \"39\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"747\", \"pixels\": [0, 0, 1, 14, 8, 8, 1, 0, 0, 0, 10, 13, 8, 16, 1, 0, 0, 2, 16, 4, 10, 11, 0, 0, 0, 7, 15, 6, 14, 16, 13, 0, 0, 3, 16, 16, 15, 9, 2, 0, 0, 0, 3, 11, 9, 0, 0, 0, 0, 0, 0, 12, 4, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0], \"target\": 4}, {\"id\": \"optdigits.tes:1052\", \"features\": [\"83\", \"74\", \"58\", \"140\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1052\", \"pixels\": [0, 0, 13, 16, 13, 1, 0, 0, 0, 6, 16, 10, 15, 5, 0, 0, 0, 3, 15, 0, 11, 9, 0, 0, 0, 0, 4, 0, 12, 8, 0, 0, 0, 0, 0, 0, 15, 8, 0, 0, 0, 0, 0, 8, 16, 4, 0, 0, 0, 0, 5, 16, 16, 13, 10, 1, 0, 0, 13, 16, 16, 16, 16, 9], \"target\": 2}, {\"id\": \"optdigits.tes:1058\", \"features\": [\"100\", \"73\", \"91\", \"69\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1058\", \"pixels\": [0, 2, 15, 12, 1, 0, 0, 0, 0, 4, 16, 13, 13, 0, 0, 0, 0, 0, 14, 3, 15, 12, 5, 0, 0, 0, 5, 16, 16, 11, 0, 0, 0, 2, 13, 13, 14, 2, 0, 0, 0, 5, 13, 0, 6, 8, 0, 0, 0, 4, 11, 0, 1, 15, 0, 0, 0, 2, 12, 16, 16, 7, 0, 0], \"target\": 8}, {\"id\": \"optdigits.tes:1063\", \"features\": [\"134\", \"54\", \"30\", \"68\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1063\", \"pixels\": [0, 0, 6, 11, 16, 16, 3, 0, 0, 5, 16, 15, 5, 0, 0, 0, 0, 11, 16, 15, 2, 0, 0, 0, 0, 12, 15, 12, 12, 0, 0, 0, 0, 2, 1, 4, 16, 0, 0, 0, 0, 0, 0, 0, 16, 4, 0, 0, 0, 0, 0, 2, 16, 3, 0, 0, 0, 0, 5, 16, 13, 0, 0, 0], \"target\": 5}, {\"id\": \"optdigits.tes:1067\", \"features\": [\"107\", \"69\", \"40\", \"99\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1067\", \"pixels\": [0, 0, 10, 13, 9, 1, 0, 0, 0, 2, 16, 7, 10, 8, 0, 0, 0, 0, 12, 12, 7, 11, 0, 0, 0, 3, 16, 16, 16, 7, 0, 0, 0, 0, 5, 8, 12, 10, 1, 0, 0, 0, 0, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, 3, 15, 0, 0, 0, 11, 16, 16, 16, 8, 0], \"target\": 9}, {\"id\": \"optdigits.tes:1074\", \"features\": [\"72\", \"95\", \"67\", \"55\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1074\", \"pixels\": [0, 0, 2, 15, 16, 15, 0, 0, 0, 0, 12, 9, 11, 12, 0, 0, 0, 5, 15, 0, 13, 7, 0, 0, 0, 5, 6, 3, 14, 5, 2, 0, 0, 0, 0, 9, 16, 16, 9, 0, 0, 0, 7, 16, 9, 2, 0, 0, 0, 0, 1, 15, 3, 0, 0, 0, 0, 0, 3, 16, 0, 0, 0, 0], \"target\": 7}, {\"id\": \"optdigits.tes:1077\", \"features\": [\"87\", \"69\", \"82\", \"69\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1077\", \"pixels\": [0, 0, 2, 16, 10, 0, 0, 0, 0, 0, 4, 16, 16, 5, 0, 0, 0, 0, 8, 16, 16, 3, 0, 0, 0, 0, 9, 16, 16, 3, 0, 0, 0, 0, 8, 16, 16, 3, 0, 0, 0, 0, 8, 16, 16, 1, 0, 0, 0, 0, 5, 16, 14, 0, 0, 0, 0, 0, 1, 12, 16, 3, 0, 0], \"target\": 1}, {\"id\": \"optdigits.tes:1078\", \"features\": [\"70\", \"52\", \"56\", \"83\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1078\", \"pixels\": [0, 0, 0, 10, 11, 1, 0, 0, 0, 0, 1, 15, 8, 8, 0, 0, 0, 5, 4, 10, 0, 12, 0, 0, 0, 7, 8, 10, 0, 7, 5, 0, 0, 6, 10, 0, 0, 2, 9, 0, 0, 1, 13, 0, 0, 2, 11, 0, 0, 0, 6, 11, 4, 10, 11, 0, 0, 0, 0, 9, 15, 14, 5, 0], \"target\": 0}, {\"id\": \"optdigits.tes:1087\", \"features\": [\"91\", \"103\", \"33\", \"119\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1087\", \"pixels\": [0, 0, 11, 16, 16, 10, 0, 0, 1, 14, 16, 9, 11, 16, 1, 0, 1, 14, 3, 0, 12, 14, 0, 0, 0, 0, 0, 6, 16, 7, 0, 0, 0, 0, 0, 0, 8, 16, 5, 0, 0, 0, 0, 0, 0, 12, 10, 0, 0, 0, 2, 4, 5, 14, 13, 0, 0, 0, 11, 16, 16, 16, 4, 0], \"target\": 3}, {\"id\": \"optdigits.tes:1093\", \"features\": [\"75\", \"7\", \"83\", \"114\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1093\", \"pixels\": [0, 0, 1, 14, 6, 0, 0, 0, 0, 0, 7, 15, 1, 0, 0, 0, 0, 0, 13, 7, 0, 0, 0, 0, 0, 0, 13, 5, 0, 0, 0, 0, 0, 0, 14, 7, 5, 4, 1, 0, 0, 0, 10, 16, 13, 14, 14, 0, 0, 0, 9, 14, 1, 4, 16, 3, 0, 0, 1, 12, 13, 16, 9, 1], \"target\": 6}, {\"id\": \"optdigits.tes:1096\", \"features\": [\"110\", \"79\", \"56\", \"62\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1096\", \"pixels\": [0, 0, 3, 15, 7, 0, 0, 0, 0, 3, 15, 11, 1, 1, 7, 0, 0, 8, 16, 2, 0, 13, 15, 0, 0, 8, 16, 13, 14, 16, 5, 0, 0, 0, 8, 9, 15, 13, 0, 0, 0, 0, 0, 8, 16, 2, 0, 0, 0, 0, 0, 12, 12, 0, 0, 0, 0, 0, 3, 16, 4, 0, 0, 0], \"target\": 4}, {\"id\": \"optdigits.tes:1415\", \"features\": [\"89\", \"81\", \"81\", \"42\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1415\", \"pixels\": [0, 0, 10, 9, 14, 10, 0, 0, 0, 2, 15, 15, 4, 14, 2, 0, 0, 0, 13, 5, 9, 12, 0, 0, 0, 0, 4, 16, 14, 2, 0, 0, 0, 0, 11, 12, 10, 0, 0, 0, 0, 0, 15, 1, 12, 0, 0, 0, 0, 3, 12, 2, 13, 0, 0, 0, 0, 0, 9, 16, 7, 0, 0, 0], \"target\": 8}, {\"id\": \"optdigits.tes:1418\", \"features\": [\"101\", \"35\", \"85\", \"92\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1418\", \"pixels\": [0, 1, 10, 16, 3, 0, 0, 0, 0, 5, 16, 14, 8, 0, 0, 0, 0, 10, 11, 8, 12, 0, 0, 0, 0, 1, 1, 8, 12, 0, 0, 0, 0, 0, 0, 12, 8, 0, 0, 0, 0, 0, 2, 15, 5, 1, 2, 0, 0, 0, 10, 16, 14, 14, 12, 0, 0, 0, 14, 16, 16, 13, 7, 0], \"target\": 2}, {\"id\": \"optdigits.tes:1426\", \"features\": [\"77\", \"78\", \"71\", \"77\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1426\", \"pixels\": [0, 0, 3, 10, 16, 4, 0, 0, 0, 1, 15, 16, 16, 10, 0, 0, 0, 6, 10, 2, 3, 14, 1, 0, 0, 8, 6, 0, 0, 10, 4, 0, 0, 4, 8, 0, 0, 5, 8, 0, 0, 0, 15, 0, 0, 9, 8, 0, 0, 0, 12, 14, 10, 16, 3, 0, 0, 0, 4, 14, 13, 5, 0, 0], \"target\": 0}, {\"id\": \"optdigits.tes:1427\", \"features\": [\"56\", \"113\", \"0\", \"110\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1427\", \"pixels\": [0, 0, 0, 0, 9, 15, 0, 0, 0, 0, 1, 10, 16, 16, 1, 0, 0, 5, 16, 15, 14, 16, 0, 0, 0, 1, 8, 0, 10, 16, 0, 0, 0, 0, 0, 0, 11, 16, 0, 0, 0, 0, 0, 0, 10, 15, 0, 0, 0, 0, 0, 0, 12, 16, 3, 0, 0, 0, 0, 0, 8, 16, 3, 0], \"target\": 1}, {\"id\": \"optdigits.tes:1429\", \"features\": [\"82\", \"82\", \"61\", \"122\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1429\", \"pixels\": [0, 0, 12, 16, 15, 1, 0, 0, 0, 5, 16, 10, 15, 8, 0, 0, 0, 1, 7, 3, 14, 6, 0, 0, 0, 0, 0, 12, 16, 7, 0, 0, 0, 0, 0, 3, 13, 16, 6, 0, 0, 0, 4, 0, 0, 15, 11, 0, 0, 2, 16, 10, 11, 16, 7, 0, 0, 0, 10, 16, 16, 10, 1, 0], \"target\": 3}, {\"id\": \"optdigits.tes:1431\", \"features\": [\"110\", \"64\", \"51\", \"97\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1431\", \"pixels\": [0, 0, 11, 10, 8, 12, 1, 0, 0, 0, 16, 13, 12, 10, 0, 0, 0, 5, 14, 2, 0, 0, 0, 0, 0, 7, 16, 16, 13, 8, 0, 0, 0, 0, 4, 4, 8, 16, 7, 0, 0, 0, 0, 0, 0, 9, 8, 0, 0, 0, 9, 4, 7, 16, 5, 0, 0, 0, 14, 16, 14, 7, 0, 0], \"target\": 5}, {\"id\": \"optdigits.tes:1433\", \"features\": [\"61\", \"131\", \"39\", \"85\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1433\", \"pixels\": [0, 0, 1, 9, 16, 16, 16, 1, 0, 0, 8, 15, 10, 14, 13, 0, 0, 0, 14, 6, 0, 14, 6, 0, 0, 0, 6, 2, 6, 16, 3, 0, 0, 0, 0, 12, 16, 16, 10, 0, 0, 0, 0, 6, 16, 8, 0, 0, 0, 0, 0, 7, 13, 0, 0, 0, 0, 0, 0, 14, 6, 0, 0, 0], \"target\": 7}, {\"id\": \"optdigits.tes:1440\", \"features\": [\"77\", \"58\", \"104\", \"92\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1440\", \"pixels\": [0, 0, 0, 12, 7, 0, 0, 0, 0, 0, 6, 15, 1, 1, 0, 0, 0, 1, 14, 8, 10, 8, 0, 0, 0, 6, 15, 0, 13, 12, 6, 0, 0, 14, 15, 12, 16, 16, 9, 0, 0, 10, 16, 15, 16, 8, 1, 0, 0, 0, 0, 10, 16, 1, 0, 0, 0, 0, 0, 12, 9, 0, 0, 0], \"target\": 4}, {\"id\": \"optdigits.tes:1442\", \"features\": [\"81\", \"7\", \"105\", \"113\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1442\", \"pixels\": [0, 0, 6, 14, 1, 0, 0, 0, 0, 0, 12, 10, 0, 0, 0, 0, 0, 3, 16, 1, 0, 0, 0, 0, 0, 5, 14, 0, 4, 2, 0, 0, 0, 7, 16, 16, 16, 16, 5, 0, 0, 4, 16, 6, 0, 9, 11, 0, 0, 0, 14, 8, 5, 13, 9, 0, 0, 0, 5, 13, 16, 12, 1, 0], \"target\": 6}, {\"id\": \"optdigits.tes:1445\", \"features\": [\"83\", \"92\", \"28\", \"76\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1445\", \"pixels\": [0, 0, 8, 13, 14, 5, 0, 0, 0, 5, 13, 4, 11, 9, 0, 0, 0, 4, 13, 1, 12, 14, 0, 0, 0, 0, 8, 14, 11, 12, 4, 0, 0, 0, 0, 0, 0, 7, 8, 0, 0, 0, 0, 0, 0, 4, 8, 0, 0, 0, 2, 2, 0, 11, 7, 0, 0, 0, 8, 16, 16, 13, 2, 0], \"target\": 9}, {\"id\": \"optdigits.tes:1771\", \"features\": [\"70\", \"85\", \"37\", \"104\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1771\", \"pixels\": [0, 2, 10, 12, 16, 8, 0, 0, 0, 4, 8, 5, 13, 16, 0, 0, 0, 0, 0, 7, 15, 7, 0, 0, 0, 0, 6, 16, 10, 0, 0, 0, 0, 0, 0, 5, 16, 11, 0, 0, 0, 0, 0, 0, 6, 16, 3, 0, 0, 0, 0, 0, 10, 16, 5, 0, 0, 2, 14, 16, 12, 9, 0, 0], \"target\": 3}, {\"id\": \"optdigits.tes:1774\", \"features\": [\"87\", \"12\", \"99\", \"117\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1774\", \"pixels\": [0, 0, 2, 13, 10, 0, 0, 0, 0, 0, 10, 13, 0, 0, 0, 0, 0, 0, 16, 6, 0, 0, 0, 0, 0, 3, 16, 8, 2, 0, 0, 0, 0, 7, 16, 16, 16, 11, 0, 0, 0, 4, 16, 2, 4, 11, 9, 0, 0, 1, 13, 11, 8, 12, 12, 0, 0, 0, 1, 12, 16, 14, 4, 0], \"target\": 6}, {\"id\": \"optdigits.tes:1775\", \"features\": [\"97\", \"99\", \"109\", \"92\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1775\", \"pixels\": [0, 0, 6, 12, 12, 6, 0, 0, 0, 0, 11, 16, 16, 13, 0, 0, 0, 0, 12, 16, 16, 8, 0, 0, 0, 0, 8, 16, 16, 12, 0, 0, 0, 2, 13, 16, 16, 12, 0, 0, 0, 1, 16, 16, 16, 10, 0, 0, 0, 0, 16, 16, 16, 8, 0, 0, 0, 0, 2, 11, 10, 4, 0, 0], \"target\": 1}, {\"id\": \"optdigits.tes:1784\", \"features\": [\"67\", \"29\", \"80\", \"93\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1784\", \"pixels\": [0, 0, 15, 13, 1, 0, 0, 0, 0, 0, 14, 14, 4, 0, 0, 0, 0, 0, 1, 4, 12, 0, 0, 0, 0, 0, 0, 6, 12, 0, 0, 0, 0, 0, 0, 11, 10, 0, 0, 0, 0, 0, 1, 16, 8, 6, 5, 0, 0, 0, 13, 16, 16, 16, 14, 0, 0, 0, 10, 13, 10, 6, 2, 0], \"target\": 2}, {\"id\": \"optdigits.tes:1786\", \"features\": [\"71\", \"98\", \"112\", \"53\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1786\", \"pixels\": [0, 1, 10, 16, 15, 2, 0, 0, 0, 1, 12, 13, 16, 4, 0, 0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 7, 11, 16, 13, 8, 0, 0, 8, 16, 16, 16, 16, 6, 0, 0, 2, 10, 16, 9, 0, 0, 0, 0, 0, 3, 16, 4, 0, 0, 0, 0, 0, 10, 15, 2, 0, 0, 0], \"target\": 7}, {\"id\": \"optdigits.tes:1788\", \"features\": [\"117\", \"57\", \"49\", \"93\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1788\", \"pixels\": [0, 0, 10, 16, 15, 1, 0, 0, 0, 0, 16, 12, 5, 0, 0, 0, 0, 2, 16, 9, 4, 0, 0, 0, 0, 4, 16, 16, 16, 14, 2, 0, 0, 1, 10, 4, 1, 16, 4, 0, 0, 0, 0, 0, 2, 16, 7, 0, 0, 0, 7, 8, 14, 16, 3, 0, 0, 0, 6, 13, 10, 4, 0, 0], \"target\": 5}, {\"id\": \"optdigits.tes:1792\", \"features\": [\"78\", \"67\", \"96\", \"106\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1792\", \"pixels\": [0, 0, 0, 3, 15, 4, 0, 0, 0, 0, 4, 16, 12, 0, 0, 0, 0, 0, 12, 15, 3, 4, 3, 0, 0, 7, 16, 5, 3, 15, 8, 0, 0, 13, 16, 13, 15, 16, 2, 0, 0, 12, 16, 16, 16, 13, 0, 0, 0, 0, 4, 5, 16, 8, 0, 0, 0, 0, 0, 1, 16, 4, 0, 0], \"target\": 4}, {\"id\": \"optdigits.tes:1794\", \"features\": [\"99\", \"91\", \"106\", \"103\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1794\", \"pixels\": [0, 0, 6, 16, 13, 11, 1, 0, 0, 0, 16, 15, 12, 16, 1, 0, 0, 3, 16, 7, 0, 13, 6, 0, 0, 4, 16, 0, 0, 10, 8, 0, 0, 8, 16, 0, 0, 14, 6, 0, 0, 5, 16, 7, 9, 16, 5, 0, 0, 1, 15, 16, 16, 16, 1, 0, 0, 0, 6, 16, 14, 6, 0, 0], \"target\": 0}, {\"id\": \"optdigits.tes:1796\", \"features\": [\"100\", \"92\", \"47\", \"105\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1796\", \"pixels\": [0, 0, 2, 10, 7, 0, 0, 0, 0, 0, 14, 16, 16, 15, 1, 0, 0, 4, 16, 7, 3, 16, 7, 0, 0, 5, 16, 10, 7, 16, 4, 0, 0, 0, 5, 14, 14, 16, 4, 0, 0, 0, 0, 0, 0, 16, 2, 0, 0, 0, 4, 7, 7, 16, 2, 0, 0, 0, 5, 12, 16, 12, 0, 0], \"target\": 9}, {\"id\": \"optdigits.tes:1797\", \"features\": [\"107\", \"65\", \"108\", \"112\"], \"role\": \"test\", \"nativeFile\": \"optdigits.tes\", \"nativeDataRow\": \"1797\", \"pixels\": [0, 0, 10, 14, 8, 1, 0, 0, 0, 2, 16, 14, 6, 1, 0, 0, 0, 0, 15, 15, 8, 15, 0, 0, 0, 0, 5, 16, 16, 10, 0, 0, 0, 0, 12, 15, 15, 12, 0, 0, 0, 4, 16, 6, 4, 16, 6, 0, 0, 8, 16, 10, 8, 16, 8, 0, 0, 1, 8, 12, 14, 12, 1, 0], \"target\": 8}, {\"id\": \"optdigits.tra:1\", \"features\": [\"101\", \"54\", \"82\", \"66\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"1\", \"pixels\": [0, 1, 6, 15, 12, 1, 0, 0, 0, 7, 16, 6, 6, 10, 0, 0, 0, 8, 16, 2, 0, 11, 2, 0, 0, 5, 16, 3, 0, 5, 7, 0, 0, 7, 13, 3, 0, 8, 7, 0, 0, 4, 12, 0, 1, 13, 5, 0, 0, 0, 14, 9, 15, 9, 0, 0, 0, 0, 6, 14, 7, 1, 0, 0], \"target\": 0}, {\"id\": \"optdigits.tra:3\", \"features\": [\"51\", \"106\", \"104\", \"56\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3\", \"pixels\": [0, 0, 8, 15, 16, 13, 0, 0, 0, 1, 11, 9, 11, 16, 1, 0, 0, 0, 0, 0, 7, 14, 0, 0, 0, 0, 3, 4, 14, 12, 2, 0, 0, 1, 16, 16, 16, 16, 10, 0, 0, 2, 12, 16, 10, 0, 0, 0, 0, 0, 2, 16, 4, 0, 0, 0, 0, 0, 9, 14, 0, 0, 0, 0], \"target\": 7}, {\"id\": \"optdigits.tra:4\", \"features\": [\"93\", \"122\", \"13\", \"77\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"4\", \"pixels\": [0, 0, 0, 3, 11, 16, 0, 0, 0, 0, 5, 16, 11, 13, 7, 0, 0, 3, 15, 8, 1, 15, 6, 0, 0, 11, 16, 16, 16, 16, 10, 0, 0, 1, 4, 4, 13, 10, 2, 0, 0, 0, 0, 0, 15, 4, 0, 0, 0, 0, 0, 3, 16, 0, 0, 0, 0, 0, 0, 1, 15, 2, 0, 0], \"target\": 4}, {\"id\": \"optdigits.tra:5\", \"features\": [\"97\", \"15\", \"74\", \"80\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"5\", \"pixels\": [0, 0, 5, 14, 4, 0, 0, 0, 0, 0, 13, 8, 0, 0, 0, 0, 0, 3, 14, 4, 0, 0, 0, 0, 0, 6, 16, 14, 9, 2, 0, 0, 0, 4, 16, 3, 4, 11, 2, 0, 0, 0, 14, 3, 0, 4, 11, 0, 0, 0, 10, 8, 4, 11, 12, 0, 0, 0, 4, 12, 14, 7, 0, 0], \"target\": 6}, {\"id\": \"optdigits.tra:6\", \"features\": [\"101\", \"81\", \"52\", \"132\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"6\", \"pixels\": [0, 0, 11, 16, 10, 1, 0, 0, 0, 4, 16, 10, 15, 8, 0, 0, 0, 4, 16, 3, 11, 13, 0, 0, 0, 1, 14, 6, 9, 14, 0, 0, 0, 0, 0, 0, 12, 10, 0, 0, 0, 0, 0, 6, 16, 6, 0, 0, 0, 0, 5, 15, 15, 8, 8, 3, 0, 0, 10, 16, 16, 16, 16, 6], \"target\": 2}, {\"id\": \"optdigits.tra:7\", \"features\": [\"94\", \"99\", \"24\", \"52\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"7\", \"pixels\": [0, 0, 1, 11, 13, 11, 7, 0, 0, 0, 9, 14, 6, 4, 3, 0, 0, 0, 16, 12, 16, 15, 2, 0, 0, 5, 16, 10, 4, 12, 6, 0, 0, 1, 1, 0, 0, 10, 4, 0, 0, 0, 0, 0, 5, 10, 0, 0, 0, 0, 0, 8, 15, 3, 0, 0, 0, 0, 1, 13, 5, 0, 0, 0], \"target\": 5}, {\"id\": \"optdigits.tra:10\", \"features\": [\"128\", \"68\", \"90\", \"95\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"10\", \"pixels\": [0, 0, 3, 13, 13, 2, 0, 0, 0, 6, 16, 12, 10, 8, 0, 0, 0, 9, 15, 12, 16, 6, 0, 0, 0, 10, 16, 16, 13, 0, 0, 0, 0, 1, 12, 16, 12, 14, 4, 0, 0, 0, 11, 8, 0, 3, 12, 0, 0, 0, 13, 11, 8, 13, 12, 0, 0, 0, 3, 15, 11, 6, 0, 0], \"target\": 8}, {\"id\": \"optdigits.tra:12\", \"features\": [\"44\", \"118\", \"63\", \"101\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"12\", \"pixels\": [0, 0, 0, 3, 16, 11, 1, 0, 0, 0, 0, 8, 16, 16, 1, 0, 0, 0, 0, 9, 16, 14, 0, 0, 0, 1, 7, 16, 16, 11, 0, 0, 0, 9, 16, 16, 16, 8, 0, 0, 0, 1, 8, 6, 16, 7, 0, 0, 0, 0, 0, 5, 16, 9, 0, 0, 0, 0, 0, 2, 14, 14, 1, 0], \"target\": 1}, {\"id\": \"optdigits.tra:13\", \"features\": [\"92\", \"158\", \"24\", \"90\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"13\", \"pixels\": [0, 0, 0, 4, 13, 16, 16, 3, 0, 0, 8, 16, 9, 12, 16, 4, 0, 7, 16, 3, 3, 15, 13, 0, 0, 9, 15, 14, 16, 16, 6, 0, 0, 1, 8, 7, 12, 15, 0, 0, 0, 0, 0, 0, 13, 10, 0, 0, 0, 0, 0, 3, 15, 6, 0, 0, 0, 0, 0, 5, 15, 4, 0, 0], \"target\": 9}, {\"id\": \"optdigits.tra:15\", \"features\": [\"68\", \"79\", \"82\", \"107\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"15\", \"pixels\": [0, 0, 7, 11, 11, 6, 0, 0, 0, 9, 16, 12, 10, 14, 0, 0, 0, 5, 2, 0, 4, 14, 0, 0, 0, 0, 1, 5, 14, 6, 0, 0, 0, 1, 15, 16, 16, 10, 0, 0, 0, 0, 7, 4, 4, 15, 6, 0, 0, 0, 5, 4, 8, 13, 12, 0, 0, 0, 14, 16, 12, 10, 1, 0], \"target\": 3}, {\"id\": \"optdigits.tra:715\", \"features\": [\"71\", \"103\", \"22\", \"102\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"715\", \"pixels\": [0, 0, 7, 16, 12, 1, 0, 0, 0, 0, 9, 12, 9, 11, 0, 0, 0, 0, 5, 13, 10, 16, 3, 0, 0, 0, 0, 9, 16, 16, 9, 0, 0, 0, 0, 0, 0, 6, 13, 0, 0, 0, 0, 0, 0, 3, 15, 0, 0, 0, 0, 0, 0, 5, 16, 0, 0, 0, 6, 16, 16, 16, 12, 0], \"target\": 9}, {\"id\": \"optdigits.tra:719\", \"features\": [\"93\", \"72\", \"38\", \"61\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"719\", \"pixels\": [0, 0, 0, 9, 10, 2, 0, 0, 0, 0, 5, 16, 16, 2, 0, 0, 0, 4, 14, 16, 16, 4, 0, 0, 0, 8, 11, 10, 16, 6, 0, 0, 0, 0, 0, 7, 16, 3, 0, 0, 0, 0, 0, 10, 16, 2, 0, 0, 0, 0, 0, 12, 11, 0, 0, 0, 0, 0, 0, 9, 13, 0, 0, 0], \"target\": 1}, {\"id\": \"optdigits.tra:721\", \"features\": [\"63\", \"111\", \"101\", \"50\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"721\", \"pixels\": [0, 0, 15, 16, 16, 15, 2, 0, 0, 0, 5, 8, 11, 16, 3, 0, 0, 0, 0, 0, 15, 8, 0, 0, 0, 3, 8, 8, 16, 7, 2, 0, 0, 6, 15, 16, 16, 16, 8, 0, 0, 0, 2, 15, 7, 3, 0, 0, 0, 0, 11, 13, 0, 0, 0, 0, 0, 0, 16, 7, 0, 0, 0, 0], \"target\": 7}, {\"id\": \"optdigits.tra:748\", \"features\": [\"79\", \"34\", \"99\", \"87\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"748\", \"pixels\": [0, 0, 0, 10, 16, 2, 0, 0, 0, 0, 4, 16, 13, 1, 0, 0, 0, 0, 10, 16, 2, 0, 0, 0, 0, 0, 13, 10, 0, 0, 0, 0, 0, 0, 16, 15, 10, 0, 0, 0, 0, 0, 14, 16, 13, 10, 0, 0, 0, 0, 11, 16, 8, 16, 1, 0, 0, 0, 1, 10, 16, 13, 0, 0], \"target\": 6}, {\"id\": \"optdigits.tra:766\", \"features\": [\"70\", \"49\", \"87\", \"68\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"766\", \"pixels\": [0, 1, 14, 16, 6, 0, 0, 0, 0, 4, 15, 10, 13, 0, 0, 0, 0, 1, 3, 4, 15, 0, 0, 0, 0, 0, 0, 2, 15, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 1, 15, 4, 0, 0, 0, 0, 1, 13, 14, 7, 2, 0, 0, 0, 3, 15, 16, 16, 16, 13, 1], \"target\": 2}, {\"id\": \"optdigits.tra:770\", \"features\": [\"116\", \"52\", \"66\", \"89\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"770\", \"pixels\": [0, 3, 16, 16, 16, 16, 0, 0, 0, 0, 13, 12, 8, 4, 0, 0, 0, 0, 12, 12, 0, 0, 0, 0, 0, 0, 16, 16, 8, 0, 0, 0, 0, 0, 11, 5, 14, 7, 0, 0, 0, 0, 0, 0, 8, 16, 0, 0, 0, 2, 11, 4, 14, 13, 0, 0, 0, 2, 15, 16, 15, 2, 0, 0], \"target\": 5}, {\"id\": \"optdigits.tra:776\", \"features\": [\"79\", \"44\", \"73\", \"65\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"776\", \"pixels\": [0, 0, 0, 15, 2, 0, 0, 0, 0, 0, 10, 12, 0, 0, 0, 0, 0, 5, 15, 1, 0, 6, 6, 0, 0, 12, 9, 0, 3, 16, 11, 0, 0, 6, 16, 12, 14, 13, 1, 0, 0, 0, 3, 11, 16, 2, 0, 0, 0, 0, 0, 10, 12, 0, 0, 0, 0, 0, 0, 15, 7, 0, 0, 0], \"target\": 4}, {\"id\": \"optdigits.tra:793\", \"features\": [\"89\", \"90\", \"48\", \"95\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"793\", \"pixels\": [0, 1, 12, 16, 15, 3, 0, 0, 0, 11, 13, 5, 13, 8, 0, 0, 0, 3, 1, 8, 16, 5, 0, 0, 0, 0, 3, 16, 16, 13, 1, 0, 0, 0, 0, 0, 1, 14, 6, 0, 0, 0, 1, 0, 0, 9, 11, 0, 0, 2, 15, 1, 0, 13, 9, 0, 0, 0, 13, 16, 15, 15, 2, 0], \"target\": 3}, {\"id\": \"optdigits.tra:826\", \"features\": [\"82\", \"61\", \"77\", \"75\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"826\", \"pixels\": [0, 0, 3, 12, 13, 1, 0, 0, 0, 1, 14, 11, 10, 8, 0, 0, 0, 4, 16, 3, 0, 12, 2, 0, 0, 4, 13, 1, 0, 9, 6, 0, 0, 6, 12, 0, 0, 5, 8, 0, 0, 3, 13, 0, 0, 4, 9, 0, 0, 0, 15, 8, 4, 13, 8, 0, 0, 0, 5, 15, 15, 9, 0, 0], \"target\": 0}, {\"id\": \"optdigits.tra:850\", \"features\": [\"91\", \"63\", \"90\", \"89\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"850\", \"pixels\": [0, 0, 1, 10, 2, 3, 0, 0, 0, 0, 8, 16, 15, 16, 0, 0, 0, 0, 12, 16, 16, 4, 0, 0, 0, 0, 12, 16, 7, 0, 0, 0, 0, 3, 16, 13, 13, 1, 0, 0, 0, 1, 16, 4, 12, 10, 0, 0, 0, 0, 11, 12, 11, 16, 2, 0, 0, 0, 2, 12, 14, 9, 1, 0], \"target\": 8}, {\"id\": \"optdigits.tra:1442\", \"features\": [\"126\", \"49\", \"59\", \"76\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"1442\", \"pixels\": [0, 0, 5, 14, 16, 14, 0, 0, 0, 7, 16, 15, 8, 8, 0, 0, 0, 14, 13, 0, 0, 0, 0, 0, 0, 13, 16, 13, 3, 0, 0, 0, 0, 0, 5, 11, 15, 1, 0, 0, 0, 0, 0, 0, 16, 9, 0, 0, 0, 0, 5, 11, 16, 8, 0, 0, 0, 0, 11, 16, 10, 1, 0, 0], \"target\": 5}, {\"id\": \"optdigits.tra:1471\", \"features\": [\"103\", \"126\", \"19\", \"108\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"1471\", \"pixels\": [0, 0, 1, 8, 15, 16, 7, 0, 0, 1, 13, 14, 9, 16, 8, 0, 0, 8, 16, 5, 11, 15, 2, 0, 0, 5, 16, 16, 16, 10, 1, 0, 0, 0, 1, 4, 10, 16, 9, 0, 0, 0, 0, 0, 3, 16, 7, 0, 0, 0, 0, 3, 14, 14, 1, 0, 0, 0, 0, 11, 15, 3, 0, 0], \"target\": 9}, {\"id\": \"optdigits.tra:1475\", \"features\": [\"62\", \"93\", \"70\", \"34\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"1475\", \"pixels\": [0, 1, 12, 16, 16, 8, 0, 0, 0, 1, 8, 5, 9, 12, 0, 0, 0, 0, 0, 0, 11, 8, 0, 0, 0, 0, 5, 14, 14, 10, 5, 0, 0, 0, 3, 15, 14, 12, 5, 0, 0, 0, 2, 16, 3, 0, 0, 0, 0, 0, 10, 9, 0, 0, 0, 0, 0, 0, 13, 2, 0, 0, 0, 0], \"target\": 7}, {\"id\": \"optdigits.tra:1488\", \"features\": [\"103\", \"39\", \"105\", \"14\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"1488\", \"pixels\": [0, 0, 2, 15, 12, 1, 0, 0, 0, 0, 6, 16, 15, 1, 0, 0, 0, 0, 14, 16, 8, 0, 0, 0, 0, 2, 16, 16, 2, 0, 0, 0, 0, 3, 16, 15, 0, 0, 0, 0, 0, 2, 16, 13, 0, 0, 0, 0, 0, 0, 9, 16, 2, 0, 0, 0, 0, 0, 2, 13, 12, 0, 0, 0], \"target\": 1}, {\"id\": \"optdigits.tra:1502\", \"features\": [\"76\", \"26\", \"84\", \"114\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"1502\", \"pixels\": [0, 0, 0, 10, 13, 0, 0, 0, 0, 0, 1, 16, 11, 2, 0, 0, 0, 0, 8, 16, 0, 0, 0, 0, 0, 0, 13, 12, 0, 0, 0, 0, 0, 0, 14, 16, 14, 9, 0, 0, 0, 0, 12, 15, 5, 9, 13, 0, 0, 0, 3, 16, 4, 6, 16, 2, 0, 0, 0, 8, 13, 14, 9, 0], \"target\": 6}, {\"id\": \"optdigits.tra:1512\", \"features\": [\"82\", \"49\", \"49\", \"114\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"1512\", \"pixels\": [0, 0, 6, 14, 3, 0, 0, 0, 0, 0, 12, 14, 14, 0, 0, 0, 0, 0, 14, 7, 14, 2, 0, 0, 0, 0, 10, 5, 10, 6, 0, 0, 0, 0, 0, 0, 13, 5, 0, 0, 0, 0, 0, 2, 14, 5, 3, 0, 0, 0, 8, 16, 16, 16, 16, 0, 0, 0, 9, 14, 8, 8, 8, 2], \"target\": 2}, {\"id\": \"optdigits.tra:1554\", \"features\": [\"60\", \"57\", \"52\", \"93\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"1554\", \"pixels\": [0, 0, 0, 2, 13, 2, 0, 0, 0, 0, 0, 14, 10, 0, 0, 0, 0, 0, 11, 10, 0, 10, 4, 0, 0, 4, 16, 3, 1, 14, 3, 0, 0, 6, 16, 16, 16, 16, 5, 0, 0, 0, 5, 8, 14, 11, 1, 0, 0, 0, 0, 0, 15, 2, 0, 0, 0, 0, 0, 1, 13, 0, 0, 0], \"target\": 4}, {\"id\": \"optdigits.tra:1560\", \"features\": [\"86\", \"90\", \"52\", \"87\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"1560\", \"pixels\": [0, 3, 16, 14, 10, 5, 0, 0, 0, 1, 8, 8, 11, 16, 2, 0, 0, 0, 2, 6, 12, 11, 1, 0, 0, 0, 12, 16, 16, 6, 0, 0, 0, 0, 0, 3, 11, 16, 2, 0, 0, 0, 0, 0, 0, 14, 7, 0, 0, 1, 8, 9, 14, 13, 0, 0, 0, 3, 16, 12, 9, 1, 0, 0], \"target\": 3}, {\"id\": \"optdigits.tra:1585\", \"features\": [\"84\", \"62\", \"72\", \"92\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"1585\", \"pixels\": [0, 0, 3, 15, 13, 1, 0, 0, 0, 1, 15, 12, 13, 10, 0, 0, 0, 3, 16, 1, 1, 12, 2, 0, 0, 6, 12, 0, 0, 4, 6, 0, 0, 4, 11, 0, 0, 4, 8, 0, 0, 0, 13, 3, 5, 13, 8, 0, 0, 0, 10, 15, 16, 16, 5, 0, 0, 0, 2, 14, 12, 5, 0, 0], \"target\": 0}, {\"id\": \"optdigits.tra:1617\", \"features\": [\"91\", \"91\", \"82\", \"72\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"1617\", \"pixels\": [0, 0, 4, 13, 15, 6, 0, 0, 0, 4, 15, 6, 7, 15, 2, 0, 0, 8, 14, 0, 4, 16, 5, 0, 0, 2, 15, 10, 14, 7, 0, 0, 0, 0, 7, 16, 14, 0, 0, 0, 0, 0, 12, 9, 15, 6, 0, 0, 0, 0, 12, 8, 11, 8, 0, 0, 0, 0, 3, 15, 15, 3, 0, 0], \"target\": 8}, {\"id\": \"optdigits.tra:2231\", \"features\": [\"95\", \"61\", \"113\", \"78\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"2231\", \"pixels\": [0, 2, 15, 16, 9, 0, 0, 0, 0, 7, 15, 12, 16, 2, 0, 0, 0, 9, 9, 2, 16, 2, 0, 0, 0, 1, 0, 7, 16, 0, 0, 0, 0, 0, 0, 14, 10, 0, 0, 0, 0, 1, 12, 15, 2, 0, 0, 0, 0, 8, 16, 14, 12, 12, 3, 0, 0, 3, 14, 16, 16, 16, 7, 0], \"target\": 2}, {\"id\": \"optdigits.tra:2250\", \"features\": [\"88\", \"91\", \"35\", \"97\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"2250\", \"pixels\": [0, 0, 11, 16, 10, 1, 0, 0, 0, 0, 16, 8, 11, 13, 1, 0, 0, 0, 13, 7, 7, 16, 1, 0, 0, 0, 4, 13, 14, 16, 1, 0, 0, 0, 0, 0, 0, 15, 4, 0, 0, 0, 0, 0, 0, 8, 11, 0, 0, 1, 7, 4, 5, 14, 12, 0, 0, 0, 8, 15, 14, 11, 3, 0], \"target\": 9}, {\"id\": \"optdigits.tra:2257\", \"features\": [\"87\", \"99\", \"87\", \"133\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"2257\", \"pixels\": [0, 0, 7, 15, 14, 2, 0, 0, 0, 0, 9, 16, 16, 11, 0, 0, 0, 0, 3, 16, 16, 11, 0, 0, 0, 0, 5, 16, 16, 13, 0, 0, 0, 0, 6, 16, 16, 14, 0, 0, 0, 0, 6, 16, 16, 12, 0, 0, 0, 0, 7, 16, 16, 15, 6, 0, 0, 0, 4, 16, 16, 15, 7, 0], \"target\": 1}, {\"id\": \"optdigits.tra:2259\", \"features\": [\"101\", \"89\", \"87\", \"85\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"2259\", \"pixels\": [0, 0, 6, 13, 15, 6, 0, 0, 0, 1, 15, 16, 16, 14, 0, 0, 0, 4, 16, 8, 4, 14, 4, 0, 0, 4, 16, 2, 0, 9, 7, 0, 0, 4, 15, 0, 0, 13, 5, 0, 0, 2, 16, 0, 5, 15, 5, 0, 0, 1, 15, 13, 16, 11, 0, 0, 0, 0, 6, 15, 12, 3, 0, 0], \"target\": 0}, {\"id\": \"optdigits.tra:2261\", \"features\": [\"36\", \"128\", \"66\", \"55\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"2261\", \"pixels\": [0, 0, 3, 10, 12, 16, 5, 0, 0, 0, 8, 8, 8, 15, 11, 0, 0, 0, 0, 0, 2, 16, 7, 0, 0, 0, 1, 6, 14, 16, 6, 0, 0, 0, 4, 14, 16, 12, 4, 0, 0, 0, 0, 9, 13, 2, 0, 0, 0, 0, 2, 16, 6, 0, 0, 0, 0, 0, 5, 16, 2, 0, 0, 0], \"target\": 7}, {\"id\": \"optdigits.tra:2272\", \"features\": [\"102\", \"67\", \"67\", \"115\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"2272\", \"pixels\": [0, 1, 10, 14, 5, 0, 0, 0, 0, 9, 16, 14, 16, 0, 0, 0, 0, 3, 5, 9, 16, 0, 0, 0, 0, 0, 5, 16, 16, 14, 0, 0, 0, 0, 8, 14, 13, 16, 6, 0, 0, 0, 0, 0, 0, 16, 11, 0, 0, 0, 11, 5, 11, 16, 7, 0, 0, 1, 12, 16, 14, 5, 0, 0], \"target\": 3}, {\"id\": \"optdigits.tra:2311\", \"features\": [\"86\", \"38\", \"106\", \"118\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"2311\", \"pixels\": [0, 0, 1, 12, 16, 7, 0, 0, 0, 0, 8, 16, 11, 4, 0, 0, 0, 0, 13, 12, 0, 0, 0, 0, 0, 2, 16, 6, 0, 0, 0, 0, 0, 4, 16, 13, 12, 5, 0, 0, 0, 6, 16, 14, 12, 15, 4, 0, 0, 0, 11, 14, 5, 14, 11, 0, 0, 0, 0, 12, 16, 16, 8, 0], \"target\": 6}, {\"id\": \"optdigits.tra:2328\", \"features\": [\"40\", \"74\", \"96\", \"101\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"2328\", \"pixels\": [0, 0, 0, 0, 10, 8, 0, 0, 0, 0, 0, 4, 15, 2, 0, 0, 0, 0, 1, 13, 9, 5, 3, 0, 0, 0, 8, 14, 2, 14, 6, 0, 0, 5, 15, 4, 1, 16, 3, 0, 0, 14, 15, 14, 16, 16, 4, 0, 0, 8, 12, 9, 12, 13, 0, 0, 0, 0, 0, 0, 12, 8, 0, 0], \"target\": 4}, {\"id\": \"optdigits.tra:2331\", \"features\": [\"89\", \"62\", \"51\", \"68\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"2331\", \"pixels\": [0, 0, 9, 12, 14, 14, 4, 0, 0, 0, 15, 7, 4, 4, 2, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 3, 15, 14, 14, 6, 0, 0, 0, 4, 7, 2, 2, 15, 0, 0, 0, 0, 0, 0, 0, 12, 2, 0, 0, 0, 9, 2, 2, 14, 0, 0, 0, 0, 11, 16, 16, 5, 0, 0], \"target\": 5}, {\"id\": \"optdigits.tra:2413\", \"features\": [\"83\", \"94\", \"69\", \"86\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"2413\", \"pixels\": [0, 0, 1, 8, 16, 8, 0, 0, 0, 2, 14, 13, 12, 16, 2, 0, 0, 10, 9, 0, 7, 15, 1, 0, 0, 3, 14, 9, 15, 2, 0, 0, 0, 0, 10, 16, 12, 2, 0, 0, 0, 0, 12, 6, 5, 15, 3, 0, 0, 0, 9, 8, 0, 13, 7, 0, 0, 0, 0, 8, 16, 12, 1, 0], \"target\": 8}, {\"id\": \"optdigits.tra:2927\", \"features\": [\"99\", \"90\", \"54\", \"83\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"2927\", \"pixels\": [0, 0, 6, 8, 12, 15, 4, 0, 0, 1, 15, 13, 12, 12, 4, 0, 0, 0, 16, 5, 0, 0, 0, 0, 0, 3, 16, 16, 16, 14, 1, 0, 0, 2, 11, 5, 5, 15, 8, 0, 0, 0, 0, 0, 0, 16, 4, 0, 0, 0, 5, 8, 13, 11, 0, 0, 0, 0, 8, 15, 10, 1, 0, 0], \"target\": 5}, {\"id\": \"optdigits.tra:3009\", \"features\": [\"60\", \"53\", \"92\", \"146\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3009\", \"pixels\": [0, 0, 0, 5, 16, 10, 0, 0, 0, 0, 0, 13, 14, 0, 0, 0, 0, 0, 3, 16, 9, 0, 0, 0, 0, 0, 7, 16, 4, 0, 0, 0, 0, 0, 10, 16, 12, 8, 1, 0, 0, 2, 16, 16, 16, 16, 11, 0, 0, 1, 9, 16, 11, 12, 16, 1, 0, 0, 0, 6, 16, 16, 10, 0], \"target\": 6}, {\"id\": \"optdigits.tra:3013\", \"features\": [\"31\", \"95\", \"86\", \"45\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3013\", \"pixels\": [0, 0, 9, 15, 16, 12, 1, 0, 0, 0, 3, 4, 4, 15, 6, 0, 0, 0, 0, 0, 0, 16, 4, 0, 0, 0, 0, 0, 8, 13, 0, 0, 0, 3, 12, 16, 16, 15, 4, 0, 0, 3, 5, 12, 9, 0, 0, 0, 0, 0, 3, 15, 1, 0, 0, 0, 0, 0, 11, 6, 0, 0, 0, 0], \"target\": 7}, {\"id\": \"optdigits.tra:3024\", \"features\": [\"82\", \"108\", \"13\", \"61\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3024\", \"pixels\": [0, 0, 2, 9, 12, 13, 3, 0, 0, 1, 14, 10, 4, 14, 5, 0, 0, 6, 12, 4, 8, 16, 2, 0, 0, 1, 11, 12, 12, 16, 3, 0, 0, 0, 0, 0, 8, 11, 0, 0, 0, 0, 0, 1, 14, 4, 0, 0, 0, 0, 0, 5, 14, 0, 0, 0, 0, 0, 0, 7, 10, 0, 0, 0], \"target\": 9}, {\"id\": \"optdigits.tra:3034\", \"features\": [\"100\", \"56\", \"47\", \"86\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3034\", \"pixels\": [0, 0, 1, 13, 10, 0, 0, 0, 0, 0, 9, 16, 4, 0, 0, 0, 0, 1, 16, 8, 0, 4, 0, 0, 0, 4, 16, 16, 16, 16, 6, 0, 0, 0, 8, 8, 12, 16, 5, 0, 0, 0, 0, 1, 16, 13, 0, 0, 0, 0, 0, 13, 16, 3, 0, 0, 0, 0, 2, 15, 5, 0, 0, 0], \"target\": 4}, {\"id\": \"optdigits.tra:3037\", \"features\": [\"86\", \"75\", \"29\", \"119\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3037\", \"pixels\": [0, 0, 2, 16, 14, 1, 0, 0, 0, 0, 6, 16, 16, 5, 0, 0, 0, 2, 16, 16, 16, 3, 0, 0, 0, 0, 3, 9, 16, 4, 0, 0, 0, 0, 0, 2, 16, 10, 0, 0, 0, 0, 0, 0, 15, 16, 0, 0, 0, 0, 2, 9, 16, 16, 3, 0, 0, 0, 2, 14, 16, 10, 1, 0], \"target\": 1}, {\"id\": \"optdigits.tra:3047\", \"features\": [\"74\", \"107\", \"106\", \"62\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3047\", \"pixels\": [0, 0, 7, 16, 16, 10, 0, 0, 0, 4, 16, 13, 16, 15, 0, 0, 0, 0, 8, 2, 16, 12, 0, 0, 0, 0, 0, 8, 16, 6, 0, 0, 0, 0, 4, 16, 9, 0, 0, 0, 0, 1, 13, 15, 2, 0, 0, 0, 0, 1, 16, 15, 12, 12, 5, 0, 0, 0, 9, 16, 14, 7, 1, 0], \"target\": 2}, {\"id\": \"optdigits.tra:3097\", \"features\": [\"68\", \"53\", \"55\", \"107\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3097\", \"pixels\": [0, 1, 11, 14, 6, 0, 0, 0, 0, 7, 12, 5, 15, 0, 0, 0, 0, 6, 6, 1, 16, 0, 0, 0, 0, 0, 0, 5, 16, 0, 0, 0, 0, 0, 0, 13, 16, 12, 0, 0, 0, 0, 0, 0, 3, 14, 6, 0, 0, 0, 5, 7, 6, 14, 8, 0, 0, 0, 14, 16, 16, 11, 1, 0], \"target\": 3}, {\"id\": \"optdigits.tra:3108\", \"features\": [\"103\", \"94\", \"106\", \"80\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3108\", \"pixels\": [0, 0, 7, 13, 16, 13, 2, 0, 0, 2, 16, 15, 5, 13, 10, 0, 0, 6, 16, 3, 0, 7, 11, 0, 0, 11, 14, 0, 0, 5, 12, 0, 0, 8, 16, 0, 0, 4, 12, 0, 0, 8, 15, 0, 0, 7, 11, 0, 0, 7, 16, 8, 8, 15, 2, 0, 0, 0, 12, 16, 16, 5, 0, 0], \"target\": 0}, {\"id\": \"optdigits.tra:3174\", \"features\": [\"100\", \"101\", \"100\", \"54\"], \"role\": \"train\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3174\", \"pixels\": [0, 0, 10, 14, 14, 11, 1, 0, 0, 4, 16, 12, 5, 14, 11, 0, 0, 5, 14, 2, 4, 13, 8, 0, 0, 1, 11, 11, 14, 6, 0, 0, 0, 0, 9, 16, 5, 0, 0, 0, 0, 4, 13, 11, 9, 0, 0, 0, 0, 5, 11, 2, 16, 2, 0, 0, 0, 0, 13, 16, 16, 6, 0, 0], \"target\": 8}, {\"id\": \"optdigits.tra:3794\", \"features\": [\"138\", \"59\", \"50\", \"73\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3794\", \"pixels\": [0, 0, 15, 15, 16, 14, 1, 0, 0, 3, 16, 15, 8, 7, 0, 0, 0, 8, 16, 9, 1, 0, 0, 0, 0, 9, 16, 16, 12, 0, 0, 0, 0, 1, 2, 0, 16, 4, 0, 0, 0, 0, 0, 0, 13, 8, 0, 0, 0, 2, 7, 7, 16, 4, 0, 0, 0, 0, 15, 16, 12, 0, 0, 0], \"target\": 5}, {\"id\": \"optdigits.tra:3796\", \"features\": [\"82\", \"73\", \"47\", \"124\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3796\", \"pixels\": [0, 0, 12, 16, 7, 0, 0, 0, 0, 2, 16, 14, 16, 5, 0, 0, 0, 0, 14, 5, 11, 13, 0, 0, 0, 0, 2, 1, 8, 13, 0, 0, 0, 0, 0, 0, 8, 15, 0, 0, 0, 0, 0, 0, 13, 10, 0, 0, 0, 0, 10, 10, 16, 6, 0, 0, 0, 0, 11, 16, 16, 16, 16, 8], \"target\": 2}, {\"id\": \"optdigits.tra:3810\", \"features\": [\"92\", \"85\", \"86\", \"99\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3810\", \"pixels\": [0, 0, 5, 15, 16, 6, 0, 0, 0, 0, 15, 12, 5, 16, 2, 0, 0, 4, 16, 3, 0, 12, 8, 0, 0, 8, 14, 0, 0, 10, 10, 0, 0, 8, 13, 0, 0, 10, 13, 0, 0, 4, 16, 0, 0, 4, 15, 0, 0, 1, 15, 9, 3, 12, 10, 0, 0, 0, 5, 15, 16, 15, 1, 0], \"target\": 0}, {\"id\": \"optdigits.tra:3812\", \"features\": [\"6\", \"114\", \"61\", \"98\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3812\", \"pixels\": [0, 0, 0, 0, 7, 11, 1, 0, 0, 0, 0, 0, 12, 16, 3, 0, 0, 0, 0, 4, 16, 16, 0, 0, 0, 0, 0, 2, 16, 16, 0, 0, 0, 0, 1, 13, 16, 12, 0, 0, 0, 0, 7, 16, 15, 14, 0, 0, 0, 2, 15, 5, 12, 11, 0, 0, 0, 0, 2, 0, 7, 11, 0, 0], \"target\": 1}, {\"id\": \"optdigits.tra:3815\", \"features\": [\"117\", \"94\", \"111\", \"19\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3815\", \"pixels\": [0, 0, 9, 16, 6, 0, 0, 0, 0, 2, 14, 16, 16, 8, 3, 0, 0, 0, 14, 16, 16, 16, 11, 0, 0, 0, 14, 16, 12, 5, 1, 0, 0, 0, 9, 16, 5, 0, 0, 0, 0, 0, 15, 16, 5, 0, 0, 0, 0, 0, 16, 16, 8, 0, 0, 0, 0, 0, 10, 13, 1, 0, 0, 0], \"target\": 8}, {\"id\": \"optdigits.tra:3817\", \"features\": [\"87\", \"88\", \"58\", \"95\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3817\", \"pixels\": [0, 1, 10, 16, 16, 4, 0, 0, 0, 8, 13, 12, 16, 10, 0, 0, 0, 2, 0, 14, 15, 3, 0, 0, 0, 0, 0, 11, 16, 8, 0, 0, 0, 0, 0, 0, 7, 16, 3, 0, 0, 2, 1, 0, 0, 13, 8, 0, 0, 8, 12, 4, 10, 16, 5, 0, 0, 2, 13, 16, 12, 5, 0, 0], \"target\": 3}, {\"id\": \"optdigits.tra:3819\", \"features\": [\"77\", \"76\", \"31\", \"90\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3819\", \"pixels\": [0, 0, 5, 13, 11, 2, 0, 0, 0, 2, 15, 6, 5, 12, 0, 0, 0, 6, 12, 0, 1, 16, 2, 0, 0, 1, 12, 5, 5, 16, 6, 0, 0, 0, 1, 9, 9, 12, 8, 0, 0, 0, 0, 0, 0, 3, 13, 0, 0, 0, 0, 0, 1, 8, 10, 0, 0, 0, 8, 13, 15, 10, 1, 0], \"target\": 9}, {\"id\": \"optdigits.tra:3820\", \"features\": [\"64\", \"36\", \"102\", \"74\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3820\", \"pixels\": [0, 0, 0, 1, 12, 1, 0, 0, 0, 0, 0, 14, 10, 0, 0, 0, 0, 0, 10, 14, 2, 0, 0, 0, 0, 2, 16, 7, 0, 5, 6, 0, 0, 12, 15, 0, 9, 15, 1, 0, 0, 12, 16, 14, 16, 8, 0, 0, 0, 7, 12, 10, 15, 1, 0, 0, 0, 0, 0, 4, 9, 0, 0, 0], \"target\": 4}, {\"id\": \"optdigits.tra:3822\", \"features\": [\"95\", \"2\", \"124\", \"127\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3822\", \"pixels\": [0, 0, 6, 16, 2, 0, 0, 0, 0, 0, 15, 10, 0, 0, 0, 0, 0, 6, 16, 3, 0, 0, 0, 0, 0, 9, 14, 0, 0, 0, 0, 0, 0, 12, 13, 11, 12, 12, 3, 0, 0, 7, 16, 15, 12, 13, 13, 0, 0, 2, 15, 12, 2, 8, 15, 0, 0, 0, 5, 16, 16, 16, 5, 0], \"target\": 6}, {\"id\": \"optdigits.tra:3823\", \"features\": [\"29\", \"116\", \"41\", \"69\"], \"role\": \"validation\", \"nativeFile\": \"optdigits.tra\", \"nativeDataRow\": \"3823\", \"pixels\": [0, 0, 2, 15, 16, 13, 1, 0, 0, 0, 3, 7, 10, 16, 10, 0, 0, 0, 0, 0, 0, 11, 11, 0, 0, 0, 0, 2, 8, 15, 5, 0, 0, 0, 0, 9, 16, 16, 8, 0, 0, 0, 0, 2, 16, 5, 0, 0, 0, 0, 0, 12, 7, 0, 0, 0, 0, 0, 4, 14, 1, 0, 0, 0], \"target\": 7}], \"alignment\": \"matched\"}')\n\nrs=INPUT['rows'];X=[[F(v)for v in r['features']]for r in rs];n=len(rs);pred=[]\nfor i,r in enumerate(rs):\n ds=[sum((x-y)**2 for x,y in zip(X[i],X[j if INPUT['alignment']=='matched'else(j+1)%n]))for j in range(n)];best=min(range(n),key=lambda j:ds[j]);pred.append(dict(id=r['id'],prediction=rs[best]['id'],correct=best==i,minimumDistance=qs(ds[best])));point('Native feature 1',r['id'],X[i][0])\nsummary=dict(records=str(n),alignment=INPUT['alignment'],pairCorrect=str(sum(r['correct']for r in pred)));result=dict(retrieval=pred,sourceScope='Retained native numeric features; both representations share their origin. Known-corpus retrieval, not semantic encoder evaluation.')\nif INPUT['case']=='person':\n predictions=[];means=[]\n for profile in ['quadrants','pixels']:\n  V=[[F(v)for v in r['features']]if profile=='quadrants'else list(map(F,r['pixels']))for r in rs];P=[]\n  for label in range(10):\n   train=[V[i]for i,r in enumerate(rs)if r['role']=='train'and r['target']==label];assert len(train)==4;P.append([sum((v[j]for v in train),F(0))/4 for j in range(len(V[0]))])\n  for i,r in enumerate(rs):\n   ds=[sum((x-y)**2 for x,y in zip(V[i],p))for p in P];best=min(range(10),key=lambda j:ds[j]);predictions.append(dict(id=r['id'],role=r['role'],profile=profile,prediction=best,target=r['target'],correct=best==r['target'],minimumDistance=qs(ds[best])))\n  for role in ['train','validation','test']:\n   a=[r for r in predictions if r['role']==role and r['profile']==profile];correct=sum(r['correct']for r in a);means.append(dict(profile=profile,role=role,correct=correct,records=len(a),accuracy=qs(F(correct,len(a)))))\n candidates=[m for m in means if m['role']=='validation'];best=max(candidates,key=lambda m:F(m['accuracy']));summary['selectedProfile']=best['profile'];summary['validationAccuracy']=best['accuracy'];summary['testAccuracy']=next(m['accuracy']for m in means if m['profile']==best['profile']and m['role']=='test');result.update(classPredictions=predictions,classMeans=means,selected=best['profile'],unsafeTargetCaptionExcluded=True)\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['label'],34)for p in points],fontsize=9);ax.invert_yaxis();ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"alignment\":\"matched\",\"pairCorrect\":\"120\",\"records\":\"120\",\"selectedProfile\":\"pixels\",\"testAccuracy\":\"5/6\",\"validationAccuracy\":\"19/20\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/realdata-person-python/stdout.txt",
        "stderrFile": "ai18-fixed/realdata-person-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "alignment",
            "value": "matched"
          },
          {
            "metric": "pairCorrect",
            "value": "120"
          },
          {
            "metric": "records",
            "value": "120"
          },
          {
            "metric": "selectedProfile",
            "value": "pixels"
          },
          {
            "metric": "testAccuracy",
            "value": "5/6"
          },
          {
            "metric": "validationAccuracy",
            "value": "19/20"
          }
        ],
        "resultFile": "ai18-fixed/realdata-person-python/result.json",
        "summaryFile": "ai18-fixed/realdata-person-python/summary.json",
        "plotDataFile": "ai18-fixed/realdata-person-python/points.csv",
        "plotFile": "ai18-fixed/realdata-person-python/plot.svg",
        "plotSHA256": "dc983ee6e98bd6b484a8b9b8fc42d09e44360bc45358e4f46b5feda7ef9c2d1c"
      },
      "realdata-company": {
        "api": "realdata",
        "variant": "realdata-company",
        "language": "python",
        "codeFile": "ai18-fixed/realdata-company-python.py",
        "codeSHA256": "2e40d25863e6391551a246864d0ea3953311e96c5b3b8c88066bd7d431766c58",
        "expectedFailure": false,
        "title": "Retained nominal company sales",
        "code": "# AI18 fixed standalone example. Standard library + Matplotlib Agg.\n# No JS engine/source model/public answer file is read. Exact fractions and\n# source-derived inputs are embedded below; logs are approximate projections.\nfrom pathlib import Path\nfrom fractions import Fraction as F\nimport json,sys,math,hashlib,csv,textwrap\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nO=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_suffix('');O.mkdir(parents=True,exist_ok=True)\ndef qs(v):return str(v.numerator) if v.denominator==1 else str(v.numerator)+'/'+str(v.denominator)\ndef f9(v):return format(v,'.9g')\nsummary={};points=[];result={}\ndef point(series,label,value):points.append(dict(series=series,label=label,valueToken=''if value is None else qs(value)if isinstance(value,F)else f9(value),defined='false'if value is None else'true'))\n\nTITLE='Retained nominal company sales'\nINPUT=json.loads('{\"case\": \"company\", \"rows\": [{\"id\": \"Apple:iPhone:2019\", \"features\": [\"142381\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"1\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:iPhone:2020\", \"features\": [\"137781\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"2\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:iPhone:2021\", \"features\": [\"191973\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"3\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:iPhone:2022\", \"features\": [\"205489\"], \"role\": \"validation\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"4\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:iPhone:2023\", \"features\": [\"200583\"], \"role\": \"test\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"5\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:iPhone:2024\", \"features\": [\"201183\"], \"role\": \"test\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"6\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Mac:2019\", \"features\": [\"25740\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"7\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Mac:2020\", \"features\": [\"28622\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"8\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Mac:2021\", \"features\": [\"35190\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"9\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Mac:2022\", \"features\": [\"40177\"], \"role\": \"validation\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"10\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Mac:2023\", \"features\": [\"29357\"], \"role\": \"test\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"11\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Mac:2024\", \"features\": [\"29984\"], \"role\": \"test\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"12\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:iPad:2019\", \"features\": [\"21280\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"13\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:iPad:2020\", \"features\": [\"23724\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"14\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:iPad:2021\", \"features\": [\"31862\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"15\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:iPad:2022\", \"features\": [\"29292\"], \"role\": \"validation\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"16\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:iPad:2023\", \"features\": [\"28300\"], \"role\": \"test\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"17\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:iPad:2024\", \"features\": [\"26694\"], \"role\": \"test\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"18\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Wearables, Home and Accessories:2019\", \"features\": [\"24482\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"19\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Wearables, Home and Accessories:2020\", \"features\": [\"30620\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"20\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Wearables, Home and Accessories:2021\", \"features\": [\"38367\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"21\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Wearables, Home and Accessories:2022\", \"features\": [\"41241\"], \"role\": \"validation\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"22\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Wearables, Home and Accessories:2023\", \"features\": [\"39845\"], \"role\": \"test\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"23\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Wearables, Home and Accessories:2024\", \"features\": [\"37005\"], \"role\": \"test\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"24\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Services:2019\", \"features\": [\"46291\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"25\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Services:2020\", \"features\": [\"53768\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"26\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Services:2021\", \"features\": [\"68425\"], \"role\": \"train\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"27\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Services:2022\", \"features\": [\"78129\"], \"role\": \"validation\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"28\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Services:2023\", \"features\": [\"85200\"], \"role\": \"test\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"29\", \"pixels\": null, \"target\": null}, {\"id\": \"Apple:Services:2024\", \"features\": [\"96169\"], \"role\": \"test\", \"nativeFile\": \"actual30-Apple-product-sales-FY2019-2024.csv\", \"nativeDataRow\": \"30\", \"pixels\": null, \"target\": null}], \"alignment\": \"cyclic-mispair\"}')\n\nrs=INPUT['rows'];X=[[F(v)for v in r['features']]for r in rs];n=len(rs);pred=[]\nfor i,r in enumerate(rs):\n ds=[sum((x-y)**2 for x,y in zip(X[i],X[j if INPUT['alignment']=='matched'else(j+1)%n]))for j in range(n)];best=min(range(n),key=lambda j:ds[j]);pred.append(dict(id=r['id'],prediction=rs[best]['id'],correct=best==i,minimumDistance=qs(ds[best])));point('Native feature 1',r['id'],X[i][0])\nsummary=dict(records=str(n),alignment=INPUT['alignment'],pairCorrect=str(sum(r['correct']for r in pred)));result=dict(retrieval=pred,sourceScope='Retained native numeric features; both representations share their origin. Known-corpus retrieval, not semantic encoder evaluation.')\nif INPUT['case']=='person':\n predictions=[];means=[]\n for profile in ['quadrants','pixels']:\n  V=[[F(v)for v in r['features']]if profile=='quadrants'else list(map(F,r['pixels']))for r in rs];P=[]\n  for label in range(10):\n   train=[V[i]for i,r in enumerate(rs)if r['role']=='train'and r['target']==label];assert len(train)==4;P.append([sum((v[j]for v in train),F(0))/4 for j in range(len(V[0]))])\n  for i,r in enumerate(rs):\n   ds=[sum((x-y)**2 for x,y in zip(V[i],p))for p in P];best=min(range(10),key=lambda j:ds[j]);predictions.append(dict(id=r['id'],role=r['role'],profile=profile,prediction=best,target=r['target'],correct=best==r['target'],minimumDistance=qs(ds[best])))\n  for role in ['train','validation','test']:\n   a=[r for r in predictions if r['role']==role and r['profile']==profile];correct=sum(r['correct']for r in a);means.append(dict(profile=profile,role=role,correct=correct,records=len(a),accuracy=qs(F(correct,len(a)))))\n candidates=[m for m in means if m['role']=='validation'];best=max(candidates,key=lambda m:F(m['accuracy']));summary['selectedProfile']=best['profile'];summary['validationAccuracy']=best['accuracy'];summary['testAccuracy']=next(m['accuracy']for m in means if m['profile']==best['profile']and m['role']=='test');result.update(classPredictions=predictions,classMeans=means,selected=best['profile'],unsafeTargetCaptionExcluded=True)\n\n(O/'summary.json').write_text(json.dumps(summary,sort_keys=True,separators=(',',':'))+'\\n',encoding='utf8');(O/'result.json').write_text(json.dumps(result,ensure_ascii=False,separators=(',',':'))+'\\n',encoding='utf8')\nwith(O/'points.csv').open('w',encoding='utf8',newline='')as f:w=csv.DictWriter(f,fieldnames=['series','label','valueToken','defined'],lineterminator='\\n');w.writeheader();w.writerows(points)\nfig,ax=plt.subplots(figsize=(9,max(4,min(18,.26*len(points)+2))));y=list(range(len(points)));values=[float(F(p['valueToken']))if p['defined']=='true'else None for p in points]\nfor i,(p,v)in enumerate(zip(points,values)):\n if v is not None:ax.barh(i,v,color='#285e86');ax.text(v,i,' '+p['valueToken'][:22],va='center',fontsize=9)\n else:ax.text(.02,i,'Undefined · no point',va='center',fontsize=10,color='#8b382e')\nax.set_yticks(y,[textwrap.fill(p['label'],34)for p in points],fontsize=9);ax.invert_yaxis();ax.axvline(0,color='#6a747d',lw=.7);ax.set_title(TITLE,fontsize=13);ax.set_xlabel('Exact input/result projection · see full JSON and CSV',fontsize=10);ax.spines[['top','right']].set_visible(False);fig.tight_layout();fig.savefig(O/'plot.svg',format='svg');plt.close(fig);print(json.dumps(summary,sort_keys=True,separators=(',',':')))\n",
        "exitCode": 0,
        "stdout": "{\"alignment\":\"cyclic-mispair\",\"pairCorrect\":\"0\",\"records\":\"30\"}\r\n",
        "stderr": "",
        "stderrIsProjection": false,
        "rawStderrSHA256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "stdoutFile": "ai18-fixed/realdata-company-python/stdout.txt",
        "stderrFile": "ai18-fixed/realdata-company-python/stderr.txt",
        "invocationTemplate": "python <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "alignment",
            "value": "cyclic-mispair"
          },
          {
            "metric": "pairCorrect",
            "value": "0"
          },
          {
            "metric": "records",
            "value": "30"
          }
        ],
        "resultFile": "ai18-fixed/realdata-company-python/result.json",
        "summaryFile": "ai18-fixed/realdata-company-python/summary.json",
        "plotDataFile": "ai18-fixed/realdata-company-python/points.csv",
        "plotFile": "ai18-fixed/realdata-company-python/plot.svg",
        "plotSHA256": "9963ed930895684b45b137d2b64fe3f5eea802c574bf729ecfcd48d6c6682228"
      }
    },
    "r": {
      "realdata-country": {
        "api": "realdata",
        "variant": "realdata-country",
        "language": "r",
        "codeFile": "ai18-fixed/realdata-country-r.R",
        "codeSHA256": "67f0fdebe77bae06b380b9a2cdbbb37624a7b1d7ec898370680d7a6955ebe765",
        "expectedFailure": false,
        "title": "Retained country numeric views",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"Retained GDP growth (annual percent)\"\nINPUT<-list(case=\"country\",rows=list(list(id=\"WB:AUS\",features=list(\"1.37340773365975\",\"3.16656665428797\"),role=\"train\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"1\",pixels=NULL,target=NULL),list(id=\"WB:BRA\",features=list(\"3.41931516501906\",\"4.36746407652336\"),role=\"train\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"2\",pixels=NULL,target=NULL),list(id=\"WB:CAN\",features=list(\"2.04626605401701\",\"2.38158383281173\"),role=\"test\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"3\",pixels=NULL,target=NULL),list(id=\"WB:CHN\",features=list(\"4.95830378788091\",\"0.218128938439177\"),role=\"train\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"4\",pixels=NULL,target=NULL),list(id=\"WB:DEU\",features=list(\"-0.495851897260366\",\"2.2564981433876\"),role=\"validation\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"5\",pixels=NULL,target=NULL),list(id=\"WB:FRA\",features=list(\"1.19046798275883\",\"1.99742599742599\"),role=\"train\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"6\",pixels=NULL,target=NULL),list(id=\"WB:GBR\",features=list(\"1.08027716858781\",\"3.2715729463592\"),role=\"validation\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"7\",pixels=NULL,target=NULL),list(id=\"WB:IDN\",features=list(\"5.03257477088519\",\"2.18151273615188\"),role=\"validation\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"8\",pixels=NULL,target=NULL),list(id=\"WB:IND\",features=list(\"7.09927893176518\",\"4.9530355097366\"),role=\"train\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"9\",pixels=NULL,target=NULL),list(id=\"WB:JPN\",features=list(\"-0.240084236041696\",\"2.7385368163524\"),role=\"train\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"10\",pixels=NULL,target=NULL),list(id=\"WB:KOR\",features=list(\"2.00361101838986\",\"2.32174328643542\"),role=\"train\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"11\",pixels=NULL,target=NULL),list(id=\"WB:MEX\",features=list(\"1.35057631384696\",\"4.72225588452931\"),role=\"test\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"12\",pixels=NULL,target=NULL),list(id=\"WB:SGP\",features=list(\"5.3435120192366\",\"2.38951123595017\"),role=\"train\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"13\",pixels=NULL,target=NULL),list(id=\"WB:USA\",features=list(\"2.79318715363841\",\"2.94952520485207\"),role=\"validation\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"14\",pixels=NULL,target=NULL),list(id=\"WB:VNM\",features=list(\"7.03955197123018\",\"3.62109273885843\"),role=\"test\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"15\",pixels=NULL,target=NULL),list(id=\"WB:ZAF\",features=list(\"0.534843531905139\",\"4.36115246518962\"),role=\"test\",nativeFile=\"actual32-country-observations-2024.csv\",nativeDataRow=\"16\",pixels=NULL,target=NULL)),alignment=\"matched\")\n\nrs<-INPUT$rows;tokens<-unlist(lapply(rs,function(r)r$features));digits<-max(vapply(strsplit(tokens,'.',fixed=TRUE),function(v)if(length(v)>1)nchar(v[2])else 0,0));den<-paste0('1',paste(rep('0',2*digits),collapse=''));X<-lapply(rs,function(r)lapply(r$features,scaled,d=digits));n<-length(rs);pred<-list()\nfor(i in seq_len(n)){ds<-lapply(seq_len(n),function(j)distance(X[[i]],X[[if(INPUT$alignment=='matched')j else j%%n+1]]));best<-1;for(j in seq_len(n))if(bcmp(ds[[j]],ds[[best]])<0)best<-j;pred[[i]]<-list(id=rs[[i]]$id,prediction=rs[[best]]$id,correct=best==i,minimumDistanceNumerator=bstr(ds[[best]]),minimumDistanceDenominator=den);point('Native feature 1',rs[[i]]$id,as.numeric(rs[[i]]$features[[1]]))}\nsummary<-list(records=as.character(n),alignment=INPUT$alignment,pairCorrect=as.character(sum(vapply(pred,function(r)r$correct,TRUE))));result<-list(retrieval=pred,sourceScope='Retained native numeric features; both representations share their origin. Known-corpus retrieval, not semantic encoder evaluation.')\nif(INPUT$case=='person'){\n predictions<-list();means<-list()\n for(profile in c('quadrants','pixels')){V<-lapply(rs,function(r)as.numeric(unlist(if(profile=='quadrants')r$features else r$pixels)));P<-list();for(label in 0:9){train<-which(vapply(rs,function(r)r$role=='train'&&r$target==label,TRUE));stopifnot(length(train)==4);P[[label+1]]<-Reduce('+',V[train])/4}\n  for(i in seq_len(n)){ds<-vapply(P,function(p)sum((V[[i]]-p)^2),0.0);best<-which.min(ds)-1;predictions[[length(predictions)+1]]<-list(id=rs[[i]]$id,role=rs[[i]]$role,profile=profile,prediction=best,target=rs[[i]]$target,correct=best==rs[[i]]$target,minimumDistance=qs(ds[best+1]*16,16))}\n  for(role in c('train','validation','test')){a<-Filter(function(r)r$role==role&&r$profile==profile,predictions);correct<-sum(vapply(a,function(r)r$correct,TRUE));means[[length(means)+1]]<-list(profile=profile,role=role,correct=correct,records=length(a),accuracy=qs(correct,length(a)))}\n }\n candidates<-Filter(function(m)m$role=='validation',means);best<-candidates[[which.max(vapply(candidates,function(m)m$correct/m$records,0.0))]];summary$selectedProfile<-best$profile;summary$validationAccuracy<-best$accuracy;summary$testAccuracy<-Filter(function(m)m$profile==best$profile&&m$role=='test',means)[[1]]$accuracy;result$classPredictions<-predictions;result$classMeans<-means;result$selected<-best$profile;result$unsafeTargetCaptionExcluded<-TRUE\n}\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(p$label,width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"alignment\":\"matched\",\"pairCorrect\":\"16\",\"records\":\"16\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/realdata-country-r/stdout.txt",
        "stderrFile": "ai18-fixed/realdata-country-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "alignment",
            "value": "matched"
          },
          {
            "metric": "pairCorrect",
            "value": "16"
          },
          {
            "metric": "records",
            "value": "16"
          }
        ],
        "resultFile": "ai18-fixed/realdata-country-r/result.json",
        "summaryFile": "ai18-fixed/realdata-country-r/summary.json",
        "plotDataFile": "ai18-fixed/realdata-country-r/points.csv",
        "plotFile": "ai18-fixed/realdata-country-r/plot.svg",
        "plotSHA256": "08b75dc36030f7481d2c36e4609be5114300b39cbee61a573d4e9a8992f381d8"
      },
      "realdata-person": {
        "api": "realdata",
        "variant": "realdata-person",
        "language": "r",
        "codeFile": "ai18-fixed/realdata-person-r.R",
        "codeSHA256": "e5067328e866329ecb12fb309ee4a1a691cdb52c380a9aec2c87fc38db34963c",
        "expectedFailure": false,
        "title": "Native digit training and validation",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"Native digit training and validation\"\nINPUT<-list(case=\"person\",rows=list(list(id=\"optdigits.tes:1\",features=list(\"82\",\"75\",\"68\",\"69\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1\",pixels=list(0,0,5,13,9,1,0,0,0,0,13,15,10,15,5,0,0,3,15,2,0,11,8,0,0,4,12,0,0,8,8,0,0,5,8,0,0,9,8,0,0,4,11,0,1,12,7,0,0,2,14,5,10,12,0,0,0,0,6,13,10,0,0,0),target=0),list(id=\"optdigits.tes:2\",features=list(\"79\",\"83\",\"62\",\"89\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"2\",pixels=list(0,0,0,12,13,5,0,0,0,0,0,11,16,9,0,0,0,0,3,15,16,6,0,0,0,7,15,16,16,2,0,0,0,0,1,16,16,3,0,0,0,0,1,16,16,6,0,0,0,0,1,16,16,6,0,0,0,0,0,11,16,10,0,0),target=1),list(id=\"optdigits.tes:3\",features=list(\"51\",\"106\",\"98\",\"89\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"3\",pixels=list(0,0,0,4,15,12,0,0,0,0,3,16,15,14,0,0,0,0,8,13,8,16,0,0,0,0,1,6,15,11,0,0,0,1,8,13,15,1,0,0,0,9,16,16,5,0,0,0,0,3,13,16,16,11,5,0,0,0,0,3,11,16,9,0),target=2),list(id=\"optdigits.tes:4\",features=list(\"82\",\"58\",\"33\",\"94\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"4\",pixels=list(0,0,7,15,13,1,0,0,0,8,13,6,15,4,0,0,0,2,1,13,13,0,0,0,0,0,2,15,11,1,0,0,0,0,0,1,12,12,1,0,0,0,0,0,1,10,8,0,0,0,8,4,5,14,9,0,0,0,7,13,13,9,0,0),target=3),list(id=\"optdigits.tes:5\",features=list(\"44\",\"46\",\"71\",\"97\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"5\",pixels=list(0,0,0,1,11,0,0,0,0,0,0,7,8,0,0,0,0,0,1,13,6,2,2,0,0,0,7,15,0,9,8,0,0,5,16,10,0,16,6,0,0,4,15,16,13,16,1,0,0,0,0,3,15,10,0,0,0,0,0,2,16,4,0,0),target=4),list(id=\"optdigits.tes:6\",features=list(\"108\",\"79\",\"38\",\"117\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"6\",pixels=list(0,0,12,10,0,0,0,0,0,0,14,16,16,14,0,0,0,0,13,16,15,10,1,0,0,0,11,16,16,7,0,0,0,0,0,4,7,16,7,0,0,0,0,0,4,16,9,0,0,0,5,4,12,16,4,0,0,0,9,16,16,10,0,0),target=5),list(id=\"optdigits.tes:7\",features=list(\"89\",\"24\",\"89\",\"104\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"7\",pixels=list(0,0,0,12,13,0,0,0,0,0,5,16,8,0,0,0,0,0,13,16,3,0,0,0,0,0,14,13,0,0,0,0,0,0,15,12,7,2,0,0,0,0,13,16,13,16,3,0,0,0,7,16,11,15,8,0,0,0,1,9,15,11,3,0),target=6),list(id=\"optdigits.tes:8\",features=list(\"49\",\"130\",\"86\",\"25\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"8\",pixels=list(0,0,7,8,13,16,15,1,0,0,7,7,4,11,12,0,0,0,0,0,8,13,1,0,0,4,8,8,15,15,6,0,0,2,11,15,15,4,0,0,0,0,0,16,5,0,0,0,0,0,9,15,1,0,0,0,0,0,13,5,0,0,0,0),target=7),list(id=\"optdigits.tes:9\",features=list(\"87\",\"82\",\"91\",\"97\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"9\",pixels=list(0,0,9,14,8,1,0,0,0,0,12,14,14,12,0,0,0,0,9,10,0,15,4,0,0,0,3,16,12,14,2,0,0,0,4,16,16,2,0,0,0,3,16,8,10,13,2,0,0,1,15,1,3,16,8,0,0,0,11,16,15,11,1,0),target=8),list(id=\"optdigits.tes:10\",features=list(\"106\",\"80\",\"53\",\"90\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"10\",pixels=list(0,0,11,12,0,0,0,0,0,2,16,16,16,13,0,0,0,3,16,12,10,14,0,0,0,1,16,1,12,15,0,0,0,0,13,16,9,15,2,0,0,0,0,3,0,9,11,0,0,0,0,0,9,15,4,0,0,0,9,12,13,3,0,0),target=9),list(id=\"optdigits.tes:335\",features=list(\"83\",\"91\",\"83\",\"87\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"335\",pixels=list(0,0,3,11,16,10,0,0,0,0,10,16,10,14,6,0,0,0,15,7,0,11,8,0,0,3,16,2,0,8,8,0,0,4,12,0,0,9,8,0,0,6,15,1,0,12,8,0,0,3,15,10,8,15,4,0,0,0,5,12,14,9,0,0),target=0),list(id=\"optdigits.tes:341\",features=list(\"74\",\"83\",\"95\",\"63\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"341\",pixels=list(0,0,10,16,16,7,0,0,0,6,15,9,14,12,0,0,0,3,5,0,13,8,0,0,0,0,0,10,13,0,0,0,0,0,2,16,4,0,0,0,0,0,12,8,0,0,0,0,0,0,16,13,11,8,3,0,0,0,12,16,16,16,5,0),target=2),list(id=\"optdigits.tes:348\",features=list(\"79\",\"57\",\"63\",\"106\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"348\",pixels=list(0,2,10,14,11,1,0,0,0,7,15,8,16,4,0,0,0,1,1,6,15,1,0,0,0,0,0,15,9,0,0,0,0,0,1,16,15,9,1,0,0,0,0,1,6,15,8,0,0,2,8,4,6,15,7,0,0,2,13,16,15,9,0,0),target=3),list(id=\"optdigits.tes:350\",features=list(\"82\",\"54\",\"78\",\"78\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"350\",pixels=list(0,0,1,14,7,0,0,0,0,0,6,16,16,1,0,0,0,0,7,16,15,0,0,0,0,0,6,16,15,0,0,0,0,0,6,16,15,0,0,0,0,0,4,16,16,1,0,0,0,0,4,16,16,6,0,0,0,0,1,15,16,8,0,0),target=1),list(id=\"optdigits.tes:361\",features=list(\"72\",\"9\",\"97\",\"110\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"361\",pixels=list(0,0,1,13,7,0,0,0,0,0,7,14,2,0,0,0,0,0,13,5,0,0,0,0,0,0,16,3,0,0,0,0,0,3,16,10,12,12,3,0,0,3,16,11,5,9,12,0,0,1,13,11,4,13,11,0,0,0,1,12,16,11,2,0),target=6),list(id=\"optdigits.tes:365\",features=list(\"56\",\"78\",\"112\",\"64\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"365\",pixels=list(0,0,8,16,16,1,0,0,0,1,12,10,16,5,0,0,0,0,0,3,16,6,0,0,0,0,0,6,16,2,0,0,0,4,12,14,16,12,5,0,0,12,16,16,14,12,5,0,0,0,6,13,0,0,0,0,0,0,11,8,0,0,0,0),target=7),list(id=\"optdigits.tes:366\",features=list(\"135\",\"62\",\"49\",\"89\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"366\",pixels=list(0,2,12,13,16,15,1,0,0,8,16,14,11,7,0,0,0,8,16,7,0,0,0,0,0,7,16,16,11,1,0,0,0,0,2,6,15,9,0,0,0,0,0,0,9,15,0,0,0,0,1,7,16,11,0,0,0,1,16,16,13,1,0,0),target=5),list(id=\"optdigits.tes:371\",features=list(\"93\",\"92\",\"88\",\"96\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"371\",pixels=list(0,0,7,13,16,11,0,0,0,3,16,5,4,14,2,0,0,8,11,1,4,15,2,0,0,3,12,14,16,8,0,0,0,0,8,16,15,1,0,0,0,1,15,5,11,12,0,0,0,3,16,5,7,16,1,0,0,0,5,14,16,15,2,0),target=8),list(id=\"optdigits.tes:376\",features=list(\"82\",\"124\",\"16\",\"64\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"376\",pixels=list(0,0,0,5,13,16,8,0,0,0,8,15,6,7,14,0,0,2,16,1,1,11,10,0,0,4,16,15,16,16,6,0,0,0,4,4,5,15,1,0,0,0,0,0,9,8,0,0,0,0,0,2,15,1,0,0,0,0,0,6,10,0,0,0),target=9),list(id=\"optdigits.tes:378\",features=list(\"89\",\"42\",\"106\",\"76\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"378\",pixels=list(0,0,1,15,7,0,0,0,0,0,6,16,3,0,0,0,0,1,16,10,0,1,3,0,0,5,16,3,1,12,15,0,0,11,16,8,14,15,3,0,0,6,16,16,16,5,0,0,0,0,1,14,11,0,0,0,0,0,2,16,12,0,0,0),target=4),list(id=\"optdigits.tes:695\",features=list(\"75\",\"73\",\"78\",\"96\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"695\",pixels=list(0,0,1,13,12,1,0,0,0,0,9,16,16,12,0,0,0,0,14,6,0,13,3,0,0,6,10,0,0,10,6,0,0,7,13,0,0,9,8,0,0,3,16,1,3,14,7,0,0,0,11,16,16,16,1,0,0,0,0,11,16,6,0,0),target=0),list(id=\"optdigits.tes:700\",features=list(\"88\",\"89\",\"76\",\"63\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"700\",pixels=list(0,0,2,12,16,10,0,0,0,3,15,10,7,16,4,0,0,9,8,0,11,10,0,0,0,3,15,11,14,1,0,0,0,0,10,16,9,0,0,0,0,0,14,7,13,4,0,0,0,0,9,7,6,10,0,0,0,0,1,12,16,5,0,0),target=8),list(id=\"optdigits.tes:701\",features=list(\"86\",\"113\",\"64\",\"79\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"701\",pixels=list(0,0,3,12,16,16,3,0,0,2,16,16,11,16,4,0,0,8,14,2,10,16,1,0,0,5,5,3,16,4,0,0,0,0,0,11,12,0,0,0,0,0,3,16,5,2,3,0,0,0,3,16,12,15,6,0,0,0,0,15,16,8,0,0),target=2),list(id=\"optdigits.tes:709\",features=list(\"65\",\"104\",\"29\",\"109\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"709\",pixels=list(0,0,4,13,16,11,0,0,0,9,16,9,10,15,0,0,0,5,4,0,12,11,0,0,0,0,0,5,16,12,1,0,0,0,0,1,9,15,8,0,0,0,0,0,0,8,12,0,0,0,1,6,8,16,8,0,0,0,5,16,15,9,1,0),target=3),list(id=\"optdigits.tes:718\",features=list(\"107\",\"59\",\"81\",\"108\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"718\",pixels=list(0,0,6,16,16,16,10,0,0,0,13,15,9,6,0,0,0,6,16,4,0,0,0,0,0,12,15,4,2,0,0,0,0,8,16,16,16,15,1,0,0,0,6,8,9,16,4,0,0,0,1,3,13,15,1,0,0,0,7,16,15,3,0,0),target=5),list(id=\"optdigits.tes:720\",features=list(\"65\",\"106\",\"29\",\"66\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"720\",pixels=list(0,0,0,0,8,13,3,0,0,0,0,12,11,11,5,0,0,0,11,8,8,16,0,0,0,2,16,16,16,15,0,0,0,2,16,11,7,10,0,0,0,0,0,0,8,7,0,0,0,0,0,0,10,8,0,0,0,0,0,0,9,7,0,0),target=9),list(id=\"optdigits.tes:727\",features=list(\"55\",\"119\",\"50\",\"78\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"727\",pixels=list(0,0,0,10,16,11,1,0,0,0,0,15,16,15,2,0,0,0,1,13,16,14,0,0,0,0,1,15,16,12,0,0,0,0,0,14,16,8,0,0,0,0,0,13,16,5,0,0,0,0,1,14,16,1,0,0,0,0,0,8,15,1,0,0),target=1),list(id=\"optdigits.tes:728\",features=list(\"51\",\"128\",\"49\",\"77\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"728\",pixels=list(0,0,0,7,14,16,5,0,0,0,7,16,12,16,8,0,0,0,4,2,1,16,4,0,0,0,3,12,12,16,8,0,0,0,12,16,16,15,5,0,0,0,5,5,13,6,0,0,0,0,0,2,14,0,0,0,0,0,0,9,8,0,0,0),target=7),list(id=\"optdigits.tes:729\",features=list(\"76\",\"3\",\"79\",\"102\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"729\",pixels=list(0,0,1,13,1,0,0,0,0,0,7,15,1,0,0,0,0,1,14,6,0,0,0,0,0,0,16,3,0,1,0,0,0,1,16,6,15,15,5,0,0,1,16,14,4,3,12,0,0,0,7,7,0,9,12,0,0,0,0,11,16,9,2,0),target=6),list(id=\"optdigits.tes:747\",features=list(\"88\",\"106\",\"73\",\"39\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"747\",pixels=list(0,0,1,14,8,8,1,0,0,0,10,13,8,16,1,0,0,2,16,4,10,11,0,0,0,7,15,6,14,16,13,0,0,3,16,16,15,9,2,0,0,0,3,11,9,0,0,0,0,0,0,12,4,0,0,0,0,0,0,12,0,0,0,0),target=4),list(id=\"optdigits.tes:1052\",features=list(\"83\",\"74\",\"58\",\"140\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1052\",pixels=list(0,0,13,16,13,1,0,0,0,6,16,10,15,5,0,0,0,3,15,0,11,9,0,0,0,0,4,0,12,8,0,0,0,0,0,0,15,8,0,0,0,0,0,8,16,4,0,0,0,0,5,16,16,13,10,1,0,0,13,16,16,16,16,9),target=2),list(id=\"optdigits.tes:1058\",features=list(\"100\",\"73\",\"91\",\"69\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1058\",pixels=list(0,2,15,12,1,0,0,0,0,4,16,13,13,0,0,0,0,0,14,3,15,12,5,0,0,0,5,16,16,11,0,0,0,2,13,13,14,2,0,0,0,5,13,0,6,8,0,0,0,4,11,0,1,15,0,0,0,2,12,16,16,7,0,0),target=8),list(id=\"optdigits.tes:1063\",features=list(\"134\",\"54\",\"30\",\"68\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1063\",pixels=list(0,0,6,11,16,16,3,0,0,5,16,15,5,0,0,0,0,11,16,15,2,0,0,0,0,12,15,12,12,0,0,0,0,2,1,4,16,0,0,0,0,0,0,0,16,4,0,0,0,0,0,2,16,3,0,0,0,0,5,16,13,0,0,0),target=5),list(id=\"optdigits.tes:1067\",features=list(\"107\",\"69\",\"40\",\"99\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1067\",pixels=list(0,0,10,13,9,1,0,0,0,2,16,7,10,8,0,0,0,0,12,12,7,11,0,0,0,3,16,16,16,7,0,0,0,0,5,8,12,10,1,0,0,0,0,0,0,11,7,0,0,0,0,0,0,3,15,0,0,0,11,16,16,16,8,0),target=9),list(id=\"optdigits.tes:1074\",features=list(\"72\",\"95\",\"67\",\"55\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1074\",pixels=list(0,0,2,15,16,15,0,0,0,0,12,9,11,12,0,0,0,5,15,0,13,7,0,0,0,5,6,3,14,5,2,0,0,0,0,9,16,16,9,0,0,0,7,16,9,2,0,0,0,0,1,15,3,0,0,0,0,0,3,16,0,0,0,0),target=7),list(id=\"optdigits.tes:1077\",features=list(\"87\",\"69\",\"82\",\"69\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1077\",pixels=list(0,0,2,16,10,0,0,0,0,0,4,16,16,5,0,0,0,0,8,16,16,3,0,0,0,0,9,16,16,3,0,0,0,0,8,16,16,3,0,0,0,0,8,16,16,1,0,0,0,0,5,16,14,0,0,0,0,0,1,12,16,3,0,0),target=1),list(id=\"optdigits.tes:1078\",features=list(\"70\",\"52\",\"56\",\"83\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1078\",pixels=list(0,0,0,10,11,1,0,0,0,0,1,15,8,8,0,0,0,5,4,10,0,12,0,0,0,7,8,10,0,7,5,0,0,6,10,0,0,2,9,0,0,1,13,0,0,2,11,0,0,0,6,11,4,10,11,0,0,0,0,9,15,14,5,0),target=0),list(id=\"optdigits.tes:1087\",features=list(\"91\",\"103\",\"33\",\"119\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1087\",pixels=list(0,0,11,16,16,10,0,0,1,14,16,9,11,16,1,0,1,14,3,0,12,14,0,0,0,0,0,6,16,7,0,0,0,0,0,0,8,16,5,0,0,0,0,0,0,12,10,0,0,0,2,4,5,14,13,0,0,0,11,16,16,16,4,0),target=3),list(id=\"optdigits.tes:1093\",features=list(\"75\",\"7\",\"83\",\"114\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1093\",pixels=list(0,0,1,14,6,0,0,0,0,0,7,15,1,0,0,0,0,0,13,7,0,0,0,0,0,0,13,5,0,0,0,0,0,0,14,7,5,4,1,0,0,0,10,16,13,14,14,0,0,0,9,14,1,4,16,3,0,0,1,12,13,16,9,1),target=6),list(id=\"optdigits.tes:1096\",features=list(\"110\",\"79\",\"56\",\"62\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1096\",pixels=list(0,0,3,15,7,0,0,0,0,3,15,11,1,1,7,0,0,8,16,2,0,13,15,0,0,8,16,13,14,16,5,0,0,0,8,9,15,13,0,0,0,0,0,8,16,2,0,0,0,0,0,12,12,0,0,0,0,0,3,16,4,0,0,0),target=4),list(id=\"optdigits.tes:1415\",features=list(\"89\",\"81\",\"81\",\"42\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1415\",pixels=list(0,0,10,9,14,10,0,0,0,2,15,15,4,14,2,0,0,0,13,5,9,12,0,0,0,0,4,16,14,2,0,0,0,0,11,12,10,0,0,0,0,0,15,1,12,0,0,0,0,3,12,2,13,0,0,0,0,0,9,16,7,0,0,0),target=8),list(id=\"optdigits.tes:1418\",features=list(\"101\",\"35\",\"85\",\"92\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1418\",pixels=list(0,1,10,16,3,0,0,0,0,5,16,14,8,0,0,0,0,10,11,8,12,0,0,0,0,1,1,8,12,0,0,0,0,0,0,12,8,0,0,0,0,0,2,15,5,1,2,0,0,0,10,16,14,14,12,0,0,0,14,16,16,13,7,0),target=2),list(id=\"optdigits.tes:1426\",features=list(\"77\",\"78\",\"71\",\"77\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1426\",pixels=list(0,0,3,10,16,4,0,0,0,1,15,16,16,10,0,0,0,6,10,2,3,14,1,0,0,8,6,0,0,10,4,0,0,4,8,0,0,5,8,0,0,0,15,0,0,9,8,0,0,0,12,14,10,16,3,0,0,0,4,14,13,5,0,0),target=0),list(id=\"optdigits.tes:1427\",features=list(\"56\",\"113\",\"0\",\"110\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1427\",pixels=list(0,0,0,0,9,15,0,0,0,0,1,10,16,16,1,0,0,5,16,15,14,16,0,0,0,1,8,0,10,16,0,0,0,0,0,0,11,16,0,0,0,0,0,0,10,15,0,0,0,0,0,0,12,16,3,0,0,0,0,0,8,16,3,0),target=1),list(id=\"optdigits.tes:1429\",features=list(\"82\",\"82\",\"61\",\"122\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1429\",pixels=list(0,0,12,16,15,1,0,0,0,5,16,10,15,8,0,0,0,1,7,3,14,6,0,0,0,0,0,12,16,7,0,0,0,0,0,3,13,16,6,0,0,0,4,0,0,15,11,0,0,2,16,10,11,16,7,0,0,0,10,16,16,10,1,0),target=3),list(id=\"optdigits.tes:1431\",features=list(\"110\",\"64\",\"51\",\"97\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1431\",pixels=list(0,0,11,10,8,12,1,0,0,0,16,13,12,10,0,0,0,5,14,2,0,0,0,0,0,7,16,16,13,8,0,0,0,0,4,4,8,16,7,0,0,0,0,0,0,9,8,0,0,0,9,4,7,16,5,0,0,0,14,16,14,7,0,0),target=5),list(id=\"optdigits.tes:1433\",features=list(\"61\",\"131\",\"39\",\"85\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1433\",pixels=list(0,0,1,9,16,16,16,1,0,0,8,15,10,14,13,0,0,0,14,6,0,14,6,0,0,0,6,2,6,16,3,0,0,0,0,12,16,16,10,0,0,0,0,6,16,8,0,0,0,0,0,7,13,0,0,0,0,0,0,14,6,0,0,0),target=7),list(id=\"optdigits.tes:1440\",features=list(\"77\",\"58\",\"104\",\"92\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1440\",pixels=list(0,0,0,12,7,0,0,0,0,0,6,15,1,1,0,0,0,1,14,8,10,8,0,0,0,6,15,0,13,12,6,0,0,14,15,12,16,16,9,0,0,10,16,15,16,8,1,0,0,0,0,10,16,1,0,0,0,0,0,12,9,0,0,0),target=4),list(id=\"optdigits.tes:1442\",features=list(\"81\",\"7\",\"105\",\"113\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1442\",pixels=list(0,0,6,14,1,0,0,0,0,0,12,10,0,0,0,0,0,3,16,1,0,0,0,0,0,5,14,0,4,2,0,0,0,7,16,16,16,16,5,0,0,4,16,6,0,9,11,0,0,0,14,8,5,13,9,0,0,0,5,13,16,12,1,0),target=6),list(id=\"optdigits.tes:1445\",features=list(\"83\",\"92\",\"28\",\"76\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1445\",pixels=list(0,0,8,13,14,5,0,0,0,5,13,4,11,9,0,0,0,4,13,1,12,14,0,0,0,0,8,14,11,12,4,0,0,0,0,0,0,7,8,0,0,0,0,0,0,4,8,0,0,0,2,2,0,11,7,0,0,0,8,16,16,13,2,0),target=9),list(id=\"optdigits.tes:1771\",features=list(\"70\",\"85\",\"37\",\"104\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1771\",pixels=list(0,2,10,12,16,8,0,0,0,4,8,5,13,16,0,0,0,0,0,7,15,7,0,0,0,0,6,16,10,0,0,0,0,0,0,5,16,11,0,0,0,0,0,0,6,16,3,0,0,0,0,0,10,16,5,0,0,2,14,16,12,9,0,0),target=3),list(id=\"optdigits.tes:1774\",features=list(\"87\",\"12\",\"99\",\"117\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1774\",pixels=list(0,0,2,13,10,0,0,0,0,0,10,13,0,0,0,0,0,0,16,6,0,0,0,0,0,3,16,8,2,0,0,0,0,7,16,16,16,11,0,0,0,4,16,2,4,11,9,0,0,1,13,11,8,12,12,0,0,0,1,12,16,14,4,0),target=6),list(id=\"optdigits.tes:1775\",features=list(\"97\",\"99\",\"109\",\"92\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1775\",pixels=list(0,0,6,12,12,6,0,0,0,0,11,16,16,13,0,0,0,0,12,16,16,8,0,0,0,0,8,16,16,12,0,0,0,2,13,16,16,12,0,0,0,1,16,16,16,10,0,0,0,0,16,16,16,8,0,0,0,0,2,11,10,4,0,0),target=1),list(id=\"optdigits.tes:1784\",features=list(\"67\",\"29\",\"80\",\"93\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1784\",pixels=list(0,0,15,13,1,0,0,0,0,0,14,14,4,0,0,0,0,0,1,4,12,0,0,0,0,0,0,6,12,0,0,0,0,0,0,11,10,0,0,0,0,0,1,16,8,6,5,0,0,0,13,16,16,16,14,0,0,0,10,13,10,6,2,0),target=2),list(id=\"optdigits.tes:1786\",features=list(\"71\",\"98\",\"112\",\"53\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1786\",pixels=list(0,1,10,16,15,2,0,0,0,1,12,13,16,4,0,0,0,0,0,0,16,8,0,0,0,0,7,11,16,13,8,0,0,8,16,16,16,16,6,0,0,2,10,16,9,0,0,0,0,0,3,16,4,0,0,0,0,0,10,15,2,0,0,0),target=7),list(id=\"optdigits.tes:1788\",features=list(\"117\",\"57\",\"49\",\"93\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1788\",pixels=list(0,0,10,16,15,1,0,0,0,0,16,12,5,0,0,0,0,2,16,9,4,0,0,0,0,4,16,16,16,14,2,0,0,1,10,4,1,16,4,0,0,0,0,0,2,16,7,0,0,0,7,8,14,16,3,0,0,0,6,13,10,4,0,0),target=5),list(id=\"optdigits.tes:1792\",features=list(\"78\",\"67\",\"96\",\"106\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1792\",pixels=list(0,0,0,3,15,4,0,0,0,0,4,16,12,0,0,0,0,0,12,15,3,4,3,0,0,7,16,5,3,15,8,0,0,13,16,13,15,16,2,0,0,12,16,16,16,13,0,0,0,0,4,5,16,8,0,0,0,0,0,1,16,4,0,0),target=4),list(id=\"optdigits.tes:1794\",features=list(\"99\",\"91\",\"106\",\"103\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1794\",pixels=list(0,0,6,16,13,11,1,0,0,0,16,15,12,16,1,0,0,3,16,7,0,13,6,0,0,4,16,0,0,10,8,0,0,8,16,0,0,14,6,0,0,5,16,7,9,16,5,0,0,1,15,16,16,16,1,0,0,0,6,16,14,6,0,0),target=0),list(id=\"optdigits.tes:1796\",features=list(\"100\",\"92\",\"47\",\"105\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1796\",pixels=list(0,0,2,10,7,0,0,0,0,0,14,16,16,15,1,0,0,4,16,7,3,16,7,0,0,5,16,10,7,16,4,0,0,0,5,14,14,16,4,0,0,0,0,0,0,16,2,0,0,0,4,7,7,16,2,0,0,0,5,12,16,12,0,0),target=9),list(id=\"optdigits.tes:1797\",features=list(\"107\",\"65\",\"108\",\"112\"),role=\"test\",nativeFile=\"optdigits.tes\",nativeDataRow=\"1797\",pixels=list(0,0,10,14,8,1,0,0,0,2,16,14,6,1,0,0,0,0,15,15,8,15,0,0,0,0,5,16,16,10,0,0,0,0,12,15,15,12,0,0,0,4,16,6,4,16,6,0,0,8,16,10,8,16,8,0,0,1,8,12,14,12,1,0),target=8),list(id=\"optdigits.tra:1\",features=list(\"101\",\"54\",\"82\",\"66\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"1\",pixels=list(0,1,6,15,12,1,0,0,0,7,16,6,6,10,0,0,0,8,16,2,0,11,2,0,0,5,16,3,0,5,7,0,0,7,13,3,0,8,7,0,0,4,12,0,1,13,5,0,0,0,14,9,15,9,0,0,0,0,6,14,7,1,0,0),target=0),list(id=\"optdigits.tra:3\",features=list(\"51\",\"106\",\"104\",\"56\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3\",pixels=list(0,0,8,15,16,13,0,0,0,1,11,9,11,16,1,0,0,0,0,0,7,14,0,0,0,0,3,4,14,12,2,0,0,1,16,16,16,16,10,0,0,2,12,16,10,0,0,0,0,0,2,16,4,0,0,0,0,0,9,14,0,0,0,0),target=7),list(id=\"optdigits.tra:4\",features=list(\"93\",\"122\",\"13\",\"77\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"4\",pixels=list(0,0,0,3,11,16,0,0,0,0,5,16,11,13,7,0,0,3,15,8,1,15,6,0,0,11,16,16,16,16,10,0,0,1,4,4,13,10,2,0,0,0,0,0,15,4,0,0,0,0,0,3,16,0,0,0,0,0,0,1,15,2,0,0),target=4),list(id=\"optdigits.tra:5\",features=list(\"97\",\"15\",\"74\",\"80\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"5\",pixels=list(0,0,5,14,4,0,0,0,0,0,13,8,0,0,0,0,0,3,14,4,0,0,0,0,0,6,16,14,9,2,0,0,0,4,16,3,4,11,2,0,0,0,14,3,0,4,11,0,0,0,10,8,4,11,12,0,0,0,4,12,14,7,0,0),target=6),list(id=\"optdigits.tra:6\",features=list(\"101\",\"81\",\"52\",\"132\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"6\",pixels=list(0,0,11,16,10,1,0,0,0,4,16,10,15,8,0,0,0,4,16,3,11,13,0,0,0,1,14,6,9,14,0,0,0,0,0,0,12,10,0,0,0,0,0,6,16,6,0,0,0,0,5,15,15,8,8,3,0,0,10,16,16,16,16,6),target=2),list(id=\"optdigits.tra:7\",features=list(\"94\",\"99\",\"24\",\"52\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"7\",pixels=list(0,0,1,11,13,11,7,0,0,0,9,14,6,4,3,0,0,0,16,12,16,15,2,0,0,5,16,10,4,12,6,0,0,1,1,0,0,10,4,0,0,0,0,0,5,10,0,0,0,0,0,8,15,3,0,0,0,0,1,13,5,0,0,0),target=5),list(id=\"optdigits.tra:10\",features=list(\"128\",\"68\",\"90\",\"95\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"10\",pixels=list(0,0,3,13,13,2,0,0,0,6,16,12,10,8,0,0,0,9,15,12,16,6,0,0,0,10,16,16,13,0,0,0,0,1,12,16,12,14,4,0,0,0,11,8,0,3,12,0,0,0,13,11,8,13,12,0,0,0,3,15,11,6,0,0),target=8),list(id=\"optdigits.tra:12\",features=list(\"44\",\"118\",\"63\",\"101\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"12\",pixels=list(0,0,0,3,16,11,1,0,0,0,0,8,16,16,1,0,0,0,0,9,16,14,0,0,0,1,7,16,16,11,0,0,0,9,16,16,16,8,0,0,0,1,8,6,16,7,0,0,0,0,0,5,16,9,0,0,0,0,0,2,14,14,1,0),target=1),list(id=\"optdigits.tra:13\",features=list(\"92\",\"158\",\"24\",\"90\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"13\",pixels=list(0,0,0,4,13,16,16,3,0,0,8,16,9,12,16,4,0,7,16,3,3,15,13,0,0,9,15,14,16,16,6,0,0,1,8,7,12,15,0,0,0,0,0,0,13,10,0,0,0,0,0,3,15,6,0,0,0,0,0,5,15,4,0,0),target=9),list(id=\"optdigits.tra:15\",features=list(\"68\",\"79\",\"82\",\"107\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"15\",pixels=list(0,0,7,11,11,6,0,0,0,9,16,12,10,14,0,0,0,5,2,0,4,14,0,0,0,0,1,5,14,6,0,0,0,1,15,16,16,10,0,0,0,0,7,4,4,15,6,0,0,0,5,4,8,13,12,0,0,0,14,16,12,10,1,0),target=3),list(id=\"optdigits.tra:715\",features=list(\"71\",\"103\",\"22\",\"102\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"715\",pixels=list(0,0,7,16,12,1,0,0,0,0,9,12,9,11,0,0,0,0,5,13,10,16,3,0,0,0,0,9,16,16,9,0,0,0,0,0,0,6,13,0,0,0,0,0,0,3,15,0,0,0,0,0,0,5,16,0,0,0,6,16,16,16,12,0),target=9),list(id=\"optdigits.tra:719\",features=list(\"93\",\"72\",\"38\",\"61\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"719\",pixels=list(0,0,0,9,10,2,0,0,0,0,5,16,16,2,0,0,0,4,14,16,16,4,0,0,0,8,11,10,16,6,0,0,0,0,0,7,16,3,0,0,0,0,0,10,16,2,0,0,0,0,0,12,11,0,0,0,0,0,0,9,13,0,0,0),target=1),list(id=\"optdigits.tra:721\",features=list(\"63\",\"111\",\"101\",\"50\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"721\",pixels=list(0,0,15,16,16,15,2,0,0,0,5,8,11,16,3,0,0,0,0,0,15,8,0,0,0,3,8,8,16,7,2,0,0,6,15,16,16,16,8,0,0,0,2,15,7,3,0,0,0,0,11,13,0,0,0,0,0,0,16,7,0,0,0,0),target=7),list(id=\"optdigits.tra:748\",features=list(\"79\",\"34\",\"99\",\"87\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"748\",pixels=list(0,0,0,10,16,2,0,0,0,0,4,16,13,1,0,0,0,0,10,16,2,0,0,0,0,0,13,10,0,0,0,0,0,0,16,15,10,0,0,0,0,0,14,16,13,10,0,0,0,0,11,16,8,16,1,0,0,0,1,10,16,13,0,0),target=6),list(id=\"optdigits.tra:766\",features=list(\"70\",\"49\",\"87\",\"68\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"766\",pixels=list(0,1,14,16,6,0,0,0,0,4,15,10,13,0,0,0,0,1,3,4,15,0,0,0,0,0,0,2,15,0,0,0,0,0,0,9,9,0,0,0,0,0,1,15,4,0,0,0,0,1,13,14,7,2,0,0,0,3,15,16,16,16,13,1),target=2),list(id=\"optdigits.tra:770\",features=list(\"116\",\"52\",\"66\",\"89\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"770\",pixels=list(0,3,16,16,16,16,0,0,0,0,13,12,8,4,0,0,0,0,12,12,0,0,0,0,0,0,16,16,8,0,0,0,0,0,11,5,14,7,0,0,0,0,0,0,8,16,0,0,0,2,11,4,14,13,0,0,0,2,15,16,15,2,0,0),target=5),list(id=\"optdigits.tra:776\",features=list(\"79\",\"44\",\"73\",\"65\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"776\",pixels=list(0,0,0,15,2,0,0,0,0,0,10,12,0,0,0,0,0,5,15,1,0,6,6,0,0,12,9,0,3,16,11,0,0,6,16,12,14,13,1,0,0,0,3,11,16,2,0,0,0,0,0,10,12,0,0,0,0,0,0,15,7,0,0,0),target=4),list(id=\"optdigits.tra:793\",features=list(\"89\",\"90\",\"48\",\"95\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"793\",pixels=list(0,1,12,16,15,3,0,0,0,11,13,5,13,8,0,0,0,3,1,8,16,5,0,0,0,0,3,16,16,13,1,0,0,0,0,0,1,14,6,0,0,0,1,0,0,9,11,0,0,2,15,1,0,13,9,0,0,0,13,16,15,15,2,0),target=3),list(id=\"optdigits.tra:826\",features=list(\"82\",\"61\",\"77\",\"75\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"826\",pixels=list(0,0,3,12,13,1,0,0,0,1,14,11,10,8,0,0,0,4,16,3,0,12,2,0,0,4,13,1,0,9,6,0,0,6,12,0,0,5,8,0,0,3,13,0,0,4,9,0,0,0,15,8,4,13,8,0,0,0,5,15,15,9,0,0),target=0),list(id=\"optdigits.tra:850\",features=list(\"91\",\"63\",\"90\",\"89\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"850\",pixels=list(0,0,1,10,2,3,0,0,0,0,8,16,15,16,0,0,0,0,12,16,16,4,0,0,0,0,12,16,7,0,0,0,0,3,16,13,13,1,0,0,0,1,16,4,12,10,0,0,0,0,11,12,11,16,2,0,0,0,2,12,14,9,1,0),target=8),list(id=\"optdigits.tra:1442\",features=list(\"126\",\"49\",\"59\",\"76\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"1442\",pixels=list(0,0,5,14,16,14,0,0,0,7,16,15,8,8,0,0,0,14,13,0,0,0,0,0,0,13,16,13,3,0,0,0,0,0,5,11,15,1,0,0,0,0,0,0,16,9,0,0,0,0,5,11,16,8,0,0,0,0,11,16,10,1,0,0),target=5),list(id=\"optdigits.tra:1471\",features=list(\"103\",\"126\",\"19\",\"108\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"1471\",pixels=list(0,0,1,8,15,16,7,0,0,1,13,14,9,16,8,0,0,8,16,5,11,15,2,0,0,5,16,16,16,10,1,0,0,0,1,4,10,16,9,0,0,0,0,0,3,16,7,0,0,0,0,3,14,14,1,0,0,0,0,11,15,3,0,0),target=9),list(id=\"optdigits.tra:1475\",features=list(\"62\",\"93\",\"70\",\"34\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"1475\",pixels=list(0,1,12,16,16,8,0,0,0,1,8,5,9,12,0,0,0,0,0,0,11,8,0,0,0,0,5,14,14,10,5,0,0,0,3,15,14,12,5,0,0,0,2,16,3,0,0,0,0,0,10,9,0,0,0,0,0,0,13,2,0,0,0,0),target=7),list(id=\"optdigits.tra:1488\",features=list(\"103\",\"39\",\"105\",\"14\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"1488\",pixels=list(0,0,2,15,12,1,0,0,0,0,6,16,15,1,0,0,0,0,14,16,8,0,0,0,0,2,16,16,2,0,0,0,0,3,16,15,0,0,0,0,0,2,16,13,0,0,0,0,0,0,9,16,2,0,0,0,0,0,2,13,12,0,0,0),target=1),list(id=\"optdigits.tra:1502\",features=list(\"76\",\"26\",\"84\",\"114\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"1502\",pixels=list(0,0,0,10,13,0,0,0,0,0,1,16,11,2,0,0,0,0,8,16,0,0,0,0,0,0,13,12,0,0,0,0,0,0,14,16,14,9,0,0,0,0,12,15,5,9,13,0,0,0,3,16,4,6,16,2,0,0,0,8,13,14,9,0),target=6),list(id=\"optdigits.tra:1512\",features=list(\"82\",\"49\",\"49\",\"114\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"1512\",pixels=list(0,0,6,14,3,0,0,0,0,0,12,14,14,0,0,0,0,0,14,7,14,2,0,0,0,0,10,5,10,6,0,0,0,0,0,0,13,5,0,0,0,0,0,2,14,5,3,0,0,0,8,16,16,16,16,0,0,0,9,14,8,8,8,2),target=2),list(id=\"optdigits.tra:1554\",features=list(\"60\",\"57\",\"52\",\"93\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"1554\",pixels=list(0,0,0,2,13,2,0,0,0,0,0,14,10,0,0,0,0,0,11,10,0,10,4,0,0,4,16,3,1,14,3,0,0,6,16,16,16,16,5,0,0,0,5,8,14,11,1,0,0,0,0,0,15,2,0,0,0,0,0,1,13,0,0,0),target=4),list(id=\"optdigits.tra:1560\",features=list(\"86\",\"90\",\"52\",\"87\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"1560\",pixels=list(0,3,16,14,10,5,0,0,0,1,8,8,11,16,2,0,0,0,2,6,12,11,1,0,0,0,12,16,16,6,0,0,0,0,0,3,11,16,2,0,0,0,0,0,0,14,7,0,0,1,8,9,14,13,0,0,0,3,16,12,9,1,0,0),target=3),list(id=\"optdigits.tra:1585\",features=list(\"84\",\"62\",\"72\",\"92\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"1585\",pixels=list(0,0,3,15,13,1,0,0,0,1,15,12,13,10,0,0,0,3,16,1,1,12,2,0,0,6,12,0,0,4,6,0,0,4,11,0,0,4,8,0,0,0,13,3,5,13,8,0,0,0,10,15,16,16,5,0,0,0,2,14,12,5,0,0),target=0),list(id=\"optdigits.tra:1617\",features=list(\"91\",\"91\",\"82\",\"72\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"1617\",pixels=list(0,0,4,13,15,6,0,0,0,4,15,6,7,15,2,0,0,8,14,0,4,16,5,0,0,2,15,10,14,7,0,0,0,0,7,16,14,0,0,0,0,0,12,9,15,6,0,0,0,0,12,8,11,8,0,0,0,0,3,15,15,3,0,0),target=8),list(id=\"optdigits.tra:2231\",features=list(\"95\",\"61\",\"113\",\"78\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"2231\",pixels=list(0,2,15,16,9,0,0,0,0,7,15,12,16,2,0,0,0,9,9,2,16,2,0,0,0,1,0,7,16,0,0,0,0,0,0,14,10,0,0,0,0,1,12,15,2,0,0,0,0,8,16,14,12,12,3,0,0,3,14,16,16,16,7,0),target=2),list(id=\"optdigits.tra:2250\",features=list(\"88\",\"91\",\"35\",\"97\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"2250\",pixels=list(0,0,11,16,10,1,0,0,0,0,16,8,11,13,1,0,0,0,13,7,7,16,1,0,0,0,4,13,14,16,1,0,0,0,0,0,0,15,4,0,0,0,0,0,0,8,11,0,0,1,7,4,5,14,12,0,0,0,8,15,14,11,3,0),target=9),list(id=\"optdigits.tra:2257\",features=list(\"87\",\"99\",\"87\",\"133\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"2257\",pixels=list(0,0,7,15,14,2,0,0,0,0,9,16,16,11,0,0,0,0,3,16,16,11,0,0,0,0,5,16,16,13,0,0,0,0,6,16,16,14,0,0,0,0,6,16,16,12,0,0,0,0,7,16,16,15,6,0,0,0,4,16,16,15,7,0),target=1),list(id=\"optdigits.tra:2259\",features=list(\"101\",\"89\",\"87\",\"85\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"2259\",pixels=list(0,0,6,13,15,6,0,0,0,1,15,16,16,14,0,0,0,4,16,8,4,14,4,0,0,4,16,2,0,9,7,0,0,4,15,0,0,13,5,0,0,2,16,0,5,15,5,0,0,1,15,13,16,11,0,0,0,0,6,15,12,3,0,0),target=0),list(id=\"optdigits.tra:2261\",features=list(\"36\",\"128\",\"66\",\"55\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"2261\",pixels=list(0,0,3,10,12,16,5,0,0,0,8,8,8,15,11,0,0,0,0,0,2,16,7,0,0,0,1,6,14,16,6,0,0,0,4,14,16,12,4,0,0,0,0,9,13,2,0,0,0,0,2,16,6,0,0,0,0,0,5,16,2,0,0,0),target=7),list(id=\"optdigits.tra:2272\",features=list(\"102\",\"67\",\"67\",\"115\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"2272\",pixels=list(0,1,10,14,5,0,0,0,0,9,16,14,16,0,0,0,0,3,5,9,16,0,0,0,0,0,5,16,16,14,0,0,0,0,8,14,13,16,6,0,0,0,0,0,0,16,11,0,0,0,11,5,11,16,7,0,0,1,12,16,14,5,0,0),target=3),list(id=\"optdigits.tra:2311\",features=list(\"86\",\"38\",\"106\",\"118\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"2311\",pixels=list(0,0,1,12,16,7,0,0,0,0,8,16,11,4,0,0,0,0,13,12,0,0,0,0,0,2,16,6,0,0,0,0,0,4,16,13,12,5,0,0,0,6,16,14,12,15,4,0,0,0,11,14,5,14,11,0,0,0,0,12,16,16,8,0),target=6),list(id=\"optdigits.tra:2328\",features=list(\"40\",\"74\",\"96\",\"101\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"2328\",pixels=list(0,0,0,0,10,8,0,0,0,0,0,4,15,2,0,0,0,0,1,13,9,5,3,0,0,0,8,14,2,14,6,0,0,5,15,4,1,16,3,0,0,14,15,14,16,16,4,0,0,8,12,9,12,13,0,0,0,0,0,0,12,8,0,0),target=4),list(id=\"optdigits.tra:2331\",features=list(\"89\",\"62\",\"51\",\"68\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"2331\",pixels=list(0,0,9,12,14,14,4,0,0,0,15,7,4,4,2,0,0,0,14,0,0,0,0,0,0,3,15,14,14,6,0,0,0,4,7,2,2,15,0,0,0,0,0,0,0,12,2,0,0,0,9,2,2,14,0,0,0,0,11,16,16,5,0,0),target=5),list(id=\"optdigits.tra:2413\",features=list(\"83\",\"94\",\"69\",\"86\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"2413\",pixels=list(0,0,1,8,16,8,0,0,0,2,14,13,12,16,2,0,0,10,9,0,7,15,1,0,0,3,14,9,15,2,0,0,0,0,10,16,12,2,0,0,0,0,12,6,5,15,3,0,0,0,9,8,0,13,7,0,0,0,0,8,16,12,1,0),target=8),list(id=\"optdigits.tra:2927\",features=list(\"99\",\"90\",\"54\",\"83\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"2927\",pixels=list(0,0,6,8,12,15,4,0,0,1,15,13,12,12,4,0,0,0,16,5,0,0,0,0,0,3,16,16,16,14,1,0,0,2,11,5,5,15,8,0,0,0,0,0,0,16,4,0,0,0,5,8,13,11,0,0,0,0,8,15,10,1,0,0),target=5),list(id=\"optdigits.tra:3009\",features=list(\"60\",\"53\",\"92\",\"146\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3009\",pixels=list(0,0,0,5,16,10,0,0,0,0,0,13,14,0,0,0,0,0,3,16,9,0,0,0,0,0,7,16,4,0,0,0,0,0,10,16,12,8,1,0,0,2,16,16,16,16,11,0,0,1,9,16,11,12,16,1,0,0,0,6,16,16,10,0),target=6),list(id=\"optdigits.tra:3013\",features=list(\"31\",\"95\",\"86\",\"45\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3013\",pixels=list(0,0,9,15,16,12,1,0,0,0,3,4,4,15,6,0,0,0,0,0,0,16,4,0,0,0,0,0,8,13,0,0,0,3,12,16,16,15,4,0,0,3,5,12,9,0,0,0,0,0,3,15,1,0,0,0,0,0,11,6,0,0,0,0),target=7),list(id=\"optdigits.tra:3024\",features=list(\"82\",\"108\",\"13\",\"61\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3024\",pixels=list(0,0,2,9,12,13,3,0,0,1,14,10,4,14,5,0,0,6,12,4,8,16,2,0,0,1,11,12,12,16,3,0,0,0,0,0,8,11,0,0,0,0,0,1,14,4,0,0,0,0,0,5,14,0,0,0,0,0,0,7,10,0,0,0),target=9),list(id=\"optdigits.tra:3034\",features=list(\"100\",\"56\",\"47\",\"86\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3034\",pixels=list(0,0,1,13,10,0,0,0,0,0,9,16,4,0,0,0,0,1,16,8,0,4,0,0,0,4,16,16,16,16,6,0,0,0,8,8,12,16,5,0,0,0,0,1,16,13,0,0,0,0,0,13,16,3,0,0,0,0,2,15,5,0,0,0),target=4),list(id=\"optdigits.tra:3037\",features=list(\"86\",\"75\",\"29\",\"119\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3037\",pixels=list(0,0,2,16,14,1,0,0,0,0,6,16,16,5,0,0,0,2,16,16,16,3,0,0,0,0,3,9,16,4,0,0,0,0,0,2,16,10,0,0,0,0,0,0,15,16,0,0,0,0,2,9,16,16,3,0,0,0,2,14,16,10,1,0),target=1),list(id=\"optdigits.tra:3047\",features=list(\"74\",\"107\",\"106\",\"62\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3047\",pixels=list(0,0,7,16,16,10,0,0,0,4,16,13,16,15,0,0,0,0,8,2,16,12,0,0,0,0,0,8,16,6,0,0,0,0,4,16,9,0,0,0,0,1,13,15,2,0,0,0,0,1,16,15,12,12,5,0,0,0,9,16,14,7,1,0),target=2),list(id=\"optdigits.tra:3097\",features=list(\"68\",\"53\",\"55\",\"107\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3097\",pixels=list(0,1,11,14,6,0,0,0,0,7,12,5,15,0,0,0,0,6,6,1,16,0,0,0,0,0,0,5,16,0,0,0,0,0,0,13,16,12,0,0,0,0,0,0,3,14,6,0,0,0,5,7,6,14,8,0,0,0,14,16,16,11,1,0),target=3),list(id=\"optdigits.tra:3108\",features=list(\"103\",\"94\",\"106\",\"80\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3108\",pixels=list(0,0,7,13,16,13,2,0,0,2,16,15,5,13,10,0,0,6,16,3,0,7,11,0,0,11,14,0,0,5,12,0,0,8,16,0,0,4,12,0,0,8,15,0,0,7,11,0,0,7,16,8,8,15,2,0,0,0,12,16,16,5,0,0),target=0),list(id=\"optdigits.tra:3174\",features=list(\"100\",\"101\",\"100\",\"54\"),role=\"train\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3174\",pixels=list(0,0,10,14,14,11,1,0,0,4,16,12,5,14,11,0,0,5,14,2,4,13,8,0,0,1,11,11,14,6,0,0,0,0,9,16,5,0,0,0,0,4,13,11,9,0,0,0,0,5,11,2,16,2,0,0,0,0,13,16,16,6,0,0),target=8),list(id=\"optdigits.tra:3794\",features=list(\"138\",\"59\",\"50\",\"73\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3794\",pixels=list(0,0,15,15,16,14,1,0,0,3,16,15,8,7,0,0,0,8,16,9,1,0,0,0,0,9,16,16,12,0,0,0,0,1,2,0,16,4,0,0,0,0,0,0,13,8,0,0,0,2,7,7,16,4,0,0,0,0,15,16,12,0,0,0),target=5),list(id=\"optdigits.tra:3796\",features=list(\"82\",\"73\",\"47\",\"124\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3796\",pixels=list(0,0,12,16,7,0,0,0,0,2,16,14,16,5,0,0,0,0,14,5,11,13,0,0,0,0,2,1,8,13,0,0,0,0,0,0,8,15,0,0,0,0,0,0,13,10,0,0,0,0,10,10,16,6,0,0,0,0,11,16,16,16,16,8),target=2),list(id=\"optdigits.tra:3810\",features=list(\"92\",\"85\",\"86\",\"99\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3810\",pixels=list(0,0,5,15,16,6,0,0,0,0,15,12,5,16,2,0,0,4,16,3,0,12,8,0,0,8,14,0,0,10,10,0,0,8,13,0,0,10,13,0,0,4,16,0,0,4,15,0,0,1,15,9,3,12,10,0,0,0,5,15,16,15,1,0),target=0),list(id=\"optdigits.tra:3812\",features=list(\"6\",\"114\",\"61\",\"98\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3812\",pixels=list(0,0,0,0,7,11,1,0,0,0,0,0,12,16,3,0,0,0,0,4,16,16,0,0,0,0,0,2,16,16,0,0,0,0,1,13,16,12,0,0,0,0,7,16,15,14,0,0,0,2,15,5,12,11,0,0,0,0,2,0,7,11,0,0),target=1),list(id=\"optdigits.tra:3815\",features=list(\"117\",\"94\",\"111\",\"19\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3815\",pixels=list(0,0,9,16,6,0,0,0,0,2,14,16,16,8,3,0,0,0,14,16,16,16,11,0,0,0,14,16,12,5,1,0,0,0,9,16,5,0,0,0,0,0,15,16,5,0,0,0,0,0,16,16,8,0,0,0,0,0,10,13,1,0,0,0),target=8),list(id=\"optdigits.tra:3817\",features=list(\"87\",\"88\",\"58\",\"95\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3817\",pixels=list(0,1,10,16,16,4,0,0,0,8,13,12,16,10,0,0,0,2,0,14,15,3,0,0,0,0,0,11,16,8,0,0,0,0,0,0,7,16,3,0,0,2,1,0,0,13,8,0,0,8,12,4,10,16,5,0,0,2,13,16,12,5,0,0),target=3),list(id=\"optdigits.tra:3819\",features=list(\"77\",\"76\",\"31\",\"90\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3819\",pixels=list(0,0,5,13,11,2,0,0,0,2,15,6,5,12,0,0,0,6,12,0,1,16,2,0,0,1,12,5,5,16,6,0,0,0,1,9,9,12,8,0,0,0,0,0,0,3,13,0,0,0,0,0,1,8,10,0,0,0,8,13,15,10,1,0),target=9),list(id=\"optdigits.tra:3820\",features=list(\"64\",\"36\",\"102\",\"74\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3820\",pixels=list(0,0,0,1,12,1,0,0,0,0,0,14,10,0,0,0,0,0,10,14,2,0,0,0,0,2,16,7,0,5,6,0,0,12,15,0,9,15,1,0,0,12,16,14,16,8,0,0,0,7,12,10,15,1,0,0,0,0,0,4,9,0,0,0),target=4),list(id=\"optdigits.tra:3822\",features=list(\"95\",\"2\",\"124\",\"127\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3822\",pixels=list(0,0,6,16,2,0,0,0,0,0,15,10,0,0,0,0,0,6,16,3,0,0,0,0,0,9,14,0,0,0,0,0,0,12,13,11,12,12,3,0,0,7,16,15,12,13,13,0,0,2,15,12,2,8,15,0,0,0,5,16,16,16,5,0),target=6),list(id=\"optdigits.tra:3823\",features=list(\"29\",\"116\",\"41\",\"69\"),role=\"validation\",nativeFile=\"optdigits.tra\",nativeDataRow=\"3823\",pixels=list(0,0,2,15,16,13,1,0,0,0,3,7,10,16,10,0,0,0,0,0,0,11,11,0,0,0,0,2,8,15,5,0,0,0,0,9,16,16,8,0,0,0,0,2,16,5,0,0,0,0,0,12,7,0,0,0,0,0,4,14,1,0,0,0),target=7)),alignment=\"matched\")\n\nrs<-INPUT$rows;tokens<-unlist(lapply(rs,function(r)r$features));digits<-max(vapply(strsplit(tokens,'.',fixed=TRUE),function(v)if(length(v)>1)nchar(v[2])else 0,0));den<-paste0('1',paste(rep('0',2*digits),collapse=''));X<-lapply(rs,function(r)lapply(r$features,scaled,d=digits));n<-length(rs);pred<-list()\nfor(i in seq_len(n)){ds<-lapply(seq_len(n),function(j)distance(X[[i]],X[[if(INPUT$alignment=='matched')j else j%%n+1]]));best<-1;for(j in seq_len(n))if(bcmp(ds[[j]],ds[[best]])<0)best<-j;pred[[i]]<-list(id=rs[[i]]$id,prediction=rs[[best]]$id,correct=best==i,minimumDistanceNumerator=bstr(ds[[best]]),minimumDistanceDenominator=den);point('Native feature 1',rs[[i]]$id,as.numeric(rs[[i]]$features[[1]]))}\nsummary<-list(records=as.character(n),alignment=INPUT$alignment,pairCorrect=as.character(sum(vapply(pred,function(r)r$correct,TRUE))));result<-list(retrieval=pred,sourceScope='Retained native numeric features; both representations share their origin. Known-corpus retrieval, not semantic encoder evaluation.')\nif(INPUT$case=='person'){\n predictions<-list();means<-list()\n for(profile in c('quadrants','pixels')){V<-lapply(rs,function(r)as.numeric(unlist(if(profile=='quadrants')r$features else r$pixels)));P<-list();for(label in 0:9){train<-which(vapply(rs,function(r)r$role=='train'&&r$target==label,TRUE));stopifnot(length(train)==4);P[[label+1]]<-Reduce('+',V[train])/4}\n  for(i in seq_len(n)){ds<-vapply(P,function(p)sum((V[[i]]-p)^2),0.0);best<-which.min(ds)-1;predictions[[length(predictions)+1]]<-list(id=rs[[i]]$id,role=rs[[i]]$role,profile=profile,prediction=best,target=rs[[i]]$target,correct=best==rs[[i]]$target,minimumDistance=qs(ds[best+1]*16,16))}\n  for(role in c('train','validation','test')){a<-Filter(function(r)r$role==role&&r$profile==profile,predictions);correct<-sum(vapply(a,function(r)r$correct,TRUE));means[[length(means)+1]]<-list(profile=profile,role=role,correct=correct,records=length(a),accuracy=qs(correct,length(a)))}\n }\n candidates<-Filter(function(m)m$role=='validation',means);best<-candidates[[which.max(vapply(candidates,function(m)m$correct/m$records,0.0))]];summary$selectedProfile<-best$profile;summary$validationAccuracy<-best$accuracy;summary$testAccuracy<-Filter(function(m)m$profile==best$profile&&m$role=='test',means)[[1]]$accuracy;result$classPredictions<-predictions;result$classMeans<-means;result$selected<-best$profile;result$unsafeTargetCaptionExcluded<-TRUE\n}\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(p$label,width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"alignment\":\"matched\",\"pairCorrect\":\"120\",\"records\":\"120\",\"selectedProfile\":\"pixels\",\"testAccuracy\":\"5/6\",\"validationAccuracy\":\"19/20\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/realdata-person-r/stdout.txt",
        "stderrFile": "ai18-fixed/realdata-person-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "alignment",
            "value": "matched"
          },
          {
            "metric": "pairCorrect",
            "value": "120"
          },
          {
            "metric": "records",
            "value": "120"
          },
          {
            "metric": "selectedProfile",
            "value": "pixels"
          },
          {
            "metric": "testAccuracy",
            "value": "5/6"
          },
          {
            "metric": "validationAccuracy",
            "value": "19/20"
          }
        ],
        "resultFile": "ai18-fixed/realdata-person-r/result.json",
        "summaryFile": "ai18-fixed/realdata-person-r/summary.json",
        "plotDataFile": "ai18-fixed/realdata-person-r/points.csv",
        "plotFile": "ai18-fixed/realdata-person-r/plot.svg",
        "plotSHA256": "8361e61ae15f6033b55c09d0b08f2d36a6a61aa80495d28d049b6d4ded3c51b5"
      },
      "realdata-company": {
        "api": "realdata",
        "variant": "realdata-company",
        "language": "r",
        "codeFile": "ai18-fixed/realdata-company-r.R",
        "codeSHA256": "603ec170df3bddb2f4df6a9e7779a820b6f6a65ad2bcabf9ee8e2fdd5b9b849d",
        "expectedFailure": false,
        "title": "Retained nominal company sales",
        "code": "if(!isTRUE(l10n_info()[['UTF-8']])){if(.Platform$OS.type=='windows')invisible(suppressWarnings(Sys.setlocale('LC_CTYPE','.UTF-8')));if(!isTRUE(l10n_info()[['UTF-8']]))stop('UTF-8 locale required')}\n# AI18 fixed standalone example. Base R only. Exact fractions for small\n# authored values; exact base10000 integer distances for retained country tokens.\n# SHA primitive explicitly reused from the source-only educational companion.\nargs<-commandArgs(trailingOnly=TRUE);Encoding(args[validUTF8(args)])<-'UTF-8';outDir<-if(length(args))args[1]else'this-example-output';dir.create(outDir,recursive=TRUE,showWarnings=FALSE)\nquotejson<-function(s){v<-utf8ToInt(enc2utf8(s));z<-vapply(v,function(c){if(c==34)'\\\\\"'else if(c==92)'\\\\\\\\'else if(c<32)sprintf('\\\\u%04x',c)else intToUtf8(c)},'');paste0('\"',paste0(z,collapse=''),'\"')}\nJ<-function(x){if(is.null(x))return('null');if(is.list(x)){if(!is.null(names(x)))return(paste0('{',paste0(vapply(seq_along(x),function(i)paste0(quotejson(names(x)[i]),':',J(x[[i]])),''),collapse=','),'}'));return(paste0('[',paste0(vapply(x,J,''),collapse=','),']'))};if(length(x)!=1)return(J(as.list(x)));if(is.logical(x))return(if(x)'true'else'false');if(is.numeric(x))return(sprintf('%.0f',x));quotejson(as.character(x))}\nB<-function(x)if(x)'true'else'false';fmt<-function(x)sprintf('%.0f',x)\ngcd<-function(a,b){while(b!=0){r<-a%%b;a<-b;b<-r};a};qs<-function(n,d=1){g<-gcd(n,d);n<-n/g;d<-d/g;if(d==1)fmt(n)else paste0(fmt(n),'/',fmt(d))}\nu32 <- 4294967296; base <- 65536\nbx <- function(x,y)as.double(bitwXor(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwXor(as.integer(floor(x/base)),as.integer(floor(y/base))))\nba <- function(x,y)as.double(bitwAnd(as.integer(x%%base),as.integer(y%%base)))+base*as.double(bitwAnd(as.integer(floor(x/base)),as.integer(floor(y/base))))\nbn <- function(x)u32-1-x\nrr <- function(x,n)floor(x/2^n)+(x%%2^n)*2^(32-n)\nhx <- function(s)strtoi(substr(s,1,4),16L)*base+strtoi(substr(s,5,8),16L)\nK <- vapply(strsplit(paste('428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5','d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174','e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da','983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967','27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85','a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070','19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3','748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2'), ' +')[[1]],hx,0.0)\nH <- vapply(strsplit('6a09e667 bb67ae85 3c6ef372 a54ff53a 510e527f 9b05688c 1f83d9ab 5be0cd19',' ')[[1]],hx,0.0)\n\n# Explicit reuse of the earlier 16-bit-half SHA256 primitive; new multi-block\n# batching below supports the complete 64-count ASCII identities (not only\n# short one-block role keys). This is a source hash, not a trust/signature proof.\nshaBatch<-function(strings){\n out<-rep('',length(strings));if(!length(strings))return(out);bytes<-lapply(strings,function(s)as.integer(charToRaw(enc2utf8(s))));stopifnot(all(vapply(bytes,function(x)all(x<128),TRUE)))\n counts<-ceiling((lengths(bytes)+9)/64)\n for(nb in unique(counts)){\n  ix<-which(counts==nb);n<-length(ix);padded<-matrix(0,n,64*nb)\n  for(i in seq_len(n)){b<-bytes[[ix[i]]];m<-length(b);if(m)padded[i,seq_len(m)]<-b;padded[i,m+1]<-128;bits<-m*8;padded[i,64*nb-3]<-floor(bits/16777216)%%256;padded[i,64*nb-2]<-floor(bits/65536)%%256;padded[i,64*nb-1]<-floor(bits/256)%%256;padded[i,64*nb]<-bits%%256}\n  state<-lapply(H,function(x)rep(x,n))\n  for(blockIndex in seq_len(nb)){\n   block<-padded[,((blockIndex-1)*64+1):(blockIndex*64),drop=FALSE];w<-vector('list',64)\n   for(t in 1:16)w[[t]]<-as.vector(block[,(4*t-3):(4*t),drop=FALSE]%*%c(16777216,65536,256,1))\n   for(t in 17:64){x<-w[[t-15]];y<-w[[t-2]];s0<-bx(bx(rr(x,7),rr(x,18)),floor(x/8));s1<-bx(bx(rr(y,17),rr(y,19)),floor(y/1024));w[[t]]<-(w[[t-16]]+s0+w[[t-7]]+s1)%%u32}\n   a<-state[[1]];b<-state[[2]];c<-state[[3]];d<-state[[4]];e<-state[[5]];f<-state[[6]];g<-state[[7]];h<-state[[8]]\n   for(t in 1:64){S1<-bx(bx(rr(e,6),rr(e,11)),rr(e,25));ch<-bx(ba(e,f),ba(bn(e),g));t1<-(h+S1+ch+K[t]+w[[t]])%%u32;S0<-bx(bx(rr(a,2),rr(a,13)),rr(a,22));maj<-bx(bx(ba(a,b),ba(a,c)),ba(b,c));t2<-(S0+maj)%%u32;h<-g;g<-f;f<-e;e<-(d+t1)%%u32;d<-c;c<-b;b<-a;a<-(t1+t2)%%u32}\n   result<-list(a,b,c,d,e,f,g,h);state<-lapply(seq_len(8),function(j)(state[[j]]+result[[j]])%%u32)\n  }\n  hashes<-rep('',n);for(z in state)hashes<-paste0(hashes,sprintf('%04x%04x',as.integer(floor(z/base)),as.integer(z%%base)));out[ix]<-hashes\n };out\n}\nstopifnot(identical(shaBatch(c('','abc',paste(rep('a',80),collapse=''))),c('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855','ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad','0f45e858fbc4176cdf4e411f88281edefc390ae5afe7df0f44cd9297f0a64580')))\n\ntrim<-function(a){while(length(a)>1&&tail(a,1)==0)a<-head(a,-1);a}\nbi<-function(s){neg<-startsWith(s,'-');s<-sub('^[+-]','',s);stopifnot(grepl('^[0-9]+$',s),nchar(s)<=256);s<-sub('^0+(?=.)','',s,perl=TRUE);ends<-seq(nchar(s),1,by=-4);a<-vapply(ends,function(e)as.numeric(substr(s,max(1,e-3),e)),0.0);list(s=if(all(a==0))0 else if(neg)-1 else 1,a=trim(a))}\nbstr<-function(v){a<-v$a;z<-paste0(c(fmt(tail(a,1)),if(length(a)>1)sprintf('%04.0f',rev(head(a,-1)))else character()),collapse='');paste0(if(v$s<0)'-'else'',z)}\nmagcmp<-function(a,b){if(length(a)!=length(b))return(sign(length(a)-length(b)));for(i in rev(seq_along(a)))if(a[i]!=b[i])return(sign(a[i]-b[i]));0}\nmagadd<-function(a,b){n<-max(length(a),length(b));length(a)<-n;length(b)<-n;a[is.na(a)]<-0;b[is.na(b)]<-0;v<-numeric(n+1);carry<-0;for(i in seq_len(n)){z<-a[i]+b[i]+carry;v[i]<-z%%10000;carry<-floor(z/10000)};v[n+1]<-carry;trim(v)}\nmagsub<-function(a,b){length(b)<-length(a);b[is.na(b)]<-0;v<-numeric(length(a));borrow<-0;for(i in seq_along(a)){z<-a[i]-b[i]-borrow;borrow<-as.numeric(z<0);v[i]<-z+borrow*10000};stopifnot(borrow==0);trim(v)}\nbadd<-function(a,b){if(a$s==0)return(b);if(b$s==0)return(a);if(a$s==b$s)return(list(s=a$s,a=magadd(a$a,b$a)));c<-magcmp(a$a,b$a);if(c==0)return(bi('0'));if(c>0)list(s=a$s,a=magsub(a$a,b$a))else list(s=b$s,a=magsub(b$a,a$a))}\nbsub<-function(a,b){b$s<--b$s;badd(a,b)}\nbmul<-function(a,b){if(a$s==0||b$s==0)return(bi('0'));stopifnot(length(a$a)+length(b$a)<=64);v<-numeric(length(a$a)+length(b$a)+1);for(i in seq_along(a$a))for(j in seq_along(b$a)){k<-i+j-1;v[k]<-v[k]+a$a[i]*b$a[j]};for(k in seq_len(length(v)-1)){carry<-floor(v[k]/10000);v[k]<-v[k]%%10000;v[k+1]<-v[k+1]+carry};list(s=a$s*b$s,a=trim(v))}\nbcmp<-function(a,b){if(a$s!=b$s)return(sign(a$s-b$s));a$s*magcmp(a$a,b$a)}\nscaled<-function(s,d){v<-strsplit(s,'.',fixed=TRUE)[[1]];fraction<-if(length(v)>1)v[2]else'';stopifnot(nchar(fraction)<=d);bi(paste0(v[1],fraction,paste(rep('0',d-nchar(fraction)),collapse='')))}\ndistance<-function(a,b){v<-bi('0');for(j in seq_along(a)){d<-bsub(a[[j]],b[[j]]);v<-badd(v,bmul(d,d))};v}\n\n\nQ<-function(n,d=1){stopifnot(d!=0,abs(n)<=2^51,abs(d)<=2^51);if(d<0){n<--n;d<--d};g<-gcd(abs(n),d);list(n=n/g,d=d/g)}\nparseq<-function(s){v<-strsplit(s,'/',fixed=TRUE)[[1]];if(length(v)==2)return(Q(as.numeric(v[1]),as.numeric(v[2])));v<-strsplit(s,'.',fixed=TRUE)[[1]];d<-if(length(v)>1)nchar(v[2])else 0;Q(as.numeric(gsub('.','',s,fixed=TRUE)),10^d)}\naddq<-function(a,b)Q(a$n*b$d+b$n*a$d,a$d*b$d);mulq<-function(a,b)Q(a$n*b$n,a$d*b$d);divq<-function(a,b)Q(a$n*b$d,a$d*b$n);qstring<-function(q)qs(q$n,q$d);sumq<-function(xs)Reduce(addq,xs,init=Q(0));f9<-function(x)sprintf('%.9g',x)\nsummary<-list();points<-list();result<-list()\npoint<-function(series,label,value=NULL){points[[length(points)+1]]<<-list(series=series,label=label,valueToken=if(is.null(value))''else if(is.list(value))qstring(value)else f9(value),defined=B(!is.null(value)))}\n\nTITLE<-\"Retained nominal company sales\"\nINPUT<-list(case=\"company\",rows=list(list(id=\"Apple:iPhone:2019\",features=list(\"142381\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"1\",pixels=NULL,target=NULL),list(id=\"Apple:iPhone:2020\",features=list(\"137781\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"2\",pixels=NULL,target=NULL),list(id=\"Apple:iPhone:2021\",features=list(\"191973\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"3\",pixels=NULL,target=NULL),list(id=\"Apple:iPhone:2022\",features=list(\"205489\"),role=\"validation\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"4\",pixels=NULL,target=NULL),list(id=\"Apple:iPhone:2023\",features=list(\"200583\"),role=\"test\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"5\",pixels=NULL,target=NULL),list(id=\"Apple:iPhone:2024\",features=list(\"201183\"),role=\"test\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"6\",pixels=NULL,target=NULL),list(id=\"Apple:Mac:2019\",features=list(\"25740\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"7\",pixels=NULL,target=NULL),list(id=\"Apple:Mac:2020\",features=list(\"28622\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"8\",pixels=NULL,target=NULL),list(id=\"Apple:Mac:2021\",features=list(\"35190\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"9\",pixels=NULL,target=NULL),list(id=\"Apple:Mac:2022\",features=list(\"40177\"),role=\"validation\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"10\",pixels=NULL,target=NULL),list(id=\"Apple:Mac:2023\",features=list(\"29357\"),role=\"test\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"11\",pixels=NULL,target=NULL),list(id=\"Apple:Mac:2024\",features=list(\"29984\"),role=\"test\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"12\",pixels=NULL,target=NULL),list(id=\"Apple:iPad:2019\",features=list(\"21280\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"13\",pixels=NULL,target=NULL),list(id=\"Apple:iPad:2020\",features=list(\"23724\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"14\",pixels=NULL,target=NULL),list(id=\"Apple:iPad:2021\",features=list(\"31862\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"15\",pixels=NULL,target=NULL),list(id=\"Apple:iPad:2022\",features=list(\"29292\"),role=\"validation\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"16\",pixels=NULL,target=NULL),list(id=\"Apple:iPad:2023\",features=list(\"28300\"),role=\"test\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"17\",pixels=NULL,target=NULL),list(id=\"Apple:iPad:2024\",features=list(\"26694\"),role=\"test\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"18\",pixels=NULL,target=NULL),list(id=\"Apple:Wearables, Home and Accessories:2019\",features=list(\"24482\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"19\",pixels=NULL,target=NULL),list(id=\"Apple:Wearables, Home and Accessories:2020\",features=list(\"30620\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"20\",pixels=NULL,target=NULL),list(id=\"Apple:Wearables, Home and Accessories:2021\",features=list(\"38367\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"21\",pixels=NULL,target=NULL),list(id=\"Apple:Wearables, Home and Accessories:2022\",features=list(\"41241\"),role=\"validation\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"22\",pixels=NULL,target=NULL),list(id=\"Apple:Wearables, Home and Accessories:2023\",features=list(\"39845\"),role=\"test\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"23\",pixels=NULL,target=NULL),list(id=\"Apple:Wearables, Home and Accessories:2024\",features=list(\"37005\"),role=\"test\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"24\",pixels=NULL,target=NULL),list(id=\"Apple:Services:2019\",features=list(\"46291\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"25\",pixels=NULL,target=NULL),list(id=\"Apple:Services:2020\",features=list(\"53768\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"26\",pixels=NULL,target=NULL),list(id=\"Apple:Services:2021\",features=list(\"68425\"),role=\"train\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"27\",pixels=NULL,target=NULL),list(id=\"Apple:Services:2022\",features=list(\"78129\"),role=\"validation\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"28\",pixels=NULL,target=NULL),list(id=\"Apple:Services:2023\",features=list(\"85200\"),role=\"test\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"29\",pixels=NULL,target=NULL),list(id=\"Apple:Services:2024\",features=list(\"96169\"),role=\"test\",nativeFile=\"actual30-Apple-product-sales-FY2019-2024.csv\",nativeDataRow=\"30\",pixels=NULL,target=NULL)),alignment=\"cyclic-mispair\")\n\nrs<-INPUT$rows;tokens<-unlist(lapply(rs,function(r)r$features));digits<-max(vapply(strsplit(tokens,'.',fixed=TRUE),function(v)if(length(v)>1)nchar(v[2])else 0,0));den<-paste0('1',paste(rep('0',2*digits),collapse=''));X<-lapply(rs,function(r)lapply(r$features,scaled,d=digits));n<-length(rs);pred<-list()\nfor(i in seq_len(n)){ds<-lapply(seq_len(n),function(j)distance(X[[i]],X[[if(INPUT$alignment=='matched')j else j%%n+1]]));best<-1;for(j in seq_len(n))if(bcmp(ds[[j]],ds[[best]])<0)best<-j;pred[[i]]<-list(id=rs[[i]]$id,prediction=rs[[best]]$id,correct=best==i,minimumDistanceNumerator=bstr(ds[[best]]),minimumDistanceDenominator=den);point('Native feature 1',rs[[i]]$id,as.numeric(rs[[i]]$features[[1]]))}\nsummary<-list(records=as.character(n),alignment=INPUT$alignment,pairCorrect=as.character(sum(vapply(pred,function(r)r$correct,TRUE))));result<-list(retrieval=pred,sourceScope='Retained native numeric features; both representations share their origin. Known-corpus retrieval, not semantic encoder evaluation.')\nif(INPUT$case=='person'){\n predictions<-list();means<-list()\n for(profile in c('quadrants','pixels')){V<-lapply(rs,function(r)as.numeric(unlist(if(profile=='quadrants')r$features else r$pixels)));P<-list();for(label in 0:9){train<-which(vapply(rs,function(r)r$role=='train'&&r$target==label,TRUE));stopifnot(length(train)==4);P[[label+1]]<-Reduce('+',V[train])/4}\n  for(i in seq_len(n)){ds<-vapply(P,function(p)sum((V[[i]]-p)^2),0.0);best<-which.min(ds)-1;predictions[[length(predictions)+1]]<-list(id=rs[[i]]$id,role=rs[[i]]$role,profile=profile,prediction=best,target=rs[[i]]$target,correct=best==rs[[i]]$target,minimumDistance=qs(ds[best+1]*16,16))}\n  for(role in c('train','validation','test')){a<-Filter(function(r)r$role==role&&r$profile==profile,predictions);correct<-sum(vapply(a,function(r)r$correct,TRUE));means[[length(means)+1]]<-list(profile=profile,role=role,correct=correct,records=length(a),accuracy=qs(correct,length(a)))}\n }\n candidates<-Filter(function(m)m$role=='validation',means);best<-candidates[[which.max(vapply(candidates,function(m)m$correct/m$records,0.0))]];summary$selectedProfile<-best$profile;summary$validationAccuracy<-best$accuracy;summary$testAccuracy<-Filter(function(m)m$profile==best$profile&&m$role=='test',means)[[1]]$accuracy;result$classPredictions<-predictions;result$classMeans<-means;result$selected<-best$profile;result$unsafeTargetCaptionExcluded<-TRUE\n}\n\nsummary<-summary[order(names(summary),method='radix')];writeLines(J(summary),file.path(outDir,'summary.json'),useBytes=TRUE);writeLines(J(result),file.path(outDir,'result.json'),useBytes=TRUE)\ndf<-if(length(points))as.data.frame(do.call(rbind,lapply(points,function(p)unlist(p))),stringsAsFactors=FALSE)else data.frame(series=character(),label=character(),valueToken=character(),defined=character());write.table(df,file.path(outDir,'points.csv'),sep=',',row.names=FALSE,col.names=TRUE,quote=TRUE,qmethod='double',fileEncoding='UTF-8',eol='\\n')\nsvg(file.path(outDir,'plot.svg'),width=9,height=max(4,min(18,.26*length(points)+2)),family='sans',pointsize=12);par(mar=c(5,16,4,7));n<-length(points);values<-vapply(points,function(p){if(p$defined!='true')return(NA_real_);v<-strsplit(p$valueToken,'/',fixed=TRUE)[[1]];as.numeric(v[1])/if(length(v)>1)as.numeric(v[2])else 1},0.0);finite<-values[is.finite(values)];lo<-min(0,finite);hi<-max(0,finite);if(lo==hi)hi<-lo+1;pad<-(hi-lo)*.18;plot(NA,xlim=c(lo-pad,hi+pad),ylim=c(.5,max(1,n)+.5),yaxt='n',xlab='Input/result projection; see full JSON and CSV',ylab='',main=TITLE);axis(2,at=n-seq_len(n)+1,labels=vapply(points,function(p)paste(strwrap(p$label,width=34),collapse='\\n'),''),las=2,cex.axis=.7);abline(v=0,col='#6a747d');for(i in seq_len(n)){y<-n-i+1;if(is.finite(values[i])){rect(min(0,values[i]),y-.34,max(0,values[i]),y+.34,col='#285e86',border=NA);text(values[i],y,labels=paste0(' ',substr(points[[i]]$valueToken,1,22)),pos=4,cex=.65)}else text(lo,y,'Undefined; no point',pos=4,col='#8b382e',cex=.8)};invisible(dev.off());cat(J(summary),'\\n')\n",
        "exitCode": 0,
        "stdout": "{\"alignment\":\"cyclic-mispair\",\"pairCorrect\":\"0\",\"records\":\"30\"} \r\n",
        "stderr": "During startup - Warning messages:\r\n1: Setting LC_COLLATE=C.UTF-8 failed \r\n2: Setting LC_CTYPE=C.UTF-8 failed \r\n3: Setting LC_MONETARY=C.UTF-8 failed \r\n4: Setting LC_TIME=C.UTF-8 failed \r\n",
        "stderrIsProjection": false,
        "rawStderrSHA256": "b3aad99a991f98252f3a0842635009f1fbec82b901a63d11a0168dadc69467cb",
        "stdoutFile": "ai18-fixed/realdata-company-r/stdout.txt",
        "stderrFile": "ai18-fixed/realdata-company-r/stderr.txt",
        "invocationTemplate": "Rscript <program-file> [output-directory]",
        "supportFiles": [],
        "summary": [
          {
            "metric": "alignment",
            "value": "cyclic-mispair"
          },
          {
            "metric": "pairCorrect",
            "value": "0"
          },
          {
            "metric": "records",
            "value": "30"
          }
        ],
        "resultFile": "ai18-fixed/realdata-company-r/result.json",
        "summaryFile": "ai18-fixed/realdata-company-r/summary.json",
        "plotDataFile": "ai18-fixed/realdata-company-r/points.csv",
        "plotFile": "ai18-fixed/realdata-company-r/plot.svg",
        "plotSHA256": "beb5e0d83d33982666bd8778fe62f4c7475ff167eb805749fa06a727e928e5e8"
      }
    }
  }
}
