Answer architecture round 1: 4 🔴, 5 🟡 (0 misread); one-way plan packages with a plan core and an Atlassian client, one parse and print of an item's cells, a pure chunk-start decision, a settings table, one plan read and one standing per pick, one config load in chunk-pr, notifier backends in notifier, and the bin regroup filed as item 392

This commit is contained in:
2026-11-16 14:47:46 +01:00
parent 3f7d85c48e
commit f58250d0ce
103 changed files with 1299 additions and 1044 deletions
+2 -14
View File
@@ -7,10 +7,9 @@ import pathlib
import typing
from adf_codec.convert import adfs_to_markdown, markdown_to_adf, Refused
from plan_store.jira_epic import basic_auth, Http, TIMEOUT, ToAdf, ToMarkdown
from atlassian.client import basic_auth, confluence_json, Http, ToAdf, ToMarkdown
from rest_client.json_request import ErrorAnswer
from failure import Failure
from rest_client import json_request
from project_config.settings import Page
from text_files.file_writes import replace_file
@@ -19,17 +18,6 @@ CONFLICT = 409
SHAPE = "not in the shape Confluence Cloud's REST API version 2 documents"
def http_json(method: str, url: str, authorization: str, body: object) -> object:
return json_request.http_json(method, url, authorization, body, TIMEOUT, error_message)
def error_message(answer: object) -> str:
"""Confluence's messages in the JSON of an error answer; empty where it holds none."""
errors = answer.get("errors") if isinstance(answer, dict) else None
found = [error.get("title") for error in errors if isinstance(error, dict)] if isinstance(errors, list) else [answer.get("message")] if isinstance(answer, dict) else []
return "; ".join(text for text in found if isinstance(text, str))
@dataclasses.dataclass(frozen=True)
class Seen:
"""The page's version number and title as the store last read or wrote them. A write needs both."""
@@ -45,7 +33,7 @@ class ConfluencePage:
page: Page
env_file: pathlib.Path
kept: pathlib.Path | None = None
http: Http = http_json
http: Http = confluence_json
to_markdown: ToMarkdown = adfs_to_markdown
to_adf: ToAdf = markdown_to_adf
seen: Seen | None = None
+2 -2
View File
@@ -5,7 +5,7 @@ import dataclasses
import pathlib
from adf_codec.convert import adfs_to_markdown, Refused
from plan_store.jira_epic import basic_auth, Http, http_json, ToMarkdown
from atlassian.client import basic_auth, Http, jira_json, ToMarkdown
from project_config.settings import Epic
from failure import Failure
@@ -17,7 +17,7 @@ class EpicDescription:
"""The description of epic as markdown, read with the credentials env_file holds."""
epic: Epic
env_file: pathlib.Path
http: Http = http_json
http: Http = jira_json
to_markdown: ToMarkdown = adfs_to_markdown
@property
+2 -4
View File
@@ -5,6 +5,8 @@ import dataclasses
import pathlib
import typing
from record_store.confluence_page import ConfluencePage
from record_store.jira_description import EpicDescription
from failure import Failure
from git_cli.git_repo import file_at, git, Git
from project_config.settings import ProjectConfig, RECORDS, TOUCH_PREDICTIONS
@@ -64,8 +66,6 @@ def store(config: ProjectConfig, record: str, kept: pathlib.Path | None = None)
raise ValueError(f"{record} is not a record; the records are {', '.join(RECORDS)}")
if record not in config.pages:
return FileStore(config.paths[record], config.tracked(record))
# Imported here, as in goals_store.
from record_store.confluence_page import ConfluencePage
# load refuses a config that names a page and no env-file.
assert config.env_file is not None
return ConfluencePage(config.pages[record], config.env_file, kept)
@@ -82,8 +82,6 @@ def goals_store(config: ProjectConfig) -> RecordStore:
"""The store config names for the goals file, which holds ## Goals and ## Audience: a markdown file, or a Jira epic's description, which the store only reads."""
if config.goals_epic is None:
return FileStore(config.paths["goals-and-audience"], config.tracked("goals-and-audience"))
# Imported here, since the Jira store builds on plan_store, which builds on this module.
from record_store.jira_description import EpicDescription
# load refuses a config that names an epic and no env-file.
assert config.env_file is not None
return EpicDescription(config.goals_epic, config.env_file)
+1 -7
View File
@@ -7,7 +7,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from record_store.confluence_page import ConfluencePage, error_message
from record_store.confluence_page import ConfluencePage
from rest_client.json_request import ErrorAnswer
from failure import Failure
from project_config.settings import Page
@@ -180,12 +180,6 @@ class ConfluencePageTest(ConfluenceCase):
self.assertTrue(written.reason.startswith(f"cannot read the version of {PAGE.spelling} that {self.kept} keeps: "), written.reason)
self.assertEqual(self.confluence.calls, [])
def test_reads_confluences_messages_from_an_error_answer(self) -> None:
self.assertEqual(error_message({"errors": [{"status": 409, "title": "Version must be incremented"}, {"title": "and more"}, "odd"]}), "Version must be incremented; and more")
self.assertEqual(error_message({"message": "Not Found"}), "Not Found")
self.assertEqual(error_message({"errors": "odd"}), "")
self.assertEqual(error_message(["odd"]), "")
def test_fails_naming_the_page_when_confluence_answers_an_error(self) -> None:
store = ConfluencePage(PAGE, self.env, None, lambda *_: ErrorAnswer("GET /wiki/api/v2/pages/2293761 answered 404: Not Found", 404), to_markdown, to_adf)
self.assertEqual(store.read(), Failure(f"cannot read {PAGE.spelling}: GET /wiki/api/v2/pages/2293761 answered 404: Not Found"))