Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions emrg/server/self_media_prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,17 @@ whole mandate:

```text
level "live" heat or trend data was actually read this round
level "fallback" it could not be read, and the product says so
level "fallback" it could not be read, and §5's readings say so
```

- **Live.** Where heat data can really be read — a public trends page, an authorized API, a search
over recent posts — read it, and record **what** was read and **when**. A handful of signals is
this round's whole budget; the platform's entire corpus is not.
- **Fallback.** Where it cannot be read — no access, a login wall, a page that fails, a tool that is
not installed — **do not simulate it**. Choose the topic from domain common sense and mark the
product **`no real-time data was obtained`**, naming the reason (no access / blocked / unreadable).
not installed — **do not simulate it**. Choose the topic from domain common sense, and record
the absence in §5's `trend_data` reading, with the reason (no access / blocked / unreadable). The
draft carries no marker for it: §3 keeps an unsourced field out of the piece rather than
labelling it there.
- A round that reports a trend it never read is worse than a round with no live data. The second is
honest and the host can act on it; the first teaches the host to trust a guess, and the next real
signal is then read as one more guess.
Expand Down Expand Up @@ -154,7 +156,7 @@ level "fallback" it could not be read, and the product says so
| `word_count` | the draft's own count, **measured** with a tool — never estimated |
| `trend_data` | `live` (with what was read and when) or `no real-time data was obtained` (with why) |
| `publish` | §4's outcome — `posted` with the platform, the posting time and the post's id or link; `failed` with the reason; `not attempted` with the reason |
| `unread` | the fields §3 kept out of the piece because no source could be named, each with its reason (page unreadable, list not public, nothing stated by the subject) — this is the one place an absence is recorded |
| `unread` | the fields §3 kept out of the piece because no source could be named, each with its reason (page unreadable, list not public, nothing stated by the subject) — an absence belongs in these readings, and never in the piece |
| `platform`, `date`, `task` | the channel this file belongs to, the round's date, and this task's name |

- **A measured number, not a guess**: an estimated word count is not a reading, and a readings block
Expand Down Expand Up @@ -182,7 +184,7 @@ posted by an earlier round, or a draft-only `extra_prompt`.
- 🛑 Never publish the same piece twice — no repost, no "just to be sure", no second attempt after a `failed` reading. One piece, one post, one attempt (§4)
- 🛑 Never sign in, and never handle a credential: no password, no verification code, no cookie and no token read, stored or typed, and no account setting changed. A step that needs the host in person is a `blocked` item (§0), not a workaround
- 🛑 Never record a publish as `posted` that the platform did not confirm — a guess recorded as a post teaches the host to trust a number that is not one
- 🛑 Never report a trend as read when it was not: §1's fallback level, marked `no real-time data was obtained`, is the honest answer and a usable one
- 🛑 Never report a trend as read when it was not: §1's fallback level is the honest answer and a usable one, and it records why in §5's `trend_data` reading rather than in the piece
- 🛑 Never fill a missing value with an invented one — a platform, an account, a source or a figure that `extra_prompt` did not give you is reported, never guessed
- 🛑 Never carry two products in one round: one file, one piece, one set of readings (§5)
- 🛑 Do not do multiple unrelated things in one round
Expand Down
74 changes: 73 additions & 1 deletion tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5082,7 +5082,7 @@ def test_self_media_template_carries_its_five_steps():

for phrase, why in (
("no real-time data was obtained",
"§1's fallback level needs a fixed marker: a round without live data must still "
"the fallback level needs a fixed marker in §5's readings: a round without live data must still "
"produce a product, and the host must be able to tell that product apart from one "
"built on a signal"),
("List-style",
Expand Down Expand Up @@ -5265,6 +5265,78 @@ def test_self_media_template_renders_in_both_extra_prompt_states():
assert extra not in out2


def _self_media_rendered_sections(extra_prompt: str | None) -> dict[str, str]:
"""The rendered self-media prompt, split by heading, each section flattened.

Flattened deliberately: the source wraps a sentence across lines, so ``mark the
product`` reads **0** against the raw render and **1** against the same text with its
whitespace collapsed. A probe that cannot hit is not a discovery.
"""
import jinja2

env = jinja2.Environment(undefined=jinja2.Undefined)
template = env.from_string(_self_media_template_text())
task = {"platform": "xiaohongshu"}
if extra_prompt is not None:
task["extra_prompt"] = extra_prompt

out = template.render(**_test_context(task=task))

sections: dict[str, str] = {}
name, body = "PREAMBLE", []
for line in out.splitlines():
if line.startswith("## ") or line.startswith("### "):
sections[name] = " ".join(" ".join(body).split())
name, body = line.strip("# ").strip(), []
else:
body.append(line)
sections[name] = " ".join(" ".join(body).split())
return sections


def test_self_media_absence_is_recorded_in_the_readings_not_in_the_piece():
"""§1's fallback and §3's no-placeholder rule have to name one home for an absence.

The two are neighbours in one prompt, and a round reads §1 first. §3 says a field whose
source cannot be named does not enter the draft, "not as 'unknown', 'not read' or 'no
data' either" — while §1 told the round to mark the product with the fallback marker.
A round obeying §1 writes a placeholder §3 forbids, and a round obeying §3 leaves the
absence unrecorded. The readings are the home the archive can carry; the piece is not.

Rendered, not grepped: a raw-text count answers "the file did not change", and the
per-section split is what makes "which section says this" a reading instead of a guess.
"""
marker = "no real-time data was obtained"

for state, extra_prompt in (("configured", "voice: plain and specific"), ("absent", None)):
sections = _self_media_rendered_sections(extra_prompt)
flat = " ".join(sections.values())
assert marker in flat, (
f"[{state}] no rendered section carries the fallback marker: the assertions below are "
f"readings of a real prompt, and a prompt that lost the marker passes them vacuously"
)

carrying = [name for name, body in sections.items() if marker in body]
outside = [name for name in carrying if not name.startswith("5. Archive")]
assert not outside, (
f"[{state}] the absence marker belongs to §5's readings, and these sections tell a "
f"round to write it into the piece instead: {outside}"
)

grading = [name for name in sections if name.startswith("1. Read the trends")]
assert grading, f"[{state}] there is no §1 section to grade the trend read"
assert "§5" in sections[grading[0]], (
f"[{state}] §1 grades the trend read and is read before §3, so it has to name §5 as the "
f"home of an absence; otherwise the two sections disagree and the reader's order "
f"decides which rule applies"
)

assert "mark the product" not in flat, (
f"[{state}] the piece carries no placeholder (§3), so no section may tell a round to "
f"mark it"
)


def test_self_media_is_listed_as_a_viewable_builtin(tmp_path):
"""`builtin: true` plus a non-empty body is what the GUI's read-only viewer shows."""
mod, orig = _p2_env(tmp_path)
Expand Down
Loading