Skip to content

feat(core): add document resource type - #1127

Merged
AlessandroPomponio merged 32 commits into
mainfrom
maj_document
Jul 30, 2026
Merged

feat(core): add document resource type#1127
AlessandroPomponio merged 32 commits into
mainfrom
maj_document

Conversation

@michael-johnston

@michael-johnston michael-johnston commented Jul 1, 2026

Copy link
Copy Markdown
Member

This PR adds a new resource type, document, for storing markdown or html docs that describe spaces, operations or combinations thereof.

Create with ado create document -f DOCUMENT.YAML. Read with ado get document $RESOURCEID. A document can have multiple related resources. It's not required that it has any - for example a document containing a report about the entire project at a point in time should not have to list every single space and operation, and there is no "project" resource.

Example document yaml

metadata:
  name: Example operation report
  description: Summary report for an operation
contentType: "markdown"
content: |
  # Operation report

  This is an example document resource.
relatedResources:
  - id: operation-test-12345678
     role: parent

The relatedResources is a list of dictionaries. The dicts have to keys

  • id (the id of the related resource)
  • role - either parent or child.

ado describe document will

  • for markdown, render the content field using rich (when redirected to a file, rich handles it)
  • for html, write the content field html (when redirected to a file, the same is done)

#925

@michael-johnston michael-johnston linked an issue Jul 1, 2026 that may be closed by this pull request
@michael-johnston michael-johnston changed the title Maj document feat: document resource type Jul 1, 2026
@michael-johnston
michael-johnston marked this pull request as ready for review July 14, 2026 10:39
@AlessandroPomponio

Copy link
Copy Markdown
Collaborator

From just the description, I wonder whether this design will lead to more of the same problems that we already have for Datacontainers. As it stands, Datacontainers store their content in the resources table and can be very large (we have examples of datacontainers from sft-trainer which exceed 18MB), ballooning the whole table up and slowing down retrieval.

In general, as well, storing byte-like objects in a stringified format in a JSON/text column seems like an antipattern. I would think about only storing references to BLOBs and having a dedicated table for those. Later on in the future we could also take advantage of it to slim down datacontainers

@michael-johnston

Copy link
Copy Markdown
Member Author

@AlessandroPomponio We could simplify this and remove the attachments functionality for initial implementation. Add it back later if needed/when we decided how to store the attachments (i.e. link instead of raw data, where the raw data goes).

@AlessandroPomponio

Copy link
Copy Markdown
Collaborator

Sounds good!

@AlessandroPomponio AlessandroPomponio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says this is also meant for HTML reports. If we keep it to markdown only, though, we could also have a describe command that uses rich's Markdown renderer to render and print the document to the terminal.

This PR is also missing updating the ado cli reference doc

Comment thread .cursor/skills/examining-ado-operations/SKILL.md
Comment thread ado/core/document/config.py
Comment thread ado/core/document/resource.py Outdated
Comment thread ado/core/document/resource.py Outdated
Comment thread tests/core/document/conftest.py Outdated
Comment thread tests/core/document/test_document_config.py
Comment thread tests/core/document/test_document_resource.py
Comment thread tests/core/document/test_document_resource.py Outdated
Comment thread tests/core/document/test_document_resource.py Outdated
Comment thread tests/fixtures/document_with_attachment.yaml Outdated
@michael-johnston

Copy link
Copy Markdown
Member Author

The PR description says this is also meant for HTML reports. If we keep it to markdown only, though, we could also have a describe command that uses rich's Markdown renderer to render and print the document to the terminal.

Yes I did think of this and it was originally markdown. However then Daniele or Vassilis was showing me that bob was creating HTML reports with graphical elements and I thought we should store them.

I mean we could have it also id html and describe open a brokers.

It would be good to have the describe for markdown in any case as reading the reports as human is not easy as is.

For discriminating markdown and html content
For discriminating markdown and html content
outputs markdown as rich objects if output stream is terminal, otherwise writes content field to pipe/file.

if html and directed to terminal the content is written to file and then browser opened.
@michael-johnston

Copy link
Copy Markdown
Member Author

If implemented describe for markdown and html, also discriminating behaviour between tty and no tty

Comment thread ado/cli/resources/document/describe.py Outdated
Comment thread ado/cli/resources/document/describe.py Outdated
Comment thread ado/cli/resources/document/describe.py Outdated
Comment thread tests/core/document/test_document_config.py
Needs a different solution
is_terminal is not accurate enough for identify non-terminal output. In particular if certain rich envvars e.g. FORCE_COLOR are set it will report True even if output is redirected.
@michael-johnston

Copy link
Copy Markdown
Member Author

So this the next steps

  • Ensure the relationships are added to the db
  • Remove isatty branching as rich removes its terminal annotations on detecting the redirect already
  • Change html behaviour just to print the html - either to terminal or file
    • human readable description of a document resource with content in markdown format is the rich rendering of the markdown - both to terminal and file (rich handles difference)
    • human readable description of a document resource with content in html format is the "print" of the html content

@michael-johnston

Copy link
Copy Markdown
Member Author

@AlessandroPomponio latest version is ready

Comment thread ado/cli/resources/document/create.py Outdated
Comment thread ado/cli/resources/document/describe.py Outdated
Comment thread ado/cli/resources/document/describe.py Outdated
Comment thread ado/core/document/config.py
Comment thread tests/ado/create/test_ado_create_document.py Outdated
Comment thread tests/ado/create/test_ado_create_document.py
Comment thread tests/ado/create/test_ado_create_document.py
Comment thread tests/ado/create/test_ado_create_document.py Outdated
Comment thread ado/metastore/sqlstore.py
@AlessandroPomponio AlessandroPomponio changed the title feat: document resource type feat(core): add document resource type Jul 30, 2026

@AlessandroPomponio AlessandroPomponio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks

@AlessandroPomponio
AlessandroPomponio added this pull request to the merge queue Jul 30, 2026
Merged via the queue into main with commit 53cc5ae Jul 30, 2026
18 checks passed
@AlessandroPomponio
AlessandroPomponio deleted the maj_document branch July 30, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: document resource type for storing reports and plans

2 participants