Skip to main content

A compact, human-writable format for storing content paired with feedback/labels

Project description

MarkBack V2

A compact, human-writable format for storing content paired with feedback/labels.

Installation

pip install -e .

Quick Start

Parse a MarkBack file

from markback import parse_file, parse_string

# Parse a file
result = parse_file("labels.mb")
for record in result.records:
    print(f"{record.id}: {record.feedback}")

# Parse a string
text = """
@id example

Some content here.
<<< positive; good quality
"""
result = parse_string(text)

Write MarkBack files

from markback import Record, FileRef, write, append

# Write records to a file
records = [
    Record(feedback="good", id="item-1", content="First item"),
    Record(feedback="bad", id="item-2", content="Second item"),
]
write("output.mb", records)

# Append a single record
append("output.mb", Record(feedback="great", id="item-3", content="Third"))

Lint files

from markback import lint_file

result = lint_file("myfile.mb")
if result.has_errors:
    for d in result.diagnostics:
        print(d)

CLI Usage

The CLI is available via markback or mb (shorthand).

Annotate files

# Single file — inline feedback, appends to myfile.txt.mb
mb myfile.txt "good; clear writing"

# URL target — derives sidecar from last path segment (or hostname)
mb https://example.com/blog/post.html "great explanation"
# → writes post.html.mb with @file https://example.com/blog/post.html

# Quote a passage by editing the .mb file directly: inline content
# under an @file header can be a full snapshot OR an excerpt.
#   @file https://example.com/post.html
#
#   the quick brown fox jumps over the lazy dog
#   <<< awkward phrasing

# Multi-segment section: several comments on one source, no repeated headers.
#   @file ./essay.txt
#
#   the lazy fox
#   <<< awkward
#
#   weak ending
#   <<< needs punch

# With input reference (what produced the file)
mb output.txt "accurate" --input prompt.txt

# With tags and attribution
mb file.txt "good" --tag "review p1" --by alice@example.com

# Multiple files — same feedback for all
mb *.jpg -f "approved"

# Interactive mode — steps through each file
mb *.jpg --print

# Sweep pattern — track issues across batches
mb *.txt -f "issue-A" --scope "issue-A issue-B" --covers "./*.txt"

Utility commands

# Lint
mb --lint myfile.mb
mb --lint --json ./data/

# List records
mb --list myfile.mb

# Statistics
mb --stats myfile.mb

# Normalize to canonical format
mb --normalize input.mb
mb --normalize --in-place input.mb

# Convert between formats
mb --convert --to multi -o output.mb input.mb
mb --convert --to compact -o output.mb input.mb

# Upgrade V1 files to V2
mb --upgrade *.mb              # preview
mb --upgrade --apply --in-place *.mb  # apply

File Format

V2 Headers

Header Purpose
@id Record identifier (plain string)
@by Who provided feedback
@tag Space-separated tags
@input What produced the content (e.g., a prompt)
@file Path to the content being annotated

File-level headers (% prefix)

%markback 2
%scope issue-A issue-B
%covers ./gen/batch3/*.txt

Record examples

@id review-001
@by alice@company.com
@file ./src/auth.py:45-67
@tag security p0

<<< vulnerable; sql-injection in query builder

Compact label list

@file ./images/001.jpg <<< approved; scene=beach
@file ./images/002.jpg <<< rejected; too dark

Sidecar files

Content in report.pdf, annotation in report.pdf.mb:

@id report-001
<<< good; grade=B+

Sweep pattern

Track issues across batches with meaningful absence:

%markback 2
%scope issue-A issue-B
%covers ./gen/batch3/*.txt

@file ./gen/batch3/file2.txt <<< issue-B; tone is off
@file ./gen/batch3/file5.txt <<< issue-A; issue-B; both problems

Files matching %covers without annotations are implicitly clean for all %scope items.

V1 Backward Compatibility

V1 headers (@uri, @source, @prior) are automatically mapped to V2 equivalents with a W010 warning. The V2 parser reads V1 files transparently.

Development

pip install -e ".[dev]"
pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

markback-0.2.0.tar.gz (62.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

markback-0.2.0-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file markback-0.2.0.tar.gz.

File metadata

  • Download URL: markback-0.2.0.tar.gz
  • Upload date:
  • Size: 62.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for markback-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7db8a1dd773eb0b5eb22e8e630561c110544c993eb2d720867366d7f2473f7e4
MD5 bdcd65cb606c3bde10de095ad998f12d
BLAKE2b-256 70b3e3bb914f536125699ec3d9165efaaf3a48a8f7872b8593d1613026e33ce2

See more details on using hashes here.

File details

Details for the file markback-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: markback-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for markback-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac119b0522cdcd9a940d0581dbec23350be35bd0b701028f3833b1cbe3fe3d9e
MD5 63b39e05d6ba0d24b3da0a91f806944d
BLAKE2b-256 4d9adffc07afed3886d3a1e125d07a83e37dd7d3ddefd3953ee6695ec46d46d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page