Skip to content

Conversation

zoewangg
Copy link
Contributor

Motivation and Context

Add kiro steering docs. I added existing guidelines from docs folder and internal docs. I also added additional guidelines that came to my mind.

@zoewangg zoewangg requested a review from a team as a code owner July 18, 2025 22:57
Copy link

return fallbackData();
}, executor);
```
- **Use appropriate completion methods**:
Copy link
Contributor

Choose a reason for hiding this comment

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

what about whenComplete? We use it a lot

- If the class does not implement `Supplier`: `{Noun}Provider` (e.g. `AwsCredentialsProvider`)
- If the "get" method has parameters: `{Noun}Factory` (e.g. `AwsJsonProtocolFactory`)

#### Service-specific classes
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this section seems a bit restrictive? We don't want any other options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually from the existing guideline

- `Optional` **SHOULD** be used when it is not obvious to a caller whether a result will be null
- `Optional` **MUST NOT** be used for "getters" in generated service model classes
- For member variables: `Optional` **SHOULD NOT** be used
- For method parameters: `Optional` **MUST NOT** be used
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we provide guidance to use @nullable instead or just not doing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is actually a feature request for #505

```
- `equals()`: Compare all fields for equality, including proper null handling
- `hashCode()`: Include all fields in the hash code calculation
- Consider using IDE-generated implementations
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this guidance useful for kiro? I think we often use the intelliJ auto-generated implementations, but not sure that will apply well here. I think the guidance maybe should be either: use java.util.Objects helpers or write explicit code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this for now, will follow up in a separate PR

@RanVaknin
Copy link
Contributor

RanVaknin commented Jul 22, 2025

Should we add a mixed version compatibility guidance?

## Version Compatibility

- **Default Behavior Substitution**: Never replace a conditional code path with an unconditional one without thorough compatibility testing. When a feature flag is removed and a previously optional code path becomes the only path, this constitutes a high-risk change that can break compatibility with older service modules.

- **Method Invocation Pattern Changes**: Be extremely cautious when changing which methods core components call on service interfaces. Even if the interface method exists in older versions, the implementation might throw UnsupportedOperationException or behave differently than expected by newer core components.

- **Interface Default Methods**: When adding methods to shared interfaces that will be called by core components:
  - Implement graceful fallback behavior in core when methods might not be properly implemented when possible.
  - Test with older service versions to verify runtime behavior, not just compile-time compatibility

- **Behavioral Assumptions**: Explicitly document and test assumptions about how service modules implement interface methods. Core components should not make new assumptions about service module behavior without ensuring backward compatibility.

- **Risk Assessment for Code Cleanup**: What appears to be simple "cleanup" or "optimization" can have significant compatibility implications. Always evaluate the runtime behavior changes, not just the code structure changes.

@@ -0,0 +1,133 @@
---
title: Asynchronous Programming Guidelines for AWS SDK v2
Copy link
Contributor

@dagnir dagnir Jul 24, 2025

Choose a reason for hiding this comment

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

Doesn't have to be in this PR but I think some guidance around locking and shared resources would be good too. For example w.r.t issues we had around making sure SdkUri/BoundedCache are performant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack. We can follow up in a separate PR

future.thenAccept(result -> processResult(result));
```
- **Add stacktrace to exceptions**: When using `CompletableFuture#join`, use `CompletableFutureUtils#joinLikeSync` to preserve stacktraces
- **Don't ignore results**: Never ignore the result of a new `CompletionStage` if the parent stage can fail (unless you're absolutely sure it's safe to)
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be good to add an example for this one, it might not be immediately apparent. e.g.

        CountDownLatch latch = new CountDownLatch(1);

        CompletableFuture<URL> future = new CompletableFuture<>();
        
        future.thenRun(url -> {
            downloadUrl(url);
            latch.countDown();
        });
        
        latch.await();

- Avoid excessive stubbing - it can make tests brittle and hard to maintain
- [Wiremock](https://wiremock.org/) is commonly used to mock server responses in functional tests

## Testing Asynchronous Code
Copy link
Contributor

Choose a reason for hiding this comment

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

Another useful method is sometimes we run hundreds/thousands of iterations of a test to ensure that none of the iterations fail, which is helpful for testing race conditions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack. We can follow up in a separate PR

@zoewangg zoewangg force-pushed the zoewang/kiroSteeringDocs branch 2 times, most recently from 039365b to 6144030 Compare October 1, 2025 18:21
@zoewangg zoewangg changed the title Add kiro steering docs Update guidelins and add kiro steering docs Oct 3, 2025
@zoewangg zoewangg force-pushed the zoewang/kiroSteeringDocs branch from 6144030 to 0200a0b Compare October 3, 2025 19:51
@zoewangg zoewangg force-pushed the zoewang/kiroSteeringDocs branch from 0200a0b to c60cd95 Compare October 6, 2025 20:20
@zoewangg zoewangg force-pushed the zoewang/kiroSteeringDocs branch from c60cd95 to 4770230 Compare October 6, 2025 20:24
@zoewangg zoewangg enabled auto-merge October 6, 2025 20:32
Copy link

sonarqubecloud bot commented Oct 6, 2025

@zoewangg zoewangg added this pull request to the merge queue Oct 6, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 6, 2025
@zoewangg zoewangg added this pull request to the merge queue Oct 6, 2025
Merged via the queue into master with commit ba102d6 Oct 6, 2025
40 checks passed
Copy link

github-actions bot commented Oct 6, 2025

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants