Conversation
iliapolo
left a comment
There was a problem hiding this comment.
@satyakigh Are you also looking for feedback on the schema itself, or just the CDK part of things?
|
|
||
| The four allowed sources are: | ||
|
|
||
| * `authored` - a person wrote or explicitly confirmed the information. |
There was a problem hiding this comment.
What if a human authored it AND any of the other three below are also true? Just something to consider
There was a problem hiding this comment.
I think it becomes more important to create a source for AI agents specifically, and less so for humans
There was a problem hiding this comment.
Added a precedence rule to Appendix A. authored applies whenever a person wrote or confirmed the text, even if it came from a comment, commit, or inference; the evidence goes in cite and note. Otherwise use the most direct evidence: comment, then commit. infer applies when the tool reasoned or combined evidence. A worked example is included.
Agreed on the second point. Three of the four values exist for automated producers, and the RFC now says so; a person writing Context directly in CDK code can omit trust. The enum is fixed by the published v1 schema (https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-attribute-metadata.html#aws-attribute-metadata-context-schema), so a dedicated agent value would be a schema change. infer already plays that role, and the authoring skill (https://github.com/aws/agent-toolkit-for-aws/blob/main/skills/core-skills/aws-cloudformation/SKILL.md) is where agent guidance is tuned.
There was a problem hiding this comment.
I see it. I think this information should be an instruction to authors and AI agents both, and should be part of the README (if not also the skill)
35cad9a to
12543b4
Compare
iliapolo
left a comment
There was a problem hiding this comment.
Also please provide the full public API of all classes we are introducing (in TypeScript form). Right now its kind of scattered between examples and hard to get a full picture.
We can then approve that API and merge it as stable from the get go.
|
|
||
| Two classes write the same documented template fields: `ResourceMetadataContext` writes | ||
| information on individual resources, and `TemplateMetadataContext` writes information once | ||
| for the whole template. `MetadataContextMixin` is a CDK Mixin, which is an API applied |
There was a problem hiding this comment.
For consistency with the aspect classes - it also makes sense because it can only be applied to resources.
| for the whole template. `MetadataContextMixin` is a CDK Mixin, which is an API applied | |
| for the whole template. `ResourceMetadataContextMixin` is a CDK Mixin, which is an API applied |
There was a problem hiding this comment.
The Mixin is removed entirely (see the thread on the Mixin form section below)
| People and automated tools that inspect a deployed template can | ||
| therefore use the author's intent instead of guessing it. | ||
|
|
||
| Two classes write the same documented template fields: `ResourceMetadataContext` writes |
There was a problem hiding this comment.
| Two classes write the same documented template fields: `ResourceMetadataContext` writes | |
| Two aspects write the same documented template fields: `ResourceMetadataContext` writes |
There was a problem hiding this comment.
Changed to "Two APIs". I avoided "aspects" because TemplateMetadataContext isn't aspect-backed: it writes the stack's template Metadata directly when add() is called. Only ResourceMetadataContext registers an aspect.
| No `trust` block appears because the caller did not provide one. The `trust` field is | ||
| optional, and CDK never adds it automatically (see *Source and confidence* below). | ||
| `mutable` is `change-with-constraints`, and the governing rule is recorded in | ||
| `must`: `VisibilityTimeout` must remain at least six times the Lambda timeout. | ||
| `change-with-constraints` means a value may change only while its stated rules remain true; | ||
| using that value without a corresponding `must` rule gives the reader no useful guidance. | ||
|
|
There was a problem hiding this comment.
No need for this entire paragraph - it should all be mentioned in the schema definition we link to already. Unless you want to emphasize a specific property - but then also give a short explanation about it. I think we can just remove it.
| `why` or `must` when another applicable declaration supplies them, and no template-level | ||
| field is required either. | ||
|
|
||
| ##### Propagation is explicit |
There was a problem hiding this comment.
This should come sooner - just after you show the example of add, that way the reader still has this API in their mind.
There was a problem hiding this comment.
Moved. Propagation is explicit now follows the first add() example directly, and the quality guidance moved to the end of the README as Writing good context.
| `change-with-constraints` means a value may change only while its stated rules remain true; | ||
| using that value without a corresponding `must` rule gives the reader no useful guidance. | ||
|
|
||
| ##### Resource context quality |
There was a problem hiding this comment.
Should go last after all other field specific explanations. Also rename to Writing good context
There was a problem hiding this comment.
Done. It is now the last section, titled Writing good context, and it also absorbed the conciseness and size paragraphs that used to trail Template-level context.
| Template level here means `TemplateMetadataContext`, not the template's built-in | ||
| `Description`. The two serve different readers: `Description` is one short, unstructured | ||
| string (at most 1,024 bytes) that CloudFormation shows in the console stack list and | ||
| returns from `DescribeStacks`, so it works best as a one-line statement of what the stack is. | ||
| `TemplateMetadataContext` holds the structured fields `arch`, `must`, `ref`, and `owner`, | ||
| which are returned only inside the template body (`GetTemplate`) and answer how the system | ||
| is shaped, which rules apply everywhere, and where supporting material lives. Avoid repeating | ||
| the `Description` text in `arch`, and keep rules out of `Description`. See *Template-level | ||
| context* below for a side-by-side comparison. |
There was a problem hiding this comment.
Too much information about a side concept. Remove it (instead just link to the relevant section in the paragraph above).
There was a problem hiding this comment.
Removed. The paragraph above now links to Template-level context
| contributing evidence in `cite` and `note`. | ||
|
|
||
| For example, a tool that lifts `why` from a comment writes `src: COMMENT` and | ||
| `cite: 'lib/queue.ts:42'`; when the author reviews and accepts it, `src` becomes `AUTHORED` |
There was a problem hiding this comment.
You mean "src should become AUTHORED"? As in, the PR author should make a change after getting approval?
There was a problem hiding this comment.
Yes. It now reads: "the author (or the tool, on the author's confirmation) should change src to AUTHORED and keep cite"
| and `cite` stays. Three of the four values exist for automated producers, where `src` matters | ||
| most: a reader must be able to tell tool-derived Context from Context a person stands behind. | ||
| A person writing Context directly in CDK code can omit `trust`, because the reviewed source | ||
| already shows who wrote it. The Agent Toolkit's CloudFormation and CDK skills will be |
There was a problem hiding this comment.
already shows who wrote it
What do you mean? how? I thought a person writing context should explicitly use AUTHORED...
There was a problem hiding this comment.
That sentence conflated source history with what a template reader can see. It now reads: a person writing Context directly uses src: AUTHORED; a tool uses COMMENT, COMMIT, or INFER according to its evidence and switches to AUTHORED only after a person confirms the text. trust stays optional per the schema, so a block without it leaves the source unstated, and the text recommends setting it wherever tool-derived and human-written Context may share a template.
| [Appendix A](#appendix-a---cloudformation-context-template-field-reference) for the | ||
| `trust` object. | ||
|
|
||
| ##### Mixin form |
There was a problem hiding this comment.
Why do we actually need the mixin here? what does it give that the aspect doesn't?
Im also seeing the mixin API doesn't have all the capabilities, for example inheritAncestorContext, is that intentional? If we don't really need the mixin, lets not have it. If we are keeping it - we should also mention how conflicts between the aspect and the mixin are handled.
There was a problem hiding this comment.
Agreed, and removed. It was a strict subset of the aspect: .with() on an L1 is ResourceMetadataContext.of(cfnResource).add(), and Mixins.of(scope).apply() is add(..., { propagate: true }), except that it applied eagerly, so resources created after the call were missed. It also needed an awslint mixin-namespace exemption. The Public API is now three classes
| directly with `CfnResource.addMetadata()`. If manually added information and a metadata- | ||
| context API target the same resource and key, template generation fails instead of silently |
There was a problem hiding this comment.
| directly with `CfnResource.addMetadata()`. If manually added information and a metadata- | |
| context API target the same resource and key, template generation fails instead of silently | |
| directly with `CfnResource.addMetadata()`. If manually added information and a metadata-context API target the same resource and key, template generation fails instead of silently |
There was a problem hiding this comment.
Applied, rewrapped so metadata-context stays on one line.
This is a request for comments about Structured design context in synthesized templates. See #972 for
additional details.
APIs are signed off by @iliapolo
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache-2.0 license