constraint-lens

    A MoonBit engine for reviewer-feedback parsing, novelty matrices, and resubmission plans.

    moonbit
    review
    resubmission
    feedback
    novelty
    planning
    Download zip
    Author
    Version
    0.2.0
    License
    MIT
    Last updated
    2 months ago
    Downloads
    43

    No dependencies

    #Constraint Lens

    Constraint Lens is a MoonBit package for turning reviewer feedback into a resubmission plan. It parses rejection notes, extracts blocking reasons, builds a novelty matrix against a related package, and renders an evidence-backed repair checklist.

    The 0.2 line deliberately narrows the project boundary. It is not a README example verifier, provenance proof toolkit, license scanner, Mooncakes package snapshot auditor, or replacement for moon check. Instead, it helps a maintainer answer this question after review feedback arrives:

    What exactly was rejected, what evidence should I attach, and how do I prove that the revised project is not duplicating an existing MoonBit package?

    #Overview

    Hackathon review feedback is often compact: it may say that a project overlaps with another package, lacks an extension relationship, or needs better evidence before a deadline. Constraint Lens models that feedback as MoonBit data:

    • ReviewIssue: parsed line-level review concerns.
    • Differentiator: a structured comparison with the related package.
    • RemediationStep: concrete repair work and proof.
    • ReviewPlan: the complete resubmission package.

    The older checklist audit engine remains as a small compatibility layer, but the primary runnable example and project positioning are now the review-feedback workflow.

    #Difference From HarborCheck

    HarborCheck-style projects focus on README example proof, source provenance, license/source evidence, and project snapshot checklists.

    Constraint Lens 0.2 focuses on a different stage:

    • Input: reviewer rejection feedback and manually supplied differentiators.
    • Output: parsed issues, overlap status, remediation steps, and a resubmission memo.
    • Non-goals: extracting README code blocks, proving third-party source origin, checking license compatibility, or auditing Mooncakes package snapshots.

    The two tools are adjacent. HarborCheck can produce evidence. Constraint Lens can cite that evidence while explaining the revised scope and resubmission plan.

    #Installation

    moon add WB-ai-nb/constraint-lens

    #Usage

    Minimal usage:

    import {
    "WB-ai-nb/constraint-lens" @lens
    }

    test {
    let plan = @lens.resubmission_plan(
    "revised application",
    @lens.sample_rejection_feedback(),
    @lens.sample_differentiators(),
    )
    inspect(plan.overlap_addressed, content="true")
    }

    Runnable example:

    moon run cmd/main

    The example prints a Markdown resubmission plan with parsed review issues, differentiation matrix, and remediation steps.

    #Local Development

    moon update moon fmt --check moon check moon build moon test moon run cmd/main moon package --list moon publish --dry-run

    #Continuous Integration

    The repository includes .github/workflows/ci.yml. On every push and pull request it installs the MoonBit toolchain, checks formatting, type-checks, builds, runs tests, executes the example, and inspects the publish package.

    #API Surface

    Review-feedback workflow:

    • parse_review_feedback(feedback) extracts duplicate-scope, missing-relation, evidence, deadline, contact-path, and general feedback issues.
    • Differentiator::make(...) records one axis of novelty against a related package.
    • resubmission_plan(title, feedback, differentiators) builds a complete plan.
    • ReviewPlan::has_issue(kind) checks parsed issue categories.
    • ReviewPlan::to_markdown() exports an attachable resubmission memo.
    • sample_rejection_feedback() and sample_differentiators() power the runnable example.

    Compatibility checklist workflow:

    • audit_text(title, text, rules) runs a deterministic weighted rule set.
    • moonbit_acceptance_profile(), release_note_profile(), and application_profile() provide legacy text checklist profiles.
    • Audit::to_markdown() and Audit::to_jsonish() export reports.

    #Supported Scope

    • Plain text review feedback and rejection notes
    • Duplicate-scope and missing-extension-relation detection
    • Deadline and evidence-gap extraction
    • Structured novelty matrix
    • Markdown resubmission reports
    • Deterministic, offline MoonBit behavior

    #Not Supported

    • README code-block extraction
    • Source provenance or license proof
    • Full Markdown parsing
    • File system traversal
    • Network calls
    • Automated GitHub, Mooncakes, or email submission
    • Subjective AI-based judgement

    #Mooncakes

    • Package name: WB-ai-nb/constraint-lens
    • Module version: 0.2.0
    • Public repository: https://github.com/WB-ai-nb/constraint-lens
    • Docs URL: https://mooncakes.io/docs/WB-ai-nb/constraint-lens
    • Manifest URL: https://mooncakes.io/api/v0/manifest/WB-ai-nb/constraint-lens

    #Testing

    The test suite covers the legacy text engine and the 0.2 resubmission workflow: feedback parsing, duplicate-scope handling, missing differentiator gating, Markdown report export, document shape analysis, legacy scoring, and report export.

    Run:

    moon test

    #License

    Constraint Lens is released under the MIT license. It contains original MoonBit source code and uses no third-party code, images, fonts, audio, or datasets. See THIRD_PARTY.md.

    ActionStatus

    pub(all) enum ActionStatus {
    Planned
    Done
    NotNeeded
    } derive(Eq,
    Debug
    )

    Status for a remediation action.

    ActionStatus::label

    fn ActionStatus::label(self : ActionStatus) -> String

    Stable label for remediation status.

    Audit

    pub(all) struct Audit {
    title : String
    score : Int
    max_score : Int
    earned_score : Int
    grade : String
    findings : Array[Finding]
    stats : AuditStats
    } derive(
    Debug
    )

    Complete audit result.

    Audit::failed

    fn Audit::failed(self : Audit) -> Array[Finding]

    Return only failed findings.

    Audit::is_success

    fn Audit::is_success(self : Audit) -> Bool

    True when the audit has no failing error-level findings.

    Audit::passed

    fn Audit::passed(self : Audit) -> Array[Finding]

    Return only passed findings.

    Audit::to_jsonish

    fn Audit::to_jsonish(self : Audit) -> String

    Render a compact JSON-like string without depending on a JSON package.

    Audit::to_markdown

    fn Audit::to_markdown(self : Audit) -> String

    Render a human-readable Markdown audit report.

    AuditStats

    pub(all) struct AuditStats {
    line_count : Int
    char_count : Int
    matched_rules : Int
    failed_rules : Int
    error_count : Int
    warning_count : Int
    heading_count : Int
    bullet_count : Int
    } derive(Eq,
    Debug
    )

    Aggregated counters for an audit run.

    Differentiator

    pub(all) struct Differentiator {
    axis : String
    this_project : String
    related_project : String
    reviewer_value : String
    } derive(Eq,
    Debug
    )

    A concrete difference between this project and a related package.

    Differentiator::make

    fn Differentiator::make(axis : StringView, this_project : StringView, related_project : StringView, reviewer_value : StringView) -> Differentiator

    Build a differentiator record without exposing struct layout to callers.

    DocumentShape

    pub(all) struct DocumentShape {
    lines : Int
    headings : Int
    bullets : Int
    code_fences : Int
    paragraphs : Int
    blanks : Int
    } derive(Eq,
    Debug
    )

    Shape summary produced while tokenizing a document.

    Evidence

    pub(all) struct Evidence {
    line : Int
    snippet : String
    matched : String
    } derive(Eq,
    Debug
    )

    Evidence points at a concrete line and matching term.

    Finding

    pub(all) struct Finding {
    rule_id : String
    title : String
    category : String
    severity : Severity
    passed : Bool
    weight : Int
    earned : Int
    message : String
    hint : String
    evidence : Array[Evidence]
    } derive(
    Debug
    )

    Result of evaluating a single rule.

    Finding::is_blocking

    fn Finding::is_blocking(self : Finding) -> Bool

    True when a failed finding should block release.

    LineKind

    pub(all) enum LineKind {
    Blank
    Heading
    Bullet
    CodeFence
    Paragraph
    } derive(Eq,
    Debug
    )

    Token category emitted by tokenize_lines.

    LineToken

    pub(all) struct LineToken {
    line : Int
    kind : LineKind
    text : String
    } derive(Eq,
    Debug
    )

    A line-level token that keeps the source line number.

    RemediationStep

    pub(all) struct RemediationStep {
    id : String
    title : String
    status : ActionStatus
    proof : String
    } derive(Eq,
    Debug
    )

    One action that can be attached to a resubmission.

    ReviewIssue

    pub(all) struct ReviewIssue {
    line : Int
    kind : ReviewIssueKind
    text : String
    evidence : String
    } derive(Eq,
    Debug
    )

    One line-level issue extracted from review feedback.

    ReviewIssueKind

    pub(all) enum ReviewIssueKind {
    DuplicateScope
    MissingExpansionRelation
    MissingEvidence
    DeadlineWindow
    ContactPath
    GeneralFeedback
    } derive(Eq,
    Debug
    )

    Categories used when turning reviewer feedback into a resubmission plan.

    ReviewIssueKind::label

    fn ReviewIssueKind::label(self : ReviewIssueKind) -> String

    Stable label for reports.

    ReviewPlan

    pub(all) struct ReviewPlan {
    title : String
    issues : Array[ReviewIssue]
    differentiators : Array[Differentiator]
    steps : Array[RemediationStep]
    overlap_addressed : Bool
    ready_to_resubmit : Bool
    } derive(
    Debug
    )

    Full resubmission plan built from feedback and differentiators.

    ReviewPlan::has_issue

    fn ReviewPlan::has_issue(self : ReviewPlan, kind : ReviewIssueKind) -> Bool

    Return true when the plan contains a parsed issue of the requested kind.

    ReviewPlan::to_markdown

    fn ReviewPlan::to_markdown(self : ReviewPlan) -> String

    Render a concise Markdown plan for attaching to an updated application.

    Rule

    pub(all) struct Rule {
    id : String
    title : String
    category : String
    severity : Severity
    weight : Int
    kind : RuleKind
    hint : String
    } derive(
    Debug
    )

    A weighted rule with an explanation-oriented hint.

    Rule::max_line_length

    fn Rule::max_line_length(id : StringView, title : StringView, category : StringView, severity : Severity, weight : Int, max : Int, hint : StringView) -> Rule

    Construct a maximum line length rule.

    Rule::min_occurrences

    fn Rule::min_occurrences(id : StringView, title : StringView, category : StringView, severity : Severity, weight : Int, needle : StringView, min : Int, hint : StringView) -> Rule

    Construct a minimum occurrence rule.

    Rule::must_contain_any

    fn Rule::must_contain_any(id : StringView, title : StringView, category : StringView, severity : Severity, weight : Int, terms : ArrayView[String], hint : StringView) -> Rule

    Construct a presence rule that passes when any term is found.

    Rule::must_not_contain_any

    fn Rule::must_not_contain_any(id : StringView, title : StringView, category : StringView, severity : Severity, weight : Int, terms : ArrayView[String], hint : StringView) -> Rule

    Construct a rule that fails when any forbidden term is found.

    Rule::requires_pair

    fn Rule::requires_pair(id : StringView, title : StringView, category : StringView, severity : Severity, weight : Int, left : StringView, right : StringView, hint : StringView) -> Rule

    Construct a rule where the right term is required when the left term exists.

    Rule::section_order

    fn Rule::section_order(id : StringView, title : StringView, category : StringView, severity : Severity, weight : Int, sections : ArrayView[String], hint : StringView) -> Rule

    Construct an ordered-section rule.

    RuleKind

    pub(all) enum RuleKind {
    MustContainAny(Array[String])
    MustNotContainAny(Array[String])
    MinOccurrences(String, Int)
    MaxLineLength(Int)
    RequiresPair(String, String)
    SectionOrder(Array[String])
    } derive(
    Debug
    )

    Rule strategies supported by the engine.

    Severity

    pub(all) enum Severity {
    Info
    Warning
    Error
    } derive(Eq,
    Debug
    )

    Core data model for explainable text audits.

    Severity::label

    fn Severity::label(self : Severity) -> String

    Stable lowercase label used by reports and external tools.

    Severity::rank

    fn Severity::rank(self : Severity) -> Int

    A small ordinal used when callers need to sort or gate findings.

    analyze_shape

    fn analyze_shape(text : StringView) -> DocumentShape

    Summarize a document shape from line tokens.

    application_profile

    fn application_profile() -> Array[Rule]

    A profile for compact project briefs and application forms.

    audit_text

    fn audit_text(title : StringView, text : StringView, rules : ArrayView[Rule]) -> Audit

    Run a weighted rule set against text.

    example_text

    fn example_text() -> String

    Built-in sample used by moon run cmd/main.

    moonbit_acceptance_profile

    fn moonbit_acceptance_profile() -> Array[Rule]

    A reusable profile for MoonBit package acceptance checklists.

    parse_review_feedback

    fn parse_review_feedback(feedback : StringView) -> Array[ReviewIssue]

    Parse rejection or review feedback into line-level issues.

    release_note_profile

    fn release_note_profile() -> Array[Rule]

    A compact profile for changelog and release-note text.

    resubmission_plan

    fn resubmission_plan(title : StringView, feedback : StringView, differentiators : ArrayView[Differentiator]) -> ReviewPlan

    Build a resubmission plan from review feedback and a novelty matrix.

    sample_differentiators

    fn sample_differentiators() -> Array[Differentiator]

    Built-in novelty matrix for the runnable example.

    sample_rejection_feedback

    fn sample_rejection_feedback() -> String

    Built-in sample based on a duplicate-scope rejection scenario.

    tokenize_lines

    fn tokenize_lines(text : StringView) -> Array[LineToken]

    Parse source text into line-level tokens.