Documentation
¶
Overview ¶
Package rules holds the shared editorial constants that both the prompt builder and the validator depend on: word limits, the banned vocabulary, metric vocabulary, and the accepted claim taxonomy. Keeping them in one place guarantees the writer is told exactly what the validator enforces.
Index ¶
Examples ¶
Constants ¶
const ( MinWords = 500 MaxWords = 3000 )
Word-count bounds for a finished body-only draft.
const ( // PostLeadAsideMarker opens the summary aside that carries the TL;DR and key // takeaways. PostLeadAsideMarker = `<aside class="post-lead"` // ExecSummaryMarker labels the executive-summary blockquote. ExecSummaryMarker = "Executive Summary" // H1Prefix begins the single title line; H2Prefix begins each section heading. H1Prefix = "# " H2Prefix = "## " )
Structural markers the writer must emit and the validator checks for. They live here so the output template (the prompt package) and the validator share a single definition and cannot silently drift apart; TestSkeletonMatchesStructureMarkers enforces that the skeleton embeds each one.
const MinQuoteChars = 12
MinQuoteChars is the shortest verbatim source span a claim may cite.
Variables ¶
var ( ClaimTypes = map[string]bool{ "metric": true, "mechanism": true, "definition": true, "method": true, "result": true, "limitation": true, } ClaimStrengths = map[string]bool{ "demonstrated": true, "hedged": true, "speculation-or-future-work": true, } HedgeStrengths = map[string]bool{ "hedged": true, "speculation-or-future-work": true, } )
ClaimTypes and ClaimStrengths are the accepted enumerations for a claim record. Anything outside them is dropped during verification.
var AssertiveVerbs = []string{
"demonstrates", "demonstrated", "proves", "proven", "proved",
"establishes", "established", "confirms", "confirmed", "guarantees",
"guaranteed", "ensures", "ensured", "shows that", "showed that",
}
AssertiveVerbs flag sentences that state a result as settled fact; combined with a hedged claim they signal a possible hedge upgrade.
var BannedPhrases = []string{
"in today's fast-paced world", "at its core", "it's important to note",
"furthermore", "moreover", "in conclusion", "in summary", "let's face it",
"but here's the kicker", "when it comes to", "in the realm of",
"look no further", "rest assured", "needless to say", "not only",
"but also", "whether you're", "that said", "in essence", "ultimately",
"paradigm shift", "the dawn of", "in today's world",
}
BannedPhrases are multi-word clichés the house style forbids.
var BannedWords = []string{
"delve", "underscore", "testament", "foster", "maximize", "navigate",
"tapestry", "catalyst", "elevate", "paradigm", "revolutionize",
"paramount", "leverage", "harness", "unlock", "seamless", "robust",
"realm", "landscape", "beacon", "game-changer", "cutting-edge",
"utilize", "myriad", "vibrant", "bustling", "whimsical", "profound",
}
BannedWords are single tokens the house style forbids. They are matched on word boundaries, case-insensitively.
var MetricTerms = []string{
"perplexity", "ppl", "cross-entropy", "cross entropy", "log-likelihood",
"log likelihood", "bleu", "rouge", "f1", "wer", "cer",
"bits per byte", "bits-per-byte",
}
MetricTerms are evaluation metrics that must never appear in a draft unless a verified claim also uses them, guarding against silent metric conversion.
var PopulationNouns = populationForms(
"adult", "bank", "borrower", "business", "ceo", "cfo", "company",
"consumer", "corporate", "corporation", "customer", "developer",
"employee", "executive", "firm", "household", "institution", "insurer",
"investor", "lender", "merchant", "organisation", "organization",
"participant", "patient", "respondent", "sme", "student", "treasurer",
"user",
)
PopulationNouns are the groups a survey or study counts, each plural mapped to its singular. Two numbers whose quotes count different groups, drawn from different parts of a source, are likely from different studies and are not one comparison.
var StyleReplacements = map[string]string{
"delve": "examine", "underscore": "highlight", "testament": "sign",
"foster": "encourage", "maximize": "increase", "navigate": "handle",
"tapestry": "mix", "catalyst": "trigger", "elevate": "raise",
"paradigm": "model", "revolutionize": "transform", "paramount": "essential",
"leverage": "use", "harness": "use", "unlock": "enable", "seamless": "smooth",
"robust": "strong", "realm": "area", "landscape": "field", "beacon": "example",
"game-changer": "breakthrough", "cutting-edge": "advanced", "utilize": "use",
"myriad": "many", "vibrant": "vivid", "bustling": "busy",
"whimsical": "playful", "profound": "deep",
"in today's fast-paced world": "today", "at its core": "essentially",
"it's important to note": "note", "furthermore": "also", "moreover": "also",
"in conclusion": "finally", "in summary": "overall", "let's face it": "admittedly",
"but here's the kicker": "but", "when it comes to": "for", "in the realm of": "in",
"look no further": "stop", "rest assured": "certainly", "needless to say": "clearly",
"not only": "not just", "but also": "but", "whether you're": "whether you are",
"that said": "still", "in essence": "essentially", "ultimately": "finally",
"paradigm shift": "shift", "the dawn of": "the start of", "in today's world": "today",
}
StyleReplacements maps every banned word and phrase to a neutral, in-style equivalent, so a draft that trips the banned-vocabulary check can be repaired in place rather than regenerated — regeneration is slow and, on a small local model, simply produces fresh clichés. Every replacement is itself outside the banned lists; matching is case-insensitive and the replacement takes the case of the first matched character. Phrases are applied before single words, so a phrase that contains a banned word (for example "in the realm of") is rewritten whole. Keys must stay in sync with BannedWords and BannedPhrases.
var WriterStopwords = map[string]bool{ "about": true, "above": true, "after": true, "again": true, "against": true, "along": true, "among": true, "around": true, "because": true, "before": true, "being": true, "below": true, "between": true, "beyond": true, "could": true, "does": true, "doing": true, "during": true, "either": true, "every": true, "framework": true, "further": true, "hence": true, "however": true, "into": true, "itself": true, "loops": true, "might": true, "other": true, "process": true, "rather": true, "result": true, "results": true, "since": true, "some": true, "such": true, "system": true, "than": true, "that": true, "their": true, "them": true, "then": true, "there": true, "these": true, "they": true, "those": true, "through": true, "under": true, "until": true, "using": true, "value": true, "when": true, "where": true, "which": true, "while": true, "with": true, "within": true, "would": true, }
WriterStopwords are common words ignored when measuring token overlap between a draft sentence and a claim, so overlap reflects meaningful shared terms.
Functions ¶
func InflectLike ¶
InflectLike inflects word to the given kind using regular English spelling rules (silent-e drop before "-ing", "-es" after a sibilant). An unknown kind — including "base" — returns word unchanged, so a banned form and its replacement stay aligned: "leverages" (kind "s") maps to InflectLike("use", "s") = "uses".
func MetricForms ¶
MetricForms returns every surface form equivalent to term (including term itself), so a grounding check accepts an abbreviation or expansion of the same metric rather than only a byte-for-byte match.
Types ¶
type Style ¶
type Style struct {
MinWords int `json:"min_words"`
MaxWords int `json:"max_words"`
BannedWords []string `json:"banned_words"`
BannedPhrases []string `json:"banned_phrases"`
// English is the language-variant instruction handed to the writer, e.g.
// "British English" or "American English". Empty means no instruction.
English string `json:"english"`
}
Style is the editorial policy a run enforces: the word band, the banned vocabulary, and the language variant. The defaults are this project's house style; a Style loaded from a file replaces or extends them, so a different publication can use draft's grounding without adopting its voice.
Only what a publication actually changes lives here. The structural rules — an H1, a lead aside, an executive summary, section headings — are the shape of a grounded article rather than a matter of taste, and stay fixed.
func DefaultStyle ¶
func DefaultStyle() Style
DefaultStyle is draft's own house style: the values the prompt and validator used before the style file existed. A loaded style starts from this.
func LoadStyle ¶
LoadStyle reads a JSON style file and returns it merged onto DefaultStyle, so a file that sets only one field keeps the defaults for the rest. An unknown field is an error, because a misspelled key that was silently ignored would leave the writer held to a rule the author thought they had changed.
func (Style) BannedWordForms ¶
BannedWordForms expands the style's banned words to their inflections, the set the validator matches on.
func (Style) ExemptSourceTerms ¶ added in v0.0.47
ExemptSourceTerms returns s without the banned words and phrases that occur in quotes, together with the exempted terms in lower case. A banned term that a verified source quote uses is the source's own vocabulary, not the writer's filler: "DeepSeek Harness" is a name, "ReAct harness" is the paper's term and "seamless" may be exactly what a report said. Banning or rewriting those changes what the source is reported to have said.
type WordForm ¶
WordForm is a surface form of a banned word paired with the inflection kind that produced it, so a replacement can be inflected the same way.
func WordForms ¶
WordForms returns the base banned word and its common inflections — plural or third-person ("s"), past ("ed"), and gerund ("ing") — so the validator and the style repair catch "leverages" and "leveraging", not only "leverage". Duplicate forms are returned in a stable order. It intentionally omits adverbial "-ly": the replacements do not carry adverb forms, so those are handled separately.
Example ¶
WordForms expands a banned word into the inflections the validator must also catch, so "leverage" covers "leverages", "leveraging", and the rest.
package main
import (
"fmt"
"github.com/sebastienrousseau/draft/rules"
)
func main() {
for _, f := range rules.WordForms("leverage") {
fmt.Printf("%s (%s)\n", f.Form, f.Kind)
}
}
Output: leverage (base) leverages (s) leveraged (ed) leveraging (ing) leveragely (ly)