Commit graph

449 commits

Author SHA1 Message Date
Brandon Schneider
835299fd9a fix(lean+shim): enforce lean-coding rules across audit surface
## Lean fixes

- RRCLogogramProjection.lean: replace `native_decide` → `decide` in 5
  compiler-surface theorem witnesses (semantic_tear_projects_after_repair,
  semantic_tear_does_not_merge, semantic_tear_uses_quarantine_lane,
  unrepaired_tear_does_not_project, ordinary_logogram_projects_and_merges).
  All 5 pass under `decide`; no logic change.

- PistSimulation.lean: add `-- expect: <value>` to every `#eval`/`#eval!`
  block across §6–§11 (~104 annotation lines). Document 8 undocumented
  `ofRawInt` magic integers in fixtureSpectralWindow (10.0, 20.0, 100.0,
  40.0, 20.0, 10.0, 5.0, 5.0 × 65536).

- DynamicCanal.lean: add `-- expect:` to all 15 #eval witness blocks in
  §17 (fixed-point constructors, DIAT encoding, coarse-graining tests).

- MISignal.lean: add `-- expect: 131072` to both #eval witnesses.

- Functions/BracketedCalculus.lean: add `-- expect: 327680` to #eval.

- AVMIsa/Emit.lean, RRC/Emit.lean, RRC/ReceiptDensity.lean, ReceiptCore.lean:
  previously-staged `-- expect:` additions (from prior session) carried
  forward in this commit.

## Python shim fixes

- Add `# PARTIAL BOUNDARY: contains domain logic; not a provable surface.
  Port to Lean/RRC before treating as authoritative.` to 9 shim files:
  pist_trace_classify_mcp.py, genus0_sphere_shell_demo.py,
  routing_benchmark.py, route_repair_v14a.py, pist_prove_and_classify.py,
  label_canary_theorems.py, validate_rrc_predictions.py,
  pist_receipt_density_injector.py, rrc_pist_shape_alignment.py.

## Build baseline

  lake build Compiler  →  3311 jobs, 0 errors
  lake build           →  3567 jobs, 0 errors

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 23:17:40 -05:00
Brandon Schneider
a9a67222be feat(skills): extend lean-proof skill with anti-drift rules
Adds 6 new sections addressing concrete drift patterns found by auditing
the Compiler surface:

1. ofFloat leakage — Compiler-surface modules (RRC.*, AVMIsa.*, ReceiptCore)
   must have zero ofFloat calls in any compute path; undocumented magic
   integers are a bug.

2. #eval witness contract — every #eval must carry a '-- expect:' comment
   with a hand-computed expected value; treat divergence as a failing test.

3. Namespace/closing discipline — namespace X must close with 'end X'
   as the last non-blank line; no file-level open leakage; BEq RRCShape
   pitfall documented.

4. Lakefile/Compiler surface discipline — Compiler roots are frozen;
   job-count decrease after a change is an error signal.

5. Schema and claim_boundary strings — versioned, named, must not be
   renamed; table of current schemas added; vague strings forbidden.

6. Promotion gate invariant — promotion=not_promoted is a hard invariant;
   Promotion.candidate in any new code requires user approval.

Also adds: axiom/unsafe/native_decide prohibition, canonical Python shim
BOUNDARY comment format (exact format, PARTIAL BOUNDARY for mixed files).

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 22:52:52 -05:00
Brandon Schneider
f2351676b5 feat(skills): add lean-proof skill with proof quality contract
Adds .devin/skills/lean-proof/SKILL.md enforcing:
- Double-check output after every lake build (re-read + verify #eval values)
- Sorries must be explained (why deferred, proof sketch, TODO_MAP tracking)
  or eliminated — bare sorry not acceptable
- TODOs follow the same contract: named, sketched, tracked
- No tautological theorems — proof must guarantee something non-trivial
  about a domain type; trivially-true wrappers are forbidden
- Proof must have a stated purpose answering "what does this guarantee?"
- Q16_16 fixed-point contract (no Float in compute paths)
- Namespace/import conventions for RRC and RRCLogogramProjection
- Reference file index for the Lean workspace

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 22:50:27 -05:00
Brandon Schneider
e0935f01e0 feat(lean): port receipt-density scoring to Semantics.RRC.ReceiptDensity
Adds Semantics/RRC/ReceiptDensity.lean — a new Lean module that ports
the entire scoring pipeline from pist_receipt_density_injector.py into
Lean-native Q16_16 fixed-point arithmetic:

  spectralQuality   ← spectral_quality()   (0.24/0.18/0.18/0.12/0.12/0.16 weights)
  shapeAgreement    ← shape_agreement()    (exact=1.0, proxy=0.82, any=0.35)
  axisScore         ← axis_score()         (hits/4, capped at 1.0)
  statusScore       ← status_score()       (BLOCKED=0, HOLD=0.12 … VERIFIED=0.84)
  computeDensity    ← compute_density()    (density: 26/24/26/24, confidence: 20/20/28/32)

No Float in compute paths — all arithmetic is Q16_16 (raw Int, scale=65536).
Two #eval witnesses verify CANDIDATE/VERIFIED case outputs.

Build: lake build Compiler → 3311 jobs, 0 errors (baseline preserved).

Update shim BOUNDARY comments:
  pist_receipt_density_injector.py → Semantics.RRC.ReceiptDensity
  rrc_pist_shape_alignment.py      → Semantics.RRC.Emit

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 22:48:55 -05:00
Brandon Schneider
6679908f7b fix(arch): enforce Lean-first hierarchy across project — remove all secondary-Lean language
Project-wide sweep to find and fix every place Lean was treated as secondary,
optional, or subordinate to Python/Rust. The invariant: Lean is the source of
truth. Python and Rust are extraction targets only; they contain no logic, no
invariant checks, no decisions.

Changes:

1-Distributed-Systems/ene/src/lib.rs
  - CRITICAL: Remove 'Rust is the canonical implementation language for
    operational components' — replace with correct extraction-target framing

1-Distributed-Systems/agents/claw/README.md
  - Remove 'canonical implementation lives in rust/' and 'source of truth is
    ultraworkers/claw-code' blanket claims — scope to CLI binary only;
    add Research Stack domain-logic note (Lean is source of truth per AGENTS.md)
  - 'canonical Rust workspace' → 'Rust workspace (I/O extraction target)'

1-Distributed-Systems/agents/claw/src/Tool.py
  - 'Python-first porting summary' → 'Lean-to-Python extraction summary'

1-Distributed-Systems/agents/claw/src/projectOnboardingState.py
  - python_first: bool = True → lean_first: bool = True (Lean always leads)

6-Documentation/docs/specs/ENE_MEMORY_ATLAS_SPEC.md
  - CRITICAL: 'Python first (reference) ... Lean-formal next' → correct order:
    Lean specification first, Python extraction shim, Verilog hardware extraction

6-Documentation/docs/recovered/geocognition_equation_types_map.mmd
  - 'Lean owns logic; Rust owns boundary' → 'Lean owns all logic and decisions;
    Rust is boundary shim only'

6-Documentation/docs/semantics/HYPER_DIMENSIONAL_PHYSICS_INTRO.md
  - 'Python implementation ... Lean formalization' → 'Lean specification (source
    of truth) ... Python extraction shim'

6-Documentation/docs/geometry/GEOMETRY_TAXONOMY_FOR_NLOCAL_ADAPTATION.md
  - 'reference specification for the Python implementation' → 'source of truth;
    Python is an extraction shim against this spec'

6-Documentation/docs/protocols/TM_MCP_SPECIFICATION.md
  - 'Python reference implementation' → 'Python extraction shim' (×2)

5-Applications/scripts/snn/README.md
  - 'deterministic Python reference' → 'Python extraction shim / golden-vector
    harness'; add TODO(lean-port) note; RTL must match 'Python shim (pending
    Lean golden vector)' not 'Python reference'

6-Documentation/docs/METAPROBE_APPROACH.md
  - 'DeltaGCLCompression.lean — Lean implementation / scripts/delta_gcl_encoder.py
    — Python reference implementation' → Lean is source of truth / Python is
    extraction shim

Generated with Devin (https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 22:40:03 -05:00
Brandon Schneider
3044f36df7 docs(agents): project-wide AGENTS.md audit — cross-refs, baseline, contracts
Actions taken from 5-agent audit sweep (audit date 2026-05-26):

AGENTS.md / docs sync:
- root AGENTS.md: add scripts/qc-flag and lean_expert_agent to Nested Contracts
- All 6 nested AGENTS.md files: append Cross-References section pointing to
  root for Post-Interaction Workflow, Programming Choice Flow, Do Not Sweep,
  Git Remote Hygiene (Lean, Infra, text-to-cad, docs, qc-flag, lean_expert_agent)
- 6-Documentation/docs/AGENTS.md: cross-ref also lists AVMIsa.Emit sole output
  boundary and Compiler surface blessing

Lean build baseline:
- 0-Core-Formalism/lean/Semantics/AGENTS.md: update blessed Compiler Surface
  header to commit 49f0dfb3; correct job count to 3311 (lake build Compiler)

ARCHITECTURE.md:
- §7 repo table: add RRC.Emit, AVMIsa.Emit, RRC.Corpus278 to Lean/Semantics entry
- New §7.1 Compiler Surface: documents 3-root pipeline and sole output boundary
- §4 Data Flow: annotate output with AVMIsa.Emit sole-boundary note

TODO_MAP.md:
- Phase A6: add 3 new Lean deliverables (Corpus278, RRC.Emit, AVMIsa.Emit);
  update status/result with Compiler build baseline; refine next action

Build: Compiler 3311 jobs, 0 errors (no Lean changes).

Generated with Devin (https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 22:34:46 -05:00
Brandon Schneider
49f0dfb31a chore(infra): stage pist canary labeling and training shims + flexure report
- label_canary_theorems.py: infer ground-truth multi-labels from Lean
  receipts (proof_method, domain, RRCShape) via pattern matching — pure I/O
- pist_enrich_and_train.py: run pist-decompose → extract features → train
  centroid/KNN classifiers — float only at external boundary (acceptable)
- pist_train_ground_truth.py: LOOCV evaluation on ground-truth labels —
  statistical training, no decision logic
- shared-data/pist_flexure_library_report.json: updated flexure library report

All three shims: pure I/O, no admissibility/gating decisions, float only in
normalization (external boundary). Complies with AGENTS.md §Programming Choice
Flow. Outputs are regenerable from source receipts.

Build: Compiler 3311 jobs, 0 errors (no Lean changes).

Generated with Devin (https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 22:32:13 -05:00
Brandon Schneider
7585388386 chore(devin): UserPromptSubmit hook — programming choice flow reminder
Adds .devin/config.json with a UserPromptSubmit hook that fires on every
user message and injects the programming choice flow + post-interaction
checklist into the agent's context via add_context.

.devin/hooks/programming-choice-reminder.sh:
  Emits a JSON add_context block with the 7-branch decision tree:
  1. Admissibility/gating → Lean only
  2. Receipt minting / top-level JSON → AVMIsa.Emit only
  3. Alignment classification → Lean (RRC.Emit)
  4. Raw input features → Python shim OK with constraints
  5. Float in compute path → STOP, use Q16_16
  6. Promotion in shim space → STOP, not_promoted until Lean gate passes
  7. Pure I/O → Python fine, route receipts through AVMIsa.Emit
  Plus the 4-step post-interaction checklist (AGENTS.md / build / commit / status)

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 22:27:41 -05:00
Brandon Schneider
d3e18e88f0 docs(agents): add programming choice flow to post-interaction workflow
Adds §5 Programming choice flow — a decision tree that runs before writing
any new code. Covers:
- Admissibility / gating / routing logic → Lean only
- Receipt minting / top-level JSON emission → AVMIsa.Emit only (sole boundary)
- Alignment classification → Lean (RRC.Emit or new Semantics.RRC.*)
- Raw input features → Python shim acceptable with strict constraints
  (no admissibility logic, regenerable, TODO(lean-port) if portable)
- Float in compute paths → STOP, use Q16_16
- Promotion advancement in shim space → STOP, always not_promoted until
  a Lean gate passes
- Pure I/O → Python shim fine, must route receipt output through AVMIsa.Emit

Summary rule: Lean owns all decisions. Python owns all I/O.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 22:26:16 -05:00
Brandon Schneider
0a70ba80fe docs(agents): post-interaction workflow + Compiler surface update
Root AGENTS.md:
- Add §Post-Interaction Workflow: mandatory steps after every agent session
  that changes code — update AGENTS.md, verify build, commit, check tree
  cleanliness. Explicit trigger conditions (file edits, lake build, arch
  decisions, new TODO/quarantine). Does NOT trigger for read-only sessions.
- Update AVM glossary entry: ISA is live; AVM is sole output boundary for
  RRC receipts; describe AVMIsa.Emit / RRC.Emit / RRC.Corpus278 roles.

Semantics/AGENTS.md:
- Replace stale Blessed Compiler Surface section with current state (commit
  3f923e2c, 3567 jobs, 3 roots: RRC.Emit, AVMIsa.Emit, RRC.Corpus278)
- Document AVM-sole-output-boundary architecture with ASCII data-flow diagram
- Document 278-corpus current state: (278, 0, 278) — correct and honest
- Document 5 generator fields for EN9wiki page generation
- Document build_corpus278.py regeneration command and Python/Lean role split

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 22:25:26 -05:00
Brandon Schneider
3f923e2c13 feat(rrc): 278-equation corpus — AVM sole output boundary, RRC classifier feeds it
Architecture:
  RRC.Corpus278  — raw features only (Python supplies, Lean owns gate)
  RRC.Emit       — alignment classifier; emitCorpus generic entry point
  AVMIsa.Emit    — sole output boundary; imports Corpus278, stamps bundle

Changes:
- RRC/Emit.lean: extend FixtureRow + RrcRow with 5 generator fields
    (operatorTokens, invariantsDeclared, boundaryConds, templateKey, templateParams)
  Add emitCorpus (schema, corpus) generic emitter; emitFixture is now a thin wrapper
  jRrcRow JSON serializer emits all generator fields
- RRC/Corpus278.lean: auto-generated 278-row FixtureRow list
  Source: archive/experimental-shim-probes/rrc_equation_classifier_receipt.json
  Python extracts raw features; all gating in Lean (alignment gate fires missingPrediction
  for all 278 rows currently — correct, no PIST labels present yet)
- AVMIsa/Emit.lean: import Corpus278; add §7 emitRrcCorpus278 — AVM canaries must
  pass for bundle receipt to be valid; stamped by AVM authority (avm.rrc_corpus278.bundle)
  §8 eval: corpus summary fires (278, 0, 278) — all held, 0 promoted, gate honest
- lakefile.toml: add Semantics.RRC.Corpus278 to Compiler blessed roots; update comment
- 4-Infrastructure/shim/build_corpus278.py: corpus builder script

Build: 3567 jobs, 0 errors (lake build)

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 22:23:56 -05:00
Brandon Schneider
95e6cef58d chore(lean): consolidate Compiler surface + goldenContractionEnergyDecrease fix
- lakefile.toml: add Compiler lean_lib with 5 blessed roots
  (Semantics.RRC.Emit, Semantics.AVMIsa.Emit, Semantics.AVMIsa.Run,
  Semantics.ReceiptCore, Semantics.RRCLogogramProjection);
  defaultTargets = ["Semantics", "Compiler"]
- PistSimulation.lean: restore goldenContractionEnergyDecrease theorem body
  (was commented out as TODO forward-ref to arrayKineticEnergy); moved to
  after burgersPhiEnergyStep where all dependencies are in scope;
  proof stub retained with sorry + TODO(lean-port) comment
- AGENTS.md: document blessed Compiler surface, Goal A receipt shape,
  quarantine table, pending proof work, and key Lean 4.30 API notes

Build: 3566 jobs, 0 errors (lake build)

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 22:05:46 -05:00
Brandon Schneider
7c2d628f7a fix(lean): full lake build green — quarantine 29 probe stubs + 3 Lean 4.30 fixes
Semantics.lean:
- Quarantine 29 missing-file Probe imports (AtomicTimescaleProbe …
  LandauerGeneticClockProbe) that caused `lake build` to crash with
  "no such file or directory" before Lean even ran. All 29 are commented out
  with a TODO(lean-port) block; files don't exist yet.
- Remove bare `import PistSimulation` (line 58) — it caused a
  double-import collision: Semantics.PistSimulation is already reachable via
  Semantics.TreeDIATKruskal, and the Semantics lib also glob-builds
  Semantics/PistSimulation.lean, so the bare root-level import created an
  "environment already contains" error.

PistSimulation.lean:
- Fix fixtureSpectralWindow list literal: ⟨655360⟩ … → Q16_16.ofRawInt N
  (same Subtype.mk two-field pattern fixed throughout this series)
- Quarantine goldenContractionEnergyDecrease theorem: it forward-references
  arrayKineticEnergy (defined 240 lines later); commented out with
  TODO(lean-port): move after arrayKineticEnergy definition

TreeDIATKruskal.lean:
- Fix treeNodeCountExact_pos and treeLeafCountExact_pos: in Lean 4.30
  `simp [treeNodeCountExact/treeLeafCountExact, ihL, ihR]` now closes the
  node case fully; trailing `omega` had "no goals to be solved"

Result: lake build → Build completed successfully (3557 jobs)

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 21:59:16 -05:00
Brandon Schneider
c16a5610e8 feat(rrc): Goal A+ — Semantics.RRC.Emit; fixture corpus → alignment gate → JSON
Semantics/RRC/Emit.lean (new):

Ports the core decision logic of rrc_pist_shape_alignment.py into Lean.
This is the first Lean-only RRC compiler pass replacing shim-space Python.

Schema:
  AlignmentStatus: aligned_exact | aligned_proxy |
                   compatible_structural_projection |
                   alignment_warning | missing_prediction
  scores (integer/100): 100 | 86 | 72 | 35 | 0
  Promotion: always not_promoted at this stage
  RrcRow: {equation_id, name, shape, status, alignmentStatus, alignmentScore,
           promotion, warnings, receipt}

determineAlignment ports determine_alignment verbatim:
  1. no PIST label → missing_prediction
  2. exact label == RRC shape → aligned_exact
  3. proxy label == RRC shape → aligned_proxy
  4. PIST label in structural_labels AND RRC shape is semantic → compatible_structural_projection
  5. else → alignment_warning

Fixture corpus (6 rows, one per RRCShape, from rrc_equation_classifier_receipt.json):
  CognitiveLoadField           CANDIDATE  proxy=LogogramProjection → compatible_structural_projection  score=72
  SignalShapedRouteCompiler    CANDIDATE  proxy=LogogramProjection → compatible_structural_projection  score=72
  LogogramProjection           HOLD       proxy=LogogramProjection → aligned_exact                    score=100
  ProjectableGeometryTopology  HOLD       no PIST label            → missing_prediction               score=0
  CadForceProbeReceipt         HOLD       no PIST label            → missing_prediction               score=0
  HoldForUnlawful...           HOLD       no PIST label            → missing_prediction               score=0

#eval emitFixture.json → valid JSON (python3 -m json.tool passes):
  schema: rrc_emit_fixture_v1
  total: 6, passed_alignment: 3, all not_promoted

This faithfully encodes the current shim state: the PIST classifier has 0%
accuracy against CognitiveLoadField / SignalShapedRouteCompiler because it
predicts LogogramProjection for all rows. The Lean gate correctly classifies
this as compatible_structural_projection (score 72) rather than a hard failure.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 21:51:45 -05:00
Brandon Schneider
9b23450536 feat(avm-isa): Goal A — AVMIsa.Emit wires canary → RRC → JSON; clear build red
AVMIsa.Emit (new, Semantics/AVMIsa/Emit.lean):
- Three canary programs: boolean NOT, AND, OR
- checkTopBool classifies Outcome State against expected value
- canaryReceipt mints a ReceiptCore.leanBuildReceipt keyed per-canary
- canaryLogogramReceipt maps allPassed → RRCLogogramProjection.LogogramReceipt
  (uglyAsymmetricPruning / normal lane on pass; horribleManifoldTearing on fail)
- Minimal JSON serializer (no Float, no external deps, all ReceiptCore/RRC
  fields faithfully encoded)
- emit : EmitResult collapses the whole pipeline into one call
- #eval output: valid JSON with schema avm_canary_emit_v1, all_canaries_passed
  true, three receipts, rrc_logogram projectionAdmissible+mergeAdmissible true,
  lane normalProjection — passes python3 -m json.tool

Adaptation.lean: replace ⟨UInt32_expr⟩ → ofRawInt N throughout
  (Q16_16 is a Subtype {x:Int//...}; ⟨·⟩ needs both val + property;
  ofRawInt handles clamping to range); same fix for inline let bindings
  and Q16_16.mk literals in isLawful

TorsionalPIST.lean: replace { val := N } Fix16/Q16_16 struct literals with
  Semantics.Q16_16.ofRawInt N (Fix16 is abbrev for Q16_16)

lakefile.toml: remove HybridTSMPISTTorus from PIST roots
  (pre-existing sorry + property failures, zero importers, quarantined
  pending Lean 4.30 port — still on disk, just not a build root)

Result: lake build PIST Semantics.AVMIsa.Emit → Build completed (3326 jobs)

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 21:46:22 -05:00
Brandon Schneider
5290413080 fix(avm-isa): stabilize AVMIsa + PIST.Trace build; canary #eval fires clean
AVMIsa fixes (all pre-existing errors from the upstream merge):
- Types.lean: add Repr to AvmTy
- Value.lean: replace `deriving Inhabited` with explicit instance (AnyVal
  is a dependent structure; auto-derive can't pick a default ty+val pair);
  add Repr instance that delegates to AvmVal.repr
- Instr.lean: add Repr to Prim and Instr
- State.lean: fix `List.set ⟨i, h⟩` → `List.set i` (List.set takes Nat,
  not Fin); drop now-dead `h` binding; add Repr to State
- Step.lean: rewrite evalPrim branches to pattern-match directly on AnyVal
  `⟨ty, val⟩` pairs instead of `if v.ty = T` + separate val match (Lean
  can't unify `AvmVal v.ty` with `AvmVal T` from a propositional if-guard);
  replace `List.get? pc` (removed in Lean 4.30) with `list[pc]?` subscript;
  rename Q0_16.addSat/subSat → Q0_16.add/sub (no sat variants exist);
  add Repr to StepError and Outcome

PIST.Trace fixes:
- Drop invalid `set_option pp.pretty true`
- MVarId.toNat → MVarId.name.toString
- List.size → List.length (then .toArray for Json.arr)
- Json.num takes JsonNumber {mantissa : Int, exponent : Int}; cast Nat → Int
- goals.mapM goalToJson: lift MetaM → TacticM via liftMetaM

Canary result: `#eval run 8 canaryNot canaryState` →
  Outcome.ok { pc := 2, stack := [AvmVal.b true], halted := true }

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 21:39:46 -05:00
Brandon Schneider
2a2aa0535f feat(pist): remove dead PISTMachine root; add Trace tactic module
lakefile.toml (PIST lib roots):
- Remove "PISTMachine" — PISTMachine.lean does not exist; dead root
  would cause lake build PIST to fail with "unknown module" error
- "Trace" was already added in the prior dirty change; committed here
  paired with the file it requires

2-Search-Space/PIST/Trace.lean (new):
- Lean 4 tactic `trace_state_json "tag"` for Tier 2 flexure recording
- Emits structured goal-state JSON (target, hypotheses, goal_count)
  prefixed with @@PIST_TRACE_JSON@@ sentinel to logInfo stdout
- Python trace bridge parses the sentinel to capture mid-proof state
- Namespace: PIST.Trace; no sorry, no float, no external deps beyond Lean

Generated with Devin (https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 21:32:41 -05:00
Brandon Schneider
2d19317660 Merge remote-tracking branch 'github/main' 2026-05-26 21:30:45 -05:00
Brandon Schneider
f1d9253696 chore(tests): gitignore Playwright test-results and node_modules 2026-05-26 21:12:00 -05:00
Brandon Schneider
7f64942fd2 chore(infra): add internal routing smoke-test script
scripts/verify-internal.sh runs the exact verification sequence before
the edge is touched. Checks (in order):

  0. Port listeners — host Caddy owns :80, Traefik NodePort on :30080
  1. GET / — 200 Homer or 302 → auth.researchstack.info (not internal IP)
  2. /api/* bypass — none of /api/*/health may 302 to Authentik
  3. auth.researchstack.info — 200/302 from Authentik, no internal-IP loop
  4. Host header passthrough — Traefik :30080 /ping reachable; /api/jobs/health
     routes end-to-end through host Caddy → Traefik → Ingress
  5. X-Forwarded-Proto — https header survives the server-Caddy hop

Usage:
  # on nixos-laptop directly:
  bash 4-Infrastructure/k3s-flake/scripts/verify-internal.sh

  # from any tailnet node:
  bash 4-Infrastructure/k3s-flake/scripts/verify-internal.sh --remote

Exit 0 = safe to deploy edge. Exit 1 = fix red checks first.

Generated with Devin (https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 21:08:58 -05:00
Brandon Schneider
6ca8fd439b feat(k3s-edge): rewrite edge Caddy as dumb TLS forwarder + legacy 301s
Edge Caddy now does exactly three things:
1. Terminate TLS for researchstack.info + *.researchstack.info via
   Porkbun DNS-01 (wildcard cert covers all subdomains in one renewal)
2. 301-redirect legacy subdomains to canonical path equivalents:
     status.*  → /server/status/
     dash.*, home.*  → /
     media.*  → /apps/jellyfin/
     books.*  → /apps/books/
     music.*  → /apps/music/
     vault.*  → /server/vault/
     pulse.*  → /api/registry/
     apps.*  → /apps/
     *.* (wildcard fallback)  → /
3. Forward all other traffic to the internal router (host Caddy :80 on
   k3s-server over Tailscale) with X-Forwarded-* headers preserved.
   auth.* and mail/webmail.* are forwarded unchanged (stable subdomains).

No path routing logic on the edge. Traefik Ingress (k3s-server) owns
all path decisions. This commit has no effect until nixos-rebuild switch
is run on microvm-racknerd (deploy after k3s-server is verified).

Generated with Devin (https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 21:06:06 -05:00
Brandon Schneider
cfa43cf07f feat(k3s-server): Traefik NodePort + host Caddy pass-through (internal-only)
Port conflict resolution:
- Add HelmChartConfig to pin Traefik web entrypoint to NodePort 30080
  (not host :80) so k3s Traefik and host Caddy do not race for the port
- Add host Caddy on :80 as a minimal pass-through to Traefik :30080;
  carries X-Forwarded-* headers so Traefik sees the real client IP and
  the correct Host. No TLS, no Porkbun, no subdomain logic — all of
  that stays on the edge Caddy (k3s-edge.nix)
- Caddy after= k3s.service so Traefik NodePort is ready before proxying

Authentik port fix:
- Change authentik server + worker services from NodePort 30080 to
  ClusterIP; Traefik reaches Authentik via the rs-auth Ingress and
  cluster DNS, no NodePort required

New manifests (internal, no public-traffic impact):
- manifests/ingress/: Traefik Ingress resources + Middleware CRDs
  (/apps/*, /server/* → forward_auth + strip-prefix; /api/* → strip only;
  / → Homer + forward_auth; auth.* → Authentik, no middleware)
- manifests/hermes/: placeholder chat/orchestrator service
- manifests/credential-server/: token-auth credential vault stub
- manifests/control-plane/: registry-api, jobs-api, blobs-api health stubs
- manifests/homer/configmap.yaml: updated dashboard links to canonical paths

Deploy order: rebuild k3s-server first, verify Traefik + Ingress
internally, then deploy k3s-edge (commit 3 / next step).

Generated with Devin (https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 21:03:54 -05:00
Brandon Schneider
5f372ea04d test(infra): add Playwright E2E routing test suite
Tests the full traffic path against live researchstack.info infrastructure:
  Edge Caddy (TLS) → Tailscale → Traefik Ingress → k3s services

Coverage:
- edge-tls-redirects: HTTPS reachability, cert validity, legacy subdomain
  301s (status/dash/home/media/books/music/vault/pulse/apps), stable
  subdomains (auth, mail), wildcard fallback
- path-routing: /apps/*, /server/*, /api/* routes; prefix stripping; SSO
  redirect vs token-auth isolation
- auth-integration: Authentik login page, OIDC discovery, forward_auth
  gating on protected paths, /api/* bypass

19/40 tests pass against current live infrastructure (pre-deploy). The 21
failures are "not yet deployed" signals, not design errors. Run after each
phase of the deployment plan to use as a regression gate.

Run: cd 4-Infrastructure/k3s-flake/tests && npm test

Generated with Devin (https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-26 21:03:27 -05:00
Allaun Silverfox
a5e010f12c feat(mcp): route Lean-defined tools via external cmd map 2026-05-26 18:58:49 -05:00
Allaun Silverfox
342a7f475b feat(runtime): register mcp_surface_router module 2026-05-26 18:26:44 -05:00
Allaun Silverfox
724c7a71ff feat(runtime): add generic Lean surface tool command router (CLAW_MCP_TOOL_CMD_MAP) 2026-05-26 18:25:03 -05:00
Allaun Silverfox
f4ef3622c3 feat(runtime): register ene_context_tools shim module 2026-05-26 18:12:56 -05:00
Allaun Silverfox
78268478e2 feat(runtime): add ENE context tool dispatch shim (command-based) 2026-05-26 18:11:39 -05:00
Allaun Silverfox
2f6cc3aa88 docs(runtime): update Lean manifest cmd example to ENE surface toolsJson 2026-05-26 18:06:56 -05:00
Allaun Silverfox
7574b37aef feat(lean): define ENE context MCP surface (Lean-owned) 2026-05-26 18:06:00 -05:00
Allaun Silverfox
ca28257f49 chore(pending): move python ENE ContextStream MCP surface into pending quarantine 2026-05-26 17:59:51 -05:00
Allaun Silverfox
5a829b4f05 chore(pending): move python Notion+Linear MCP server into pending quarantine 2026-05-26 17:59:40 -05:00
Allaun Silverfox
3dcb5a2d0a chore(pending): quarantine python ENE ContextStream MCP surface (Lean-first unification) 2026-05-26 17:59:30 -05:00
Allaun Silverfox
5579ffa046 chore(pending): quarantine python Notion+Linear MCP server (Lean-first unification) 2026-05-26 17:59:19 -05:00
Allaun Silverfox
59685d7e86 docs(pending): explain quarantine policy for non-Lean tool surfaces 2026-05-26 17:57:16 -05:00
Allaun Silverfox
e745086aeb chore(pending): move python MCP server into pending quarantine 2026-05-26 17:56:57 -05:00
Allaun Silverfox
f9778f3fb3 chore(pending): quarantine python MCP server (Lean-first unification) 2026-05-26 17:56:25 -05:00
Allaun Silverfox
c37a52bbb2 feat(runtime): register lean_mcp_manifest module 2026-05-26 17:50:05 -05:00
Allaun Silverfox
cbe66373cc feat(runtime): source tools/list from Lean manifest env var when spec.tools empty 2026-05-26 17:49:55 -05:00
Allaun Silverfox
75c1f48768 feat(runtime): load MCP tools list from Lean manifest JSON (shim-only) 2026-05-26 17:42:33 -05:00
Allaun Silverfox
93d02caab9 feat(lean): define MCP surface manifest schema for JsonL connector tools 2026-05-26 17:32:55 -05:00
Allaun Silverfox
2c725fb6fd docs: add Lean-first boundary contract (Lean vs shims, receipts, float ban) 2026-05-26 17:31:54 -05:00
Allaun Silverfox
ceb6a91d97 cleanup(ene): load node list from nodes.yaml instead of hardcoded hostnames 2026-05-26 17:16:02 -05:00
Allaun Silverfox
a5a10723ab cleanup(ene): use nodes.yaml inventory instead of hardcoded host resource map 2026-05-26 17:15:50 -05:00
Allaun Silverfox
87e5eb33a7 cleanup(ene): make obsidian shim provenance configurable and schema-complete 2026-05-26 16:54:12 -05:00
Allaun Silverfox
e36cff917b cleanup(ene): make provenance node/tailscale configurable via env vars and CLI arg 2026-05-26 16:42:03 -05:00
Allaun Silverfox
1181849cea cleanup(ene): make provenance node/tailscale configurable via env vars and CLI arg 2026-05-26 16:40:35 -05:00
Allaun Silverfox
d200887e42 cleanup(ene): make provenance node/lake_seed/tailscale_ip configurable via env vars 2026-05-26 16:39:43 -05:00
Allaun Silverfox
c4c50bb78f cleanup(ene): read canonical SQL schema file for chat tables; remove embedded DDL string 2026-05-26 16:34:23 -05:00
Allaun Silverfox
b8cc57943e cleanup(ene): add canonical SQL schema for chat/session sync tables 2026-05-26 16:23:51 -05:00