Skip to content

promote: main → prod (E0008 encode architecture + context handling)#99

Merged
klappy merged 4 commits intoprodfrom
main
Apr 16, 2026
Merged

promote: main → prod (E0008 encode architecture + context handling)#99
klappy merged 4 commits intoprodfrom
main

Conversation

@klappy
Copy link
Copy Markdown
Owner

@klappy klappy commented Apr 16, 2026

Promotion PR bringing the governance-driven encode architecture to production.

What's included

PR #96 — Governance-driven encode architecture

Replaced hardcoded detectEncodeType() with governance-driven encoding:

  • discoverEncodingTypes() searches canon for encoding-type tagged docs
  • Parses Type Identity, Trigger Words, and Quality Criteria sections
  • Per-type quality scoring with governance-defined criteria
  • artifacts[] array + backward-compat artifact field
  • governance[] in response teaches the model discovered types
  • Cached at module level (0ms after first load)
  • Graceful degradation when no governance docs exist

PR #98 — Context vs input governance compliance

Closed the gap between governance and code:

  • input generates artifacts; context only informs quality scoring
  • Parsers receive input only (not fullInput)
  • scoreArtifactQuality accepts optional scoringText parameter
  • Structural criteria (non-empty, has constraint keyword, no interpretation words) stay on artifact.body
  • Interpretive criteria (word count, rationale keywords) use scoring text with context
  • Inline comments cite governance doc to prevent regression

Verification

  • TypeScript compiles clean
  • All 5 CI checks pass (Workers Builds, Cursor Bugbot, Test CF Preview, Version Sync, Creed Freshness)
  • Manual testing on preview: input + context produces 1 artifact (not 3), scored with context informing quality

Governance baseline

The klappy.dev baseline (PR #97 + #98 in klappy.dev) has the encoding-type governance docs that this server now discovers:

  • odd/encoding-types/decision.md (D)
  • odd/encoding-types/observation.md (O, fallback: true)
  • odd/encoding-types/learning.md (L)
  • odd/encoding-types/constraint.md (C)
  • odd/encoding-types/handoff.md (H)
  • odd/encoding-types/how-to-write-encoding-types.md (protocol spec)
  • odd/encoding-types/serialization-format.md (TSV format spec)

No oddkit deploy needed when canon changes.


Note

Medium Risk
Changes encode artifact generation and quality scoring behavior, which can affect downstream consumers expecting prior artifact counts or scores. Scope is limited to encoding/scoring logic with no auth or persistence changes.

Overview
Updates encode so context no longer gets concatenated into the text passed to isStructuredInput/parsers, preventing context paragraphs from being turned into extra artifacts.

Extends scoreArtifactQuality with an optional scoringText and, when context is provided, scores each artifact against artifact.body + context while keeping structural checks (e.g., non-empty/keywords) anchored to the artifact’s own fields/body; adds inline governance comments to lock in this behavior.

Reviewed by Cursor Bugbot for commit 760f613. Bugbot is set up for automated code reviews on this repo. Configure here.

Claude (oddkit project) and others added 4 commits April 16, 2026 03:01
Server now follows klappy://odd/encoding-types/how-to-write-encoding-types
section 'Context vs Input': input generates artifacts; context only
informs quality scoring.

Before this change, fullInput (input + context) was passed to both
the parser and the scorer, causing context paragraphs to become
separate standalone artifacts. The governance says context is
metadata, not content.

Changes:
- runEncodeAction: parsers receive input only (not fullInput)
- runEncodeAction: scoring receives input + context per artifact so
  background information still counts toward quality
- scoreArtifactQuality: accepts optional scoringText parameter that
  defaults to artifact.body when not provided
- Inline comments cite the governance doc to prevent regression

Closes the gap between governance and code surfaced during PR #96
testing.
The non-empty check in scoreArtifactQuality was using text (which
includes appended context) instead of artifact.body. This meant an
artifact with an empty body would pass the non-empty check whenever
context was supplied, defeating the purpose of the validity check.

Restored the check to use artifact.body.length so context informs
quality scoring but cannot substitute for actual artifact content.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
oddkit 760f613 Commit Preview URL

Branch Preview URL
Apr 16 2026, 03:19 AM

@klappy klappy merged commit f912e31 into prod Apr 16, 2026
5 checks passed
klappy added a commit that referenced this pull request Apr 17, 2026
Mirrors the PR #96 encode pattern. Extracts challenge behavior from
live governance articles (landed in klappy.dev canon via PR #99)
rather than hardcoded source logic.

New functions in workers/src/orchestrate.ts:
- discoverChallengeTypes — per-canonUrl cached type discovery
- fetchBasePrerequisites — universal prerequisite checks
- fetchNormativeVocabulary — RFC 2119 + architectural load-bearing terms
- fetchStakesCalibration — mode-to-depth filter
- extractPrereqTable / extractKeywordsFromCheck — shared helpers

Refactored:
- runChallengeAction — replaces hardcoded detectClaimType /
  generateChallenges / findTensions / findMissingPrerequisites
  with governance extraction. Supports multi-match. Filters output
  by stakes calibration based on mode parameter.
- runCleanupStorage — clears all four new caches on invalidation

Invariant: voice-dump mode suppresses all challenge output
regardless of matched types. Load-bearing per stakes-calibration
governance — some modes exist for raw capture and pressure-testing
at that stage damages the mode.

Graceful degradation: missing governance articles fall back to
minimal built-in behavior with warnings, rather than failing.

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants