Ship oracle journal values, bytecode/frontend hardening, and replay-policy Lean.
Host exposes oracle journals as language values with refuse/copy gates; bytecode and foreign session paths get modularized; applications and verification replay-policy sources land with Lake builds ignored. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
e3d9021bb6
commit
8f1010f967
101 files changed
+17962
-1727
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,34 @@
|
||||
# Application composition corpus
|
||||
|
||||
Four authored tasks exercise the actual document loader, tree/bytecode evaluators
|
||||
and interactive history API. Each has separate Python and Node implementations
|
||||
of the producer and consumer. `CASES.json` is the eight-case regression subset;
|
||||
the reviewer driver generates 80 size/seed/direction instances before execution.
|
||||
They are four application families, not 80 independent real-user applications.
|
||||
|
||||
- Invoice ledger: discard void rows, first-posted invoice deduplication, integer
|
||||
cents/discount accounting, signed refunds with floor division, regional totals.
|
||||
- Routes: minimum nonnegative parallel edge, zero-cost edges, disconnected nodes
|
||||
and weighted single-source distances. Python uses heap-based Dijkstra, Node a
|
||||
linear frontier; independent reference uses SQL and all-pairs Floyd-Warshall.
|
||||
- Concordance: NFC plus **ASCII** lowercase, explicit space/tab/LF/CR/NBSP
|
||||
separators, occurrence/document frequencies, UTF-8 byte order. This is not
|
||||
Unicode full case folding. Wide IDs remain strings; special object-key text,
|
||||
combining marks, BMP and astral characters are included.
|
||||
- Wine: UCI red-wine CSV, exact decimal density/pH scaling to integers and
|
||||
quality-group count/sum/min/max. Full input contains 1599 rows; no predictor
|
||||
accuracy or general machine-learning performance is claimed.
|
||||
|
||||
Independent SQL/Fraction/Floyd references live in the reviewer experiment
|
||||
`application_cases.py`; no foreign program output supplies expected answers.
|
||||
The raw/public-data digest, citation, license and retrieval source are preserved
|
||||
in `data/PROVENANCE.json`. Wine Quality is by Cortez, Cerdeira, Almeida, Matos and
|
||||
Reis (2009), UCI, DOI 10.24432/C56S3T, CC BY 4.0. CSV text fixture generation
|
||||
normalizes physical line endings and uses the requested first N data rows.
|
||||
|
||||
The composition copies input into a producer, gets a normalized value, copies it
|
||||
into the consumer, records an expected ordinary exception after saving `answer`,
|
||||
recovers it, replaces the consumer's bridge with null, verifies the producer's
|
||||
copy and answer remain, and closes both sessions. Interactive recordings repeat
|
||||
these actions and strictly replay both raw and losslessly packed history.
|
||||
Native and independent checks distinguish explicit null from display stdout.
|
||||
@@ -0,0 +1,10 @@
|
||||
var index = new Map();
|
||||
for (var row of bridge) {
|
||||
for (var word of row.tokens) {
|
||||
var value = index.get(word) || {count:0,docs:new Set()};
|
||||
value.count++; value.docs.add(row.id); index.set(word,value);
|
||||
}
|
||||
}
|
||||
var answer = [...index].sort((a,b)=>Buffer.compare(Buffer.from(a[0]),Buffer.from(b[0])))
|
||||
.map(([word,v])=>({word,occurrences:v.count,documents:v.docs.size}));
|
||||
answer;
|
||||
@@ -0,0 +1,10 @@
|
||||
from collections import Counter, defaultdict
|
||||
occurrences = Counter()
|
||||
documents = defaultdict(set)
|
||||
for row in bridge:
|
||||
for word in row['tokens']:
|
||||
occurrences[word] += 1
|
||||
documents[word].add(row['id'])
|
||||
answer = [{'word':word,'occurrences':occurrences[word],'documents':len(documents[word])}
|
||||
for word in sorted(occurrences,key=lambda s:s.encode('utf-8'))]
|
||||
answer
|
||||
@@ -0,0 +1,3 @@
|
||||
var bridge = data.map(row=>({id:row.id,tokens:row.text.normalize('NFC').replace(/[A-Z]/g,c=>c.toLowerCase()).split(/[ \n\t\r\u00a0]+/).filter(t=>t.length)}));
|
||||
bridge.sort((a,b)=>Buffer.compare(Buffer.from(a.id),Buffer.from(b.id)));
|
||||
bridge;
|
||||
@@ -0,0 +1,6 @@
|
||||
import re, unicodedata
|
||||
ascii_lower = str.maketrans('ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')
|
||||
bridge = [{'id': row['id'], 'tokens': [t for t in re.split('[ \n\t\r\u00a0]+',unicodedata.normalize('NFC',row['text']).translate(ascii_lower)) if t]}
|
||||
for row in data]
|
||||
bridge.sort(key=lambda row:row['id'].encode('utf-8'))
|
||||
bridge
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"source": "https://archive.ics.uci.edu/static/public/186/wine+quality.zip",
|
||||
"landing_page": "https://archive.ics.uci.edu/dataset/186/wine%2Bquality",
|
||||
"doi": "10.24432/C56S3T",
|
||||
"authors": [
|
||||
"Paulo Cortez",
|
||||
"A. Cerdeira",
|
||||
"F. Almeida",
|
||||
"T. Matos",
|
||||
"J. Reis"
|
||||
],
|
||||
"year": 2009,
|
||||
"license": "CC BY 4.0",
|
||||
"license_url": "https://creativecommons.org/licenses/by/4.0/",
|
||||
"retrieved": "2026-11-03",
|
||||
"files": {
|
||||
"winequality.names": "15d215e73b39105952380fd487e4ce1bf5a6b83a425abb285c2ec55193d3ca92",
|
||||
"winequality-red.csv": "4a402cf041b025d4566d954c3b9ba8635a3a8a01e039005d97d6a710278cf05e",
|
||||
"wine-quality.zip": "3ed56667f4b828242bd732d7d1dd7f2861e54432239d7fa63877014cbb0304d4"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,72 @@
|
||||
Citation Request:
|
||||
This dataset is public available for research. The details are described in [Cortez et al., 2009].
|
||||
Please include this citation if you plan to use this database:
|
||||
|
||||
P. Cortez, A. Cerdeira, F. Almeida, T. Matos and J. Reis.
|
||||
Modeling wine preferences by data mining from physicochemical properties.
|
||||
In Decision Support Systems, Elsevier, 47(4):547-553. ISSN: 0167-9236.
|
||||
|
||||
Available at: [@Elsevier] http://dx.doi.org/10.1016/j.dss.2009.05.016
|
||||
[Pre-press (pdf)] http://www3.dsi.uminho.pt/pcortez/winequality09.pdf
|
||||
[bib] http://www3.dsi.uminho.pt/pcortez/dss09.bib
|
||||
|
||||
1. Title: Wine Quality
|
||||
|
||||
2. Sources
|
||||
Created by: Paulo Cortez (Univ. Minho), Antonio Cerdeira, Fernando Almeida, Telmo Matos and Jose Reis (CVRVV) @ 2009
|
||||
|
||||
3. Past Usage:
|
||||
|
||||
P. Cortez, A. Cerdeira, F. Almeida, T. Matos and J. Reis.
|
||||
Modeling wine preferences by data mining from physicochemical properties.
|
||||
In Decision Support Systems, Elsevier, 47(4):547-553. ISSN: 0167-9236.
|
||||
|
||||
In the above reference, two datasets were created, using red and white wine samples.
|
||||
The inputs include objective tests (e.g. PH values) and the output is based on sensory data
|
||||
(median of at least 3 evaluations made by wine experts). Each expert graded the wine quality
|
||||
between 0 (very bad) and 10 (very excellent). Several data mining methods were applied to model
|
||||
these datasets under a regression approach. The support vector machine model achieved the
|
||||
best results. Several metrics were computed: MAD, confusion matrix for a fixed error tolerance (T),
|
||||
etc. Also, we plot the relative importances of the input variables (as measured by a sensitivity
|
||||
analysis procedure).
|
||||
|
||||
4. Relevant Information:
|
||||
|
||||
The two datasets are related to red and white variants of the Portuguese "Vinho Verde" wine.
|
||||
For more details, consult: http://www.vinhoverde.pt/en/ or the reference [Cortez et al., 2009].
|
||||
Due to privacy and logistic issues, only physicochemical (inputs) and sensory (the output) variables
|
||||
are available (e.g. there is no data about grape types, wine brand, wine selling price, etc.).
|
||||
|
||||
These datasets can be viewed as classification or regression tasks.
|
||||
The classes are ordered and not balanced (e.g. there are munch more normal wines than
|
||||
excellent or poor ones). Outlier detection algorithms could be used to detect the few excellent
|
||||
or poor wines. Also, we are not sure if all input variables are relevant. So
|
||||
it could be interesting to test feature selection methods.
|
||||
|
||||
5. Number of Instances: red wine - 1599; white wine - 4898.
|
||||
|
||||
6. Number of Attributes: 11 + output attribute
|
||||
|
||||
Note: several of the attributes may be correlated, thus it makes sense to apply some sort of
|
||||
feature selection.
|
||||
|
||||
7. Attribute information:
|
||||
|
||||
For more information, read [Cortez et al., 2009].
|
||||
|
||||
Input variables (based on physicochemical tests):
|
||||
1 - fixed acidity
|
||||
2 - volatile acidity
|
||||
3 - citric acid
|
||||
4 - residual sugar
|
||||
5 - chlorides
|
||||
6 - free sulfur dioxide
|
||||
7 - total sulfur dioxide
|
||||
8 - density
|
||||
9 - pH
|
||||
10 - sulphates
|
||||
11 - alcohol
|
||||
Output variable (based on sensory data):
|
||||
12 - quality (score between 0 and 10)
|
||||
|
||||
8. Missing Attribute Values: None
|
||||
@@ -0,0 +1,10 @@
|
||||
var totals = new Map();
|
||||
for (var row of bridge) {
|
||||
var value = totals.get(row.region) || [0, 0];
|
||||
value[0] += 1;
|
||||
value[1] += Math.floor(row.units * row.cents * (10000-row.discount) / 10000);
|
||||
totals.set(row.region, value);
|
||||
}
|
||||
var answer = [...totals].sort((a,b) => Buffer.compare(Buffer.from(a[0]),Buffer.from(b[0])))
|
||||
.map(([region, value]) => ({region, invoices: value[0], net_cents: value[1]}));
|
||||
answer;
|
||||
@@ -0,0 +1,8 @@
|
||||
from collections import defaultdict
|
||||
totals = defaultdict(lambda: [0, 0])
|
||||
for row in bridge:
|
||||
totals[row['region']][0] += 1
|
||||
totals[row['region']][1] += row['units'] * row['cents'] * (10000-row['discount']) // 10000
|
||||
answer = [{'region': k, 'invoices': v[0], 'net_cents': v[1]}
|
||||
for k, v in sorted(totals.items(), key=lambda kv: kv[0].encode('utf-8'))]
|
||||
answer
|
||||
@@ -0,0 +1,10 @@
|
||||
var seen = new Set();
|
||||
var bridge = [];
|
||||
for (var row of data) {
|
||||
if (row.status === 'posted' && !seen.has(row.id)) {
|
||||
seen.add(row.id);
|
||||
bridge.push({id: row.id, region: row.region, units: row.units, cents: row.cents, discount: row.discount});
|
||||
}
|
||||
}
|
||||
bridge.sort((a, b) => Buffer.compare(Buffer.from(a.id), Buffer.from(b.id)));
|
||||
bridge;
|
||||
@@ -0,0 +1,8 @@
|
||||
seen = set()
|
||||
bridge = []
|
||||
for row in data:
|
||||
if row['status'] == 'posted' and row['id'] not in seen:
|
||||
seen.add(row['id'])
|
||||
bridge.append({k: row[k] for k in ('id', 'region', 'units', 'cents', 'discount')})
|
||||
bridge.sort(key=lambda r: r['id'].encode('utf-8'))
|
||||
bridge
|
||||
@@ -0,0 +1,14 @@
|
||||
var distance = new Map(bridge.nodes.map(n=>[n,Infinity]));
|
||||
distance.set(bridge.source,0);
|
||||
var unvisited = new Set(bridge.nodes);
|
||||
while (unvisited.size) {
|
||||
var best = [...unvisited].reduce((a,b)=>distance.get(a)<=distance.get(b)?a:b);
|
||||
unvisited.delete(best);
|
||||
if (!Number.isFinite(distance.get(best))) break;
|
||||
for (var edge of bridge.edges) {
|
||||
if (edge.from === best && distance.get(best)+edge.weight < distance.get(edge.to))
|
||||
distance.set(edge.to,distance.get(best)+edge.weight);
|
||||
}
|
||||
}
|
||||
var answer = bridge.nodes.map(node=>({node,distance:Number.isFinite(distance.get(node))?distance.get(node):null}));
|
||||
answer;
|
||||
@@ -0,0 +1,17 @@
|
||||
import heapq
|
||||
adjacency = {node: [] for node in bridge['nodes']}
|
||||
for edge in bridge['edges']:
|
||||
adjacency[edge['from']].append((edge['to'], edge['weight']))
|
||||
distance = {bridge['source']: 0}
|
||||
pending = [(0, bridge['source'])]
|
||||
while pending:
|
||||
cost, node = heapq.heappop(pending)
|
||||
if distance[node] != cost:
|
||||
continue
|
||||
for target, weight in adjacency[node]:
|
||||
candidate = cost + weight
|
||||
if target not in distance or candidate < distance[target]:
|
||||
distance[target] = candidate
|
||||
heapq.heappush(pending, (candidate, target))
|
||||
answer = [{'node': n, 'distance': distance.get(n)} for n in bridge['nodes']]
|
||||
answer
|
||||
@@ -0,0 +1,11 @@
|
||||
var minimum = new Map();
|
||||
for (var edge of data.edges) {
|
||||
if (edge.weight >= 0) {
|
||||
var key = JSON.stringify([edge.from, edge.to]);
|
||||
minimum.set(key, Math.min(minimum.has(key) ? minimum.get(key) : edge.weight, edge.weight));
|
||||
}
|
||||
}
|
||||
var edges = [...minimum].map(([key,weight]) => ({from: JSON.parse(key)[0], to: JSON.parse(key)[1], weight}));
|
||||
edges.sort((a,b) => Buffer.compare(Buffer.from(a.from),Buffer.from(b.from)) || Buffer.compare(Buffer.from(a.to),Buffer.from(b.to)));
|
||||
var bridge = {source:data.source, nodes:[...data.nodes].sort((a,b)=>Buffer.compare(Buffer.from(a),Buffer.from(b))), edges};
|
||||
bridge;
|
||||
@@ -0,0 +1,8 @@
|
||||
minimum = {}
|
||||
for edge in data['edges']:
|
||||
if edge['weight'] >= 0:
|
||||
key = (edge['from'], edge['to'])
|
||||
minimum[key] = min(minimum.get(key, edge['weight']), edge['weight'])
|
||||
bridge = {'source': data['source'], 'nodes': sorted(data['nodes'], key=lambda n:n.encode('utf-8')),
|
||||
'edges': [{'from': a, 'to': b, 'weight': w} for (a,b), w in sorted(minimum.items(), key=lambda kv: (kv[0][0].encode('utf-8'), kv[0][1].encode('utf-8')))]}
|
||||
bridge
|
||||
@@ -0,0 +1,9 @@
|
||||
var groups = new Map();
|
||||
for (var row of bridge) {
|
||||
var g=groups.get(row.quality) || {quality:row.quality,count:0,sum_density_ppm:0,min_ph_cent:row.ph_cent,max_ph_cent:row.ph_cent};
|
||||
g.count++;g.sum_density_ppm+=row.density_ppm;
|
||||
g.min_ph_cent=Math.min(g.min_ph_cent,row.ph_cent);g.max_ph_cent=Math.max(g.max_ph_cent,row.ph_cent);
|
||||
groups.set(row.quality,g);
|
||||
}
|
||||
var answer=[...groups.values()].sort((a,b)=>a.quality-b.quality);
|
||||
answer;
|
||||
@@ -0,0 +1,7 @@
|
||||
from itertools import groupby
|
||||
answer = []
|
||||
for quality, group in groupby(sorted(bridge,key=lambda r:r['quality']),key=lambda r:r['quality']):
|
||||
rows = list(group)
|
||||
answer.append({'quality':quality,'count':len(rows),'sum_density_ppm':sum(r['density_ppm'] for r in rows),
|
||||
'min_ph_cent':min(r['ph_cent'] for r in rows),'max_ph_cent':max(r['ph_cent'] for r in rows)})
|
||||
answer
|
||||
@@ -0,0 +1,13 @@
|
||||
function scaledDecimal(s, digits) {
|
||||
var parts = s.split('.');
|
||||
var tail = parts.length > 1 ? parts[1] : '';
|
||||
if (tail.length > digits) throw Error('unsupported decimal precision');
|
||||
return Number(parts[0])*10**digits + Number(tail.padEnd(digits,'0'));
|
||||
}
|
||||
var lines = data.trim().split(/\r?\n/);
|
||||
var header = lines[0].split(';').map(s=>s.replaceAll('"',''));
|
||||
var bridge = lines.slice(1).map(line=>{
|
||||
var fields=line.split(';');
|
||||
return {quality:Number(fields[header.indexOf('quality')]),density_ppm:scaledDecimal(fields[header.indexOf('density')],6),ph_cent:scaledDecimal(fields[header.indexOf('pH')],2)};
|
||||
});
|
||||
bridge;
|
||||
@@ -0,0 +1,5 @@
|
||||
import csv, io
|
||||
from decimal import Decimal
|
||||
bridge = [{'quality':int(row['quality']), 'density_ppm':int(Decimal(row['density'])*1000000), 'ph_cent':int(Decimal(row['pH'])*100)}
|
||||
for row in csv.DictReader(io.StringIO(data),delimiter=';')]
|
||||
bridge
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: Private grandchildren are not in the enclosing scope
|
||||
---
|
||||
# main
|
||||
> concealed
|
||||
|
||||
## outer
|
||||
|
||||
### concealed
|
||||
*1*
|
||||
+74
-18
@@ -45,14 +45,18 @@ fn run_with_env(args: &[&str], env: &[(&str, &str)]) -> (i32, String, String) {
|
||||
}
|
||||
|
||||
fn assert_out(path: &str, expect: &str) {
|
||||
let (code, stdout, stderr) = run(&["run", path]);
|
||||
assert_eq!(code, 0, "{path} stderr={stderr}");
|
||||
assert_eq!(stdout.trim_end(), expect.trim_end(), "{path}");
|
||||
for backend in ["tree", "bytecode"] {
|
||||
let (code, stdout, stderr) = run(&["run", path, "--backend", backend]);
|
||||
assert_eq!(code, 0, "{path} {backend} stderr={stderr}");
|
||||
assert_eq!(stdout.trim_end(), expect.trim_end(), "{path} {backend}");
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_run_ok(path: &str) {
|
||||
let (code, _stdout, stderr) = run(&["run", path]);
|
||||
assert_eq!(code, 0, "{path} stderr={stderr}");
|
||||
for backend in ["tree", "bytecode"] {
|
||||
let (code, _stdout, stderr) = run(&["run", path, "--backend", backend]);
|
||||
assert_eq!(code, 0, "{path} {backend} stderr={stderr}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Skip live LLM/agent tests when no real API key is configured.
|
||||
@@ -189,6 +193,21 @@ fn assert_err(path: &str, line_col: &str, substr: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Imported faults have an actual library origin and a separate authored call site.
|
||||
fn assert_import_err(path: &str, library: &str, origin: &str, caller: &str, substr: &str) {
|
||||
for backend in ["tree", "bytecode"] {
|
||||
let (code, stdout, stderr) = run(&["run", path, "--backend", backend]);
|
||||
assert_ne!(code, 0, "{path} backend={backend} unexpectedly succeeded stdout={stdout}");
|
||||
let origin = format!("{library}:{origin}:");
|
||||
assert!(stderr.lines().next().unwrap_or("").contains(&origin),
|
||||
"{path} backend={backend} missing actual library origin {origin:?}: {stderr}");
|
||||
let caller = format!(" from {path}:{caller}");
|
||||
assert!(stderr.lines().skip(1).any(|line| line.starts_with(" called ") && line.ends_with(&caller)),
|
||||
"{path} backend={backend} missing authored call site {caller:?}: {stderr}");
|
||||
assert!(stderr.contains(substr), "{path} backend={backend} stderr missing {substr:?}: {stderr}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Like [`assert_out`], but sets a dummy OpenAI key so offline LLM/agent paths
|
||||
/// that only check for the env var (no live HTTP) can proceed.
|
||||
/// Also points `MARQDO_EXT` at the repo `ext/` so tests do not pick up a stale
|
||||
@@ -1228,7 +1247,7 @@ fn bytecode_paragraph_comment() {
|
||||
|
||||
#[test]
|
||||
fn trace_eval_json_tree() {
|
||||
let (code, stdout, stderr) = run(&["run", "tests/structure/hello.mq.md", "--trace-eval"]);
|
||||
let (code, stdout, stderr) = run(&["run", "tests/structure/hello.mq.md", "--backend", "tree", "--trace-eval"]);
|
||||
assert_eq!(code, 0, "{stderr}");
|
||||
assert_eq!(stdout.trim_end(), "Hello World!");
|
||||
assert!(stderr.contains("\"event\":\"enter_fn\""), "{stderr}");
|
||||
@@ -1237,6 +1256,21 @@ fn trace_eval_json_tree() {
|
||||
assert!(stderr.contains("\"event\":\"leave_fn\""), "{stderr}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn structure_self_method_paths_are_instance_methods() {
|
||||
assert_out("tests/structure/self-method-paths.mq.md", "41\n41\n7");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn structure_lexical_siblings_recursion_and_shadowing() {
|
||||
assert_out("tests/structure/lexical-sibling-calls.mq.md", "120\n41\n99");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn error_lexical_private_descendant_is_not_visible() {
|
||||
assert_err("tests/errors/lexical-private-descendant.mq.md", "6:1", "unknown function `concealed`");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trace_eval_json_bytecode() {
|
||||
let (code, stdout, stderr) = run(&[
|
||||
@@ -1884,19 +1918,23 @@ fn lib_json_vsafe_string_ok() {
|
||||
|
||||
#[test]
|
||||
fn lib_json_vsafe_refuse() {
|
||||
// Span points at lib/json.mq.md `parse` body while path stays the caller file.
|
||||
assert_err(
|
||||
// Check both the actual library body and the user call, without mixing them.
|
||||
assert_import_err(
|
||||
"tests/lib/json-vsafe-refuse.mq.md",
|
||||
"lib/json.mq.md",
|
||||
"16:1",
|
||||
"10:1",
|
||||
"json: integer outside V_safe",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_json_vsafe_stringify_refuse() {
|
||||
assert_err(
|
||||
assert_import_err(
|
||||
"tests/lib/json-vsafe-stringify-refuse.mq.md",
|
||||
"lib/json.mq.md",
|
||||
"24:1",
|
||||
"11:1",
|
||||
"json: integer outside V_safe",
|
||||
);
|
||||
}
|
||||
@@ -3630,9 +3668,11 @@ fn lib_foreign_session_vsafe_refuse() {
|
||||
return;
|
||||
}
|
||||
// Span points at lib/foreign.mq.md session_set body.
|
||||
assert_err(
|
||||
assert_import_err(
|
||||
"tests/lib/foreign-session-vsafe-refuse.mq.md",
|
||||
"lib/foreign.mq.md",
|
||||
"207:1",
|
||||
"12:1",
|
||||
"json: integer outside V_safe",
|
||||
);
|
||||
}
|
||||
@@ -3643,9 +3683,11 @@ fn lib_foreign_session_use_after_close() {
|
||||
eprintln!("skip lib_foreign_session_use_after_close: no node on PATH");
|
||||
return;
|
||||
}
|
||||
assert_err(
|
||||
assert_import_err(
|
||||
"tests/lib/foreign-session-use-after-close.mq.md",
|
||||
"lib/foreign.mq.md",
|
||||
"198:1",
|
||||
"12:1",
|
||||
"foreign session",
|
||||
);
|
||||
}
|
||||
@@ -3656,9 +3698,11 @@ fn lib_foreign_session_double_close() {
|
||||
eprintln!("skip lib_foreign_session_double_close: no node on PATH");
|
||||
return;
|
||||
}
|
||||
assert_err(
|
||||
assert_import_err(
|
||||
"tests/lib/foreign-session-double-close.mq.md",
|
||||
"lib/foreign.mq.md",
|
||||
"231:1",
|
||||
"12:1",
|
||||
"foreign session",
|
||||
);
|
||||
}
|
||||
@@ -3666,9 +3710,11 @@ fn lib_foreign_session_double_close() {
|
||||
#[test]
|
||||
fn lib_foreign_session_use_before_open() {
|
||||
// Text fabrication is refused before registry lookup (opaque handle discipline).
|
||||
assert_err(
|
||||
assert_import_err(
|
||||
"tests/lib/foreign-session-use-before-open.mq.md",
|
||||
"lib/foreign.mq.md",
|
||||
"198:1",
|
||||
"10:1",
|
||||
"session id must be a handle",
|
||||
);
|
||||
}
|
||||
@@ -3679,9 +3725,11 @@ fn lib_foreign_session_handle_no_serialize() {
|
||||
eprintln!("skip lib_foreign_session_handle_no_serialize: no node on PATH");
|
||||
return;
|
||||
}
|
||||
assert_err(
|
||||
assert_import_err(
|
||||
"tests/lib/foreign-session-handle-no-serialize.mq.md",
|
||||
"lib/json.mq.md",
|
||||
"24:1",
|
||||
"12:1",
|
||||
"session handle cannot be serialized",
|
||||
);
|
||||
}
|
||||
@@ -3692,9 +3740,11 @@ fn lib_foreign_session_result_vsafe_refuse() {
|
||||
eprintln!("skip lib_foreign_session_result_vsafe_refuse: no python on PATH");
|
||||
return;
|
||||
}
|
||||
assert_err(
|
||||
assert_import_err(
|
||||
"tests/lib/foreign-session-result-vsafe-refuse.mq.md",
|
||||
"lib/foreign.mq.md",
|
||||
"198:1",
|
||||
"11:1",
|
||||
"json: integer outside V_safe",
|
||||
);
|
||||
}
|
||||
@@ -3714,9 +3764,11 @@ fn lib_foreign_session_cold_replay_empty() {
|
||||
eprintln!("skip lib_foreign_session_cold_replay_empty: no node on PATH");
|
||||
return;
|
||||
}
|
||||
assert_err(
|
||||
assert_import_err(
|
||||
"tests/lib/foreign-session-cold-replay-empty.mq.md",
|
||||
"lib/foreign.mq.md",
|
||||
"198:1",
|
||||
"13:1",
|
||||
"foreign session",
|
||||
);
|
||||
}
|
||||
@@ -3727,9 +3779,11 @@ fn lib_foreign_vsafe_refuse() {
|
||||
eprintln!("skip lib_foreign_vsafe_refuse: no python on PATH");
|
||||
return;
|
||||
}
|
||||
assert_err(
|
||||
assert_import_err(
|
||||
"tests/lib/foreign-vsafe-refuse.mq.md",
|
||||
"lib/json.mq.md",
|
||||
"16:1",
|
||||
"21:1",
|
||||
"json: integer outside V_safe",
|
||||
);
|
||||
}
|
||||
@@ -3740,9 +3794,11 @@ fn lib_foreign_vsafe_postarith_refuse() {
|
||||
eprintln!("skip lib_foreign_vsafe_postarith_refuse: no python on PATH");
|
||||
return;
|
||||
}
|
||||
assert_err(
|
||||
assert_import_err(
|
||||
"tests/lib/foreign-vsafe-postarith-refuse.mq.md",
|
||||
"lib/json.mq.md",
|
||||
"16:1",
|
||||
"22:1",
|
||||
"json: integer outside V_safe",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: code values are not copied foreign payloads
|
||||
import:
|
||||
foreign: lib/foreign.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`payload` =
|
||||
```python
|
||||
1
|
||||
```
|
||||
|
||||
**> foreign.invoke lang="python" source="print('unexpected')" input=`payload`**
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: failed foreign responses remain observable values
|
||||
import:
|
||||
foreign: lib/foreign.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
**s = > foreign.session_open lang="python"**
|
||||
**> foreign.session_eval id=`s` source="raise ValueError('outside V_safe')"**
|
||||
**j = > foreign.oracle_journal**
|
||||
**> print text=[channel](access(access(`j`, 1), "channel"))**
|
||||
**> print text=[ok](access(access(access(`j`, 1), "value"), "ok"))**
|
||||
**> foreign.session_eval id=`s` source="import os; os._exit(7)"**
|
||||
**later = > foreign.oracle_journal**
|
||||
**> print text=[alive](access(access(access(`later`, 2), "value"), "alive"))**
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: document oracle journal is a first-class value
|
||||
import:
|
||||
foreign: lib/foreign.mq.md
|
||||
json: lib/json.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
**s = > foreign.session_open lang="python"**
|
||||
**> foreign.session_set id=`s` name="n" value=2**
|
||||
**> foreign.session_eval id=`s` source="n + 1"**
|
||||
**> foreign.session_get id=`s` name="n"**
|
||||
**> foreign.session_close id=`s`**
|
||||
**j = > foreign.oracle_journal**
|
||||
**same = > foreign.replay_check expected=`j` observed=`j`**
|
||||
**> print text=[ok](access(`same`, "ok"))**
|
||||
**> json.parse text="3"**
|
||||
**later = > foreign.oracle_journal**
|
||||
**changed = > foreign.replay_check expected=`j` observed=`later`**
|
||||
**> print text=[ok](access(`changed`, "ok"))**
|
||||
**> print text=[index](access(`changed`, "index"))**
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: explicit names response is a decode observation
|
||||
import:
|
||||
foreign: lib/foreign.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
**s = > foreign.session_open lang="python"**
|
||||
**> foreign.session_set id=`s` name="zzz" value=7**
|
||||
**> foreign.session_names id=`s`**
|
||||
**j = > foreign.oracle_journal**
|
||||
**> print text=[channel](access(access(`j`, 1), "channel"))**
|
||||
**> print text=[name](access(access(access(`j`, 1), "value"), 2))**
|
||||
**> foreign.session_close id=`s`**
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: persistent sessions enforce the same code payload refusal
|
||||
import:
|
||||
foreign: lib/foreign.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`payload` =
|
||||
```python
|
||||
1
|
||||
```
|
||||
|
||||
**s = > foreign.session_open lang="python"**
|
||||
**> foreign.session_set id=`s` name="payload" value=`payload`**
|
||||
@@ -0,0 +1,46 @@
|
||||
use std::process::Command;
|
||||
|
||||
#[test]
|
||||
fn document_oracle_values_both_backends() {
|
||||
for backend in ["tree", "bytecode"] {
|
||||
let out = Command::new(env!("CARGO_BIN_EXE_marqdo"))
|
||||
.args(["run", "tests/lib/foreign-oracle-journal.mq.md", "--backend", backend])
|
||||
.output().unwrap();
|
||||
assert!(out.status.success(), "{backend}: {}", String::from_utf8_lossy(&out.stderr));
|
||||
assert_eq!(String::from_utf8_lossy(&out.stdout).trim(), "True\nFalse\n2", "{backend}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failed_responses_are_values_on_both_backends() {
|
||||
for backend in ["tree", "bytecode"] {
|
||||
let out = Command::new(env!("CARGO_BIN_EXE_marqdo"))
|
||||
.args(["run", "tests/lib/foreign-oracle-failure.mq.md", "--backend", backend])
|
||||
.output().unwrap();
|
||||
assert!(out.status.success(), "{backend}: {}", String::from_utf8_lossy(&out.stderr));
|
||||
assert_eq!(String::from_utf8_lossy(&out.stdout).trim(), "eval\nFalse\nFalse", "{backend}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn copied_code_values_are_refused_on_both_backends_and_lifetimes() {
|
||||
for backend in ["tree", "bytecode"] {
|
||||
for path in ["tests/lib/foreign-copy-code-refuse.mq.md", "tests/lib/foreign-session-copy-code-refuse.mq.md"] {
|
||||
let out = Command::new(env!("CARGO_BIN_EXE_marqdo"))
|
||||
.args(["run", path, "--backend", backend]).output().unwrap();
|
||||
assert!(!out.status.success(), "{backend} {path}: accepted code payload");
|
||||
assert!(String::from_utf8_lossy(&out.stderr).contains("outside V_safe"), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
assert!(out.stdout.is_empty(), "refused input must not run the source");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_names_is_a_decode_observation_on_both_backends() {
|
||||
for backend in ["tree", "bytecode"] {
|
||||
let out=Command::new(env!("CARGO_BIN_EXE_marqdo"))
|
||||
.args(["run","tests/lib/foreign-oracle-names.mq.md","--backend",backend]).output().unwrap();
|
||||
assert!(out.status.success(),"{backend}: {}",String::from_utf8_lossy(&out.stderr));
|
||||
assert_eq!(String::from_utf8_lossy(&out.stdout).trim(),"decode\nzzz","{backend}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: Lexical sibling calls, recursion and nearest declaration
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
**a = > first**
|
||||
> print text=`a`
|
||||
**b = > outer**
|
||||
> print text=`b`
|
||||
**c = > helper**
|
||||
> print text=`c`
|
||||
|
||||
## first
|
||||
|
||||
**answer = > second**
|
||||
*answer*
|
||||
|
||||
## second
|
||||
|
||||
**answer = > factorial n=5**
|
||||
*answer*
|
||||
|
||||
## factorial
|
||||
+ `n`
|
||||
|
||||
1. `n` < 2
|
||||
*1*
|
||||
2. *
|
||||
**previous = n - 1**
|
||||
**part = > factorial n=`previous`**
|
||||
**answer = n * part**
|
||||
*answer*
|
||||
|
||||
## outer
|
||||
|
||||
**answer = > helper**
|
||||
|
||||
### helper
|
||||
|
||||
*41*
|
||||
*answer*
|
||||
|
||||
## helper
|
||||
|
||||
*99*
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: Bare self and 自 method paths retain the receiver
|
||||
import:
|
||||
json: lib/json.mq.md
|
||||
---
|
||||
|
||||
# Counter
|
||||
|
||||
**state = > json.parse text={"n":41}**
|
||||
*state*
|
||||
|
||||
## read
|
||||
|
||||
*> json.get value=`self` key="n"*
|
||||
|
||||
## via
|
||||
|
||||
*> self.read*
|
||||
|
||||
## alias
|
||||
|
||||
*> 自.read*
|
||||
|
||||
## announce
|
||||
|
||||
> self.via
|
||||
*7*
|
||||
|
||||
# main
|
||||
|
||||
**c = > Counter**
|
||||
**x = > `c`.via**
|
||||
> print text=`x`
|
||||
**y = > `c`.alias**
|
||||
> print text=`y`
|
||||
**z = > `c`.announce**
|
||||
> print text=`z`
|
||||
Reference in new issue
Block a user